/* Drift Master — Game CMB (gamecmb.com)
   Modern / premium / arcade / dark / neon. System font stack only (no
   external web font — keeps the CSP simple and avoids any pre-consent
   third-party request). Mobile-first, 44px+ touch targets throughout. */

:root {
    --bg: #05040e;
    --bg2: #0a0620;
    --panel: rgba(18, 14, 36, 0.72);
    --panel-solid: #14102a;
    --border: rgba(255, 255, 255, 0.09);
    --text: #eef1ff;
    --text-dim: #9aa0c0;
    --cyan: #00f0ff;
    --pink: #ff2d95;
    --gold: #ffd23d;
    --green: #35e6a0;
    --red: #ff4d5e;
    --radius: 16px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    background: radial-gradient(1200px 800px at 50% -10%, #1a1040 0%, var(--bg2) 45%, var(--bg) 100%);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

[hidden] { display: none !important; }

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

img { max-width: 100%; display: block; }

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    touch-action: manipulation;
}
button:focus-visible, a:focus-visible, input:focus-visible {
    outline: 2px solid var(--cyan);
    outline-offset: 2px;
}

.container {
    max-width: 980px;
    margin: 0 auto;
    padding: 0 16px;
}

/* ---------------------------------------------------------------- header ---- */
.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px calc(10px + var(--safe-top));
    gap: 10px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: var(--text);
    text-decoration: none;
    font-size: 1.05rem;
}
.brand img { width: 28px; height: 28px; }
.brand .accent { color: var(--cyan); }

/* ---------------------------------------------------------------- game shell ---- */
#game-shell {
    position: relative;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px var(--border);
}
@media (max-width: 640px) {
    #game-shell {
        width: 100%;
        max-width: 100%;
        border-radius: 0;
        aspect-ratio: auto;
        height: min(82svh, calc(100vw * 9 / 16 + 140px));
    }
}
#game-shell:fullscreen,
#game-shell:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    aspect-ratio: auto;
    border-radius: 0;
}
#game-shell:fullscreen #game-canvas,
#game-shell:-webkit-full-screen #game-canvas { position: absolute; inset: 0; }

#game-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
    user-select: none;
}

.screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    text-align: center;
    gap: 14px;
    background: linear-gradient(180deg, rgba(5, 4, 14, 0.88), rgba(5, 4, 14, 0.94));
    overflow-y: auto;
}
.screen.transparent-top { background: transparent; pointer-events: none; }

/* Thin, unobtrusive scrollbar for the rare case a screen still needs to
   scroll (a very short game-shell height) — the default fat native
   scrollbar cutting across the neon UI is what a design review flagged,
   not scrolling itself, which stays as a safety net. */
.screen::-webkit-scrollbar { width: 6px; }
.screen::-webkit-scrollbar-track { background: transparent; }
.screen::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.18); border-radius: 3px; }
.screen { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.18) transparent; }

/* Game-over specifically packs the most content of any screen (title,
   stat grid, nickname form, 4 buttons) — tightened so it fits inside a
   typical game-shell height without needing to scroll at all, rather
   than relying on the scrollbar fallback above. */
#screen-gameover {
    gap: 4px;
    padding: 4px 14px 6px;
    justify-content: flex-start;
}
#screen-gameover h2 { font-size: 0.95rem; line-height: 1.15; }
#screen-gameover .btn-row { gap: 6px; }
#screen-gameover .btn { min-height: 36px; padding: 7px 14px; font-size: 0.85rem; }
#screen-gameover .daily-card { padding: 5px 12px; font-size: 0.7rem; }
#screen-gameover .daily-card .row { margin-top: 2px; }
#screen-gameover .record-banner { font-size: 0.88rem; }

/* ---------------------------------------------------------------- HUD ---- */
#hud {
    position: absolute;
    inset: 0;
    pointer-events: none;
    padding: calc(10px + var(--safe-top)) 12px 0;
    display: flex;
    flex-direction: column;
}
.hud-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}
.hud-cell {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px 12px;
    min-width: 64px;
    backdrop-filter: blur(6px);
}
.hud-label { font-size: 0.6rem; letter-spacing: 1px; color: var(--text-dim); text-transform: uppercase; }
.hud-value { font-size: 1.15rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.hud-value.combo { color: var(--gold); }
.hud-value.score { color: var(--cyan); }
.hud-value.best { color: var(--pink); }
#hud-speed.boosting { color: var(--gold); text-shadow: 0 0 8px rgba(255, 210, 61, 0.6); }

#hud-center-banner {
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    font-weight: 900;
    font-size: clamp(1.4rem, 6vw, 2.4rem);
    letter-spacing: 1px;
    color: var(--gold);
    text-shadow: 0 0 18px currentColor, 0 2px 6px rgba(0, 0, 0, 0.6);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s, transform 0.15s;
    white-space: nowrap;
}
#hud-center-banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

