:root {
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #a855f7; /* Pigeon purple */
    --accent-hover: #d946ef;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow: hidden; /* Prevent pull-to-refresh on mobile */
    overscroll-behavior: none;
}

.game-wrapper {
    width: 100%;
    max-width: 420px;
    height: 100%;
    display: flex;
    justify-content: center;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 24px;
    width: 100%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.header {
    text-align: center;
}

.header h1 {
    font-size: 2.2rem;
    font-weight: 900;
    letter-spacing: 1px;
    margin-bottom: 15px;
    text-transform: uppercase;
    background: linear-gradient(to right, #e2e8f0, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header h1 span {
    background: linear-gradient(to right, #34d399, #a855f7); /* Pigeon green/purple */
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stats {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.stat-box {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
}

.game-layout {
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

.game-container {
    position: relative;
    flex: 1;
    aspect-ratio: 10/20; /* Keep Tetris aspect ratio */
    max-height: 60vh;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    border: 2px solid var(--glass-border);
    overflow: hidden;
    /* Touch settings for swipe */
    touch-action: none; 
}

.side-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 60px; /* Base width depending on screen size, wait max-width container will scale it */
    flex-shrink: 0;
}

.next-pieces-box {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.next-pieces-box canvas {
    width: 100%;
    height: auto;
    aspect-ratio: 4/12;
    image-rendering: pixelated;
    margin-top: 5px;
}

@keyframes shake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    20% { transform: translate(-3px, 0px) rotate(1deg); }
    30% { transform: translate(3px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); }
    70% { transform: translate(3px, 1px) rotate(-1deg); }
    80% { transform: translate(-1px, -1px) rotate(1deg); }
    90% { transform: translate(1px, 2px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}

.shake {
    animation: shake 0.15s;
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
    /* Crisp pixel rendering */
    image-rendering: pixelated; 
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.overlay.active {
    opacity: 1;
    pointer-events: all;
}

#overlay-title {
    font-size: 2.5rem;
    font-weight: 900;
    margin-bottom: 10px;
    background: linear-gradient(to right, #f8fafc, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

#overlay-text {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.brand-btn {
    background: linear-gradient(135deg, var(--accent) 0%, #7e22ce 100%);
    color: white;
    border: none;
    padding: 14px 28px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 50px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}

.brand-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(168, 85, 247, 0.6);
}

.brand-btn:active {
    transform: translateY(1px);
}

.controls-hint {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

.game-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: -5px;
}

.action-btn {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    padding: 10px 20px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    border-radius: 20px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: background 0.2s, transform 0.2s;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.action-btn:active {
    transform: translateY(1px);
}

/* Responsive tweaks */
@media (max-width: 480px) {
    .glass-panel {
        padding: 16px;
        border-radius: 16px;
    }
    .header h1 {
        font-size: 1.8rem;
    }
    .stat-value {
        font-size: 1rem;
    }
    .game-container {
        max-height: 65vh;
    }
}
