/* Rattletrap: the menus, the garage and the driving controls. The road and the truck are
   drawn on the canvas by game.js. */

@font-face {
  font-family: "Nunito";
  src: url("fonts/nunito.woff2") format("woff2");
  font-weight: 600 900;
  font-display: swap;
}

:root {
  --ink: #23263a;
  --muted: rgba(35, 38, 58, 0.74); /* 5.4:1 on white, readable on small text */
  --card: rgba(255, 251, 244, 0.94);
  --line: rgba(35, 38, 58, 0.12);
  --button: #ffffff;
  --primary: #ff6b3d;
  --primary-dark: #d94a1e;
  --gold: #ffc83d;
  --good: #2ebf7a;
  --bad: #ff4d5e;
  --shadow: 0 24px 60px rgba(20, 30, 60, 0.28), 0 2px 6px rgba(20, 30, 60, 0.1);
  --font: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  --spring: cubic-bezier(0.2, 0.9, 0.3, 1.25);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #6ec3f4;
  color: var(--ink);
  font-family: var(--font);
  font-weight: 800;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
  touch-action: none;
}

canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

h1, h2, p { margin: 0; }

.icon {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  vertical-align: -0.2em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- buttons ---------- */

.button {
  font: inherit;
  font-weight: 900;
  font-size: 1rem;
  color: var(--ink);
  background: var(--button);
  border: none;
  border-radius: 16px;
  padding: 0.75rem 1.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.08);
  transition: transform 0.15s var(--spring), filter 0.2s;
}
.button:hover { transform: translateY(-2px); }
.button:active { transform: translateY(1px) scale(0.97); box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.12); }
.button:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.button.primary { background: var(--primary); color: #fff; box-shadow: inset 0 -5px 0 var(--primary-dark), 0 6px 16px rgba(255, 107, 61, 0.35); }
.button.ghost { background: transparent; box-shadow: none; color: var(--muted); }
.button.big { font-size: 1.2rem; padding: 0.95rem 1.2rem; border-radius: 18px; width: 100%; }
.button.round { border-radius: 50%; padding: 0.6rem; }
.button:disabled { opacity: 0.45; cursor: default; transform: none; }

/* ---------- panels ---------- */

.panel {
  position: fixed;
  left: 50%;
  top: 50%;
  width: min(360px, calc(100vw - 32px));
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  transform: translate(-50%, -44%) scale(0.96);
  opacity: 0;
  pointer-events: none;
  background: var(--card);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.7rem;
  text-align: center;
  transition: opacity 0.25s, transform 0.4s var(--spring);
  z-index: 10;
}
.panel.wide { width: min(560px, calc(100vw - 24px)); }
.panel > *, #vehicle-detail > * { flex-shrink: 0; }
body[data-screen="menu"] #menu,
body[data-screen="stages"] #stages,
body[data-screen="garage"] #garage,
body[data-screen="paused"] #paused,
body[data-screen="result"] #result {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

.logo {
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--primary);
  text-shadow: 0 3px 0 var(--primary-dark);
  transform: rotate(-3deg);
  margin-top: 0.3rem;
}
.logo span { color: var(--ink); text-shadow: 0 3px 0 rgba(0, 0, 0, 0.15); }
.tagline { color: var(--muted); font-size: 0.95rem; margin-bottom: 0.2rem; }

.wallet { display: flex; justify-content: center; gap: 1.2rem; font-size: 1.05rem; margin: 0.2rem 0 0.4rem; }
.wallet span { display: inline-flex; align-items: center; gap: 0.3rem; }
.wallet .icon[style], .wallet span:last-child .icon { color: var(--primary); }

.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 3px rgba(255, 77, 94, 0.25); }
.dot[hidden] { display: none; }

.menu-foot { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; margin-top: 0.3rem; }
.toggle { display: inline-flex; align-items: center; gap: 0.4rem; cursor: pointer; color: var(--muted); }
.toggle input { width: 18px; height: 18px; accent-color: var(--primary); }
.keys { font-size: 0.8rem; color: var(--muted); }
kbd { font: inherit; background: rgba(0, 0, 0, 0.07); border-radius: 6px; padding: 0 0.35rem; }
@media (pointer: coarse) { .keys { display: none; } }

/* ---------- garage ---------- */

