/* Nitro Rush — neon street-racing arcade theme. No external font
   requests (GDPR: this project self-hosts or skips webfonts entirely —
   see claude/standing-conventions.md-adjacent learning from Drift
   Master's Google Fonts migration). System font stack styled heavy +
   uppercase + tracked-out to read as an arcade display face. */

:root {
    --bg: #07030f;
    --panel: #140a24;
    --panel-2: #1c1033;
    --neon-blue: #5ab4ff;
    --neon-purple: #b166ff;
    --neon-pink: #ff3d9a;
    --neon-orange: #ff8a1e;
    --neon-cyan: #4dffe0;
    --text: #f2eefc;
    --text-dim: #a99bc9;
    --danger: #ff4d4d;
    --success: #4dffb0;
    --radius: 16px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

body {
    min-height: 100vh;
}

a { color: var(--neon-cyan); }

.visually-hidden {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------------------------------------------------------------- */
/* Game shell */
/* ---------------------------------------------------------------- */

#game-shell {
    position: relative;
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    aspect-ratio: 9 / 16;
    max-height: 92vh;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 0 0 1px rgba(177,102,255,0.25), 0 20px 60px rgba(0,0,0,0.6), 0 0 80px rgba(90,180,255,0.08);
    touch-action: none;
    user-select: none;
}

@media (min-width: 900px) and (min-height: 700px) {
    #game-shell { max-height: 90vh; }
}

#game-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

#game-shell:fullscreen,
#game-shell:-webkit-full-screen {
    max-width: 100vw;
    max-height: 100vh;
    aspect-ratio: auto;
    border-radius: 0;
}

/* ---------------------------------------------------------------- */
/* Header icon bar */
/* ---------------------------------------------------------------- */

#header-bar {
    position: absolute;
    top: calc(10px + env(safe-area-inset-top, 0px));
    right: 10px;
    z-index: 30;
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 38px; height: 38px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.18);
    background: rgba(10,6,20,0.55);
    backdrop-filter: blur(6px);
    color: var(--text);
    font-size: 16px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
}
.icon-btn:active { transform: scale(0.92); }

/* ---------------------------------------------------------------- */
/* HUD */
/* ---------------------------------------------------------------- */

#hud {
    /* top offset clears #header-bar's icon row (38px buttons + 10px
       offset) — both are visible together during PLAYING/PAUSED/CRASH
       and, being independently top-right-anchored, overlapped the score/
       speed text under the pause/mute/fullscreen buttons until this was
       caught in an actual gameplay screenshot. */
    position: absolute;
    top: calc(56px + env(safe-area-inset-top, 0px));
    left: 10px;
    right: 10px;
    z-index: 20;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    font-weight: 700;
}

.hud-block { display: flex; flex-direction: column; gap: 2px; }
.hud-label { font-size: 10px; letter-spacing: 0.14em; color: var(--text-dim); text-transform: uppercase; }
#hud-score { font-size: 22px; text-shadow: 0 0 10px rgba(90,180,255,0.7); }
#hud-speed { font-size: 20px; color: var(--neon-orange); text-shadow: 0 0 10px rgba(255,138,30,0.7); }
#hud-distance { font-size: 12px; color: var(--text-dim); }

#hud-nitro-bar {
    position: absolute;
    left: 10px; right: 10px;
    bottom: calc(74px + env(safe-area-inset-bottom, 0px));
    height: 12px;
    border-radius: 8px;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.2);
    overflow: hidden;
    z-index: 20;
}
#hud-nitro-fill {
    height: 100%;
    width: 35%;
    background: linear-gradient(90deg, var(--neon-blue), var(--neon-purple));
    transition: width 0.1s linear;
}
#hud-nitro-bar.active #hud-nitro-fill {
    background: linear-gradient(90deg, #fff, var(--neon-cyan), var(--neon-blue));
    box-shadow: 0 0 12px var(--neon-cyan);
}

#hud-combo {
    position: absolute;
    top: calc(104px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%);
    z-index: 20;
    font-weight: 800;
    font-size: 18px;
    letter-spacing: 0.06em;
    color: #fff;
    background: linear-gradient(90deg, var(--neon-pink), var(--neon-orange));
    padding: 4px 14px;
    border-radius: 999px;
    box-shadow: 0 0 16px rgba(255,61,154,0.6);
}

/* ---------------------------------------------------------------- */
/* Touch controls */
/* ---------------------------------------------------------------- */

#touch-controls {
    position: absolute;
    left: 0; right: 0;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    pointer-events: none;
}

