:root {
    --bg-color: #1a1a1a;
    --panel-color: #2d2d2d;
    --snake-green: #4ade80;
    --snake-dark: #166534;
    --apple-red: #ef4444;
    --text-color: #ffffff;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Press Start 2P', cursive;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    overflow: hidden;
    touch-action: none;
}

#game-wrapper {
    position: relative;
    padding: 20px;
    background: var(--panel-color);
    border: 8px solid #444;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

#ui-layer {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    padding: 0 10px;
}

.stat-box {
    font-size: 14px;
    text-transform: uppercase;
}

#canvas-container {
    position: relative;
    background: #000;
    line-height: 0;
    border: 4px solid #111;
}

canvas {
    image-rendering: pixelated;
    max-width: 100%;
    height: auto;
}

/* CRT Scanline Effect */
#canvas-container::after {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%), 
                linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03));
    background-size: 100% 4px, 3px 100%;
    pointer-events: none;
    z-index: 10;
}

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

.hidden { display: none !important; }

.btn {
    background: var(--snake-green);
    border: none;
    padding: 15px 30px;
    color: #000;
    font-family: 'Press Start 2P', cursive;
    cursor: pointer;
    margin-top: 20px;
    box-shadow: 0 4px 0 #166534;
}

.btn:active {
    transform: translateY(4px);
    box-shadow: none;
}

#mobile-controls {
    display: grid;
    grid-template-areas: 
        ". up ."
        "left down right";
    gap: 10px;
    margin-top: 20px;
}

.dir-btn {
    width: 60px;
    height: 60px;
    background: #333;
    border: 2px solid #555;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 20px;
}

.up { grid-area: up; }
.down { grid-area: down; }
.left { grid-area: left; }
.right { grid-area: right; }

@media (min-width: 768px) {
    #mobile-controls { display: none; }
}