.panel-head { display: flex; align-items: center; gap: 0.6rem; }
.panel-head h2 { flex: 1; text-align: left; font-size: 1.6rem; font-weight: 900; }
.wallet-chip { display: inline-flex; align-items: center; gap: 0.3rem; background: rgba(255, 200, 61, 0.22); border-radius: 99px; padding: 0.3rem 0.8rem; font-size: 1.05rem; }

.upgrades { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
@media (max-width: 420px) {
  .upgrades { grid-template-columns: 1fr 1fr; gap: 0.45rem; }
  .upgrade { padding: 0.6rem; }
  .upgrade .about { display: none; }
  .upgrade .button { font-size: 0.82rem; padding: 0.5rem 0.3rem; gap: 0.25rem; }
  .vehicle-hero { grid-template-columns: 1fr; }
  .vehicle-hero canvas { width: 100%; height: 110px; }
}
.upgrade {
  background: #fff;
  border-radius: 20px;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  text-align: left;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.upgrade-top { display: flex; align-items: center; gap: 0.55rem; }
.upgrade-top .icon { width: 2rem; height: 2rem; padding: 0.35rem; border-radius: 12px; background: rgba(255, 107, 61, 0.14); color: var(--primary); }
.upgrade h3 { margin: 0; font-size: 1.05rem; font-weight: 900; }
.upgrade p { font-size: 0.8rem; color: var(--muted); line-height: 1.25; }
.pips { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; }
.pips i { height: 7px; border-radius: 4px; background: rgba(0, 0, 0, 0.09); }
.pips i.on { background: var(--good); }
.upgrade .button { width: 100%; padding: 0.55rem; font-size: 0.95rem; }
.upgrade .button .icon { width: 1.1em; }
.upgrade.bought { animation: bought 0.5s var(--spring); }
@keyframes bought { 40% { transform: scale(1.05); background: #e9fff3; } }

/* ---------- driving ---------- */

.hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  align-items: start;
  gap: 0.6rem;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.4s var(--spring);
  z-index: 5;
}
body:not([data-screen="drive"]):not([data-screen="paused"]) .hud { opacity: 0; transform: translateY(-16px); }
.hud > * { pointer-events: auto; }

/* The HUD pills: a thin dark rim keeps them readable on bright sky and white snow. */
.fuel, .coins, .distance {
  background: rgba(255, 255, 255, 0.92);
  border-radius: 16px;
  padding: 0.4rem 0.7rem;
  border: 2px solid rgba(35, 38, 58, 0.16);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
}
.fuel { display: flex; align-items: center; gap: 0.45rem; max-width: 220px; color: var(--bad); }
.gauge { flex: 1; height: 14px; min-width: 70px; border-radius: 8px; background: rgba(0, 0, 0, 0.1); overflow: hidden; }
.gauge i { display: block; height: 100%; width: 100%; border-radius: 8px; background: var(--good); transform-origin: left; transition: background 0.3s; }
.fuel.low .gauge i { background: var(--bad); animation: blink 0.6s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.35; } }
.distance { text-align: center; display: flex; flex-direction: column; line-height: 1.1; min-width: 100px; }
.distance strong { font-size: 1.5rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.distance span { font-size: 0.72rem; color: var(--muted); }
.coins { justify-self: end; display: flex; align-items: center; gap: 0.35rem; font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.coins.bump { animation: bump 0.25s var(--spring); }
@keyframes bump { 50% { transform: scale(1.15); } }

.pedals {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.4s var(--spring);
  z-index: 5;
}
body:not([data-screen="drive"]) .pedals { opacity: 0; transform: translateY(30px); }
body:not([data-screen="drive"]) .pedals .pedal { pointer-events: none; }
.pedal {
  pointer-events: auto;
  width: clamp(84px, 22vmin, 130px);
  height: clamp(110px, 30vmin, 170px);
  border: none;
  border-radius: 22px;
  font: inherit;
  font-weight: 900;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.95);
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 0.8rem;
  touch-action: none;
  transform-origin: bottom;
  transition: transform 0.08s;
  box-shadow: inset 0 -7px 0 rgba(0, 0, 0, 0.22), 0 8px 20px rgba(0, 0, 0, 0.18);
}
.pedal.brake { background: #4b5068; }
.pedal.gas { background: #1a9158; } /* darker than --good so the white label reads (4:1) */
.pedal b { display: inline-flex; align-items: center; gap: 0.25rem; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); }
.pedal b .icon { width: 1.3em; height: 1.3em; }
/* Easy to hit without looking: each pedal also answers to touches in most of its bottom corner
   of the screen (an invisible extension of the button), not just on the drawn pedal. */
.pedal::before { content: ""; position: absolute; bottom: -16px; width: 40vw; height: 62vh; }
body:not(.swap) .pedal.brake::before, body.swap .pedal.gas::before { left: -16px; }
body:not(.swap) .pedal.gas::before, body.swap .pedal.brake::before { right: -16px; }
#pause { min-width: 48px; min-height: 48px; }
.pedal-face {
  position: absolute;
  inset: 14px 14px 40px;
  border-radius: 12px;
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.22) 0 6px, transparent 6px 12px);
}
.pedal.down { transform: perspective(300px) rotateX(16deg) scale(0.97); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.22), 0 3px 8px rgba(0, 0, 0, 0.18); }
@media (pointer: fine) { .pedal { opacity: 0.75; } }

/* ---------- result ---------- */

.reason { font-size: 0.85rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--bad); }
.result-distance { display: flex; flex-direction: column; align-items: center; }
.result-distance strong { font-size: 3rem; font-weight: 900; line-height: 1; }
.result-distance span { color: var(--muted); font-size: 0.95rem; }
.result-distance span.close { color: var(--primary-dark); }
.result-distance span.new { color: var(--good); animation: bump 0.6s 0.3s var(--spring) both; }
.lines { display: flex; flex-direction: column; gap: 0.25rem; background: rgba(0, 0, 0, 0.04); border-radius: 16px; padding: 0.6rem 0.9rem; }
.lines div { display: flex; justify-content: space-between; font-size: 0.92rem; color: var(--muted); }
.lines b { color: var(--ink); }
.result-total { display: flex; justify-content: space-between; align-items: center; font-size: 1.1rem; padding: 0 0.9rem; }
.result-total b { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 1.5rem; }
.tip { font-size: 0.85rem; color: var(--muted); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.row .button.big { font-size: 1.05rem; padding: 0.85rem 0.6rem; }
#result .row { grid-template-columns: 1fr 1.5fr; } /* Drive again: the big one, under your right thumb */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, calc(100% + 60px));
  visibility: hidden;
  background: var(--ink);
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 14px;
  z-index: 30;
  transition: transform 0.35s var(--spring);
  pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); visibility: visible; }

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

