/* Car Launch: bright, rounded, thumb-friendly. The 3D scene is a full-screen canvas;
   every screen is an overlay on top of it. */
:root {
  --ink: #1f2a44;
  --ink-soft: #5a6580;
  --line: #e7ecf4;
  --panel: #ffffff;
  --panel-soft: rgba(255, 255, 255, 0.86);
  --gold: #ffc21a;
  --gold-hi: #ffe27a;
  --gold-lo: #e09a00;
  --orange: #ff6b2c;
  --orange-lo: #e04a12;
  --green: #2fbf71;
  --red: #ff4a3d;
  --blue: #3f8ef0;
  --shadow: 0 10px 24px -12px rgba(31, 42, 68, 0.45);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  font-family: "Baloo 2", ui-rounded, system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #5aa8f5 0%, #e4f5ff 70%);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

button, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: var(--sg-corner-top) calc(var(--safe-right) + 12px) 0 calc(var(--safe-left) + 12px); /* the top row lines up with the corner (shared/menu.css) */
  pointer-events: none;
}
.screen > * { pointer-events: auto; }

/* ---------- Shared bits ---------- */
.coin-icon {
  display: inline-block;
  flex: none;
  width: 1em;
  height: 1em;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, transparent 0 46%, rgba(160, 98, 0, 0.55) 47% 53%, transparent 54%),
    radial-gradient(circle at 35% 30%, var(--gold-hi), var(--gold) 55%, var(--gold-lo));
  box-shadow: inset 0 -1px 0 rgba(120, 70, 0, 0.35), 0 1px 0 rgba(31, 42, 68, 0.15);
  vertical-align: -0.14em;
}

.coins {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 0 16px 0 12px;
  border-radius: 999px;
  background: var(--panel);
  box-shadow: var(--shadow);
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
}
.coins .coin-icon { width: 26px; height: 26px; }
.coins b { padding-top: 3px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--ink);
  text-decoration: none;
}
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:active { transform: scale(0.94); }
.sound-toggle.off .wave { display: none; }
.sound-toggle.off::after {
  content: "";
  position: absolute;
  width: 26px;
  height: 3px;
  border-radius: 2px;
  background: var(--red);
  transform: rotate(-45deg);
}
.sound-toggle { position: relative; }

