:root {
    --bg-dark: #0a0b10;
    --card-bg: rgba(18, 20, 32, 0.85);
    --border-color: rgba(255, 255, 255, 0.08);
    --neon-purple: #9d4edd;
    --neon-pink: #ff007f;
    --text-color: #f0f4f8;
    --text-muted: #828a9b;
    --font-pixel: 'Press Start 2P', monospace;
    --font-sans: 'Outfit', sans-serif;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-color);
    font-family: var(--font-sans);
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background: radial-gradient(circle at center, #17192a 0%, #050609 100%);
}

#game-container {
    position: relative;
    width: 95%;
    max-width: 1000px;
    aspect-ratio: 16 / 9;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8),
                0 0 30px rgba(157, 78, 221, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    background-color: #0d0f17;
}

/* Heads Up Display (HUD) */
#hud {
    position: absolute;
    top: 15px;
    left: 0;
    width: 100%;
    padding: 0 25px;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    z-index: 10;
}

.hud-item {
    background: rgba(13, 15, 25, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    backdrop-filter: blur(4px);
}

.hud-label {
    font-family: var(--font-pixel);
    font-size: 8px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.hud-value {
    font-family: var(--font-pixel);
    font-size: 14px;
    color: #fff;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.2);
}

#score-val {
    color: #ffcc00;
}

#speed-val {
    color: #00f3ff;
}

/* Overlays and Cards */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(6, 7, 12, 0.8);
    backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 30px 40px;
    width: 90%;
    max-width: 440px;
    text-align: center;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.border-red {
    border-color: rgba(255, 0, 127, 0.3);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5), 0 0 15px rgba(255, 0, 127, 0.1);
}

.logo {
    font-family: var(--font-pixel);
    font-size: 24px;
    letter-spacing: 1px;
    color: #fff;
    text-shadow: 0 0 10px var(--neon-purple);
}

.tagline {
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.controls-card {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 14px;
}

.key {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.2);
    border-bottom: 2px solid rgba(0,0,0,0.5);
    border-radius: 4px;
    padding: 2px 6px;
    font-weight: bold;
    color: #fff;
}

.btn {
    background: linear-gradient(135deg, var(--neon-purple) 0%, var(--neon-pink) 100%);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-family: var(--font-sans);
    font-weight: bold;
    font-size: 15px;
    padding: 12px 24px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
    box-shadow: 0 0 10px rgba(157, 78, 221, 0.3);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 18px rgba(157, 78, 221, 0.6);
}

.btn:active {
    transform: translateY(0);
}

.btn-restart {
    background: linear-gradient(135deg, #e63946 0%, #ff007f 100%);
    box-shadow: 0 0 10px rgba(230, 57, 70, 0.3);
}

.btn-restart:hover {
    box-shadow: 0 0 18px rgba(230, 57, 70, 0.6);
}

.gameover-title {
    font-family: var(--font-pixel);
    font-size: 20px;
    color: #ff007f;
    text-shadow: 0 0 10px rgba(255, 0, 127, 0.4);
}

.gameover-desc {
    font-size: 14px;
    color: var(--text-muted);
}

.scores-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.score-card {
    background: rgba(0, 0, 0, 0.25);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
}

.score-card span {
    color: var(--text-muted);
}

.score-card strong {
    font-family: var(--font-pixel);
    font-size: 16px;
    color: #fff;
}

.stats-footer {
    font-size: 11px;
    color: var(--text-muted);
}

/* Mobile responsive scaling overrides */
@media (max-width: 550px) {
    .logo {
        font-size: 18px;
    }
    .hud-value {
        font-size: 10px;
    }
    .card {
        padding: 20px;
        gap: 12px;
    }
}