/* ---------- menu extras ---------- */

.wallet { font-size: 1.25rem; align-items: center; gap: 0.35rem; }
.picks { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.pick {
  font: inherit;
  border: none;
  cursor: pointer;
  border-radius: 18px;
  padding: 0.6rem 0.7rem;
  background: #fff;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 0.05rem;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.08);
  background-image: var(--art, none);
  background-size: cover;
  transition: transform 0.15s var(--spring);
}
.pick:hover { transform: translateY(-2px); }
.pick:active { transform: scale(0.97); }
.pick:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.pick-label { font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.7; }
.pick b { font-size: 1.05rem; font-weight: 900; }
.pick-note { font-size: 0.75rem; opacity: 0.75; }
.pick.light { color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35); }

.missions { background: rgba(0, 0, 0, 0.04); border-radius: 18px; padding: 0.6rem 0.75rem; text-align: left; }
.missions h3 { margin: 0 0 0.35rem; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); display: flex; align-items: center; gap: 0.3rem; }
.mission { display: grid; grid-template-columns: 1fr auto; gap: 0.1rem 0.5rem; align-items: center; padding: 0.3rem 0; font-size: 0.88rem; }
.mission + .mission { border-top: 1px solid var(--line); }
.mission .reward { font-size: 0.8rem; color: var(--muted); display: inline-flex; align-items: center; gap: 0.2rem; }
.mission .bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: rgba(0, 0, 0, 0.08); overflow: hidden; }
.mission .bar i { display: block; height: 100%; background: var(--good); border-radius: 3px; }

.menu-foot { flex-direction: row; justify-content: center; flex-wrap: wrap; gap: 0.2rem; }
.button.small { padding: 0.5rem 0.75rem; font-size: 0.9rem; border-radius: 12px; }
.button.gift { background: var(--gold); color: var(--ink); box-shadow: inset 0 -3px 0 #d08a00; animation: wiggle 2.4s ease-in-out infinite; }
.button.gift[hidden] { display: none; }
@keyframes wiggle { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(-6deg); } 90% { transform: rotate(6deg); } 95% { transform: rotate(-3deg); } }