#drift-meter-wrap {
    position: absolute;
    bottom: calc(14px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%);
    width: min(70%, 340px);
}
#drift-meter-label {
    text-align: center;
    font-size: 0.65rem;
    letter-spacing: 2px;
    color: var(--cyan);
    text-shadow: 0 0 10px var(--cyan);
    margin-bottom: 4px;
    opacity: 0;
    transition: opacity 0.15s;
}
#drift-meter-label.show { opacity: 1; }
#drift-meter-bar {
    height: 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.12);
    overflow: hidden;
    border: 1px solid var(--border);
}
#drift-meter-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--cyan), var(--pink));
    transition: width 0.08s linear;
}

#btn-pause {
    position: absolute;
    top: calc(10px + var(--safe-top));
    right: 12px;
    pointer-events: auto;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---------------------------------------------------------------- countdown ---- */
#countdown-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(5, 4, 14, 0.5);
    z-index: 5;
}
#countdown-num {
    font-size: clamp(4rem, 22vw, 8rem);
    font-weight: 900;
    color: var(--cyan);
    text-shadow: 0 0 30px var(--cyan);
}

/* ---------------------------------------------------------------- typography ---- */
.title-logo {
    font-size: clamp(2.1rem, 9vw, 3.4rem);
    font-weight: 900;
    letter-spacing: 1px;
    margin: 0;
    background: linear-gradient(90deg, var(--cyan), var(--pink));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 0 22px rgba(0, 240, 255, 0.35));
}
.tagline {
    margin: 0 0 6px;
    color: var(--text-dim);
    font-weight: 700;
    letter-spacing: 3px;
    font-size: 0.8rem;
    text-transform: uppercase;
}

.hint {
    color: var(--text-dim);
    font-size: 0.85rem;
    line-height: 1.5;
}
.hint strong { color: var(--text); }

/* ---------------------------------------------------------------- buttons ---- */
.btn {
    appearance: none;
    border-radius: 12px;
    padding: 14px 22px;
    font-weight: 800;
    font-size: 1rem;
    letter-spacing: 0.5px;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text);
    background: var(--panel-solid);
    border: 1px solid var(--border);
    width: 100%;
    max-width: 320px;
    transition: transform 0.08s ease, box-shadow 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
    background: linear-gradient(90deg, var(--cyan), #0891a8);
    color: #04141a;
    box-shadow: 0 8px 28px rgba(0, 240, 255, 0.28);
}
.btn-daily {
    background: linear-gradient(90deg, var(--pink), #a3175c);
    color: #1a0210;
    box-shadow: 0 8px 28px rgba(255, 45, 149, 0.25);
}
.btn-ghost { background: rgba(255, 255, 255, 0.04); }
.btn-small { min-height: 40px; padding: 8px 14px; font-size: 0.85rem; width: auto; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; width: 100%; max-width: 420px; }
.btn-row .btn { flex: 1 1 140px; }

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
}

/* ---------------------------------------------------------------- menu extras ---- */
.best-badge {
    display: inline-flex;
    gap: 6px;
    align-items: baseline;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 6px 16px;
    font-size: 0.85rem;
}
.best-badge b { color: var(--gold); font-variant-numeric: tabular-nums; }

.daily-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    width: 100%;
    max-width: 340px;
    font-size: 0.8rem;
    color: var(--text-dim);
}
.daily-card .num { color: var(--pink); font-weight: 800; }
.daily-card .row { display: flex; justify-content: space-between; margin-top: 4px; }
.daily-card .row b { color: var(--text); }

.menu-toggles { display: flex; gap: 8px; }

