:root {
  color-scheme: dark;
  --bg: #080b13;
  --panel: rgba(13, 18, 31, .78);
  --panel-strong: rgba(13, 18, 31, .94);
  --line: rgba(255, 255, 255, .10);
  --text: #f7f8fb;
  --muted: #9da8bc;
  --accent: #4f8cff;
  --accent-2: #58e0d1;
  --danger: #ff5f6f;
  --success: #7df2b5;
  --shadow: 0 24px 80px rgba(0, 0, 0, .42);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); }
button, input { font: inherit; }
button { color: inherit; }

#app { position: relative; width: 100%; height: 100%; overflow: hidden; isolation: isolate; background: #0a0f1a; }
#gameCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#app::after { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 1; background: radial-gradient(circle at 50% 45%, transparent 30%, rgba(0,0,0,.28) 100%); }

.loading-screen { position: absolute; inset: 0; z-index: 50; display: grid; place-content: center; justify-items: center; gap: 12px; background: #080b13; opacity: 0; visibility: hidden; transition: opacity .4s ease, visibility .4s ease; }
.loading-screen.active { opacity: 1; visibility: visible; }
.loading-screen strong { letter-spacing: .18em; font-size: 20px; }
.loading-screen small { color: var(--muted); }
.loading-logo { position: relative; width: 62px; height: 62px; }
.loading-logo span { position: absolute; inset: 0; border: 4px solid transparent; border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
.loading-logo span:last-child { inset: 10px; border-top-color: var(--accent-2); animation-direction: reverse; animation-duration: .75s; }
@keyframes spin { to { transform: rotate(360deg); } }

.topbar { position: absolute; z-index: 12; left: 0; right: 0; top: 0; min-height: 76px; display: flex; align-items: center; justify-content: space-between; padding: max(18px, env(safe-area-inset-top)) clamp(20px, 3vw, 54px) 14px; border-bottom: 1px solid rgba(255,255,255,.06); background: linear-gradient(180deg, rgba(4,7,13,.72), rgba(4,7,13,.08)); backdrop-filter: blur(10px); }
.mini-brand { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 850; letter-spacing: .16em; }
.mini-brand i { width: 18px; height: 18px; display: block; border: 3px solid var(--accent); border-radius: 50%; position: relative; box-shadow: 0 0 20px rgba(79,140,255,.35); }
.mini-brand i::after { content: ""; position: absolute; width: 8px; height: 3px; background: var(--accent); left: 5px; top: 5px; transform: rotate(-18deg); transform-origin: left center; border-radius: 4px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.best-pill { min-width: 104px; height: 42px; padding: 0 16px; border: 1px solid var(--line); background: rgba(9,13,23,.64); border-radius: 13px; display: flex; align-items: center; justify-content: space-between; gap: 14px; box-shadow: inset 0 1px 0 rgba(255,255,255,.04); }
.best-pill span { color: var(--muted); font-size: 10px; letter-spacing: .13em; font-weight: 800; }
.best-pill strong { font-size: 15px; }
.icon-button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 13px; background: rgba(9,13,23,.65); display: grid; place-content: center; font-weight: 900; font-size: 18px; cursor: pointer; transition: transform .2s ease, background .2s ease, opacity .2s ease; }
.icon-button:hover { transform: translateY(-2px); background: rgba(255,255,255,.1); }
.hidden { display: none !important; }

.screen { position: absolute; inset: 0; z-index: 5; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .35s ease, visibility .35s ease; }
.screen.active { opacity: 1; visibility: visible; pointer-events: auto; }

.menu-screen { padding: 110px clamp(22px, 5vw, 88px) 40px; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(290px, .65fr); align-items: center; gap: clamp(24px, 5vw, 80px); }
.hero-panel { max-width: 820px; }
.eyebrow { color: var(--accent); font-size: clamp(11px, 1.2vw, 15px); font-weight: 900; letter-spacing: .22em; margin-bottom: 12px; }
.hero-panel h1 { margin: 0; font-size: clamp(64px, 10vw, 150px); line-height: .78; letter-spacing: -.075em; font-weight: 950; text-shadow: 0 18px 50px rgba(0,0,0,.35); }
.hero-panel h1 span { display: block; color: transparent; -webkit-text-stroke: 2px rgba(255,255,255,.86); text-stroke: 2px rgba(255,255,255,.86); }
.hero-panel > p { max-width: 650px; margin: clamp(18px, 3vh, 32px) 0 26px; color: #c2cad8; font-size: clamp(15px, 1.5vw, 20px); line-height: 1.55; }
.menu-actions { width: min(640px, 100%); display: grid; gap: 12px; }
.play-button, .secondary-button { border: 0; cursor: pointer; min-height: 72px; border-radius: 18px; padding: 0 22px; display: flex; align-items: center; justify-content: space-between; gap: 20px; transition: transform .2s ease, box-shadow .2s ease, filter .2s ease; }
.play-button { background: linear-gradient(135deg, #6fa2ff, #3f72f2); color: #ffffff; box-shadow: 0 14px 36px rgba(79,140,255,.24), inset 0 1px 0 rgba(255,255,255,.45); }
.play-button:hover { transform: translateY(-3px) scale(1.006); box-shadow: 0 20px 48px rgba(79,140,255,.32); }
.play-button span, .secondary-button span { display: grid; text-align: left; }
.play-button small, .secondary-button small { font-size: 10px; letter-spacing: .12em; font-weight: 850; opacity: .68; }
.play-button strong, .secondary-button strong { font-size: 21px; line-height: 1.1; }
.play-button b, .secondary-button b { font-size: 28px; }
.secondary-button { background: rgba(13,18,31,.77); border: 1px solid rgba(255,255,255,.10); box-shadow: inset 0 1px 0 rgba(255,255,255,.04), 0 15px 35px rgba(0,0,0,.16); }
.secondary-button:hover { transform: translateY(-2px); background: rgba(21,29,48,.86); }
.secondary-button .button-icon { display: grid; place-content: center; width: 38px; height: 38px; border-radius: 12px; background: rgba(88,224,209,.12); color: var(--accent-2); font-size: 18px; }
.controls-strip { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 10px; }
.controls-strip div { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
kbd { border: 1px solid rgba(255,255,255,.13); border-bottom-color: rgba(255,255,255,.25); background: rgba(6,9,16,.68); border-radius: 8px; padding: 7px 9px; color: #e9edf5; font-size: 9px; letter-spacing: .09em; font-weight: 900; box-shadow: inset 0 -2px 0 rgba(255,255,255,.03); }

.menu-aside { display: grid; gap: 14px; align-content: center; }
.route-card, .stats-card { background: linear-gradient(160deg, rgba(18,25,41,.88), rgba(9,13,23,.82)); border: 1px solid rgba(255,255,255,.10); border-radius: 24px; box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.05); backdrop-filter: blur(18px); }
.route-card { padding: 18px; }
.route-card-top { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 10px; font-weight: 850; letter-spacing: .13em; }
.route-card-top strong { color: var(--text); }
.skin-preview { height: 190px; position: relative; display: grid; place-content: center; overflow: hidden; isolation: isolate; }
.skin-preview::before { content: ""; position: absolute; inset: auto -20px 8px; height: 84px; background: radial-gradient(circle at 50% 45%, rgba(88,224,209,.20), transparent 56%), linear-gradient(180deg, rgba(19,27,43,0), rgba(19,27,43,.85)); }
.skin-preview::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: 24px; height: 18px; border-radius: 999px; background: radial-gradient(circle at 50% 50%, rgba(88,224,209,.18), rgba(88,224,209,0) 70%); filter: blur(10px); }
.skin-orbit { position: absolute; width: 270px; height: 92px; border: 1px solid rgba(88,224,209,.26); border-radius: 50%; left: 50%; bottom: 30px; transform: translateX(-50%); box-shadow: 0 0 50px rgba(88,224,209,.10); }
.skin-orbit::before, .skin-orbit::after { content: ""; position: absolute; inset: 12px; border: 1px dashed rgba(255,255,255,.11); border-radius: inherit; }
.garage-canvas { position: relative; z-index: 2; width: min(100%, 330px); height: auto; aspect-ratio: 2 / 1; filter: drop-shadow(0 22px 24px rgba(0,0,0,.38)); transform: translateY(-2px); }
.skin-preview:hover .garage-canvas { transform: translateY(-6px) scale(1.015); transition: transform .25s ease; }
.selector-label { margin: 10px 0 8px; font-size: 10px; letter-spacing: .22em; color: rgba(255,255,255,.52); }
.selector-label-paint { margin-top: 12px; }
.skin-selector { display: grid; grid-template-columns: 42px 1fr 42px; gap: 10px; align-items: center; }
.skin-selector button { width: 42px; height: 42px; border-radius: 13px; border: 1px solid var(--line); background: rgba(255,255,255,.04); cursor: pointer; font-size: 25px; }
.skin-selector div { display: grid; text-align: center; }
.skin-selector strong { font-size: 16px; }.skin-selector small { color: var(--muted); margin-top: 3px; font-size: 11px; }
.stats-card { padding: 20px; display: grid; grid-template-columns: 1fr repeat(3, auto); gap: 15px; align-items: end; }
.stats-card > span { align-self: start; color: var(--muted); font-size: 10px; font-weight: 850; letter-spacing: .14em; }
.stats-card div { display: grid; text-align: right; gap: 2px; }
.stats-card small { color: var(--muted); font-size: 10px; }.stats-card strong { font-size: 20px; }

.hud-screen { padding: 100px clamp(22px, 4vw, 64px) 32px; }
.route-info { position: absolute; left: clamp(22px, 4vw, 64px); top: 98px; display: grid; gap: 3px; text-shadow: 0 3px 16px rgba(0,0,0,.45); }
.route-info span { color: var(--accent); font-size: 10px; font-weight: 900; letter-spacing: .15em; }
.route-info strong { font-size: clamp(18px, 2vw, 28px); letter-spacing: .03em; }
.route-info small { color: #c7ced9; font-size: 11px; font-weight: 800; letter-spacing: .12em; }
.live-score { position: absolute; top: 98px; right: clamp(22px, 4vw, 64px); display: flex; gap: 8px; }
.live-score > div { min-width: 92px; min-height: 58px; border: 1px solid rgba(255,255,255,.10); border-radius: 16px; background: rgba(8,12,21,.58); backdrop-filter: blur(14px); display: grid; align-content: center; padding: 10px 14px; box-shadow: inset 0 1px 0 rgba(255,255,255,.04); }
.live-score span { color: var(--muted); font-size: 9px; font-weight: 850; letter-spacing: .12em; }
.live-score strong { font-size: 20px; margin-top: 1px; }.live-score .charges strong { color: var(--accent); letter-spacing: .1em; font-size: 15px; }
.target-readout { position: absolute; left: 50%; top: 102px; transform: translateX(-50%); display: grid; justify-items: center; text-shadow: 0 3px 14px rgba(0,0,0,.4); }
.target-readout span { font-size: 9px; font-weight: 850; letter-spacing: .15em; color: #bdc6d4; }
.target-readout strong { font-size: clamp(24px, 3vw, 44px); letter-spacing: -.04em; }

.brake-panel { position: absolute; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(760px, calc(100% - 36px)); min-height: 118px; padding: 16px; display: grid; grid-template-columns: 1fr 1.25fr auto; align-items: center; gap: 18px; border: 1px solid rgba(255,255,255,.11); border-radius: 24px; background: rgba(8,12,21,.78); backdrop-filter: blur(20px); box-shadow: 0 22px 70px rgba(0,0,0,.36), inset 0 1px 0 rgba(255,255,255,.05); }
.brake-copy { display: grid; gap: 2px; }
.brake-copy span { color: var(--accent); font-size: 9px; font-weight: 900; letter-spacing: .15em; }
.brake-copy strong { font-size: 20px; }
.heat-wrap { min-width: 0; }.heat-label { display: flex; justify-content: space-between; color: var(--muted); font-size: 9px; font-weight: 850; letter-spacing: .11em; margin-bottom: 7px; }
.heat-track { height: 10px; border-radius: 20px; background: rgba(255,255,255,.07); overflow: hidden; box-shadow: inset 0 1px 4px rgba(0,0,0,.4); }
.heat-track span { display: block; height: 100%; width: 0%; border-radius: inherit; background: linear-gradient(90deg, #5be1cf, #4f8cff 65%, #ff6676); box-shadow: 0 0 16px rgba(79,140,255,.35); transition: width .07s linear; }
.brake-button { width: 160px; min-height: 82px; border: 0; border-radius: 20px; cursor: pointer; background: linear-gradient(145deg, #ff6676, #d93c53); color: white; box-shadow: 0 13px 34px rgba(217,60,83,.28), inset 0 1px 0 rgba(255,255,255,.32), inset 0 -5px 0 rgba(105,13,35,.18); display: grid; place-content: center; touch-action: none; user-select: none; transition: transform .08s ease, filter .15s ease; }
.brake-button span { font-size: 22px; font-weight: 950; letter-spacing: .05em; }.brake-button small { font-size: 8px; opacity: .78; margin-top: 3px; letter-spacing: .09em; font-weight: 800; }
.brake-button.active { transform: translateY(3px) scale(.985); filter: brightness(.9); }
.brake-button:disabled { cursor: default; opacity: .88; }
.brake-button.locked { background: linear-gradient(145deg, #6fa2ff, #3569e8); color: #ffffff; box-shadow: 0 13px 34px rgba(79,140,255,.24), inset 0 1px 0 rgba(255,255,255,.4), inset 0 -5px 0 rgba(13,45,116,.18); }

.stage-screen, .gameover-screen { display: grid; place-content: center; padding: 90px 20px 30px; background: rgba(4,7,13,.16); backdrop-filter: blur(8px); }
.stage-card, .gameover-card { width: min(520px, calc(100vw - 34px)); border: 1px solid rgba(255,255,255,.12); border-radius: 28px; background: linear-gradient(155deg, rgba(19,26,43,.95), rgba(8,12,21,.94)); box-shadow: 0 35px 100px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.06); padding: clamp(24px, 4vw, 38px); text-align: center; }
.stage-card > span, .gameover-card > span { color: var(--accent); font-size: 10px; font-weight: 900; letter-spacing: .18em; }
.stage-card h2, .gameover-card h2 { margin: 8px 0 16px; font-size: clamp(44px, 7vw, 78px); line-height: .92; letter-spacing: -.055em; }
.stage-points, .final-score { display: grid; margin: 10px 0 20px; }.stage-points small, .final-score small { color: var(--muted); font-size: 9px; letter-spacing: .14em; font-weight: 850; }.stage-points strong, .final-score strong { font-size: clamp(38px, 7vw, 68px); color: var(--accent); }
.stage-breakdown, .final-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-bottom: 18px; }
.stage-breakdown div, .final-grid div { border: 1px solid var(--line); border-radius: 15px; padding: 13px 8px; display: grid; gap: 4px; background: rgba(255,255,255,.025); }
.stage-breakdown span, .final-grid span { color: var(--muted); font-size: 9px; }.stage-breakdown strong, .final-grid strong { font-size: 16px; }
.stage-actions, .gameover-actions { display: grid; gap: 10px; }.compact { min-height: 62px; border-radius: 16px; }.compact strong { font-size: 18px; }

.toast { position: absolute; z-index: 30; left: 50%; top: 30%; transform: translate(-50%, -10px) scale(.94); padding: 11px 18px; border: 1px solid rgba(255,255,255,.14); border-radius: 999px; background: rgba(7,10,18,.88); color: white; font-size: 13px; font-weight: 950; letter-spacing: .08em; opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease; box-shadow: 0 16px 50px rgba(0,0,0,.35); }
.toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }.toast.good { color: var(--accent); box-shadow: 0 0 35px rgba(79,140,255,.18); }
.rotate-notice { display: none; position: absolute; inset: 0; z-index: 90; background: #080b13; place-content: center; justify-items: center; gap: 8px; text-align: center; }.rotate-notice b { font-size: 46px; }.rotate-notice small { color: var(--muted); }

@media (max-width: 930px) {
  .menu-screen { grid-template-columns: 1fr; padding-top: 95px; align-content: center; gap: 22px; }
  .menu-aside { grid-template-columns: 1fr 1fr; }
  .route-card { display: none; }
  .stats-card { grid-column: 1 / -1; }
  .hero-panel h1 { font-size: clamp(62px, 16vw, 110px); }
  .brake-panel { grid-template-columns: 1fr 1fr auto; }
}

@media (max-width: 700px) {
  .topbar { min-height: 60px; padding: 10px 14px; }.mini-brand span { display: none; }.best-pill { min-width: 88px; height: 38px; }.icon-button { width: 38px; height: 38px; }
  .menu-screen { padding: 72px 16px 16px; }.hero-panel > p { margin: 14px 0 18px; font-size: 14px; }.play-button, .secondary-button { min-height: 60px; border-radius: 15px; }.play-button strong, .secondary-button strong { font-size: 17px; }.controls-strip { display: none; }.stats-card { padding: 14px; gap: 8px; }.stats-card strong { font-size: 16px; }
  .hud-screen { padding: 72px 15px 15px; }.route-info { left: 15px; top: 72px; }.route-info strong { font-size: 17px; }.live-score { right: 15px; top: 70px; }.live-score > div { min-width: 65px; min-height: 48px; padding: 8px 9px; }.live-score strong { font-size: 15px; }.live-score .charges { display: none; }.target-readout { top: 72px; }.target-readout strong { font-size: 25px; }
  .brake-panel { min-height: 86px; padding: 10px; border-radius: 18px; grid-template-columns: 1fr auto; }.brake-copy { display: none; }.heat-wrap { padding-left: 4px; }.brake-button { width: 124px; min-height: 64px; border-radius: 16px; }.brake-button span { font-size: 18px; }.brake-button small { font-size: 7px; }
}

@media (orientation: portrait) and (max-width: 760px) {
  .rotate-notice { display: grid; }
}

@media (orientation: landscape) and (max-height: 520px) {
  .topbar { min-height: 54px; padding: 8px 18px; }
  .menu-screen { display: block; padding: 66px 34px 14px; overflow-y: auto; }
  .menu-aside, .controls-strip { display: none; }
  .hero-panel { max-width: 760px; }
  .eyebrow { margin-bottom: 7px; font-size: 9px; }
  .hero-panel h1 { font-size: clamp(48px, 9.5vw, 72px); line-height: .88; letter-spacing: -.06em; white-space: nowrap; }
  .hero-panel h1 span { display: inline; margin-left: 12px; -webkit-text-stroke-width: 1px; }
  .hero-panel > p { margin: 7px 0 12px; max-width: 600px; font-size: 12px; line-height: 1.35; }
  .menu-actions { width: min(760px, 100%); grid-template-columns: 1.12fr .88fr; gap: 8px; }
  .play-button, .secondary-button { min-height: 58px; border-radius: 15px; padding: 0 17px; }
  .play-button strong, .secondary-button strong { font-size: 16px; }
  .play-button small, .secondary-button small { font-size: 8px; }
  .secondary-button .button-icon { width: 32px; height: 32px; }
  .route-info { top: 62px; }
  .live-score { top: 60px; }
  .target-readout { top: 61px; }
  .brake-panel { bottom: 9px; }
}