.lane-btn, #btn-nitro-touch {
    pointer-events: all;
    border: none;
    color: #fff;
    font-weight: 800;
    display: flex; align-items: center; justify-content: center;
}

.lane-btn {
    width: 52px; height: 52px;
    border-radius: 50%;
    background: rgba(20,10,36,0.6);
    border: 1px solid rgba(255,255,255,0.2);
    font-size: 20px;
}
.lane-btn:active { background: rgba(90,180,255,0.35); }

#btn-nitro-touch {
    width: 84px; height: 84px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #8fd8ff, var(--neon-blue) 55%, #1a5fa8 100%);
    box-shadow: 0 0 24px rgba(90,180,255,0.7), inset 0 -4px 10px rgba(0,0,0,0.3);
    font-size: 13px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
#btn-nitro-touch.active {
    background: radial-gradient(circle at 35% 30%, #fff, var(--neon-cyan) 55%, var(--neon-blue) 100%);
    box-shadow: 0 0 40px rgba(120,255,230,0.9);
    transform: scale(0.95);
}

/* ---------------------------------------------------------------- */
/* Screens & modals */
/* ---------------------------------------------------------------- */

.nr-screen, .nr-modal {
    position: absolute;
    inset: 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px calc(18px + env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)) calc(18px + env(safe-area-inset-left, 0px));
    background: radial-gradient(circle at 50% 20%, rgba(60,20,90,0.92), rgba(6,3,15,0.97));
    overflow-y: auto;
}

.nr-modal { z-index: 60; background: rgba(4,2,10,0.86); backdrop-filter: blur(4px); }

.brand-title {
    font-size: clamp(40px, 11vw, 64px);
    font-weight: 900;
    letter-spacing: 0.03em;
    line-height: 0.95;
    margin: 0;
    background: linear-gradient(180deg, #fff, var(--neon-cyan) 55%, var(--neon-blue));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: 0 0 30px rgba(90,180,255,0.5);
    text-transform: uppercase;
}
.brand-sub {
    font-size: clamp(14px, 3.6vw, 18px);
    color: var(--neon-pink);
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin: 2px 0 18px;
    text-shadow: 0 0 12px rgba(255,61,154,0.6);
}

.menu-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 320px; }

.btn {
    font-family: inherit;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-size: 15px;
    padding: 14px 18px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    color: #fff;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
    background: linear-gradient(90deg, var(--neon-blue), var(--neon-purple));
    box-shadow: 0 6px 22px rgba(120,90,255,0.45);
}
.btn-secondary {
    background: linear-gradient(90deg, var(--neon-orange), var(--neon-pink));
    box-shadow: 0 6px 22px rgba(255,80,140,0.4);
}
.btn-ghost {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.18);
}
.btn-small { padding: 9px 14px; font-size: 12px; border-radius: 9px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

.menu-links { display: flex; gap: 18px; margin-top: 20px; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.menu-links button { background: none; border: none; color: var(--text-dim); font-weight: 700; cursor: pointer; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; padding: 6px; }
.menu-links button:hover { color: var(--neon-cyan); }

.best-badge, .daily-badge {
    margin-top: 16px;
    font-size: 12px;
    color: var(--text-dim);
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    padding: 8px 14px;
}
.best-badge b, .daily-badge b { color: var(--neon-cyan); font-size: 14px; }

/* Countdown */
#screen-countdown { background: rgba(4,2,10,0.55); }
#countdown-number {
    font-size: 34vw;
    max-font-size: 220px;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 40px var(--neon-blue);
    animation: pulseCountdown 0.9s ease-out;
}
@keyframes pulseCountdown { from { transform: scale(1.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Pause */
#screen-pause .brand-title { font-size: 34px; }

/* Submitting */
#screen-submitting { font-size: 14px; color: var(--text-dim); letter-spacing: 0.08em; text-transform: uppercase; }

/* Game over */
.go-title { font-size: 30px; font-weight: 900; color: var(--danger); text-shadow: 0 0 20px rgba(255,77,77,0.6); margin: 0; letter-spacing: 0.04em; }
#go-mode-label { font-size: 11px; letter-spacing: 0.16em; color: var(--text-dim); margin-bottom: 6px; }
#go-newrecord {
    margin: 8px 0; font-weight: 800; color: #1a1206;
    background: linear-gradient(90deg, #ffe680, #ffb020);
    padding: 5px 14px; border-radius: 999px; font-size: 12px; letter-spacing: 0.08em;
    box-shadow: 0 0 18px rgba(255,190,60,0.6);
}
.go-score { font-size: 40px; font-weight: 900; margin: 4px 0 10px; text-shadow: 0 0 20px rgba(90,180,255,0.6); }
.go-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; max-width: 340px; margin-bottom: 12px; }
.go-stat { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1); border-radius: 10px; padding: 8px 4px; }
.go-stat-label { font-size: 9px; letter-spacing: 0.1em; color: var(--text-dim); text-transform: uppercase; }
.go-stat-value { font-size: 16px; font-weight: 800; margin-top: 2px; }

.note { font-size: 12px; border-radius: 10px; padding: 8px 12px; margin: 6px 0; max-width: 320px; }
.note-pending { background: rgba(255,180,60,0.15); color: #ffcf80; border: 1px solid rgba(255,180,60,0.3); }
.note-error { background: rgba(255,77,77,0.15); color: #ff9a9a; border: 1px solid rgba(255,77,77,0.3); }

#nickname-form { display: flex; gap: 6px; width: 100%; max-width: 320px; margin: 10px 0; }
#nickname-input {
    flex: 1; min-width: 0; padding: 10px 12px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.06); color: #fff; font-family: inherit; font-size: 14px;
}
#nickname-status { font-size: 11px; color: var(--text-dim); min-height: 14px; }

/* Modals */
.modal-card {
    background: var(--panel);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: var(--radius);
    max-width: 420px;
    width: 100%;
    max-height: 84%;
    overflow-y: auto;
    padding: 20px;
    text-align: left;
}
.modal-title { font-size: 18px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 12px; color: var(--neon-cyan); }
.modal-close { float: right; background: none; border: none; color: var(--text-dim); font-size: 20px; cursor: pointer; }

.howto-section { margin-bottom: 14px; }
.howto-section h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--neon-pink); margin: 0 0 6px; }
.howto-section p, .howto-section ul { font-size: 13px; color: var(--text-dim); margin: 0; line-height: 1.55; }
.howto-section ul { padding-left: 18px; }