.primary, .secondary {
  min-height: 56px;
  padding: 0 24px;
  border: 0;
  border-radius: 18px;
  font-size: 21px;
  font-weight: 800;
  line-height: 1;
}
.primary {
  color: #fff;
  background: linear-gradient(180deg, #ff8a4c, var(--orange) 55%, var(--orange-lo));
  box-shadow: 0 5px 0 #b83a0c, 0 12px 20px -10px rgba(184, 58, 12, 0.7);
  text-shadow: 0 2px 0 rgba(120, 30, 0, 0.3);
}
.secondary {
  color: var(--ink);
  background: #f1f4f9;
  box-shadow: 0 5px 0 #cfd6e3;
}
.primary:active, .secondary:active { transform: translateY(3px); box-shadow: 0 2px 0 #b83a0c; }
.secondary:active { box-shadow: 0 2px 0 #cfd6e3; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }

/* ---------- Loading ---------- */
.loading {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 0 rgba(31, 42, 68, 0.3);
  text-align: center;
  padding: 24px;
}

/* ---------- Garage ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
}
/* All games (shared/menu.css) on the left of the top bar; the game's name and the coins under it. */
.topbar .sg-corner-slot { margin: 0 auto 0 calc(var(--sg-corner-left) - var(--safe-left) - 12px); }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; pointer-events: none !important; }
.title-row > * { pointer-events: auto; }
.game-name { margin: 0; font: 800 clamp(34px, 9.8vw, 42px)/1.05 "Baloo 2", ui-rounded, system-ui, sans-serif; color: var(--orange); text-shadow: 0 3px 0 var(--orange-lo), 0 0 18px rgba(255, 255, 255, 0.55); pointer-events: none !important; }

/* The level being played: name, best distance as a bar, and the way into the level list. */
.level-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  min-height: 60px;
  padding: 8px 12px 8px 14px;
  border: 0;
  border-radius: 20px;
  background: var(--panel-soft);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  text-align: left;
}
.level-pill:active { transform: scale(0.98); }
.level-dot {
  width: 18px;
  height: 18px;
  flex: none;
  border-radius: 50%;
  background: var(--c, var(--green));
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--c, var(--green));
}
.level-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.level-text b { font-size: 19px; font-weight: 800; line-height: 1.05; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.level-text small { font-size: 13px; font-weight: 600; line-height: 1; color: var(--ink-soft); }
.level-bar { display: block; height: 7px; border-radius: 4px; background: #d9e0eb; overflow: hidden; }
.level-bar i { display: block; height: 100%; width: 0; border-radius: 4px; background: linear-gradient(90deg, var(--green), var(--gold)); }
.level-more {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex: none;
  height: 40px;
  padding: 2px 6px 0 14px;
  border-radius: 14px;
  background: #fff;
  font-size: 16px;
  font-weight: 800;
}
.level-more svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }

.car-title {
  align-self: center;
  max-width: 100%;
  margin: -40px 0 8px;
  padding: 6px 20px 6px;
  border-radius: 20px;
  background: var(--panel);
  box-shadow: 0 -6px 18px -10px rgba(31, 42, 68, 0.45);
  text-align: center;
  flex: none;
}
.car-title h1 { margin: 0; font-size: 24px; font-weight: 800; line-height: 1.05; }
.car-title p { margin: 0; font-size: 15px; font-weight: 600; color: var(--ink-soft); white-space: nowrap; }
.car-title p b { color: var(--orange); font-weight: 800; }

.panel {
  margin: auto calc(-1 * (var(--safe-right) + 12px)) 0 calc(-1 * (var(--safe-left) + 12px));
  display: flex;
  flex-direction: column;
  border-radius: 28px 28px 0 0;
  background: var(--panel);
  box-shadow: 0 -8px 30px -12px rgba(31, 42, 68, 0.45);
  padding: 12px calc(var(--safe-right) + 14px) calc(var(--safe-bottom) + 12px) calc(var(--safe-left) + 14px);
}

/* Three big upgrade buttons; "Upgrade car" is the star. */
.upgrades {
  display: grid;
  grid-template-columns: 1.25fr 1fr 1fr;
  gap: 8px;
}
.up {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
  padding: 10px 6px 8px;
  border: 0;
  border-radius: 20px;
  background: #f1f4f9;
  box-shadow: 0 4px 0 #d4dbe6;
  touch-action: manipulation;
}
.up:active { transform: translateY(2px); box-shadow: 0 2px 0 #d4dbe6; }
.up-car { background: #fff3e6; box-shadow: 0 4px 0 #f2c49a, inset 0 0 0 3px var(--orange); }
.up-car:active { box-shadow: 0 2px 0 #f2c49a, inset 0 0 0 3px var(--orange); }
.up-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--c);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.15);
}
.up-icon svg { width: 26px; height: 26px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.up-name { font-size: 16px; font-weight: 800; line-height: 1.1; white-space: nowrap; }
.up-sub { font-size: 12px; font-weight: 700; line-height: 1.1; color: var(--ink-soft); white-space: nowrap; }
.up-sub.two { white-space: pre; text-align: center; } /* rockets: burn on one line, friction on the next */
.part-pips { display: flex; gap: 4px; margin: 2px 0 1px; }
.part-pips i { width: 12px; height: 12px; border-radius: 50%; background: #f2dccb; }
.part-pips i.on { background: var(--orange); box-shadow: 0 0 0 2px rgba(255, 107, 44, 0.25); }
.price {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  height: 36px;
  margin-top: 4px;
  padding-top: 2px;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold) 60%);
  box-shadow: inset 0 -3px 0 var(--gold-lo);
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.price .coin-icon { width: 17px; height: 17px; }
.price svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.up.poor .price { background: #e3e8f0; box-shadow: inset 0 -3px 0 #cfd6e3; color: #8a94a8; }
.up.maxed .price { background: #dff5e8; box-shadow: none; color: var(--green); }
.up.locked { opacity: 0.7; }
.up.locked .up-icon { background: #c3cbd8; }
.up.locked .price { background: #e3e8f0; box-shadow: none; color: #6f7a90; font-size: 13px; }
.up.nope { animation: nope 0.35s; }
@keyframes nope {
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}

.launch-row {
  display: flex;
  gap: 10px;
  flex: none;
  margin-top: 12px;
}
.driver-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  height: 60px;
  padding: 0 14px 0 8px;
  border: 0;
  border-radius: 18px;
  background: #f1f4f9;
  text-align: left;
}
.driver-chip:active { transform: scale(0.97); }
.driver-chip img { width: 44px; height: 44px; border-radius: 50%; background: #fdf3e4; }
.crew-faces { position: relative; flex: none; display: block; width: 52px; height: 48px; }
.crew-faces img { position: absolute; left: 0; top: 0; }
.crew-faces .rider { left: auto; right: -2px; top: auto; bottom: -4px; width: 30px; height: 30px; box-shadow: 0 0 0 2px #f1f4f9; }
.crew-faces .rider[hidden] { display: none; }
.crew-names { display: flex; flex-direction: column; min-width: 0; max-width: 92px; line-height: 1.05; }
.crew-names b, .crew-names small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.driver-chip small { font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.driver-chip b { font-size: 18px; font-weight: 800; }
.launch-btn {
  flex: 1;
  min-height: 60px;
  border: 0;
  border-radius: 18px;
  color: #fff;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.02em;
  background: linear-gradient(180deg, #ff8a4c, var(--orange) 55%, var(--orange-lo));
  box-shadow: 0 5px 0 #b83a0c, 0 12px 20px -10px rgba(184, 58, 12, 0.7);
  text-shadow: 0 2px 0 rgba(120, 30, 0, 0.3);
}
.launch-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #b83a0c; }

/* ---------- Pickers (levels, drivers) ---------- */
.picker { max-height: min(86%, 640px); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.sheet-head h2 { margin: 0; font-size: 28px; font-weight: 800; line-height: 1; }
.icon-btn.small { width: 44px; height: 44px; box-shadow: none; background: #f1f4f9; }
.areas { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.area { padding: 10px 12px 12px; border-radius: 18px; background: #f4f7fb; }
.area-name { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 800; line-height: 1.1; }
.area-name .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--c); }
.area.closed .area-name { color: #8a94a8; }
.area.closed .area-name .dot { background: #c3cbd8; }
.lvls { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.lvls.eight { grid-template-columns: repeat(4, 1fr); } /* the universes: two rows of four */
.lvl {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  max-width: 56px;
  margin: 0 auto;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 3px var(--c), 0 3px 0 #d4dbe6;
  font-size: 20px;
  font-weight: 800;
  color: var(--ink);
}
button.lvl:active { transform: scale(0.94); }
.lvl.done { background: var(--c); color: #fff; box-shadow: 0 3px 0 rgba(31, 42, 68, 0.25); }
.lvl.current { box-shadow: 0 0 0 4px var(--orange), 0 3px 0 #d4dbe6; }
.lvl.done.current { box-shadow: 0 0 0 4px var(--orange); }
.lvl.locked { background: #e3e8f0; box-shadow: none; color: #8a94a8; }
.lvl svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.lvl.locked svg { width: 18px; height: 18px; stroke-width: 2.4; }

.list {
  list-style: none;
  margin: 0;
  padding: 2px 0 6px;
}
.row-name { font-size: 18px; font-weight: 800; line-height: 1.15; }

.driver-grid { list-style: none; }
.driver-grid ul {
  list-style: none;
  margin: 0;
  padding: 6px 0 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.driver-grid li { min-width: 0; }
.driver {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  width: 100%;
  height: 100%;
  padding: 8px 4px 10px;
  border: 0;
  border-radius: 18px;
  background: #f4f7fb;
  text-align: center;
  font: inherit;
  color: inherit;
}
button.driver:active { transform: scale(0.97); }
.driver.selected { background: #fff3ea; box-shadow: inset 0 0 0 3px var(--orange); }
.cat-wrap { position: relative; display: block; }
.driver .cat { display: block; width: 64px; height: 64px; border-radius: 50%; background: #fdf3e4; }
.driver.locked .cat { filter: grayscale(1) brightness(0.55) contrast(0.8); opacity: 0.7; }
.ribbon {
  position: absolute;
  left: 50%;
  bottom: -6px;
  transform: translateX(-50%);
  padding: 1px 8px 0;
  border-radius: 999px;
  background: var(--orange);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.driver .row-name { margin-top: 4px; font-size: 18px; }
.driver.locked .row-name { color: #8a94a8; }
.perk {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.15;
  color: var(--ink-soft);
}
.perk b { display: block; color: var(--ink); font-weight: 800; }
.locked-note {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.1;
  color: #8a94a8;
}
.locked-note svg, .r-news svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.driver-story {
  list-style: none;
  padding: 10px 4px 0;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--ink-soft);
  text-align: center;
}
.driver-story b { color: var(--ink); }
.crew-head { list-style: none; padding: 14px 2px 0; }
.crew-head:first-child { padding-top: 2px; }
.crew-head h3 { margin: 0; font-size: 19px; font-weight: 800; line-height: 1.1; }
.crew-note { margin: 4px 0 0; font-size: 14px; font-weight: 600; line-height: 1.25; color: #b3261e; list-style: none; }
.crew-note.coins { color: #8a5a00; } /* two coin perks adding up: news, not a warning */
.driver.blocked { opacity: 0.45; filter: grayscale(0.8); }
.no-cats .driver.selected { opacity: 1; filter: none; }

/* ---------- Aim ---------- */
.aim { touch-action: none; pointer-events: auto; }
.aim-hint {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 215px); /* clear of the car, which sits low on the slingshot screen */
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: max-content;
  max-width: calc(100% - 32px);
  pointer-events: none;
  transition: opacity 0.2s;
}
.aim-hint svg {
  width: 56px;
  height: 56px;
  fill: none;
  stroke: #fff;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 0 rgba(31, 42, 68, 0.35));
  animation: pull-hint 1.4s ease-in-out infinite;
}
.aim-hint p {
  margin: 0;
  padding: 8px 18px 6px;
  border-radius: 999px;
  background: var(--panel);
  box-shadow: var(--shadow);
  font-size: 19px;
  font-weight: 800;
  text-align: center;
}
.aim-hint .aim-tip { margin-top: 6px; padding: 6px 14px 4px; font-size: 15px; background: var(--gold); }
.aim-hint .aim-tip[hidden] { display: none; }
.aim-hint.gone { opacity: 0; }
@keyframes pull-hint {
  0%, 100% { transform: translateY(-6px); }
  50% { transform: translateY(10px); }
}

.meter {
  position: fixed;
  z-index: 3;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 70px);
  width: min(320px, calc(100% - 48px));
  transform: translateX(-50%) translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
}
.meter.active { opacity: 1; transform: translateX(-50%); }
/* For a moment after a release (logic.js READOUT_MS) the meter holds still where it was read and says
   how it went; then it fades. */
.meter.registered { opacity: 1; transform: translateX(-50%); transition: opacity 0.3s, transform 0.15s; }
.meter[data-verdict='gold'] .meter-sweet { box-shadow: 0 0 0 2px #fff, 0 0 18px 6px rgba(255, 210, 63, 0.95); }
.meter[data-verdict='gold'] .meter-label { background: linear-gradient(180deg, #fff3b0, var(--gold)); }
.meter[data-verdict='near'] .meter-label { background: #fff; }
.meter[data-verdict='far'] .meter-label { background: #ffe1dc; color: #b3261e; }
.meter.registered .meter-needle::before { box-shadow: 0 0 0 2px #fff, 0 0 10px 3px rgba(255, 255, 255, 0.9); }
.meter.coach .meter-label { animation: coach-pulse 1s ease-in-out infinite; }
.meter.coach .meter-sweet { animation: coach-glow 1s ease-in-out infinite; }
@keyframes coach-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes coach-glow {
  0%, 100% { box-shadow: 0 0 0 2px #fff, 0 0 4px 1px rgba(255, 210, 63, 0.5); }
  50% { box-shadow: 0 0 0 2px #fff, 0 0 18px 6px rgba(255, 210, 63, 0.95); }
}
@media (prefers-reduced-motion: reduce) { .meter.coach .meter-label, .meter.coach .meter-sweet { animation: none; } }
.meter-label {
  display: block;
  width: max-content;
  margin: 0 auto 8px;
  padding: 6px 16px 4px;
  border-radius: 999px;
  background: var(--panel);
  box-shadow: var(--shadow);
  font-size: 17px;
  font-weight: 800;
}
.meter-track {
  position: relative;
  height: 30px;
  border-radius: 15px;
  border: 3px solid #fff;
  background: linear-gradient(90deg, #ff4a3d, #ffc21a 30%, #5cb84f 44%, #5cb84f 56%, #ffc21a 70%, #ff4a3d);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.meter:not(.armed) .meter-track { filter: saturate(0.35) brightness(1.1); }
.meter.registered .meter-track { filter: none; } /* (the readout shows the real colors) */
/* The perfect zone: |x| <= --zone of the half-width (logic.js PERFECT_ZONE, 0.15; wider for Bri and Tom's redo). */
.meter-sweet {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(50% - var(--zone, 0.15) * 50%);
  width: calc(var(--zone, 0.15) * 100%);
  background: linear-gradient(180deg, #fff3b0, var(--gold) 55%, var(--gold-lo));
  box-shadow: 0 0 0 2px #fff;
}
.meter.hot .meter-sweet { box-shadow: 0 0 0 2px #fff, 0 0 18px 6px rgba(255, 210, 63, 0.95); }
/* The bullseye: a hair-thin bright line at the very middle of the gold (logic.js BULLSEYE). */
.meter-bull {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: #ff2d6f;
  box-shadow: 0 0 3px 1px rgba(255, 255, 255, 0.95);
}
/* The needle's rail: the track's inside width (inside its 3 px border, where the gold is measured), so
   translateX(x × 50%) of it puts the needle at x of the half width, right over the gold it reads.
   main.js animates the transform on the compositor (logic.js needleDrawn); --x is where it rests. */
.meter-needle {
  position: absolute;
  left: 3px;
  right: 3px;
  bottom: -6px;
  height: 46px;
  transform: translateX(calc(var(--x, -1) * 50%));
  will-change: transform;
  pointer-events: none;
}
.meter-needle::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 6px;
  margin-left: -3px;
  border-radius: 3px;
  background: var(--ink);
  box-shadow: 0 0 0 2px #fff;
}
/* Tom's redo: twice the gold (--zone), and a soapy blue label that says so. */
.meter.redo .meter-label { background: linear-gradient(180deg, #e8f6ff, #bfe6ff); }

.back-btn {
  position: absolute;
  top: calc(var(--safe-top) + 10px);
  left: calc(var(--safe-left) + 12px);
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 48px;
  padding: 0 18px 0 10px;
  border: 0;
  border-radius: 999px;
  background: var(--panel);
  box-shadow: var(--shadow);
  font-size: 18px;
  font-weight: 800;
}
.back-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; }
/* ---------- Driving HUD ---------- */
.hud { touch-action: none; pointer-events: auto; }
.hud-top {
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
/* Progress along the course: the bar fills as the car goes; a tick marks the best run. */
.course {
  position: relative;
  height: 22px;
  margin: 11px 26px 0 calc(var(--sg-corner-left) - var(--safe-left) + 44px - 12px + 10px); /* beside the corner's menu button, on its middle */
}
.course-track {
  position: absolute;
  left: 0;
  right: 0;
  top: 6px;
  height: 10px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.55);
  box-shadow: 0 2px 6px rgba(31, 42, 68, 0.25);
  overflow: hidden;
}
.course-fill { position: absolute; inset: 0; background: linear-gradient(90deg, var(--green), var(--gold)); transform: scaleX(0); transform-origin: 0 50%; }
.course-best { position: absolute; top: 0; bottom: 0; width: 3px; margin-left: -1px; background: var(--ink); }
.course-car {
  position: absolute;
  top: 0;
  left: 0;
  width: 22px;
  height: 22px;
  margin-left: -11px;
  border-radius: 50%;
  background: var(--orange);
  border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(31, 42, 68, 0.4);
}
.course-flag {
  position: absolute;
  right: -26px;
  top: -4px;
  width: 22px;
  height: 28px;
  background:
    linear-gradient(#1f2a44, #1f2a44) 0 0 / 3px 100% no-repeat,
    conic-gradient(#111 25%, #fff 0 50%, #111 0 75%, #fff 0) 3px 0 / 8px 8px;
  clip-path: polygon(0 0, 100% 0, 100% 58%, 14% 58%, 14% 100%, 0 100%);
}
.hud-row { position: relative; display: flex; justify-content: center; }
.distance {
  display: flex;
  align-items: baseline;
  gap: 4px;
  color: #fff;
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 3px 0 rgba(31, 42, 68, 0.55), 0 0 12px rgba(31, 42, 68, 0.35);
  font-variant-numeric: tabular-nums;
}
.distance b { font-size: 46px; }
.distance span { font-size: 24px; }
.coins.small {
  position: absolute;
  right: 0;
  top: 2px;
  height: 38px;
  padding: 0 12px 0 9px;
  font-size: 18px;
  gap: 6px;
}
.coins.small .coin-icon { width: 20px; height: 20px; }

.speedo {
  position: absolute;
  left: calc(var(--safe-left) + 14px);
  bottom: calc(var(--safe-bottom) + 18px);
  width: 108px;
  height: 108px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  pointer-events: none;
}
.speedo svg {
  position: absolute;
  inset: 4px;
  width: calc(100% - 8px);
  height: calc(100% - 8px);
  transform: rotate(135deg);
}
.speedo circle { fill: none; stroke-width: 9; stroke-linecap: round; }
.speedo-bg { stroke: #e3e8f0; stroke-dasharray: 188.5 251.3; }
.speedo-arc { stroke: var(--orange); stroke-dasharray: 251.3 251.3; stroke-dashoffset: 251.3; transition: stroke-dashoffset 0.1s linear; }
.speedo b { font-size: 32px; font-weight: 800; line-height: 0.9; margin-top: 10px; font-variant-numeric: tabular-nums; }
.speedo span { font-size: 13px; font-weight: 700; color: var(--ink-soft); }

.nitro-btn {
  position: absolute;
  right: calc(var(--safe-right) + 14px);
  bottom: calc(var(--safe-bottom) + 18px);
  width: 92px;
  height: 92px;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #8aa4ff, #5b7cfa 60%, #3d5ad6);
  box-shadow: 0 5px 0 #2e44a8, 0 12px 20px -8px rgba(46, 68, 168, 0.7);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.nitro-btn.on { transform: translateY(3px) scale(0.96); box-shadow: 0 2px 0 #2e44a8, 0 0 24px 6px rgba(255, 160, 60, 0.6); }
.nitro-btn.empty { filter: grayscale(0.8) brightness(0.9); }
.rocket-count {
  position: absolute;
  right: -2px;
  top: -2px;
  min-width: 32px;
  height: 32px;
  padding: 3px 6px 0;
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  font-size: 20px;
  font-weight: 800;
  line-height: 29px;
  box-shadow: 0 2px 6px rgba(31, 42, 68, 0.35);
}
.nitro-btn.urge { animation: urge 0.6s ease-in-out infinite alternate; }
@keyframes urge { to { transform: scale(1.12); box-shadow: 0 5px 0 #2e44a8, 0 0 0 10px rgba(91, 124, 250, 0.35); } }
.nitro-icon { position: relative; width: 40px; height: 40px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
/* The burn ring: shows while a rocket burns and empties with the time left. */
.burn-ring { position: absolute; inset: -9px; width: calc(100% + 18px); height: calc(100% + 18px); transform: rotate(-90deg); pointer-events: none; opacity: 0; transition: opacity 0.15s; }
.burn-track { fill: none; stroke: rgba(255, 255, 255, 0.35); stroke-width: 6; }
.burn-arc { fill: none; stroke: #ffb02e; stroke-width: 6; stroke-linecap: round; stroke-dasharray: 289.03; stroke-dashoffset: 0; filter: drop-shadow(0 0 4px rgba(255, 140, 40, 0.9)); }
.nitro-btn.on .burn-ring { opacity: 1; }
.nitro-btn.on .nitro-icon { animation: rumble 0.09s linear infinite alternate; }
@keyframes rumble { from { transform: translate(-1px, 1px); } to { transform: translate(1px, -1px); } }
/* The universes' ability button: where the rocket button usually is (a Gas Station Cat rocket
   moves up above it). Each ability has its own color; Bubble and Ghost car work by themselves,
   so theirs is a smaller badge that can't be pressed. */
.ability-btn { --a: #ff8fb8; --a2: #e8507f; --a3: #b8325c; background: radial-gradient(circle at 50% 40%, var(--a), var(--a2) 60%, var(--a3)); box-shadow: 0 5px 0 var(--a3), 0 12px 20px -8px rgba(31, 42, 68, 0.5); }
.ability-btn.on { transform: translateY(3px) scale(0.96); box-shadow: 0 2px 0 var(--a3), 0 0 24px 6px rgba(255, 255, 255, 0.55); }
.ability-btn.empty { filter: grayscale(0.85) brightness(0.9); }
.ability-btn.urge { animation: urge-a 0.6s ease-in-out infinite alternate; }
@keyframes urge-a { to { transform: scale(1.12); box-shadow: 0 5px 0 var(--a3), 0 0 0 10px rgba(255, 255, 255, 0.35); } }
.ability-btn.pounce { --a: #ffb36b; --a2: #f08a2e; --a3: #b85e14; }
.ability-btn.gear { --a: #ffd76a; --a2: #e8a90f; --a3: #9c6f05; }
.ability-btn.glide { --a: #8fd3ff; --a2: #3d9fe0; --a3: #2470a8; }
.ability-btn.bubble { --a: #a8f0ff; --a2: #3fc4e8; --a3: #1f8aa8; }
.ability-btn.ghost { --a: #e3dcff; --a2: #a796e8; --a3: #6e5cb8; }
.ability-btn.combine { --a: #ffe08a; --a2: #d8a830; --a3: #8a6a1a; }
.ability-btn.oil { --a: #c8d870; --a2: #8aa02a; --a3: #5a6a14; }
.ability-btn.airjet { --a: #b8e4ff; --a2: #5aa8e0; --a3: #2f6fa8; }
.ability-btn.skip { --a: #f2d8a0; --a2: #b4823a; --a3: #6a1a1e; }
.ability-btn.dryer { --a: #ffb8dc; --a2: #ff6fb0; --a3: #c03a7a; }
.ability-btn.drift { --a: #ff6fb8; --a2: #c02a8a; --a3: #2a1a4a; }
.ability-btn.veto { --a: #f2dc9a; --a2: #c8a040; --a3: #6a5020; }
.ability-btn.fob { --a: #9ff0b8; --a2: #3dbf6a; --a3: #1f7a3a; }
.ability-btn.foil { --a: #a8e8f0; --a2: #3fa8b8; --a3: #1f6a7a; }
.ability-btn.sunbeam { --a: #fff0a8; --a2: #ffc83a; --a3: #c08a10; }
.ability-btn.auto { width: 70px; height: 70px; pointer-events: none; opacity: 0.92; }
.ability-btn.auto .nitro-icon { width: 32px; height: 32px; }
.ability-btn .burn-arc { stroke: #fff; filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.9)); }
.ability-btn.ring .burn-ring { opacity: 1; }
#rocket-btn.stacked { bottom: calc(var(--safe-bottom) + 128px); width: 72px; height: 72px; }
#rocket-btn.stacked .nitro-icon { width: 32px; height: 32px; }
/* Gear shift: a little metronome on the button; tap with the needle in the gold. */
.gear-meter { display: none; position: absolute; left: 12px; right: 12px; bottom: 14px; height: 10px; border-radius: 5px; background: rgba(31, 42, 68, 0.55); }
.ability-btn.gear .gear-meter { display: block; }
.ability-btn.gear .nitro-icon { margin-top: -14px; }
.gear-sweet { position: absolute; top: 0; bottom: 0; left: calc(50% - var(--zone, 0.15) * 50%); width: calc(var(--zone, 0.15) * 100%); border-radius: 5px; background: #ffd23f; box-shadow: 0 0 6px rgba(255, 210, 63, 0.9); }
.gear-needle { position: absolute; top: -4px; bottom: -4px; width: 4px; margin-left: -2px; left: calc((var(--x, 0) + 1) * 50%); border-radius: 2px; background: #fff; box-shadow: 0 0 4px rgba(0, 0, 0, 0.5); }
.ability-btn.gear.hot .gear-meter { box-shadow: 0 0 0 2px #fff; }
/* Paris's Eiffel lift: the same meter stood on end while the cabin climbs, the gold at the top (--zone,
   the top share of the climb) and the needle rising with the cabin (--x, -1 at the foot to 1 at the top). */
.ability-btn.eiffel { --a: #8fb4ff; --a2: #3d68d8; --a3: #1f3a8a; }
.ability-btn.eiffel.lifting .gear-meter { display: block; left: auto; right: 12px; top: 14px; bottom: 14px; width: 10px; height: auto; }
.ability-btn.eiffel.lifting .nitro-icon { margin-left: -12px; }
.ability-btn.eiffel .gear-sweet { left: 0; right: 0; top: 0; width: auto; height: calc(var(--zone, 0.2) * 100%); }
.ability-btn.eiffel .gear-needle { left: -4px; right: -4px; width: auto; height: 4px; margin: -2px 0 0; top: calc((1 - var(--x, -1)) * 50%); }
.ability-btn.eiffel.hot .gear-meter { box-shadow: 0 0 0 2px #fff; }
.ability-btn.glide.on .nitro-icon { animation: rumble 0.18s linear infinite alternate; }

/* Speed lines streaming in from the edges while a rocket burns (one layer, compositor only). */
.burn-lines {
  position: absolute;
  inset: -10%;
  pointer-events: none;
  opacity: 0;
  background: repeating-conic-gradient(from 0deg at 50% 52%, rgba(255, 255, 255, 0.55) 0deg 0.7deg, transparent 0.7deg 5.3deg, rgba(255, 236, 200, 0.4) 5.3deg 5.8deg, transparent 5.8deg 11deg);
  -webkit-mask-image: radial-gradient(ellipse 55% 50% at 50% 52%, transparent 55%, #000 100%);
  mask-image: radial-gradient(ellipse 55% 50% at 50% 52%, transparent 55%, #000 100%);
  transition: opacity 0.25s;
}
.burn-lines.on { opacity: 1; animation: streak 0.32s linear infinite; }
/* Audra's second wind: the same lines in gold while she powers the car up a climb. */
.burn-lines.wind {
  opacity: 0.85;
  animation: streak 0.4s linear infinite;
  background: repeating-conic-gradient(from 0deg at 50% 52%, rgba(255, 214, 80, 0.6) 0deg 0.8deg, transparent 0.8deg 6deg, rgba(255, 243, 176, 0.45) 6deg 6.6deg, transparent 6.6deg 12deg);
}
@keyframes streak { from { transform: scale(1.12) rotate(0deg); } to { transform: scale(1) rotate(2.5deg); } }

.steer-hint {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 150px);
  transform: translateX(-50%);
  padding: 10px 20px 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  width: max-content;
  max-width: calc(100% - 40px);
  border-radius: 22px;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
.steer-hint::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -40px;
  width: 30px;
  height: 30px;
  margin-left: -15px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.35);
  animation: swipe 1.6s ease-in-out infinite;
}
.steer-hint.show { opacity: 1; }
@keyframes swipe {
  0%, 100% { transform: translateX(-60px); }
  50% { transform: translateX(60px); }
}

.best-banner {
  position: absolute;
  left: 0;
  right: 0;
  top: 17%;
  text-align: center;
  font-size: 30px;
  font-weight: 800;
  color: #fff3b0;
  text-shadow: 0 2px 0 #8a5a00, 0 0 18px rgba(255, 201, 60, 0.9);
  opacity: 0;
  pointer-events: none;
}
.best-banner.on { animation: best-banner 2.2s ease-out forwards; }
@keyframes best-banner {
  0% { opacity: 0; transform: scale(1.8); }
  12% { opacity: 1; transform: scale(1); }
  75% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: translateY(-14px) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .best-banner.on { animation: none; opacity: 1; }
}
.toasts {
  position: absolute;
  left: 0;
  right: 0;
  top: 26%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.toast {
  padding: 6px 18px 3px;
  border-radius: 999px;
  font-size: 24px;
  font-weight: 800;
  color: #fff;
  background: var(--ink);
  box-shadow: var(--shadow);
  animation: toast 1.3s ease-out forwards;
}
.toast.gold { background: linear-gradient(180deg, #ffd23f, #f5a400); color: var(--ink); }
.toast.green { background: #2fbf71; }
.toast.red { background: var(--red); }
.toast.plain { background: rgba(31, 42, 68, 0.8); }
/* A crew member's big moment: their face on the toast (Audra's second wind). */
.toast.face { display: flex; align-items: center; gap: 8px; padding-left: 6px; }
.toast.face img { width: 36px; height: 36px; margin: -3px 0 0; border-radius: 50%; background: #fdf3e4; box-shadow: 0 0 0 2px #fff; flex: none; }
.toast.wind { box-shadow: 0 0 0 3px #fff3b0, 0 0 22px 6px rgba(255, 201, 60, 0.55), var(--shadow); }
/* Longer heads-ups (the abilities' "Corn wall! Your combine cuts 6 m") stay inside a 360 px screen. */
.toast.long { max-width: calc(100% - 40px); font-size: 19px; line-height: 1.2; text-align: center; border-radius: 20px; }
/* Right on the bullseye: bigger, hot pink and gold, and it stays up a little longer. */
.toast.bullseye {
  padding: 8px 26px 5px;
  font-size: 40px;
  letter-spacing: 0.04em;
  color: #fff;
  background: linear-gradient(180deg, #ff5a8c, #ff2d6f 55%, #d81b5a);
  box-shadow: 0 0 0 4px #ffd23f, 0 0 26px 8px rgba(255, 45, 111, 0.6), var(--shadow);
  animation-duration: 2.1s;
}

/* Tom's redo: a pill under the course bar for a couple of seconds after a launch that missed the
   gold. The bar along its bottom empties as the time runs out. */
.redo-btn {
  position: absolute;
  left: 50%;
  top: calc(var(--safe-top) + 92px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 6px 20px 6px 8px;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 0 0 3px #5b7cfa, var(--shadow);
  font: inherit;
  font-size: 20px;
  font-weight: 800;
  cursor: pointer;
}
.redo-btn img { width: 36px; height: 36px; border-radius: 50%; background: #e8eefc; }
.redo-btn:active { transform: translateX(-50%) scale(0.96); }
.redo-time {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: #5b7cfa;
  transform-origin: left;
  transform: scaleX(var(--left, 1));
}
@keyframes toast {
  0% { opacity: 0; transform: translateY(14px) scale(0.7); }
  15% { opacity: 1; transform: translateY(0) scale(1.08); }
  25% { transform: scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-30px); }
}
.region-toast {
  position: absolute;
  left: 50%;
  top: calc(var(--safe-top) + 90px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 26px 6px;
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--shadow);
  font-size: 32px;
  font-weight: 800;
  line-height: 1.05;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
}
.region-toast small { font-size: 15px; font-weight: 700; color: var(--orange); text-transform: uppercase; letter-spacing: 0.06em; }
.region-toast.show { animation: region 2.6s ease-out forwards; }
.region-toast.part { top: auto; bottom: calc(var(--safe-bottom) + 300px); font-size: 26px; color: var(--orange); z-index: 2; }
.region-toast.part.show { animation-duration: 1.6s; }
@keyframes region {
  0% { opacity: 0; transform: translateX(-50%) scale(0.6); }
  12% { opacity: 1; transform: translateX(-50%) scale(1.06); }
  20% { transform: translateX(-50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-16px); }
}

/* ---------- Results sheet ---------- */
.sheet {
  width: min(100%, 460px);
  max-width: 100%;
  max-height: calc(100% - var(--safe-top) - 40px);
  margin: auto auto 0;
  padding: 20px calc(var(--safe-right) + 20px) calc(var(--safe-bottom) + 18px) calc(var(--safe-left) + 20px);
  border: 0;
  border-radius: 28px 28px 0 0;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 -10px 40px -10px rgba(31, 42, 68, 0.5);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sheet[open] { display: flex; flex-direction: column; animation: sheet-up 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.15); }
.sheet::backdrop { background: rgba(31, 42, 68, 0.28); }
@keyframes sheet-up { from { transform: translateY(100%); } }
.results h2 { margin: 0; font-size: 34px; font-weight: 800; line-height: 1; text-align: center; }
.r-dist {
  margin: 6px 0 0;
  display: flex;
  align-items: baseline;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 6px;
  font-size: 22px;
  font-weight: 700;
}
.r-dist b { font-size: 44px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.r-best {
  align-self: center;
  padding: 3px 10px 1px;
  border-radius: 999px;
  background: var(--gold);
  font-size: 15px;
  font-weight: 800;
  animation: best 0.8s ease-in-out infinite alternate;
}
@keyframes best { to { transform: scale(1.08) rotate(-3deg); } }
.r-course { height: 10px; margin: 8px 8px 6px; border-radius: 5px; background: #e3e8f0; overflow: hidden; }
.r-course i { display: block; height: 100%; background: linear-gradient(90deg, var(--green), var(--gold)); transform-origin: 0 50%; }
.r-sub { margin: 0; text-align: center; font-size: 15px; font-weight: 600; color: var(--ink-soft); }
.r-lines { list-style: none; margin: 12px 0 0; padding: 0; }
.r-lines li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 5px 2px;
  border-bottom: 2px dashed var(--line);
  font-size: 17px;
  font-weight: 600;
}
.r-lines small { font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.r-lines b { display: inline-flex; align-items: center; gap: 5px; font-weight: 800; }
.r-total {
  margin: 8px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 32px;
  font-weight: 800;
}
.r-total .coin-icon { width: 30px; height: 30px; margin-right: 4px; }
.r-news { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.news {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 5px 12px;
  border-radius: 14px;
  background: #f4f7fb;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
}
.news > span:not(.dot):not(.check):not(.part-icon) { flex: 1; min-width: 0; }
.news b { font-weight: 800; }
.news > b { display: inline-flex; align-items: center; gap: 4px; flex: none; }
.news .dot { width: 16px; height: 16px; border-radius: 50%; background: var(--c); flex: none; }
.news .check { width: 26px; height: 26px; background: var(--green); border-color: var(--green); }
.news .check svg { width: 15px; height: 15px; }
.news img { width: 34px; height: 34px; border-radius: 50%; background: #fdf3e4; flex: none; }
.news .part-icon { width: 34px; height: 34px; border-radius: 10px; }
.news .part-icon svg { width: 20px; height: 20px; }
.news-region, .news-driver { background: #fff6dc; }
.sheet-actions {
  position: sticky;
  bottom: calc(-1 * (var(--safe-bottom) + 18px));
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 10px;
  margin: 12px calc(-1 * (var(--safe-right) + 20px)) calc(-1 * (var(--safe-bottom) + 18px)) calc(-1 * (var(--safe-left) + 20px));
  padding: 10px calc(var(--safe-right) + 20px) calc(var(--safe-bottom) + 18px) calc(var(--safe-left) + 20px);
  background: linear-gradient(rgba(255, 255, 255, 0), #fff 14px);
  flex: none;
}

/* ---------- Celebrations ---------- */
.celebrate {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-top) + 20px) 18px calc(var(--safe-bottom) + 20px);
  background: radial-gradient(circle at 50% 40%, rgba(255, 236, 160, 0.25), rgba(31, 42, 68, 0.45));
  animation: fade-in 0.25s;
}
.celebrate.low {
  align-items: flex-end;
  padding-bottom: calc(var(--safe-bottom) + 6vh);
  background: linear-gradient(180deg, rgba(31, 42, 68, 0) 40%, rgba(31, 42, 68, 0.45));
}
@keyframes fade-in { from { opacity: 0; } }
.celebrate-card {
  width: min(100%, 380px);
  padding: 20px 22px 22px;
  border-radius: 28px;
  background: var(--panel);
  box-shadow: 0 20px 50px -16px rgba(31, 42, 68, 0.6);
  text-align: center;
  animation: card-pop 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.4);
}
@keyframes card-pop { from { transform: scale(0.6); opacity: 0; } }
.celebrate-kicker { margin: 0; font-size: 16px; font-weight: 800; color: var(--orange); text-transform: uppercase; letter-spacing: 0.06em; }
.celebrate-card h2 { margin: 2px 0 4px; font-size: 38px; font-weight: 800; line-height: 1.05; }
.celebrate-card p#c-text { margin: 0 0 16px; font-size: 17px; font-weight: 600; color: var(--ink-soft); line-height: 1.3; }
.celebrate-card .primary { width: 100%; }
.c-cats { display: flex; justify-content: center; gap: 4px; margin: 6px 0 8px; }
.c-cats img { width: 84px; height: 84px; animation: bob 1.2s ease-in-out infinite alternate; }
.c-cats img:nth-child(2) { animation-delay: 0.2s; }
.c-cats img:nth-child(3) { animation-delay: 0.4s; }
.c-cats.many { flex-wrap: wrap; max-width: 300px; margin-left: auto; margin-right: auto; }
.c-cats.many img { width: 60px; height: 60px; }
.c-cats img:nth-child(4) { animation-delay: 0.1s; }
.c-cats img:nth-child(5) { animation-delay: 0.3s; }
.c-cats img:nth-child(n+6) { animation-delay: 0.5s; }
@keyframes bob { to { transform: translateY(-8px) rotate(4deg); } }

.flash {
  position: fixed;
  inset: 0;
  z-index: 9;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}
.flash.go { animation: flash 0.7s ease-out; }
@keyframes flash { 0% { opacity: 0.95; } 100% { opacity: 0; } }

/* ---------- Small and short screens ---------- */
@media (max-width: 370px) {
  .up-name { font-size: 14px; }
  .price { font-size: 15px; }
  .launch-btn { font-size: 23px; }
  .driver-chip { padding-right: 10px; }
  .driver-chip b { font-size: 16px; }
  .crew-names { max-width: 78px; }
}
@media (max-height: 700px) {
  .level-pill { min-height: 52px; padding-top: 6px; padding-bottom: 6px; }
  .up-icon { width: 36px; height: 36px; }
  .up-icon svg { width: 22px; height: 22px; }
  .region-toast.part { bottom: calc(var(--safe-bottom) + 270px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .burn-lines.on, .burn-lines.wind { opacity: 0.45; } /* still lines, fainter */
  .speed-fx { display: none; }
  .ach-toast.show { animation: fade-only 4.2s linear forwards !important; }
  .bank-toast.show { animation: fade-only 3.8s linear forwards !important; }
  .toast, .region-toast.show { animation: fade-only 1.6s linear forwards !important; }
  @keyframes fade-only { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }
}

/* Narrow phones: smaller top buttons so four fit beside the coins. */
@media (max-width: 380px) {
  .topbar { gap: 6px; }
  .topbar .icon-btn { width: 44px; height: 44px; }
  .title-row .coins { padding: 0 12px 0 10px; font-size: 20px; }
}

/* ---------- Upgrade pips for the slingshot ---------- */
.part-pips.small i { width: 10px; height: 10px; background: #e3e8f0; }
.part-pips.small i.on { background: #e8402f; box-shadow: 0 0 0 2px rgba(232, 64, 47, 0.25); }
#up-launch .up-sub { margin-top: -1px; }

/* ---------- Level list: each area's car ---------- */
.area-car {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: auto;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
}
.area-car svg { width: 16px; height: 16px; fill: none; stroke: var(--green); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Showroom ---------- */
.showroom { justify-content: flex-end; }
.show-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: auto 0 calc(var(--safe-bottom) + 16px);
  padding: 12px;
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.show-card .icon-btn { flex: none; background: #f1f4f9; box-shadow: none; }
.show-card .icon-btn:disabled { opacity: 0.35; }
.show-text { flex: 1; min-width: 0; text-align: center; }
.show-area {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 800;
  color: var(--ink-soft);
}
.show-area .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c, var(--green)); }
.show-count { font-weight: 700; opacity: 0.7; }
.show-text h2 { margin: 2px 0 0; font-size: 26px; font-weight: 800; line-height: 1.05; }
.show-text p { margin: 2px 0 0; font-size: 14px; font-weight: 600; color: var(--ink-soft); }

/* ---------- Looks sheet ---------- */
#looks .sheet-head .coins { margin-left: auto; margin-right: 10px; height: 40px; padding: 0 12px 0 9px; font-size: 18px; gap: 6px; box-shadow: none; background: #f1f4f9; }
#looks .sheet-head .coin-icon { width: 20px; height: 20px; }
.looks-group { list-style: none; }
.looks-group h3 { margin: 8px 0 8px; font-size: 18px; font-weight: 800; }
.looks-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.look {
  display: grid;
  grid-template-columns: 44px 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 64px;
  padding: 8px 10px;
  border: 0;
  border-radius: 16px;
  background: #f4f7fb;
  text-align: left;
}
.look:active { transform: scale(0.98); }
.look-swatch {
  grid-row: 1 / 3;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.7), 0 2px 0 rgba(31, 42, 68, 0.15);
}
.look b { font-size: 15px; font-weight: 800; line-height: 1.1; }
.look-state {
  display: block;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--ink-soft);
}
.look-state .coin-icon { display: inline-block; width: 15px; height: 15px; margin-right: 4px; vertical-align: -3px; }
.look-state svg { width: 13px; height: 13px; margin-right: 3px; vertical-align: -2px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.look.chosen { background: #fff3ea; box-shadow: inset 0 0 0 3px var(--orange); }
.look.chosen .look-state { color: var(--orange); }
.look.buy .look-state { color: var(--ink); }
.look.buy.poor .look-state { color: #8a94a8; }
.look.locked b { color: #8a94a8; }
.look.by-ach .look-swatch { filter: grayscale(0.85) opacity(0.55); }
.looks-grid.ornaments .look-swatch { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.9), 0 2px 0 rgba(31, 42, 68, 0.12); }

/* Looks | Achievements */
.looks-tabs {
  display: flex;
  gap: 4px;
  margin: 0 0 10px;
  padding: 4px;
  border-radius: 16px;
  background: #eef2f8;
}
.looks-tab {
  flex: 1;
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  color: var(--ink-soft);
}
.looks-tab[aria-selected="true"] { background: var(--panel); color: var(--ink); box-shadow: 0 2px 6px -2px rgba(31, 42, 68, 0.3); }
.tab-count { font-size: 13px; font-weight: 700; opacity: 0.75; }
.tab-count.new { opacity: 1; padding: 1px 7px; border-radius: 10px; background: #ff2d6f; color: #fff; }
#looks-btn { position: relative; }
#looks-btn.has-new::after {
  content: '';
  position: absolute;
  top: 5px;
  right: 5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ff2d6f;
  box-shadow: 0 0 0 2px var(--panel);
}

.ach-head {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-soft);
}
.ach-head svg { width: 30px; height: 30px; flex: none; fill: #ffd23f; stroke: #c98a00; stroke-width: 1.6; stroke-linejoin: round; }
.ach-head b { color: var(--ink); font-weight: 800; }
.ach {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 62px;
  margin: 0 0 6px;
  padding: 8px 10px;
  border-radius: 16px;
  background: #f4f7fb;
}
.ach.got { background: #fff8e2; }
.ach.new { box-shadow: inset 0 0 0 3px #ffd23f; }
.ach-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 12px;
  background: radial-gradient(circle at 50% 40%, #ffffff, #e3e9f2);
}
.ach-icon img { width: 44px; height: 44px; }
.ach.locked .ach-icon svg { width: 20px; height: 20px; fill: none; stroke: #9aa4b8; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.ach-swatch { width: 34px; height: 34px; border-radius: 10px; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.7); }
.ach-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ach-text b { font-size: 15px; font-weight: 800; line-height: 1.15; }
.ach-text small { font-size: 13px; font-weight: 600; line-height: 1.2; color: var(--ink-soft); }
.ach.locked .ach-text b { color: #6f7a90; }
.ach-bar { display: block; height: 6px; margin-top: 5px; border-radius: 3px; background: #dfe5ef; overflow: hidden; }
.ach-bar i { display: block; height: 100%; background: linear-gradient(90deg, #ffc21a, #ff8a1a); transform-origin: left; }
.ach-text .ach-num { font-size: 11px; font-weight: 700; color: #8a94a8; }
.ach-check { display: grid; place-items: center; width: 26px; height: 26px; flex: none; border-radius: 50%; background: var(--green); }
.ach-check svg { width: 15px; height: 15px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.ach-prize { flex: none; max-width: 76px; font-size: 11px; font-weight: 800; line-height: 1.1; text-align: right; text-transform: uppercase; letter-spacing: 0.03em; color: #a0aabd; }

/* An achievement at the end of a run: a news line with what it unlocks, and a little toast. */
.news-ach { background: linear-gradient(90deg, #fff1b8, #fff8e2); }
.news-ach img { background: radial-gradient(circle at 50% 40%, #ffffff, #e9edf4); }
.news-ach .ach-swatch { width: 34px; height: 34px; flex: none; }
.ach-toast {
  position: fixed;
  left: 50%;
  top: calc(var(--safe-top) + 14px);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 8px 18px 8px 8px;
  border-radius: 28px;
  background: linear-gradient(180deg, #2c3a5e, #1f2a44);
  color: #fff;
  box-shadow: 0 12px 28px -10px rgba(10, 16, 30, 0.6), inset 0 0 0 2px rgba(255, 210, 63, 0.7);
  transform: translateX(-50%);
  pointer-events: none;
}
.ach-toast.show { animation: ach-in 4.2s cubic-bezier(0.2, 0.9, 0.3, 1.2) forwards; }
@keyframes ach-in {
  0% { opacity: 0; transform: translate(-50%, -24px) scale(0.9); }
  8% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  88% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -12px) scale(0.98); }
}
.ach-toast img { width: 40px; height: 40px; border-radius: 50%; background: radial-gradient(circle at 50% 40%, #ffffff, #dfe6f0); }
.ach-toast-icon { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 50%; background: #ffd23f; }
.ach-toast-icon svg { width: 24px; height: 24px; fill: #fff3b0; stroke: #8a5a00; stroke-width: 1.8; stroke-linejoin: round; }
.ach-toast span { display: flex; flex-direction: column; min-width: 0; }
.ach-toast small { font-size: 12px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: #ffd23f; }
.ach-toast b { font-size: 17px; font-weight: 800; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; }
/* What it was for, under the name. */
.ach-toast b + small { margin-top: 1px; font-size: 13px; font-weight: 600; letter-spacing: 0; text-transform: none; color: #dfe6f0; }

/* Speed: at high speed the edges of the view blur into streaks and darken a touch (main.js sets
   its opacity from 0 to 0.85, in steps; off with reduced motion). */
.speed-fx {
  position: absolute;
  inset: -6%;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(ellipse 62% 56% at 50% 54%, transparent 62%, rgba(12, 18, 34, 0.32) 100%),
    repeating-conic-gradient(from 3deg at 50% 54%, rgba(255, 255, 255, 0.34) 0deg 0.45deg, transparent 0.45deg 7.5deg, rgba(255, 255, 255, 0.2) 7.5deg 7.8deg, transparent 7.8deg 13deg);
  -webkit-mask-image: radial-gradient(ellipse 60% 55% at 50% 54%, transparent 58%, #000 100%);
  mask-image: radial-gradient(ellipse 60% 55% at 50% 54%, transparent 58%, #000 100%);
}
.speed-fx.on { animation: streak 0.4s linear infinite; }

/* ---------- Endless Highway in the level list, the secret driver ---------- */
.lvls .lvl-endless { grid-column: 1 / -1; }
.lvl.endless {
  width: 100%;
  max-width: none;
  aspect-ratio: auto;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 26px;
}
.lvl.endless small { font-size: 15px; font-weight: 700; }
.cat.mystery { filter: brightness(0) opacity(0.3); }

/* ---------- Pause ---------- */
/* The menu button is the corner's (shared/menu.css), top left at the slingshot and on the HUD; the slingshot's
   Garage button sits top right, and the HUD's course bar starts right of the button. */
#aim-back { left: auto; right: calc(var(--safe-right) + 12px); top: calc(var(--sg-corner-top) - 2px); padding: 0 16px 0 12px; gap: 8px; }
/* Paused: the HUD's own animations (toasts, a nudging button) hold still too. */
body.paused .screen *, body.paused .screen *::before { animation-play-state: paused !important; }

.p-sub { margin: 4px 0 0; text-align: center; font-size: 15px; font-weight: 600; color: var(--ink-soft); }
.p-volume { display: flex; align-items: center; gap: 12px; margin: 16px 0 0; padding: 4px 14px 4px 4px; border-radius: 26px; background: #f4f7fb; }
.p-volume .icon-btn.small { background: var(--panel); box-shadow: 0 2px 0 #d4dbe6; }
.p-vol-num { flex: none; width: 54px; text-align: right; font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; }
.p-volume.off .p-vol-num { color: var(--ink-soft); }
/* The volume slider: a rounded track filled in orange up to the thumb (--v). */
.p-vol { --v: 100%; flex: 1; min-width: 0; height: 44px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; cursor: pointer; }
.p-vol::-webkit-slider-runnable-track { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--orange) var(--v), #dfe5ef var(--v)); }
.p-vol::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 30px; height: 30px; margin-top: -9px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 0 0 4px var(--orange), 0 3px 8px rgba(31, 42, 68, 0.35); }
.p-vol::-moz-range-track { height: 12px; border-radius: 6px; background: #dfe5ef; }
.p-vol::-moz-range-progress { height: 12px; border-radius: 6px; background: var(--orange); }
.p-vol::-moz-range-thumb { width: 30px; height: 30px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 0 0 4px var(--orange), 0 3px 8px rgba(31, 42, 68, 0.35); }
.p-volume.off .p-vol { filter: grayscale(1); opacity: 0.6; }
.p-note { margin: 14px 0 0; text-align: center; font-size: 15px; font-weight: 600; line-height: 1.3; color: var(--ink-soft); }
.p-note b { color: var(--ink); font-weight: 800; }
.p-note .coin-icon { display: inline-block; width: 17px; height: 17px; margin: 0 3px 0 2px; vertical-align: -3px; }
.p-timing small { font-size: 14px; font-weight: 700; opacity: 0.7; }
/* Launch timing (main.js openTiming): a meter, a pad to hold and let go, and how many tries are left. */
.timing h2 { margin: 0; font-size: 30px; font-weight: 800; line-height: 1; text-align: center; }
.t-sub { margin: 10px 0 0; font-size: 16px; line-height: 1.35; text-align: center; }
.t-meter { position: relative; margin: 26px 8px 18px; }
.t-meter .meter-needle { transform: translateX(-50%); }
.t-pad {
  display: grid; place-items: center; height: 150px; border-radius: 22px;
  border: 3px dashed rgba(0, 0, 0, 0.2); background: rgba(0, 0, 0, 0.05);
  font-size: 20px; font-weight: 800; touch-action: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.t-pad.down { border-style: solid; border-color: var(--gold); background: rgba(255, 194, 26, 0.22); }
.t-progress { min-height: 2.6em; margin: 10px 0 0; font-weight: 800; line-height: 1.3; text-align: center; }
#p-resume { min-height: 58px; font-size: 22px; }
#p-restart, #p-garage { min-height: 58px; }
#p-resume svg { width: 24px; height: 24px; fill: currentColor; stroke-width: 2; }

/* What a run ended from the pause sheet banked (and its achievements), over the slingshot or garage. */
.bank-toast {
  position: fixed;
  left: 50%;
  top: calc(var(--safe-top) + 190px);
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: max-content;
  max-width: calc(100% - 32px);
  transform: translateX(-50%);
  pointer-events: none;
}
.bank-toast.show { animation: ach-in 3.8s cubic-bezier(0.2, 0.9, 0.3, 1.2) forwards; }
.bank-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 8px 18px 8px 8px;
  border-radius: 28px;
  background: linear-gradient(180deg, #2c3a5e, #1f2a44);
  color: #fff;
  box-shadow: 0 12px 28px -10px rgba(10, 16, 30, 0.6), inset 0 0 0 2px rgba(255, 210, 63, 0.7);
}
.bank-pill > .coin-icon { width: 36px; height: 36px; margin: 2px; }
.bank-pill img { width: 40px; height: 40px; border-radius: 50%; background: radial-gradient(circle at 50% 40%, #ffffff, #dfe6f0); }
.bank-pill span:not(.coin-icon):not(.ach-toast-icon) { display: flex; flex-direction: column; min-width: 0; }
.bank-pill small { font-size: 12px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: #ffd23f; }
.bank-pill b { font-size: 19px; font-weight: 800; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- How a third upgrade works: the "i" and its tooltip (main.js toggleAbilityTip) ---------- */
.upgrades { position: relative; }
/* The "i" on the third upgrade: a 24px dot at the card's corner, a 44px target around it. */
.info-btn {
  position: absolute;
  top: -12px;
  right: -12px;
  z-index: 6;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: none;
  touch-action: manipulation;
}
.info-btn span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding-top: 2px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 2px 0 #2a63b0, 0 0 0 2px #fff;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  font-style: italic;
  line-height: 1;
}
.info-btn:active span { transform: scale(0.9); }
/* A tap anywhere closes it (and does nothing else). */
.ab-tip-back { position: fixed; inset: 0; z-index: 4; }
.ab-tip {
  position: absolute;
  right: 0;
  bottom: calc(100% + 12px);
  z-index: 5;
  width: min(100%, 330px);
  padding: 12px 14px;
  border-radius: 18px;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 12px 30px -10px rgba(31, 42, 68, 0.6);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  animation: tip-in 0.18s ease-out;
}
.ab-tip::after {
  content: "";
  position: absolute;
  right: 22px;
  bottom: -7px;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  background: var(--ink);
  transform: rotate(45deg);
}
.ab-tip[hidden], .ab-tip-back[hidden] { display: none; }
.ab-tip p { margin: 0 0 4px; }
.ab-tip b { font-weight: 800; color: var(--gold-hi); }
.ab-tip .ab-tip-next { margin: 8px 0 0; padding-top: 7px; border-top: 1px solid rgba(255, 255, 255, 0.18); font-weight: 800; color: #9ff0b8; }
@keyframes tip-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Prestige (main.js "Prestige") ---------- */
/* The garage's coin count opens "Clear coins". */
button.coins { border: 0; color: var(--ink); font-family: inherit; cursor: pointer; }
button.coins:active { transform: scale(0.97); }
.sw { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
[data-tier="silver"] { --tier: #8b95a6; }
[data-tier="gold"] { --tier: #e0a100; }
[data-tier="diamond"] { --tier: #2fb4e8; }

/* The run's clock in the garage (under the level), and on the HUD under this run's coins. */
.prestige-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  margin-top: 8px;
  padding: 6px 14px 6px 10px;
  border: 0;
  border-radius: 16px;
  background: var(--panel-soft);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: var(--ink);
  font-family: inherit;
  text-align: left;
}
.prestige-chip[hidden] { display: none; }
.prestige-chip:active { transform: scale(0.98); }
.prestige-chip .sw { width: 24px; height: 24px; flex: none; color: var(--tier, var(--ink)); }
.prestige-chip > b { font-size: 22px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.pc-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; margin-left: 4px; }
.pc-text small { font-size: 12px; font-weight: 700; line-height: 1.1; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-text span { font-size: 14px; font-weight: 800; line-height: 1.15; }
.prestige-chip.warn { background: #fff1e6; box-shadow: 0 0 0 2px var(--orange), var(--shadow); }
.hud-clock {
  position: absolute;
  right: 0;
  top: 46px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 30px;
  padding: 0 10px 0 7px;
  border-radius: 999px;
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.hud-clock[hidden] { display: none; }
.hud-clock .sw { width: 18px; height: 18px; color: var(--tier, var(--ink)); }

/* A universe's border in the level list: metal, with a shine sweeping across now and then. */
.area { position: relative; }
.area[class*="border-"]::before {
  content: '';
  position: absolute;
  inset: -3px;
  padding: 3px;
  border-radius: 21px;
  pointer-events: none;
  background: linear-gradient(110deg, transparent 38%, rgba(255, 255, 255, 0.95) 50%, transparent 62%) 100% 0 / 300% 100% no-repeat, var(--metal);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: border-shine 3.6s ease-in-out infinite;
}
.area.border-silver { --metal: linear-gradient(135deg, #8d97a8, #eef1f6 30%, #a5aebd 50%, #f7f9fb 70%, #8d97a8); }
.area.border-gold { --metal: linear-gradient(135deg, #b77d00, #ffe27a 30%, #e0a100 50%, #fff1b8 70%, #b77d00); box-shadow: 0 0 16px -3px rgba(255, 194, 26, 0.65); }
.area.border-diamond { --metal: linear-gradient(135deg, #4cc3f0, #ffffff 25%, #b9a8ff 45%, #8be3ff 60%, #ffd6f2 78%, #4cc3f0); box-shadow: 0 0 18px -2px rgba(76, 195, 240, 0.7); }
.area.border-diamond::before { animation-duration: 2.4s; }
@keyframes border-shine { 0% { background-position: 100% 0, 0 0; } 55%, 100% { background-position: 0% 0, 0 0; } }
.area.live { background: #fff4ea; box-shadow: 0 0 0 2px var(--orange); }

.area-prestige { display: flex; align-items: center; gap: 8px; min-height: 44px; margin-top: 10px; }
.area-prestige .pr-note { font-size: 13px; font-weight: 700; line-height: 1.2; color: var(--ink-soft); }
.area-prestige.live .sw { width: 22px; height: 22px; flex: none; color: var(--orange); }
.area-prestige .pr-clock { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.pr-badge {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
  font-variant-numeric: tabular-nums;
}
.pr-badge[data-tier="silver"] { background: linear-gradient(135deg, #7f8a9c, #b3bcc9); }
.pr-badge[data-tier="gold"] { background: linear-gradient(135deg, #c98a00, #f2bd2a); }
.pr-badge[data-tier="diamond"] { background: linear-gradient(135deg, #2fb4e8, #8f7cf2); }
.pr-btn {
  flex: none;
  margin-left: auto;
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 3px 0 #d4dbe6;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  font-weight: 800;
}
.pr-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #d4dbe6; }
.pr-btn.stop { color: var(--orange-lo); }

/* The prestige and Clear coins sheet. */
.pr-sheet h2 { margin: 0; font-size: 28px; font-weight: 800; line-height: 1.05; text-align: center; }
.pr-body { font-size: 16px; font-weight: 600; line-height: 1.35; color: var(--ink-soft); }
.pr-body p { margin: 12px 0 0; }
.pr-body b { color: var(--ink); font-weight: 800; }
.pr-body .coin-icon { display: inline-block; width: 17px; height: 17px; margin: 0 3px 0 2px; vertical-align: -3px; }
.pr-tiers { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.pr-tiers li { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 14px; background: #f4f7fb; }
.pr-tiers li::before { content: ''; width: 16px; height: 16px; flex: none; border-radius: 50%; background: var(--dot); box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--tier); }
.pr-tiers li[data-tier="silver"] { --dot: linear-gradient(135deg, #8d97a8, #eef1f6); }
.pr-tiers li[data-tier="gold"] { --dot: linear-gradient(135deg, #e0a100, #ffe27a); }
.pr-tiers li[data-tier="diamond"] { --dot: linear-gradient(135deg, #4cc3f0, #ffffff 50%, #b9a8ff); }
.pr-tiers li.gone { opacity: 0.45; }
.pr-warn { padding: 10px 12px; border-radius: 14px; background: #fff1e6; color: var(--ink); }
.pr-big { display: flex; align-items: center; justify-content: center; gap: 8px; }
.pr-big .sw { width: 34px; height: 34px; color: var(--orange); }
.pr-big b { font-size: 40px; line-height: 1; font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) {
  .area[class*="border-"]::before { animation: none; background-position: 100% 0, 0 0; }
}

/* iPhone: no double-tap zoom anywhere. touch-action isn't inherited, so it goes on every element
   (anything with its own touch-action keeps it). Text fields stay selectable. */
* { touch-action: manipulation; }
input, textarea { -webkit-user-select: text; user-select: text; }

/* Title screen and pause sheet: the shared layout (shared/mainmenu.js); these are only Zoomies' colors. */
#mm {
  --sg-bg: linear-gradient(180deg, #5aa8f5 0%, #e4f5ff 70%);
  --sg-ink: var(--ink); --sg-ink-soft: var(--ink-soft);
  --sg-title: var(--orange); --sg-title-shadow: 0 3px 0 var(--orange-lo), 0 0 18px rgba(255, 255, 255, 0.55);
  --sg-accent: var(--orange); --sg-accent-ink: #fff;
  --sg-card: var(--panel); --sg-card-ink: var(--ink); --sg-line: var(--line);
}
.sg-sheet { --sg-sheet-bg: var(--panel); --sg-sheet-ink: var(--ink); --sg-accent: var(--orange); --sg-accent-ink: #fff; --sg-ink-soft: var(--ink-soft); }
