:root {
    --bg-color: #070a12;
    --accent-cyan: #38bdf8;
    --accent-purple: #c084fc;
    --accent-gold: #facc15;
    --accent-orange: #fb923c;
    --accent-green: #4ade80;
    --font-mono: 'Fira Code', monospace;
    --font-sans: 'Outfit', sans-serif;
}

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

body {
    background-color: var(--bg-color);
    color: #f8fafc;
    font-family: var(--font-sans);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
    text-align: center;
    overflow-x: hidden;
    background-image: radial-gradient(circle at 50% 0%, rgba(56, 189, 248, 0.1) 0%, rgba(7, 10, 18, 1) 70%);
}

.header-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
}

h1 {
    font-size: 2.2rem;
    font-weight: 900;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #ffffff 0%, var(--accent-cyan) 60%, var(--accent-purple) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

p.instructions {
    color: #94a3b8;
    font-size: 0.95rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.key-badge {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    padding: 0.15rem 0.55rem;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 700;
}

#game-container {
    position: relative;
    width: 100%;
    max-width: 840px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), 0 0 40px rgba(56, 189, 248, 0.15);
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid rgba(56, 189, 248, 0.3);
    background: #0b1120;
}

canvas {
    display: block;
    width: 100%;
    height: auto;
    background: #070a12;
    cursor: pointer;
}

.hud {
    position: absolute;
    top: 15px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
    pointer-events: none;
    z-index: 10;
}

.hud-item {
    background: rgba(11, 17, 32, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 0.4rem 0.85rem;
    border-radius: 20px;
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

#game-over-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(7, 10, 18, 0.88);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    backdrop-filter: blur(12px);
    z-index: 20;
    padding: 2rem;
}

#game-over-overlay h2 {
    font-size: 2.2rem;
    font-weight: 900;
    color: #f87171;
    text-shadow: 0 0 20px rgba(248, 113, 113, 0.4);
    letter-spacing: -0.01em;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    width: 100%;
    max-width: 460px;
    margin: 0.5rem 0;
}

.stat-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.85rem;
    border-radius: 12px;
    text-align: center;
}

.stat-card .val {
    font-family: var(--font-mono);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--accent-cyan);
}

.stat-card .lbl {
    font-size: 0.75rem;
    color: #94a3b8;
    text-transform: uppercase;
    margin-top: 0.2rem;
}

.btn-restart {
    background: linear-gradient(135deg, var(--accent-cyan) 0%, #0284c7 100%);
    color: #0b0f19;
    border: none;
    padding: 0.85rem 2.25rem;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(56, 189, 248, 0.4);
    font-family: var(--font-sans);
    transition: all 0.25s ease;
}

.btn-restart:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 12px 30px rgba(56, 189, 248, 0.6);
}

footer {
    margin-top: 1.75rem;
    font-size: 0.88rem;
    color: #94a3b8;
}
footer a { color: var(--accent-cyan); text-decoration: none; font-weight: 600; }

@media (max-width: 640px) {
    h1 { font-size: 1.5rem; }
    .instructions { font-size: 0.82rem; }
    .hud { font-size: 0.75rem; gap: 0.3rem; flex-wrap: wrap; justify-content: center; }
    .hud-item { padding: 0.25rem 0.55rem; }
    .stats-grid { grid-template-columns: 1fr; gap: 0.5rem; }
    #game-over-overlay h2 { font-size: 1.5rem; }
    .btn-restart { padding: 0.7rem 1.5rem; font-size: 0.95rem; }
}