.lb-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.lb-tab-mode, .lb-tab-range {
    flex: 1; padding: 8px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.04); color: var(--text-dim); font-size: 11px; font-weight: 700;
    letter-spacing: 0.06em; text-transform: uppercase; cursor: pointer;
}
.lb-tab-mode.active, .lb-tab-range.active { background: linear-gradient(90deg, var(--neon-blue), var(--neon-purple)); color: #fff; border-color: transparent; }
#lb-range-tabs { display: flex; gap: 6px; margin-bottom: 10px; }

.lb-row {
    display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 8px;
    padding: 8px 6px; border-bottom: 1px solid rgba(255,255,255,0.06); font-size: 13px;
}
.lb-row.lb-top { color: #ffd35c; font-weight: 800; }
.lb-rank { color: var(--text-dim); font-weight: 700; }
.lb-score { font-weight: 800; }
.lb-loading, .lb-empty { text-align: center; color: var(--text-dim); font-size: 13px; padding: 20px 0; }

.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.08); }
.settings-row label { font-size: 13px; font-weight: 600; }
.settings-row input[type="range"] { width: 120px; }

/* Toast */
#toast {
    position: absolute; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    background: rgba(10,6,20,0.9); color: #fff; padding: 8px 16px; border-radius: 999px;
    font-size: 12px; z-index: 80; border: 1px solid rgba(255,255,255,0.15);
    max-width: 90%; text-align: center;
}

[hidden] { display: none !important; }

/* ---------------------------------------------------------------- */
/* Below-fold SEO content (outside #game-shell) */
/* ---------------------------------------------------------------- */

.page-wrap { max-width: 720px; margin: 0 auto; padding: 18px 16px 60px; }
.game-frame { display: flex; justify-content: center; padding-top: 14px; }
.seo-content { color: var(--text-dim); font-size: 14px; line-height: 1.7; margin-top: 34px; }
.seo-content h1 { color: var(--text); font-size: 24px; margin-bottom: 6px; }
.seo-content h2 { color: var(--text); font-size: 17px; margin: 28px 0 8px; }
.seo-content ul { padding-left: 20px; }
.seo-content a { text-decoration: underline; }
.faq-item { margin-bottom: 14px; }
.faq-item h3 { color: var(--text); font-size: 14px; margin: 0 0 4px; }
.related-games { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.related-games a {
    display: inline-block; padding: 6px 12px; border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.15); color: var(--text-dim); font-size: 12px; text-decoration: none;
}
.site-footer { text-align: center; font-size: 11px; color: #6a5c8a; margin-top: 40px; }
.site-footer a { color: #6a5c8a; }
