/* 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: calc(var(--safe-top) + 10px) calc(var(--safe-right) + 12px) 0 calc(var(--safe-left) + 12px);
  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-btn.off .wave { display: none; }
#sound-btn.off::after {
  content: "";
  position: absolute;
  width: 26px;
  height: 3px;
  border-radius: 2px;
  background: var(--red);
  transform: rotate(-45deg);
}
#sound-btn { 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: 10px;
}
.topbar .coins { margin-right: auto; }

.journey {
  margin-top: 10px;
  padding: 10px 6px 6px;
  border-radius: 20px;
  background: var(--panel-soft);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.journey-rail {
  position: relative;
  height: 18px;
  margin: 0 calc(100% / 14);
}
.journey-track {
  position: absolute;
  left: 0;
  right: 0;
  top: 6px;
  height: 6px;
  border-radius: 3px;
  background: #d9e0eb;
  overflow: hidden;
}
.journey-fill {
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: linear-gradient(90deg, #5cb84f, #ffc21a 25%, #7cc4f2 45%, #3f7fd9 60%, #ff6a2a 75%, #a35cff 92%);
  background-size: 390px 100%;
}
.journey-marker {
  position: absolute;
  top: -3px;
  width: 22px;
  height: 22px;
  margin-left: -11px;
  border-radius: 50%;
  background: var(--ink);
  border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(31, 42, 68, 0.4);
  z-index: 2;
}
.journey-stops {
  list-style: none;
  margin: -18px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.journey-stops li {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}
.journey-stops .dot {
  position: relative;
  z-index: 1;
  width: 16px;
  height: 16px;
  margin-top: 1px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #c3cbd8;
}
.journey-stops li.reached .dot { background: var(--c); border-color: #fff; box-shadow: 0 0 0 2px var(--c); }
.journey-stops li.moon .dot { width: 18px; height: 18px; margin-top: 0; }
.journey-stops .name {
  margin-top: 3px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.05;
  text-align: center;
  color: #8a94a8;
  white-space: nowrap;
}
.journey-stops li.reached .name { color: var(--ink); }
.journey-caption {
  margin: 4px 0 0;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  color: var(--ink-soft);
  line-height: 1.2;
}
.journey-caption b { color: var(--ink); font-weight: 800; }

.car-title {
  align-self: center;
  max-width: 100%;
  margin: -44px 0 6px;
  padding: 6px 18px 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-evolve { display: flex; align-items: center; justify-content: center; gap: 8px; }
.car-title p {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
}
.stage-dots { display: flex; gap: 4px; flex: none; }
.stage-dots i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #d9e0eb;
}
.stage-dots i.on { background: var(--orange); }
.stage-dots i.now { box-shadow: 0 0 0 2.5px rgba(255, 107, 44, 0.3); }

.panel {
  margin: auto calc(-1 * (var(--safe-right) + 12px)) 0 calc(-1 * (var(--safe-left) + 12px));
  height: min(47vh, 460px);
  height: min(47dvh, 460px);
  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);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: 16px;
  background: #eef2f8;
  flex: none;
}
.tab {
  position: relative;
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink-soft);
}
.tab[aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: 0 2px 6px rgba(31, 42, 68, 0.14); }
.badge {
  position: absolute;
  top: 3px;
  right: 6px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--orange);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 21px;
}

.lists {
  flex: 1;
  min-height: 0;
  position: relative;
  margin: 6px -14px 0;
}
.list {
  list-style: none;
  margin: 0;
  padding: 2px 14px 10px;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.lists::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 16px;
  background: linear-gradient(rgba(255, 255, 255, 0), #fff);
  pointer-events: none;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  padding: 8px 0;
  border-bottom: 2px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-name { font-size: 18px; font-weight: 800; line-height: 1.15; }
.row-name small { font-size: 13px; font-weight: 700; color: var(--ink-soft); margin-left: 2px; }
.row-sub { font-size: 14px; font-weight: 500; line-height: 1.2; color: var(--ink-soft); }
.row-story { font-size: 13px; font-weight: 500; line-height: 1.2; color: #8a94a8; margin-top: 2px; }

.part-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 14px;
  background: var(--c);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.15);
}
.part-icon svg { width: 26px; height: 26px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.part-icon.locked-icon { background: #e3e8f0; box-shadow: none; }
.part-icon.locked-icon svg { stroke: #8a94a8; }
.row.locked .row-name { color: #8a94a8; }

.pips { display: flex; gap: 3px; margin-top: 4px; }
.pips i { flex: 1; max-width: 14px; height: 6px; border-radius: 3px; background: #e3e8f0; }
.pips i.on { background: var(--green); }

.buy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 92px;
  height: 48px;
  padding: 2px 12px 0;
  flex: none;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold) 60%);
  box-shadow: 0 4px 0 var(--gold-lo);
  font-size: 18px;
  font-weight: 800;
}
.buy .coin-icon { width: 18px; height: 18px; }
.buy:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--gold-lo); }
.buy.poor { background: #eef2f8; box-shadow: 0 4px 0 #d4dbe6; color: #8a94a8; }
.buy.nope { animation: nope 0.35s; }
@keyframes nope {
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}
.maxed {
  min-width: 92px;
  text-align: center;
  font-size: 17px;
  font-weight: 800;
  color: var(--green);
}

.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); }

.goal-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0 2px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.goal-head small { text-transform: none; font-weight: 600; letter-spacing: 0; }
.goal-head .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c); }
.goal { min-height: 54px; }
.goal-text { font-size: 16px; font-weight: 600; line-height: 1.2; }
.check {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  border: 3px solid #d4dbe6;
}
.check svg { width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.goal.done .check { background: var(--green); border-color: var(--green); }
.goal.done .goal-text { color: var(--ink-soft); }
.goal.locked { opacity: 0.55; }
.reward {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
  font-size: 16px;
  font-weight: 800;
}
.goal.done .reward { opacity: 0.45; }

.launch-row {
  display: flex;
  gap: 10px;
  flex: none;
  padding-top: 10px;
  border-top: 2px solid var(--line);
}
.start-at {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  flex: 0 1 46%;
  height: 60px;
  padding: 2px 12px 0;
  border-radius: 16px;
  background: #eef2f8;
  position: relative;
}
.start-at span { font-size: 12px; font-weight: 700; color: var(--ink-soft); line-height: 1; }
.start-at select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  border: 0;
  padding: 0 18px 0 0;
  background: transparent;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.start-at::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 30px;
  width: 8px;
  height: 8px;
  border-right: 3px solid var(--ink-soft);
  border-bottom: 3px solid var(--ink-soft);
  transform: rotate(45deg);
  pointer-events: none;
}
.start-at:has(select:disabled)::after { display: none; }
.start-at select:disabled { opacity: 1; color: var(--ink); }
.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; }

/* ---------- Aim ---------- */
.aim { touch-action: none; pointer-events: auto; }
.aim-hint {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 64px);
  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.gone { opacity: 0; }
