:root {
  --asphalt: #151a26;
  --asphalt-2: #1e2535;
  --asphalt-3: #2a3347;
  --line: #ffcc00;
  --ocean: #19b5c8;
  --ocean-deep: #0e5f7a;
  --land: #2f8f5b;
  --land-2: #3fae6d;
  --coral: #ff5a5f;
  --go: #3ddc84;
  --text: #f4f6fb;
  --muted: #a8b1c7;
  --radius: 16px;
  --shadow: 0 8px 24px rgba(0, 0, 0, .35);
  --display: "Bungee", "Impact", system-ui, sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--asphalt);
  background-image: radial-gradient(circle at 20% 0%, #24304a 0, transparent 45%), radial-gradient(circle at 100% 100%, #10343f 0, transparent 40%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.45;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
#app { max-width: 920px; margin: 0 auto; padding: 16px 16px 48px; }
h1, h2, h3, .display { font-family: var(--display); font-weight: 400; letter-spacing: .5px; margin: 0; }
h1 { font-size: clamp(28px, 7vw, 46px); line-height: 1.05; }
h2 { font-size: clamp(22px, 5vw, 30px); }
h3 { font-size: 18px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 12px; }
.hidden { display: none !important; }

/* Buttons */
button { font: inherit; color: inherit; cursor: pointer; }
.btn {
  border: 0; border-radius: 999px; padding: 12px 20px; font-weight: 800;
  background: var(--asphalt-3); color: var(--text);
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.25);
  transition: transform .08s ease, filter .15s ease;
  min-height: 46px;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(2px); }
.btn:focus-visible, .choice:focus-visible, .stop:focus-visible, .chip:focus-visible { outline: 3px solid var(--line); outline-offset: 3px; }
.btn.primary { background: var(--line); color: #1b1b1b; }
.btn.go { background: var(--go); color: #0d2a19; }
.btn.danger { background: var(--coral); color: #2b0b0c; }
.btn.ghost { background: transparent; border: 2px solid var(--asphalt-3); }
.btn.big { font-size: 18px; padding: 16px 28px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.linkish { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 4px; }

/* Cards */
.card {
  background: var(--asphalt-2); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); border: 1px solid rgba(255,255,255,.05);
}

/* Title / road stripe */
.road-stripe {
  height: 10px; border-radius: 6px; margin: 14px 0;
  background: repeating-linear-gradient(90deg, var(--line) 0 34px, transparent 34px 58px), var(--asphalt-3);
  background-size: 58px 100%;
}
.anim .road-stripe { animation: roll 1.2s linear infinite; }
@keyframes roll { to { background-position: -58px 0, 0 0; } }

/* Garage (profiles) */
.hero { padding: 26px 4px 8px; }
.hero h1 span { color: var(--line); }
.profiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-top: 16px; }
.profile {
  text-align: left; border: 2px solid transparent; border-radius: var(--radius); padding: 14px;
  background: var(--asphalt-2); display: flex; gap: 12px; align-items: center;
}
.profile:hover { border-color: var(--asphalt-3); }
.profile .name { font-weight: 800; font-size: 17px; }
.profile .meta { color: var(--muted); font-size: 13px; }
.car-badge { width: 54px; height: 36px; flex: none; }
.new-profile { justify-content: center; border: 2px dashed var(--asphalt-3); background: transparent; color: var(--muted); font-weight: 800; min-height: 70px; }
.field { display: block; width: 100%; padding: 14px; border-radius: 12px; border: 2px solid var(--asphalt-3); background: var(--asphalt); color: var(--text); font: inherit; font-size: 18px; }
.field:focus { outline: none; border-color: var(--line); }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 44px; height: 44px; border-radius: 50%; border: 3px solid transparent; }
.swatch[aria-pressed="true"] { border-color: #fff; transform: scale(1.08); }

/* HUD */
.hud { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--asphalt-2);
  padding: 8px 12px; border-radius: 999px; font-weight: 800; font-size: 14px; border: 0;
}
.chip b { color: var(--line); }
.chip.streak b { color: var(--coral); }
.xpbar { height: 8px; background: var(--asphalt-3); border-radius: 6px; overflow: hidden; margin-top: 6px; }
.xpbar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--ocean), var(--go)); }

