:root {
    color-scheme: dark;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --panel: rgba(7, 12, 28, .78);
    --border: rgba(174, 191, 255, .18);
    --text: #f6f8ff;
    --muted: #aeb7ce;
    --purple: #8b5dff;
    --cyan: #38e2df;
    --danger: #ff5c7c;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #040711; }
body { display: grid; place-items: center; color: var(--text); user-select: none; -webkit-user-select: none; touch-action: none; }
button, a { -webkit-tap-highlight-color: transparent; }

.game-shell, .game-stage { width: 100%; height: 100%; min-width: 0; min-height: 0; }
.game-shell { background: #040711; }
.game-stage { position: relative; overflow: hidden; display: grid; place-items: center; }

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    aspect-ratio: 16 / 9;
    object-fit: contain;
    background: #070b18;
    outline: none;
}

.hud {
    position: absolute;
    top: 16px;
    left: 16px;
    right: 146px;
    z-index: 5;
    display: grid;
    grid-template-columns: 136px 92px minmax(160px, 1fr) 122px;
    gap: 10px;
    align-items: stretch;
    pointer-events: none;
}

.hud-card {
    min-width: 0;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--panel);
    box-shadow: 0 14px 38px rgba(0,0,0,.24), inset 0 1px rgba(255,255,255,.035);
    backdrop-filter: blur(10px);
}

.hud-card > span {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 10px;
    line-height: 1;
    font-weight: 900;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.hud-card strong {
    display: block;
    font-size: 21px;
    line-height: 1.05;
    white-space: nowrap;
}

.hud-card--score strong { color: #fff4a0; }
.hud-card--lives strong { color: #ff6888; letter-spacing: .12em; }

.speed-track {
    height: 9px;
    margin-top: 7px;
    overflow: hidden;
    border: 1px solid rgba(134, 150, 205, .28);
    border-radius: 999px;
    background: rgba(18, 24, 46, .86);
    box-shadow: inset 0 2px 7px rgba(0,0,0,.35);
}
.speed-track i {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #35d8ef, #7a72ff, #a763ff);
    box-shadow: 0 0 12px rgba(75, 220, 255, .7);
    transition: width 160ms linear;
}

.audio-toggle {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 7;
    min-width: 118px;
    min-height: 49px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 16px;
    color: var(--text);
    background: var(--panel);
    box-shadow: 0 14px 38px rgba(0,0,0,.24);
    backdrop-filter: blur(10px);
    cursor: pointer;
}
.audio-toggle:focus-visible, .audio-toggle:hover { outline: none; border-color: rgba(139,93,255,.72); }
#audioText { font-size: 12px; font-weight: 900; }

.help-card {
    position: absolute;
    z-index: 5;
    left: 50%;
    bottom: 23px;
    transform: translateX(-50%);
    width: max-content;
    max-width: calc(100% - 32px);
    padding: 10px 18px;
    border: 1px solid rgba(255,255,255,.11);
    border-radius: 15px;
    text-align: center;
    background: rgba(5, 9, 20, .77);
    box-shadow: 0 16px 44px rgba(0,0,0,.25);
    backdrop-filter: blur(10px);
    pointer-events: none;
    transition: opacity .25s ease, transform .25s ease;
}
.help-card.is-hidden { opacity: 0; transform: translate(-50%, 10px); }
.help-card strong, .help-card span { display: block; }
.help-card strong { font-size: 12px; letter-spacing: .14em; }
.help-card span { margin-top: 3px; color: var(--muted); font-size: 11px; }

.level-toast {
    position: absolute;
    z-index: 6;
    top: 88px;
    left: 50%;
    transform: translate(-50%, -8px) scale(.96);
    min-width: 210px;
    padding: 12px 18px;
    border: 1px solid rgba(124, 91, 255, .45);
    border-radius: 16px;
    text-align: center;
    background: rgba(7, 11, 25, .9);
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease;
}
.level-toast.is-visible { opacity: 1; transform: translate(-50%, 0) scale(1); }
.level-toast small { display: block; color: #48ddd5; font-size: 9px; font-weight: 900; letter-spacing: .16em; }
.level-toast strong { display: block; margin-top: 3px; font-size: 23px; }

.mobile-controls {
    position: absolute;
    z-index: 8;
    left: 18px;
    right: 18px;
    bottom: 18px;
    display: none;
    justify-content: space-between;
    pointer-events: none;
}
.mobile-controls button {
    width: 76px;
    height: 76px;
    display: grid;
    place-items: center;
    padding: 8px;
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 23px;
    color: #fff;
    background: rgba(8, 13, 29, .78);
    box-shadow: 0 14px 34px rgba(0,0,0,.28);
    backdrop-filter: blur(10px);
    pointer-events: auto;
}
.mobile-controls b { display: block; font-size: 26px; line-height: 1; }
.mobile-controls small { display: block; margin-top: -6px; color: #bfc8dc; font-size: 9px; font-weight: 900; letter-spacing: .08em; }

.game-over-panel {
    position: absolute;
    z-index: 10;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(420px, calc(100% - 40px));
    padding: 26px 28px;
    border: 1px solid rgba(139,93,255,.48);
    border-radius: 24px;
    text-align: center;
    background: rgba(6,10,23,.94);
    box-shadow: 0 30px 90px rgba(0,0,0,.5), 0 0 44px rgba(104,64,255,.14);
    backdrop-filter: blur(14px);
}
.game-over-panel small { display: block; color: #54e1d7; font-size: 10px; font-weight: 900; letter-spacing: .16em; }
.game-over-panel strong { display: block; margin-top: 7px; font-size: 28px; }
.game-over-panel span { display: block; margin-top: 8px; color: var(--muted); font-size: 13px; }

.game-footer {
    position: absolute;
    z-index: 4;
    right: 10px;
    bottom: 8px;
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 6px 9px;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 999px;
    color: #808aa1;
    background: rgba(4,7,16,.58);
    font-size: 9px;
    pointer-events: auto;
}
.game-footer a { color: #949db1; text-decoration: none; }
.game-footer a:hover { color: #d5ddf4; }

@media (max-width: 760px), (pointer: coarse) {
    .hud { right: 126px; grid-template-columns: 110px 75px minmax(105px, 1fr) 105px; gap: 6px; }
    .hud-card { padding: 8px 10px; border-radius: 13px; }
    .hud-card strong { font-size: 17px; }
    .audio-toggle { min-width: 102px; min-height: 43px; }
    .mobile-controls { display: flex; }
    .help-card { bottom: 18px; }
    .game-footer { display: none; }
}
