:root {
    --bg-color: #1a1a1a;
    --panel-bg: #000000;
    --border-color: #ffffff;
    --neon-blue: #00f3ff;
    --neon-pink: #ff00ff;
    --neon-purple: #bc13fe;
    --text-color: #ffffff;
    --font-family: 'Press Start 2P', cursive;
    --pixel-size: 4px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-family);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background: #111;
    image-rendering: pixelated;
}

.game-container {
    display: grid;
    grid-template-columns: 160px auto 160px;
    gap: 30px;
    align-items: start;
    padding: 20px;
    max-width: 900px;
    width: 100%;
    position: relative;
    z-index: 10;
}

.retro-panel {
    background: var(--panel-bg);
    border: 4px solid var(--border-color);
    padding: 20px;
    box-shadow:
        8px 8px 0 rgba(0, 0, 0, 0.5),
        inset 2px 2px 0 rgba(255, 255, 255, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.game-info {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
}

.game-info .retro-panel {
    width: 100%;
    align-items: center;
}

.next-piece-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    min-height: 160px;
    justify-content: center;
    align-items: center;
}

.label {
    font-size: 0.8rem;
    color: #aaa;
    margin-bottom: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.value {
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 2px 2px 0 #555;
}

.game-area {
    position: relative;
    padding: 4px;
    border: 4px solid var(--border-color);
    background: #000;
    box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.5);
}

canvas {
    display: block;
    image-rendering: pixelated;
}

#game-canvas {
    background: rgba(20, 20, 20, 1);
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    z-index: 20;
}

.overlay h1 {
    font-size: 2rem;
    margin-bottom: 20px;
    color: var(--neon-pink);
    text-shadow: 4px 4px 0 var(--neon-blue);
    text-align: center;
    line-height: 1.5;
}

.overlay p {
    font-size: 1rem;
    margin-bottom: 30px;
    color: #fff;
}

.neon-btn {
    margin-top: 10px;
    padding: 15px 20px;
    font-size: 1rem;
    font-weight: bold;
    color: #fff;
    background: #000;
    border: 4px solid #fff;
    cursor: pointer;
    text-transform: uppercase;
    font-family: var(--font-family);
    box-shadow: 4px 4px 0 #fff;
    transition: transform 0.1s, box-shadow 0.1s;
}

.neon-btn:hover {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 #fff;
    background: #222;
}

.neon-btn:active {
    transform: translate(4px, 4px);
    box-shadow: 0 0 0 #fff;
}

.controls-hint {
    grid-column: 1 / -1;
    text-align: center;
    margin-top: 30px;
    color: #888;
    font-size: 0.7rem;
    line-height: 1.5;
}

.mobile-hint {
    display: none;
}

/* CRT Scanline Effect */
body::before {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(to bottom,
            rgba(18, 16, 16, 0) 50%,
            rgba(0, 0, 0, 0.25) 50%);
    background-size: 100% 4px;
    z-index: 1000;
    pointer-events: none;
}

body::after {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: rgba(18, 16, 16, 0.1);
    opacity: 0;
    z-index: 1000;
    pointer-events: none;
    animation: flicker 0.15s infinite;
}

@keyframes flicker {
    0% {
        opacity: 0.027906;
    }

    5% {
        opacity: 0.048532;
    }

    10% {
        opacity: 0.026790;
    }

    15% {
        opacity: 0.042651;
    }

    20% {
        opacity: 0.027576;
    }

    25% {
        opacity: 0.042798;
    }

    30% {
        opacity: 0.028006;
    }

    35% {
        opacity: 0.041988;
    }

    40% {
        opacity: 0.026734;
    }

    45% {
        opacity: 0.043475;
    }

    50% {
        opacity: 0.026072;
    }

    55% {
        opacity: 0.041409;
    }

    60% {
        opacity: 0.029738;
    }

    65% {
        opacity: 0.040291;
    }

    70% {
        opacity: 0.027906;
    }

    75% {
        opacity: 0.041988;
    }

    80% {
        opacity: 0.026982;
    }

    85% {
        opacity: 0.041409;
    }

    90% {
        opacity: 0.027832;
    }

    95% {
        opacity: 0.043298;
    }

    100% {
        opacity: 0.026790;
    }
}

.hidden {
    display: none !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        gap: 20px;
        max-width: 400px;
    }

    .game-info {
        flex-direction: row;
        justify-content: space-between;
        width: 100%;
    }

    .retro-panel {
        padding: 10px;
    }

    .game-area {
        order: 2;
        justify-self: center;
    }

    .next-piece-container {
        display: none;
    }

    .desktop-hint {
        display: none;
    }

    .mobile-hint {
        display: block;
    }
}