:root {
  --ink: #1d2b53;
  --muted: #5b6b8c;
  --card: #ffffff;
  --go: #22c55e;
  --go-dark: #15803d;
  --blue: #2f80ff;
  --blue-dark: #1d5fd1;
  --pink: #ff4fa3;
  --pink-dark: #c2307a;
  --orange: #ff9500;
  --font: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Nunito", system-ui, sans-serif;
  --gap: clamp(10px, 2vmin, 20px);
  --safe-t: max(16px, env(safe-area-inset-top));
  --safe-r: max(16px, env(safe-area-inset-right));
  --safe-b: max(16px, env(safe-area-inset-bottom));
  --safe-l: max(16px, env(safe-area-inset-left));
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(#59c3ff, #c8efff);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: 0.45; }
[hidden] { display: none !important; }

/* ---------- screens ---------- */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: var(--gap);
  padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
  overflow-y: auto;
}
.screen.on { display: flex; }

/* ---------- buttons ---------- */
.big-btn {
  font-size: clamp(26px, 5vmin, 46px);
  font-weight: 800;
  color: #fff;
  padding: 0.45em 1.3em;
  border-radius: 999px;
  background: var(--go);
  box-shadow: 0 0.18em 0 var(--go-dark);
  transition: transform 0.08s, box-shadow 0.08s;
}
.big-btn:active { transform: translateY(0.14em); box-shadow: 0 0.04em 0 var(--go-dark); }
.big-btn.blue { background: var(--blue); box-shadow: 0 0.18em 0 var(--blue-dark); }
.big-btn.blue:active { box-shadow: 0 0.04em 0 var(--blue-dark); }
.pill {
  font-size: clamp(16px, 2.6vmin, 22px);
  font-weight: 800;
  padding: 0.45em 0.9em;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
  white-space: nowrap;
}
.pill.icon { padding: 0.45em 0.6em; }
.pill.stars { background: #fff6d6; }
.pill.level { background: #e8f0ff; }
.pill.speed { background: #ffe9dc; }
.pill.trophies { background: #fff6d6; }
.link { font-size: 18px; font-weight: 700; color: var(--muted); text-decoration: underline; padding: 12px; }

/* ---------- who's racing ---------- */
.title { display: flex; align-items: center; gap: 0.25em; margin-top: 2vmin; font-size: clamp(44px, 10vmin, 96px); }
.title h1 {
  font-size: 1em;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0.06em 0 var(--blue-dark), 0 0.1em 0.15em rgba(0, 0, 0, 0.2);
}
.ask { font-size: clamp(30px, 6.5vmin, 60px); font-weight: 800; text-align: center; }
.racers { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--gap); max-width: 1100px; margin-bottom: auto; }
.racer-card {
  width: clamp(150px, 26vmin, 230px);
  aspect-ratio: 3 / 4;
  border-radius: 32px;
  background: var(--paint, #fff);
  box-shadow: 0 10px 0 rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 14px 10px 16px;
  border: 5px solid #fff;
  transition: transform 0.1s;
}
.racer-card:active { transform: translateY(6px) scale(0.98); }
.racer-car { width: 100%; flex: 1; min-height: 0; background: rgba(255, 255, 255, 0.92); border-radius: 22px; }
.racer-name { font-size: clamp(26px, 5vmin, 42px); font-weight: 900; color: #fff; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.3); }
.racer-stars { font-size: clamp(16px, 2.6vmin, 22px); font-weight: 800; background: rgba(255, 255, 255, 0.92); border-radius: 999px; padding: 0.2em 0.7em; }
.racer-card.add { background: rgba(255, 255, 255, 0.6); border: 5px dashed #fff; justify-content: center; gap: 8px; }
.racer-card.add .plus { font-size: clamp(60px, 12vmin, 110px); font-weight: 900; color: var(--blue); line-height: 1; }
.racer-card.add .racer-name { color: var(--blue); text-shadow: none; font-size: clamp(20px, 3.6vmin, 30px); }

/* ---------- new racer ---------- */
.back { position: absolute; top: var(--safe-t); left: var(--safe-l); z-index: 1; }
.step { display: none; flex-direction: column; align-items: center; gap: calc(var(--gap) * 1.5); margin: auto; width: 100%; }
.step.on { display: flex; }
.name-input {
  font: inherit;
  font-size: clamp(36px, 8vmin, 72px);
  font-weight: 800;
  text-align: center;
  width: min(90%, 620px);
  padding: 0.25em 0.5em;
  border-radius: 28px;
  border: 5px solid #fff;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.12);
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}
.name-input:focus { border-color: var(--blue); }
.ages { --size: clamp(90px, 17vmin, 150px); display: flex; flex-wrap: wrap; justify-content: center; gap: var(--gap); max-width: calc(4 * var(--size) + 3 * var(--gap)); }
.ages button {
  width: var(--size);
  aspect-ratio: 1;
  border-radius: 50%;
  font-size: clamp(40px, 9vmin, 80px);
  font-weight: 900;
  color: #fff;
  background: var(--blue);
  box-shadow: 0 8px 0 var(--blue-dark);
}
.ages button:nth-child(3n + 2) { background: var(--pink); box-shadow: 0 8px 0 var(--pink-dark); }
.ages button:nth-child(3n) { background: var(--go); box-shadow: 0 8px 0 var(--go-dark); }
.ages button:active { transform: translateY(6px); box-shadow: none; }
.swatches { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--gap); max-width: 820px; }
.swatch {
  width: clamp(80px, 14vmin, 120px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--paint);
  border: 5px solid #fff;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.2), inset 0 -8px 0 rgba(0, 0, 0, 0.12);
  position: relative;
  flex-shrink: 0;
}
.swatches.small { justify-content: flex-start; gap: 10px; }
.swatches.row-scroll { flex-wrap: nowrap; overflow-x: auto; max-width: none; padding: 7px 8px 12px; scrollbar-width: none; }
.swatches.row-scroll::-webkit-scrollbar { display: none; }
.swatches.small .swatch { width: clamp(44px, 7vmin, 62px); border-width: 4px; box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2); }
.swatch.on { outline: 5px solid var(--ink); outline-offset: 2px; }
.swatch.locked { filter: grayscale(0.7) opacity(0.6); }
.swatch.locked::after { content: "🔒"; position: absolute; inset: 0; display: grid; place-items: center; font-size: clamp(16px, 3vmin, 24px); }

/* ---------- garage ---------- */
.topbar { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 1100px; flex-wrap: wrap; }
.topbar h2 { flex: 1; font-size: clamp(24px, 4.6vmin, 40px); font-weight: 900; text-align: center; min-width: 180px; }
.garage-body { display: flex; gap: calc(var(--gap) * 1.5); align-items: center; justify-content: center; width: 100%; max-width: 1100px; flex: 1 0 auto; }
.podium {
  width: clamp(130px, 22vmin, 230px);
  aspect-ratio: 3 / 5;
  border-radius: 40px;
  background: radial-gradient(circle at 50% 60%, #fff 0 46%, rgba(255, 255, 255, 0.45) 47%);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.podium canvas { width: 92%; height: 92%; }
.pickers { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; max-width: 660px; }
.pickers h3 { font-size: clamp(18px, 3vmin, 26px); font-weight: 800; }
.tiles { display: flex; gap: 10px; overflow-x: auto; padding: 4px 4px 12px; scrollbar-width: none; }
.tiles::-webkit-scrollbar { display: none; }
.tile {
  flex: 0 0 auto;
  width: clamp(84px, 13vmin, 116px);
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.14);
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: 4px solid transparent;
}
.tile.on { border-color: var(--ink); }
.tile.locked { background: #eef2f8; }
.tile.locked canvas, .tile.locked .track-swatch { opacity: 0.35; filter: grayscale(0.8); }
.tile canvas { width: 100%; height: clamp(58px, 9vmin, 84px); }
.tile-name { font-size: clamp(13px, 2vmin, 16px); font-weight: 800; text-align: center; line-height: 1.1; }
.track-swatch {
  width: 100%;
  height: clamp(58px, 9vmin, 84px);
  border-radius: 14px;
  background: var(--ground);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px;
  font-size: clamp(18px, 3vmin, 26px);
}
.track-swatch::before { content: ""; position: absolute; inset: 0 34%; background: var(--road); }
.track-swatch span { position: relative; }
.next-unlock { width: min(100%, 640px); display: flex; flex-direction: column; gap: 6px; font-weight: 800; font-size: clamp(16px, 2.6vmin, 22px); text-align: center; }
.bar { height: 16px; border-radius: 999px; background: rgba(255, 255, 255, 0.75); overflow: hidden; box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.08); }
.bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #ffd23f, var(--orange));
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 0.5s;
  border-radius: inherit;
}
.go { font-size: clamp(40px, 9vmin, 80px); padding: 0.22em 1.6em; animation: pulse 1.6s ease-in-out infinite; position: sticky; bottom: 12px; }

/* ---------- race ---------- */
.race { padding: 0; touch-action: none; background: #333; }
#track { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 12px max(12px, env(safe-area-inset-left));
  pointer-events: none;
}
.hud button { pointer-events: auto; }
.lapbox {
  flex: 1;
  max-width: 420px;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  padding: 6px 18px 9px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.15);
  font-weight: 900;
  font-size: clamp(14px, 3vmin, 26px);
  white-space: nowrap;
}
.lapbox .bar { width: 100%; height: 10px; background: #e3e8f2; }
.lapbox .bar i { transition: none; }
.hud-right { display: flex; align-items: center; gap: 8px; }
.pips { display: flex; gap: 5px; background: rgba(255, 255, 255, 0.92); padding: 9px 10px; border-radius: 999px; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.15); }
.pips i { width: 16px; height: 16px; border-radius: 50%; background: #d9dee8; }
.pips i.on { background: #ff6a00; box-shadow: 0 0 8px #ffb300; }
.pips.turbo i { background: #ff6a00; animation: flicker 0.3s infinite alternate; }
.steer {
  position: absolute;
  bottom: max(20px, env(safe-area-inset-bottom));
  font-size: clamp(40px, 8vmin, 72px);
  color: rgba(255, 255, 255, 0.8);
  text-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  animation: nudge 1.2s ease-in-out infinite;
}
.steer.left { left: max(20px, env(safe-area-inset-left)); }
.steer.right { right: max(20px, env(safe-area-inset-right)); }
.banner {
  position: absolute;
  top: 36%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(64px, 15vmin, 150px);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0.06em 0 var(--blue-dark), 0 0.1em 0.2em rgba(0, 0, 0, 0.3);
  pointer-events: none;
  opacity: 0;
  white-space: nowrap;
}
.banner.small { font-size: clamp(40px, 9vmin, 90px); }
.banner.show { animation: banner 1.1s ease-out forwards; }
.banner.turbo { color: #ffd23f; text-shadow: 0 0.06em 0 #ff6a00, 0 0 0.3em #ff6a00; }

/* ---------- overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: rgba(20, 30, 60, 0.35);
  z-index: 10;
}
.overlay.open { display: flex; animation: fade 0.2s; }
.card {
  background: var(--card);
  border-radius: 36px;
  box-shadow: 0 14px 0 rgba(0, 0, 0, 0.15), 0 20px 50px rgba(0, 0, 0, 0.25);
  padding: clamp(16px, 3vmin, 32px);
  width: min(100%, 920px);
  max-height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(10px, 2vmin, 18px);
  position: relative;
  animation: pop 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}

/* pit stop */
.pit-head { display: flex; align-items: center; gap: 12px; width: 100%; }
.pit-head h2 { flex: 1; font-size: clamp(28px, 5.5vmin, 52px); font-weight: 900; color: var(--blue); }
.wrench { font-size: clamp(28px, 5.5vmin, 52px); display: inline-block; animation: wiggle 1s ease-in-out infinite; }
.pics { display: flex; align-items: center; justify-content: center; gap: clamp(10px, 2.5vmin, 28px); flex-wrap: wrap; }
.pics .op, .pics .or { font-size: clamp(36px, 7vmin, 64px); font-weight: 900; color: var(--muted); }
.pics .or { font-size: clamp(24px, 4.5vmin, 40px); }
.group { display: grid; grid-template-columns: repeat(5, auto); gap: 4px 6px; justify-content: center; }
.group.win { border-radius: 18px; box-shadow: 0 0 0 5px var(--go); background: #dcfce7; }
.pic { font-size: clamp(34px, 6.5vmin, 60px); line-height: 1.15; position: relative; display: inline-block; }
.pic.gone .emo { opacity: 0.3; }
.pic.gone::before { content: "✕"; position: absolute; inset: 0; display: grid; place-items: center; color: #ff3b30; font-weight: 900; font-size: 0.8em; }
.missed .pic:not(.gone)::after {
  content: attr(data-n);
  position: absolute;
  right: -0.15em;
  bottom: -0.1em;
  min-width: 1.4em;
  padding: 0 0.25em;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 0.38em;
  font-weight: 900;
  text-align: center;
  line-height: 1.4;
  animation: pop 0.3s backwards;
  animation-delay: calc(var(--i) * 90ms);
}
.dots { display: grid; grid-template-columns: repeat(var(--cols, 5), auto); gap: 6px; justify-content: center; }
.dot { width: clamp(16px, 3vmin, 26px); aspect-ratio: 1; border-radius: 50%; background: var(--blue); position: relative; }
.dot.b { background: var(--orange); }
.dot.c { background: var(--pink); }
.dot.gone { background: #d0d4dc; }
.dot.gone::after { content: "✕"; position: absolute; inset: 0; display: grid; place-items: center; color: #ff3b30; font-size: 0.75em; font-weight: 900; }
.qtext { display: flex; align-items: center; justify-content: center; gap: 0.22em; font-size: clamp(56px, 13vmin, 130px); font-weight: 900; line-height: 1.05; flex-wrap: wrap; text-align: center; }
.pics:not([hidden]) + .qtext { font-size: clamp(44px, 9vmin, 96px); }
.qtext .op, .work .op { color: var(--muted); }
.qtext .blank, .work .blank { color: var(--blue); min-width: 1.1em; text-align: center; border-bottom: 0.08em solid var(--blue); animation: blink 1.2s ease-in-out infinite; }
.qtext .ans, .line .ans { color: var(--go-dark); background: #dcfce7; border-radius: 0.18em; padding: 0 0.15em; animation: pop 0.4s; }

/* how to work it out: lines of working, or a written column */
.work { display: flex; flex-direction: column; align-items: center; gap: 0.2em; font-size: clamp(32px, 6.5vmin, 64px); font-weight: 900; line-height: 1.1; }
.line { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 0.25em; animation: pop 0.35s; }
.line:not(:last-child) { font-size: 0.75em; opacity: 0.6; }
.column { display: grid; grid-template-columns: repeat(var(--w), 0.9em); justify-items: center; font-size: clamp(48px, 11vmin, 104px); }
.column > span { width: 100%; text-align: center; border-radius: 0.15em; }
.column .on { background: #e6f0ff; }
.column .above { font-size: 0.45em; color: var(--orange); align-self: end; }
.column .crossed { color: #a0a6b3; text-decoration: line-through 0.08em #ff3b30; }
.column .sign { color: var(--muted); }
.column .rule { grid-column: 1 / -1; height: 0.07em; background: var(--ink); border-radius: 0; margin: 0.05em 0; }
.column .ans { color: var(--go-dark); }
.column .new { animation: pop 0.35s; }
.column .ans.lead { opacity: 0.3; }
.column .blank { min-width: 0; }
@media (max-height: 500px) {
  .column { font-size: 34px; }
  .work { font-size: 26px; }
  .work:not([hidden]) ~ .choices .choice { min-height: 60px; font-size: 38px; }
}
.work-say { max-width: 34em; text-align: center; color: var(--muted); font-weight: 800; font-size: clamp(16px, 2.6vmin, 24px); line-height: 1.3; }
.qtext .word { font-size: 0.55em; }
.choices { display: grid; grid-template-columns: repeat(var(--n, 3), 1fr); gap: clamp(10px, 2vmin, 20px); width: 100%; }
.choice {
  --c: var(--blue);
  min-height: clamp(96px, 17vmin, 170px);
  border-radius: 28px;
  background: #fff;
  border: 5px solid #d8e3f5;
  box-shadow: 0 10px 0 #b9c7e0;
  font-size: clamp(48px, 11vmin, 110px);
  font-weight: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.08s, box-shadow 0.08s;
}
.choice:nth-child(2) { --c: var(--pink); }
.choice:nth-child(3) { --c: var(--orange); }
.choice:nth-child(4) { --c: #8b5cf6; }
.choice .num { color: var(--c); line-height: 1; }
.choice:active { transform: translateY(8px); box-shadow: 0 2px 0 #b9c7e0; }
.choice.right { background: #dcfce7; border-color: var(--go); box-shadow: 0 10px 0 var(--go-dark); animation: bounce 0.5s; }
.choice.right .num, .choice.reveal .num { color: var(--go-dark); }
.choice.wrong { background: #f1f2f6; border-color: #d0d4dc; box-shadow: 0 4px 0 #c0c4cc; transform: translateY(6px); animation: shake 0.4s; }
.choice.wrong .num { color: #a0a6b3; }
.choice.dim { opacity: 0.35; }
.key-hint { display: none; color: var(--muted); font-weight: 700; font-size: clamp(14px, 2vmin, 18px); }
@media (hover: hover) and (pointer: fine) { .key-hint { display: block; } }
.choice.reveal { background: #dcfce7; border-color: var(--go); box-shadow: 0 10px 0 var(--go-dark), 0 0 0 8px rgba(34, 197, 94, 0.25); animation: glow 0.9s ease-in-out infinite alternate; }
.mini { display: grid; grid-template-columns: repeat(5, auto); gap: 3px; }
.mini i { width: clamp(7px, 1.3vmin, 11px); aspect-ratio: 1; border-radius: 50%; background: var(--c); opacity: 0.8; }
.fuel { display: flex; align-items: center; gap: 10px; width: min(100%, 520px); font-size: clamp(22px, 4vmin, 34px); }
.fuel .bar { flex: 1; height: 18px; background: #e3e8f2; }
.fuel .bar i { background: linear-gradient(90deg, var(--go), #a3e635); transition: transform 1s ease-out; }
.fuel .bar i.full { transform: scaleX(1); }
.toast {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--blue);
  color: #fff;
  font-weight: 900;
  font-size: clamp(22px, 4vmin, 34px);
  padding: 0.3em 1em;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 5px 0 var(--blue-dark);
}
.toast.show { animation: toast 2.6s ease-out forwards; }
.float { position: fixed; font-weight: 900; font-size: clamp(28px, 5vmin, 44px); color: var(--orange); text-shadow: 0 2px 0 #fff, 0 0 8px #fff; pointer-events: none; animation: float 1.1s ease-out forwards; z-index: 30; transform: translateX(-50%); }

/* finish */
.finish-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.3em; }
.finish-body { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: clamp(12px, 3vmin, 32px); width: 100%; }
.prize { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1 1 240px; max-width: 340px; text-align: center; }
.prize-tier { font-size: clamp(16px, 2.6vmin, 22px); font-weight: 900; padding: 0.1em 0.8em; border-radius: 999px; color: #fff; background: var(--metal, #999); }
.prize-tier.silver, .prize-tier.gold, .prize-tier.diamond { color: var(--ink); }
.prize-name { font-size: clamp(22px, 4vmin, 34px); font-weight: 900; line-height: 1.1; }
.badges { display: flex; gap: 8px; margin-top: 4px; }
.badge { width: 2.1em; aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%; background: #eef2f8; font-size: clamp(16px, 2.6vmin, 22px); filter: grayscale(1); opacity: 0.45; }
.badge.on { background: #dcfce7; box-shadow: 0 0 0 3px var(--go); filter: none; opacity: 1; }
.tally { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: 1 1 300px; min-width: 0; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.finish-card .row { position: sticky; bottom: 0; width: 100%; padding-top: 8px; background: var(--card); }
.trophy { line-height: 1; animation: trophy 1s cubic-bezier(0.2, 1.4, 0.4, 1) both, bob 2s ease-in-out 1s infinite; }
.symbols { position: absolute; width: 0; height: 0; overflow: hidden; }
.bronze { --metal: #c98a4b; --edge: #8f5a2a; }
.silver { --metal: #cfd6df; --edge: #8e98a6; }
.gold { --metal: #ffcc33; --edge: #c78f00; }
.diamond { --metal: #8ff0ff; --edge: #2fa8d5; }
.cup { position: relative; display: inline-block; width: clamp(72px, 12vmin, 104px); aspect-ratio: 100 / 120; flex-shrink: 0; }
.cup svg { display: block; width: 100%; height: 100%; overflow: visible; }
.cup.big { width: clamp(96px, 20vmin, 180px); }
.cup.diamond { animation: shimmer 1.6s ease-in-out infinite alternate; }
.cup-emoji { position: absolute; left: 0; right: 0; top: 16%; text-align: center; line-height: 1; font-size: calc(var(--cup-size, 1) * clamp(28px, 5vmin, 42px)); }
.cup.big .cup-emoji { --cup-size: 1.75; }
.cup.medal .cup-emoji { top: 47%; }
.cup.star .cup-emoji { top: 26%; }
.cup.shield .cup-emoji { top: 20%; }
.metal { fill: var(--metal); stroke: var(--edge); stroke-width: 2; }
.edge { fill: var(--edge); stroke: var(--edge); }
.gloss { fill: rgba(255, 255, 255, 0.45); }
.ribbon-a { fill: #ff4fa3; }
.ribbon-b { fill: #2f80ff; }
.finish-card h2 { font-size: clamp(32px, 6.5vmin, 60px); font-weight: 900; text-align: center; }
.finish-lines { list-style: none; width: min(100%, 520px); font-size: clamp(18px, 3.2vmin, 28px); font-weight: 700; }
.finish-lines li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 4px; border-bottom: 2px dashed #e3e8f2; }
.finish-lines li.total { font-size: 1.3em; font-weight: 900; border: 0; color: #e08600; }
.unlocks { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.unlock { width: 150px; padding: 10px; border-radius: 24px; background: #fff6d6; box-shadow: 0 6px 0 #f0d58a; display: flex; flex-direction: column; align-items: center; gap: 6px; font-weight: 900; text-align: center; animation: pop 0.5s 0.6s backwards; }
.unlock .new { color: var(--pink); font-size: 22px; }
.unlock canvas, .unlock .track-swatch { width: 100px; height: 100px; }
.unlock .swatch { width: 90px; }
.finish-card .unlock { width: auto; flex-direction: row; padding: 6px 14px 6px 8px; border-radius: 18px; box-shadow: 0 4px 0 #f0d58a; }
.finish-card .unlock canvas, .finish-card .unlock .track-swatch { width: 44px; height: 56px; }
.finish-card .unlock .swatch { width: 44px; border-width: 3px; box-shadow: none; }
.finish-card .unlock .new { font-size: 16px; }
.row { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }

/* trophy case */
.trophy-room { background: linear-gradient(#3a2f6b, #6b4fa0); color: #fff; }
.trophy-room .pill { color: var(--ink); }
.trophy-room h2 { text-shadow: 0 3px 0 rgba(0, 0, 0, 0.25); }
.case-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(120px, 20vmin, 170px), 1fr)); gap: var(--gap); width: 100%; max-width: 1100px; }
.case-item { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 8px 14px; color: #fff; background: rgba(255, 255, 255, 0.12); border-radius: 22px; box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.18); content-visibility: auto; contain-intrinsic-size: 160px 190px; }
.case-item.cheer .cup { animation: bounce 0.5s; }
.case-name { font-size: clamp(14px, 2.2vmin, 18px); font-weight: 800; line-height: 1.15; text-align: center; }

/* pause and grown-up gate */
.pause-card, .gate-card { width: min(100%, 480px); }
.pause-card h2, .gate-card h2 { font-size: clamp(30px, 6vmin, 52px); font-weight: 900; }
.gate-q { font-size: 44px; font-weight: 900; }
.gate-show { font-size: 40px; font-weight: 900; min-height: 1.3em; min-width: 3em; text-align: center; border-bottom: 4px solid #d8e3f5; }
.pad { display: grid; grid-template-columns: repeat(3, 80px); gap: 10px; }
.pad button { height: 68px; border-radius: 18px; background: #eef3fb; font-size: 32px; font-weight: 800; box-shadow: 0 5px 0 #c9d5ea; }
.pad button:active { transform: translateY(4px); box-shadow: 0 1px 0 #c9d5ea; }
.shake { animation: shake 0.4s; }

/* ---------- grown-ups ---------- */
.grown { background: #f4f7fb; align-items: stretch; font-family: system-ui, -apple-system, sans-serif; }
.grown .topbar { max-width: 760px; margin: 0 auto; }
.grown-list { display: flex; flex-direction: column; gap: 16px; }
.grown-card {
  background: #fff;
  border-radius: 20px;
  padding: 18px 20px;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  -webkit-user-select: text;
  user-select: text;
  flex-shrink: 0;
}
.grown-card h3 { font-size: 22px; margin-bottom: 10px; }
.grown-card h4 { font-size: 17px; margin: 14px 0 4px; }
.grown-card dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 17px; }
.grown-card dt { color: var(--muted); }
.grown-card dd { font-weight: 700; }
.grown-card ul { margin: 4px 0 0 20px; font-size: 16px; line-height: 1.5; }
.grown-card p { font-size: 16px; line-height: 1.5; margin-bottom: 10px; color: #33415c; }
.edit { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-top: 16px; }
.edit label { display: flex; flex-direction: column; font-size: 14px; color: var(--muted); gap: 4px; }
.edit input, .edit select { font: inherit; font-size: 18px; padding: 8px 10px; border-radius: 10px; border: 2px solid #d8e3f5; background: #fff; color: var(--ink); }
.edit input[type=checkbox] { width: 28px; height: 28px; padding: 0; }
.small-btn { font-size: 16px; font-weight: 700; padding: 11px 14px; border-radius: 12px; background: #eef3fb; }
.small-btn.danger { background: #ffe8e6; color: #c0281c; }
.check { display: flex; align-items: center; gap: 10px; font-size: 18px; padding: 6px 0; }
.check input { width: 24px; height: 24px; }

/* ---------- confetti ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 20; overflow: hidden; }
.confetti i { position: absolute; top: -24px; width: 12px; height: 18px; border-radius: 3px; animation: fall 2.6s linear forwards; }

@media (max-width: 640px) {
  .garage-body { flex-direction: column; }
  .podium { width: 110px; }
  .pickers { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

@keyframes pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fade { from { opacity: 0; } }
@keyframes pulse { 50% { transform: scale(1.06); } }
@keyframes bounce { 30% { transform: scale(1.12); } 60% { transform: scale(0.96); } }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
@keyframes glow { to { box-shadow: 0 10px 0 var(--go-dark), 0 0 0 14px rgba(34, 197, 94, 0.35); } }
@keyframes blink { 50% { opacity: 0.35; } }
@keyframes wiggle { 50% { transform: rotate(-20deg); } }
@keyframes banner {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  35% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(1); }
}
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 10px); } 12%, 82% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }
@keyframes float { from { opacity: 1; margin-top: 0; } to { opacity: 0; margin-top: -90px; } }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
@keyframes trophy { from { transform: scale(0) rotate(-30deg); } }
@keyframes bob { 50% { transform: translateY(-10px); } }
@keyframes shimmer { to { filter: brightness(1.2) drop-shadow(0 0 10px #8ff0ff); } }
@keyframes nudge { 50% { transform: scale(1.15); } }
@keyframes flicker { to { opacity: 0.6; } }

/* grade meter */
.pill.grade { background: #e3f8ea; display: inline-flex; align-items: center; gap: 8px; }
.pill.grade .meter { width: clamp(40px, 7vw, 72px); height: 10px; border-radius: 5px; background: #fff; box-shadow: inset 0 0 0 1.5px #9fdcb5; overflow: hidden; }
.pill.grade .meter::after { content: ''; display: block; height: 100%; width: var(--done, 0%); background: linear-gradient(90deg, #4ade80, #16a34a); border-radius: 5px; }
.pill.grade.news { animation: bounce 0.6s 1.2s 2; box-shadow: 0 0 0 3px #4ade80; }

/* grown-ups skill tables */
.skill-tables details { margin: 6px 0; }
.skill-tables summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.skill-tables .small-btn { margin-top: 10px; }
table.skills { width: 100%; border-collapse: collapse; font-size: 14px; margin: 4px 0 8px; }
table.skills th, table.skills td { padding: 4px 6px; text-align: right; border-bottom: 1px solid #e4e8f0; }
table.skills th:first-child, table.skills td:first-child, table.skills th:nth-child(2), table.skills td:nth-child(2) { text-align: left; }
table.skills tr.mastered td:last-child { color: #15803d; font-weight: 700; }
table.skills tr.learning td:last-child { color: #b45309; font-weight: 700; }
table.skills tr.later td { color: var(--muted); }
@media (max-width: 560px) { table.skills th:nth-child(2), table.skills td:nth-child(2), table.skills th:nth-child(6), table.skills td:nth-child(6) { display: none; } }