@keyframes pull-hint {
  0%, 100% { transform: translateY(-6px); }
  50% { transform: translateY(10px); }
}

.power {
  position: absolute;
  right: calc(var(--safe-right) + 18px);
  top: 50%;
  width: 26px;
  height: min(240px, 34vh);
  transform: translateY(-50%);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow), inset 0 0 0 3px #fff;
  overflow: visible;
  pointer-events: none;
}
.power::before {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 10px;
  background: #e3e8f0;
}
.power-fill {
  position: absolute;
  left: 3px;
  right: 3px;
  bottom: 3px;
  top: 3px;
  border-radius: 10px;
  background: linear-gradient(0deg, #5cb84f, #ffc21a 60%, #ff6b2c);
  transform: scaleY(0);
  transform-origin: 50% 100%;
}
.power-sweet {
  position: absolute;
  left: -6px;
  right: -6px;
  bottom: calc(3px + (100% - 6px) * 0.82);
  height: calc((100% - 6px) * 0.12);
  border-radius: 6px;
  border: 3px solid #fff;
  background: rgba(255, 210, 63, 0.35);
  box-shadow: 0 0 0 2px var(--gold-lo);
  z-index: 1;
}
.power-label {
  position: absolute;
  right: 36px;
  bottom: calc(3px + (100% - 6px) * 0.82);
  padding: 4px 10px 2px;
  border-radius: 10px;
  background: var(--gold);
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.12s, transform 0.12s;
}
.power.sweet .power-label { opacity: 1; transform: scale(1); }
.power.sweet .power-sweet { background: rgba(255, 210, 63, 0.9); }

.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 {
  position: relative;
  display: flex;
  justify-content: center;
  pointer-events: none;
}
.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); }

.fuel {
  position: absolute;
  right: calc(var(--safe-right) + 14px);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 4px;
  padding: 8px 6px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  pointer-events: none;
}
.fuel svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; order: 3; }
.fuel span { font-size: 15px; font-weight: 800; line-height: 1; order: 1; font-variant-numeric: tabular-nums; }
.fuel-bar {
  order: 2;
  width: 16px;
  height: min(170px, 24vh);
  border-radius: 8px;
  background: #e3e8f0;
  overflow: hidden;
  position: relative;
}
.fuel-fill {
  position: absolute;
  inset: 0;
  border-radius: 8px;
  background: linear-gradient(0deg, #ff9f1c, #2fbf71 45%);
  transform-origin: 50% 100%;
}
.fuel.low .fuel-fill { background: var(--red); }
.fuel.low span { color: var(--red); }
.fuel.low { animation: low-fuel 0.8s ease-in-out infinite; }
@keyframes low-fuel { 50% { box-shadow: var(--shadow), 0 0 0 4px rgba(255, 74, 61, 0.45); } }

.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); }
.nitro-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.nitro-ring circle { fill: none; stroke-width: 7; }
.ring-bg { stroke: rgba(255, 255, 255, 0.25); }
.ring-fill { stroke: #ffd23f; stroke-linecap: round; stroke-dasharray: 276.5 276.5; stroke-dashoffset: 0; }
.nitro-icon { position: relative; width: 40px; height: 40px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.steer-hint {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 150px);
  transform: translateX(-50%);
  padding: 10px 20px 8px;
  border-radius: 999px;
  background: var(--panel);
  box-shadow: var(--shadow);
  font-size: 19px;
  font-weight: 800;
  white-space: nowrap;
  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); }
}

.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); }
@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); }
}
.coin-pop {
  position: absolute;
  right: calc(var(--safe-right) + 18px);
  top: -14vh;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 0 rgba(31, 42, 68, 0.6);
  animation: coin-pop 1s ease-out forwards;
}
.coin-pop .coin-icon { width: 20px; height: 20px; }
@keyframes coin-pop {
  0% { opacity: 0; transform: translateY(16px); }
  20% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-24px); }
}

.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; }
@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-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; }
@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) {
  .journey-stops .name { font-size: 10px; }
  .row-name { font-size: 17px; }
  .buy { min-width: 84px; padding: 2px 10px 0; font-size: 17px; }
  .launch-btn { font-size: 23px; }
  .start-at select { font-size: 16px; }
}
@media (max-height: 700px) {
  .journey-caption { display: none; }
  .panel { height: min(50vh, 460px); height: min(50dvh, 460px); }
  .row { min-height: 62px; padding: 6px 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .toast, .coin-pop, .region-toast.show { animation: fade-only 1.6s linear forwards !important; }
  @keyframes fade-only { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }
}