/* ---------- adventures and garage ---------- */

.panel-head .button.round { flex: none; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 0.6rem; }
.card {
  font: inherit;
  border: 3px solid transparent;
  border-radius: 20px;
  overflow: hidden;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  padding: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  transition: transform 0.15s var(--spring);
}
.card:hover { transform: translateY(-2px); }
.card.chosen { border-color: var(--primary); }
.card .art { height: 70px; position: relative; }
.card .art span { position: absolute; left: 8px; top: 6px; font-size: 0.68rem; padding: 0.1rem 0.45rem; border-radius: 99px; background: rgba(255, 255, 255, 0.85); }
.card .body { padding: 0.55rem 0.7rem 0.7rem; display: flex; flex-direction: column; gap: 0.2rem; }
.card h3 { margin: 0; font-size: 1rem; font-weight: 900; }
.card p { margin: 0; font-size: 0.76rem; color: var(--muted); line-height: 1.25; }
.card .state { font-size: 0.85rem; display: flex; align-items: center; gap: 0.3rem; margin-top: 0.15rem; }
.card.locked .art { filter: grayscale(0.7) brightness(0.85); }
.card .buy { color: var(--primary-dark); }
.card .buy.poor { color: var(--muted); }
.medals { display: flex; gap: 0.15rem; }
.medals .icon { width: 1em; height: 1em; color: rgba(0, 0, 0, 0.12); }
.medals .bronze { color: #cd7f32; }
.medals .silver { color: #a8b2bd; }
.medals .gold { color: #f2b70f; }

.tabs { display: flex; gap: 0.4rem; overflow-x: auto; padding-bottom: 0.2rem; scrollbar-width: none; }
.tab {
  font: inherit;
  font-weight: 900;
  border: none;
  border-radius: 14px;
  padding: 0.5rem 0.8rem;
  background: rgba(0, 0, 0, 0.05);
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.tab[aria-selected="true"] { background: var(--ink); color: #fff; }
.tab .icon { width: 0.9em; height: 0.9em; }

.vehicle-hero { display: grid; grid-template-columns: 170px 1fr; gap: 0.8rem; align-items: center; text-align: left; background: #fff; border-radius: 20px; padding: 0.7rem; }
.vehicle-hero canvas { position: static; width: 170px; height: 100px; border-radius: 14px; background: linear-gradient(#bfe6ff, #eaf7ff); }
.vehicle-hero h3 { margin: 0; font-size: 1.2rem; font-weight: 900; }
.vehicle-hero p { margin: 0.1rem 0 0.4rem; font-size: 0.82rem; color: var(--muted); }
.traits { display: grid; grid-template-columns: auto 1fr; gap: 0.15rem 0.5rem; font-size: 0.74rem; color: var(--muted); align-items: center; }
.traits i { height: 6px; border-radius: 3px; background: rgba(0, 0, 0, 0.08); position: relative; overflow: hidden; }
.traits i::after { content: ""; position: absolute; inset: 0; width: var(--v); background: var(--primary); border-radius: 3px; }
.paints { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; justify-content: center; font-size: 0.8rem; color: var(--muted); }
.paint { width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; position: relative; }
.paint.on { box-shadow: 0 0 0 3px var(--ink); }
.paint.locked::after { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: rgba(255, 255, 255, 0.55); }
#vehicle-detail { display: flex; flex-direction: column; gap: 0.6rem; }
.buy-vehicle { width: 100%; }

/* ---------- driving extras ---------- */

.fuel-box { display: flex; flex-direction: column; gap: 0.25rem; align-items: flex-start; }
.next-fuel { font-size: 0.75rem; background: rgba(255, 255, 255, 0.9); border: 1.5px solid rgba(35, 38, 58, 0.14); border-radius: 10px; padding: 0.1rem 0.5rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.next-fuel:empty { display: none; }
.stuck { position: fixed; left: 50%; top: 84px; transform: translateX(-50%); z-index: 6; font-size: 0.9rem; padding: 0.55rem 0.9rem; }
.stuck[hidden] { display: none; }
body:not([data-screen="drive"]) .stuck { display: none; }
body.swap .pedals { flex-direction: row-reverse; }

.button.double { background: var(--gold); color: var(--ink); box-shadow: inset 0 -4px 0 #d08a00; }
.button.double[hidden] { display: none; }

/* ---------- sheets ---------- */

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  width: min(480px, 100%);
  max-height: 88dvh;
  overflow-y: auto;
  transform: translate(-50%, 105%);
  background: #fffbf4;
  border-radius: 28px 28px 0 0;
  box-shadow: var(--shadow);
  padding: 1.2rem 1.3rem max(1.4rem, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  z-index: 20;
  transition: transform 0.4s var(--spring);
}
.sheet.open { transform: translate(-50%, 0); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet h2 { font-size: 1.5rem; font-weight: 900; }
.sheet h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin: 0.4rem 0 0; }
.scrim { position: fixed; inset: 0; background: rgba(10, 15, 40, 0.35); opacity: 0; pointer-events: none; transition: opacity 0.3s; z-index: 19; }
.scrim.open { opacity: 1; pointer-events: auto; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 1rem; cursor: pointer; padding: 0.25rem 0; font-size: 0.95rem; }
.switch small { color: var(--muted); font-weight: 700; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch i { flex: none; width: 48px; height: 28px; border-radius: 99px; background: rgba(0, 0, 0, 0.18); position: relative; transition: background 0.2s; }
.switch i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform 0.25s var(--spring); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); }
.switch input:checked + i { background: var(--good); }
.switch input:checked + i::after { transform: translateX(20px); }
.switch input:focus-visible + i { outline: 3px solid var(--ink); outline-offset: 2px; }
.rules { margin: 0; padding-left: 1.2rem; color: var(--muted); font-size: 0.88rem; display: flex; flex-direction: column; gap: 0.3rem; }
.rules b { color: var(--ink); }
.credits { font-size: 0.75rem; color: var(--muted); }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.45rem; }
.tiles div { background: rgba(0, 0, 0, 0.04); border-radius: 14px; padding: 0.6rem 0.3rem; text-align: center; }
.tiles b { display: block; font-size: 1.3rem; font-weight: 900; }
.tiles span { font-size: 0.72rem; color: var(--muted); }
.bests { display: flex; flex-direction: column; gap: 0.3rem; }
.bests div { display: flex; justify-content: space-between; font-size: 0.92rem; padding: 0.3rem 0; border-bottom: 1px solid var(--line); }
.bests span { color: var(--muted); }

/* ---------- small screens ---------- */

/* Phones held sideways: everything a bit tighter, and the garage in one row of four. */
@media (max-height: 600px) {
  .panel { padding: 0.9rem 1.1rem; gap: 0.45rem; border-radius: 22px; }
  .panel.wide { width: min(780px, calc(100vw - 24px)); }
  .logo { font-size: 2.2rem; }
  .tagline { font-size: 0.85rem; }
  .button.big { font-size: 1.05rem; padding: 0.7rem 1rem; }
  .upgrades { grid-template-columns: repeat(4, 1fr); gap: 0.45rem; }
  .upgrade { padding: 0.6rem; gap: 0.3rem; }
  .upgrade .about { display: none; }
  .upgrade-top .icon { width: 1.6rem; height: 1.6rem; padding: 0.25rem; }
  .upgrade h3 { font-size: 0.92rem; }
  .upgrade .button { font-size: 0.82rem; padding: 0.45rem 0.3rem; gap: 0.25rem; }
  .panel-head h2 { font-size: 1.3rem; }
  .result-distance strong { font-size: 2.2rem; }
  .lines { padding: 0.4rem 0.8rem; }
  .tip { font-size: 0.78rem; }
  .missions { display: none; }
  .vehicle-hero { grid-template-columns: 130px 1fr; padding: 0.5rem; }
  .vehicle-hero canvas { width: 130px; height: 76px; }
  .vehicle-hero p, .traits { display: none; }
  .card .art { height: 46px; }
  .card p { display: none; }
  .cards { grid-template-columns: repeat(3, 1fr); }
}
@media (max-height: 600px) and (max-width: 560px) {
  .upgrades { grid-template-columns: 1fr 1fr; }
}

/* Phones held upright: the menu sits lower, so you can see the truck above it. */
@media (orientation: portrait) and (min-height: 600px) {
  #menu { top: 61%; max-height: 76dvh; }
}