/* ---------------------------------------------------------------- game over ---- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(74px, 1fr));
    gap: 5px;
    width: 100%;
    max-width: 460px;
}
.stat-cell {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2px 5px;
}
.stat-cell .hud-label { display: block; margin-bottom: 0; font-size: 0.5rem; }
.stat-cell .hud-value { font-size: 0.88rem; }

.record-banner {
    font-weight: 900;
    font-size: 1.02rem;
    color: var(--gold);
    text-shadow: 0 0 16px currentColor;
    letter-spacing: 0.5px;
}

.away-line { color: var(--text-dim); font-size: 0.75rem; margin: 0; }
.away-line b { color: var(--cyan); }

#nickname-form-wrap { display: flex; flex-direction: column; align-items: center; gap: 2px; }
#nickname-form-wrap .hint { margin: 0 0 2px; font-size: 0.72rem; }
#nickname-form {
    display: flex;
    gap: 6px;
    width: 100%;
    max-width: 340px;
    flex-wrap: wrap;
    justify-content: center;
}
#nickname-input {
    flex: 1 1 180px;
    min-width: 140px;
    min-height: 38px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    padding: 0 14px;
    font-size: 0.95rem;
}
#nickname-status { font-size: 0.72rem; color: var(--text-dim); min-height: 1em; margin: 1px 0 0; }

/* ---------------------------------------------------------------- modals ---- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(3, 2, 10, 0.72);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 50;
    padding: 0;
}
@media (min-width: 640px) {
    .modal-backdrop { align-items: center; padding: 20px; }
}
.modal-card {
    background: var(--panel-solid);
    border: 1px solid var(--border);
    border-radius: 18px 18px 0 0;
    width: 100%;
    max-width: 460px;
    max-height: 86vh;
    overflow-y: auto;
    padding: 18px 18px calc(18px + var(--safe-bottom));
}
@media (min-width: 640px) {
    .modal-card { border-radius: 18px; }
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h2 { margin: 0; font-size: 1.15rem; }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tab-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-dim);
    border-radius: 999px;
    padding: 8px 14px;
    font-weight: 700;
    font-size: 0.78rem;
    min-height: 36px;
}
.tab-btn.active { background: var(--cyan); color: #04141a; }

.lb-list { display: flex; flex-direction: column; gap: 6px; }
.lb-row {
    display: grid;
    grid-template-columns: 34px 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
}
.lb-row.top3 { background: rgba(255, 210, 61, 0.08); }
.lb-rank { font-weight: 800; color: var(--text-dim); }
.lb-row.top3 .lb-rank { color: var(--gold); }
.lb-name { text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--cyan); }
.lb-empty { color: var(--text-dim); font-size: 0.85rem; padding: 20px 0; text-align: center; }

.howto-list { text-align: left; color: var(--text-dim); font-size: 0.88rem; line-height: 1.7; padding-left: 18px; }
.howto-list b { color: var(--text); }

.setting-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border-bottom: none; }
.switch { position: relative; width: 46px; height: 26px; border-radius: 999px; background: rgba(255, 255, 255, 0.12); border: 1px solid var(--border); }
.switch.on { background: var(--cyan); }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left 0.15s; }
.switch.on::after { left: 22px; }

/* ---------------------------------------------------------------- SEO content ---- */
.content-section { padding: 34px 0; }
.content-section h2 { font-size: 1.4rem; margin: 0 0 12px; }
.content-section p, .content-section li { color: var(--text-dim); line-height: 1.7; }
.content-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 14px; }
.content-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.content-card h3 { margin: 0 0 8px; font-size: 1rem; color: var(--cyan); }

.faq-item { border-bottom: 1px solid var(--border); padding: 12px 0; }
.faq-item summary { cursor: pointer; font-weight: 700; }
.faq-item p { margin: 8px 0 0; }

.related-games { display: flex; flex-wrap: wrap; gap: 10px; }
.related-games a {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    text-decoration: none;
    color: var(--text);
    font-size: 0.85rem;
}

.ad-slot {
    max-width: 980px;
    margin: 20px auto;
    min-height: 90px;
    border: 1px dashed var(--border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    font-size: 0.75rem;
    letter-spacing: 1px;
}

.site-footer {
    text-align: center;
    color: var(--text-dim);
    font-size: 0.78rem;
    padding: 24px 16px calc(30px + var(--safe-bottom));
    border-top: 1px solid var(--border);
    margin-top: 20px;
}
.site-footer a { color: var(--text-dim); }
.footer-links { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }

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

.skip-link {
    position: absolute;
    left: 8px;
    top: -50px;
    background: var(--cyan);
    color: #04141a;
    padding: 8px 14px;
    border-radius: 8px;
    z-index: 100;
    transition: top 0.15s;
    font-weight: 700;
    text-decoration: none;
}
.skip-link:focus { top: 8px; }