/* Map */
.map-wrap { position: relative; margin-top: 12px; }
.map { width: 100%; height: auto; display: block; border-radius: var(--radius); background: linear-gradient(180deg, #0f4a63, #0b3346); box-shadow: var(--shadow); }
.map .island { fill: var(--land); stroke: #e9d8a6; stroke-width: 6; stroke-linejoin: round; }
.map .ridge { fill: none; stroke: #23704a; stroke-width: 14; stroke-linecap: round; stroke-linejoin: round; opacity: .9; }
.map .route { fill: none; stroke: #0d1119; stroke-width: 12; stroke-linecap: round; stroke-linejoin: round; }
.map .route-dash { fill: none; stroke: var(--line); stroke-width: 3; stroke-dasharray: 10 10; stroke-linecap: round; }
.map .route-done { fill: none; stroke: var(--go); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.map .wave { fill: none; stroke: rgba(255,255,255,.15); stroke-width: 2; }
.map .label { fill: #fff; font: 800 15px var(--body); paint-order: stroke; stroke: rgba(0,0,0,.6); stroke-width: 4px; }
.map .stop-dot { stroke: #0d1119; stroke-width: 4; }
.map .stop { cursor: pointer; }
.map .stop.locked { cursor: not-allowed; }
.map .stop.locked .stop-dot { fill: #59627a; }
.map .stop .ring { fill: none; stroke: var(--line); stroke-width: 3; opacity: 0; }
.map .stop.next .ring { opacity: 1; }
.anim .map .stop.next .ring { animation: pulse 1.6s ease-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes pulse { 0% { transform: scale(.7); opacity: 1; } 100% { transform: scale(1.9); opacity: 0; } }
.map .stars { fill: var(--line); font: 800 13px var(--body); paint-order: stroke; stroke: #0d1119; stroke-width: 3px; }
.map .boss-tag { fill: var(--coral); font: 400 12px var(--display); paint-order: stroke; stroke: #0d1119; stroke-width: 3px; }

/* Stop list (mobile-friendly alternative to tapping the map) */
.stop-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; margin-top: 14px; }
.stop-row {
  display: flex; gap: 12px; align-items: center; text-align: left; padding: 12px 14px;
  border-radius: 14px; border: 2px solid transparent; background: var(--asphalt-2);
}
.stop-row:hover:not([disabled]) { border-color: var(--asphalt-3); }
.stop-row[disabled] { opacity: .5; cursor: not-allowed; }
.stop-row .num { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-family: var(--display); background: var(--asphalt-3); flex: none; }
.stop-row.done .num { background: var(--go); color: #0d2a19; }
.stop-row.next { border-color: var(--line); }
.stop-row .title { font-weight: 800; }
.stop-row .sub { font-size: 13px; color: var(--muted); }
.stop-row .st { margin-left: auto; color: var(--line); font-weight: 800; letter-spacing: 2px; white-space: nowrap; }

.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 16px; }
.mode {
  text-align: left; border: 0; border-radius: var(--radius); padding: 16px; background: var(--asphalt-2);
  border-top: 5px solid var(--ocean); min-height: 116px;
}
.mode h3 { margin-bottom: 4px; }
.mode p { color: var(--muted); font-size: 14px; margin: 0; }
.mode.pit { border-top-color: var(--go); }
.mode.ot { border-top-color: var(--coral); }
.mode.boss { border-top-color: var(--line); }
.mode .pill { display: inline-block; margin-top: 8px; font-size: 12px; font-weight: 800; background: var(--asphalt-3); padding: 3px 10px; border-radius: 999px; }

/* Drive (question) screen */
.drive-top { display: flex; align-items: center; gap: 10px; }
.track {
  position: relative; height: 64px; margin: 14px 0 6px; border-radius: 14px; overflow: hidden;
  background: var(--asphalt-3);
}
.track::before { content: ""; position: absolute; left: 0; right: 0; top: 30px; height: 4px; background: repeating-linear-gradient(90deg, var(--line) 0 24px, transparent 24px 44px); }
.track .finish { position: absolute; right: 8px; top: 8px; bottom: 8px; width: 16px; background: repeating-conic-gradient(#fff 0 25%, #111 0 50%) 0 0 / 8px 8px; border-radius: 3px; }
.track .car { position: absolute; top: 12px; left: 0; width: 64px; height: 40px; transition: left .5s cubic-bezier(.3, 1.4, .5, 1); }
.track .car.bump { animation: bump .45s ease; }
@keyframes bump { 20% { transform: translate(-4px, 2px) rotate(-6deg); } 50% { transform: translate(4px, -2px) rotate(5deg); } 80% { transform: translate(-2px, 0) rotate(-2deg); } }
.track .car.boost { animation: boost .5s ease; }
@keyframes boost { 50% { transform: translateY(-6px) scale(1.08); } }

.timer { height: 8px; border-radius: 6px; background: var(--asphalt-3); overflow: hidden; }
.timer > i { display: block; height: 100%; background: var(--coral); transition: width .25s linear; }

.question { font-size: clamp(19px, 4.6vw, 24px); font-weight: 800; line-height: 1.3; margin: 10px 0 14px; }
.choices { display: grid; gap: 10px; }
.choice {
  display: flex; gap: 12px; align-items: center; text-align: left; width: 100%;
  border: 2px solid var(--asphalt-3); background: var(--asphalt-2); border-radius: 14px; padding: 14px; font-size: 17px; min-height: 56px;
}
.choice:hover:not([disabled]) { border-color: var(--ocean); }
.choice .key { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--asphalt-3); font-weight: 800; flex: none; font-size: 14px; }
.choice.right { border-color: var(--go); background: rgba(61, 220, 132, .14); }
.choice.right .key { background: var(--go); color: #0d2a19; }
.choice.wrong { border-color: var(--coral); background: rgba(255, 90, 95, .14); }
.choice.wrong .key { background: var(--coral); color: #2b0b0c; }
.choice[disabled] { cursor: default; }

.feedback { margin-top: 14px; border-radius: 14px; padding: 14px; background: var(--asphalt-3); border-left: 6px solid var(--go); }
.feedback.bad { border-left-color: var(--coral); }
.feedback .head { font-family: var(--display); font-size: 20px; margin-bottom: 4px; }
.feedback .src { font-size: 13px; color: var(--muted); margin-top: 6px; }

.combo { font-family: var(--display); color: var(--line); }
.float-xp { position: fixed; left: 50%; top: 40%; transform: translateX(-50%); font-family: var(--display); font-size: 34px; color: var(--go); pointer-events: none; text-shadow: 0 3px 0 #000; z-index: 50; }
.anim .float-xp { animation: floatup .9s ease forwards; }
@keyframes floatup { from { opacity: 1; transform: translate(-50%, 0) scale(1); } to { opacity: 0; transform: translate(-50%, -70px) scale(1.3); } }

/* Signs */
.sign-art { display: flex; justify-content: center; margin: 4px 0 2px; }
.sign-art svg { width: 120px; height: 120px; filter: drop-shadow(0 6px 10px rgba(0,0,0,.4)); }

/* Sign-picture answer choices */
.choices.sign-choices { grid-template-columns: repeat(2, 1fr); }
.sign-choices .choice { flex-direction: column; justify-content: center; padding: 12px 8px; min-height: 130px; position: relative; }
.sign-choices .choice .key { position: absolute; top: 8px; left: 8px; }
.choice-sign { width: 96px; height: 96px; filter: drop-shadow(0 4px 6px rgba(0,0,0,.35)); }
.review-sign { width: 56px; height: 56px; float: right; margin: 0 0 6px 10px; }

/* Readiness */
.ready-card { margin-top: 14px; border-top: 5px solid var(--asphalt-3); }
.ready-card.is-ready { border-top-color: var(--go); }
.ready-pct { font-family: var(--display); color: var(--line); font-weight: 400; }
.ready-card.is-ready .ready-pct { color: var(--go); }
.checks { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 6px; }
.checks li { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 15px; }
.checks li.ok { color: var(--text); }
.checks .tick { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--asphalt-3); display: grid; place-items: center; flex: none; font-weight: 800; }
.checks li.ok .tick { background: var(--go); border-color: var(--go); color: #0d2a19; }

/* Save code */
.field.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; line-height: 1.35; word-break: break-all; resize: vertical; }

/* Coach Corner */
.plan { padding-left: 22px; margin: 0; }
.plan li { margin-bottom: 8px; }
.plan a { color: var(--ocean); }
.spot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.spot { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px; border-radius: 12px; border: 2px solid var(--asphalt-3); background: var(--asphalt); font-size: 12px; line-height: 1.25; text-align: center; }
.spot svg { width: 54px; height: 54px; }
.spot.on { border-color: var(--go); background: rgba(61, 220, 132, .12); }
.talk { background: var(--asphalt-3); border-radius: 12px; padding: 12px 14px; }
.talk summary { cursor: pointer; font-weight: 800; }
.talk p { margin: 8px 0 0; color: var(--muted); }

/* Results */
.result-hero { text-align: center; padding: 10px 0; }
.big-stars { font-size: 54px; letter-spacing: 6px; color: var(--line); line-height: 1; }
.big-stars .off { color: var(--asphalt-3); }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.stat { background: var(--asphalt-3); border-radius: 12px; padding: 12px; text-align: center; }
.stat b { display: block; font-family: var(--display); font-size: 24px; color: var(--line); }
.stat span { font-size: 13px; color: var(--muted); }
.review-list { list-style: none; padding: 0; margin: 0; }
.review-list li { padding: 12px 0; border-top: 1px solid var(--asphalt-3); }
.review-list .ans { color: var(--go); font-weight: 800; }
.review-list .yours { color: var(--coral); }

.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.badge { background: var(--asphalt-3); border-radius: 12px; padding: 12px; text-align: center; font-size: 13px; }
.badge .ico { font-family: var(--display); font-size: 22px; color: var(--line); display: block; }
.badge.locked { opacity: .35; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60;
  background: var(--line); color: #1b1b1b; font-weight: 800; padding: 12px 18px; border-radius: 999px; box-shadow: var(--shadow);
  max-width: calc(100% - 32px); text-align: center;
}

.footer { margin-top: 28px; font-size: 13px; color: var(--muted); }
.footer a { color: var(--muted); }

@media (max-width: 560px) {
  #app { padding: 12px 16px 40px; }
  .card { padding: 14px; }
  .stat-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .stat b { font-size: 20px; }
  .map .label { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
