:root {
  --sign-green: #1f5a33;
  --sign-green-dark: #163f24;
  --cream: #f7f2e5;
  --card: #fffdf6;
  --ink: #1d2420;
  --muted: #5d6660;
  --line: #ddd5c0;
  --accent: #2f7a45;
  --good: #3fbf62;
  --warn: #f0b429;
  --bad: #e5484d;
  --panel: rgba(16, 22, 18, 0.62);
  --panel-line: rgba(255, 255, 255, 0.14);
  --hud-ink: #f5f3ea;
  --radius: 14px;
  --ui: 'Overpass', 'Helvetica Neue', Arial, sans-serif;
  --display: 'Fredoka', 'Overpass', sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --cream: #1c211d;
    --card: #242a25;
    --ink: #eef0e8;
    --muted: #a8b0a8;
    --line: #3a423b;
    --accent: #5fbf7a;
  }
}
:root[data-theme='dark'] {
  --cream: #1c211d;
  --card: #242a25;
  --ink: #eef0e8;
  --muted: #a8b0a8;
  --line: #3a423b;
  --accent: #5fbf7a;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #9fb7c6;
  font-family: var(--ui);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  /* it's a game, not a document: no text selection, copy menus or pinch/double-tap zoom.
     pan-x pan-y still lets the menu scroll */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: pan-x pan-y;
}
#game {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: block;
  touch-action: none;
}
button {
  font-family: var(--ui);
  cursor: pointer;
}
kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0.05em 0.4em;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--card);
  font: 700 0.82em var(--ui);
  text-align: center;
  color: var(--ink);
}
[hidden] {
  display: none !important;
}

/* ---------------- screens ---------------- */
.screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow-y: auto;
}
.screen.dim {
  background: rgba(10, 16, 12, 0.55);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 16px;
}

/* ---------------- menu ---------------- */
#menu {
  padding: 24px;
}
.menu-card {
  width: min(760px, 100%);
  background: var(--cream);
  border-radius: 22px;
  padding: 26px 28px 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.5);
}
.title {
  margin-bottom: 8px;
}
.sign {
  display: inline-flex;
  flex-direction: column;
  background: var(--sign-green);
  color: #fff;
  border: 4px solid #fff;
  outline: 3px solid var(--sign-green);
  border-radius: 12px;
  padding: 10px 20px 8px;
  font: 800 34px/1 var(--ui);
  letter-spacing: -0.5px;
  box-shadow: 0 6px 0 var(--sign-green-dark);
}
.sign span + span {
  color: #ffd84a;
  font-size: 27px;
  margin-top: 4px;
}
.tagline {
  margin: 14px 0 4px;
  font-size: 16px;
  color: var(--muted);
  line-height: 1.45;
}
section h2 {
  font: 600 19px var(--display);
  margin: 20px 0 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.step {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--sign-green);
  color: #fff;
  font: 700 15px var(--ui);
}
.cards {
  display: grid;
  gap: 10px;
}
.cards.regions {
  grid-template-columns: repeat(3, 1fr);
}
.cards.vehicles {
  grid-template-columns: repeat(4, 1fr);
}
.card {
  position: relative;
  text-align: left;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 12px 10px;
  color: var(--ink);
  transition:
    transform 0.12s,
    border-color 0.12s,
    box-shadow 0.12s;
  overflow: hidden;
}
.card:hover {
  transform: translateY(-2px);
}
.card.sel {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent);
}
.card.sel::after {
  content: '✓';
  position: absolute;
  top: 8px;
  right: 10px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font: 700 13px/22px var(--ui);
  text-align: center;
}
.card .stripe {
  height: 6px;
  border-radius: 3px;
  margin: -2px 0 8px;
  width: 54px;
}
.card .kicker {
  font: 700 11px var(--ui);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.card .name {
  font: 600 17px var(--display);
  margin: 2px 0 4px;
}
.card .blurb {
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted);
  margin: 0;
}
.card .best {
  margin-top: 8px;
  font: 700 12px var(--ui);
  color: var(--accent);
}
.card svg {
  width: 100%;
  height: 46px;
  display: block;
  margin: 0 0 4px;
}
.stat {
  display: grid;
  grid-template-columns: 62px 1fr;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 3px;
}
.dots {
  display: flex;
  gap: 3px;
}
.dots i {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--line);
}
.dots i.on {
  background: var(--accent);
}
.mult {
  display: inline-block;
  margin-top: 8px;
  padding: 2px 8px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
  font: 800 12px var(--ui);
}
.colours {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.colours .lbl {
  font-size: 13px;
  color: var(--muted);
  margin-right: 4px;
}
.swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid var(--card);
  box-shadow: 0 0 0 2px var(--line);
  padding: 0;
}
.swatch.sel {
  box-shadow: 0 0 0 3px var(--accent);
}
.go-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 18px;
  margin-top: 20px;
}
.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
}
.check input {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
}
.go {
  border: 0;
  border-radius: 999px;
  background: var(--sign-green);
  color: #fff;
  font: 700 18px var(--ui);
  padding: 13px 28px;
  box-shadow: 0 4px 0 var(--sign-green-dark);
  transition: transform 0.1s;
}
.go:hover {
  transform: translateY(-1px);
}
.go:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--sign-green-dark);
}
.go span {
  font-size: 14px;
  margin-left: 6px;
}
.ghost {
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  font: 700 16px var(--ui);
  padding: 11px 22px;
}
.howto {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.howto summary {
  cursor: pointer;
  font: 600 16px var(--display);
}
.howto-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 20px;
  font-size: 13.5px;
  line-height: 1.5;
}
.howto h3 {
  font: 700 13px var(--ui);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 12px 0 6px;
}
.howto ul {
  margin: 0;
  padding-left: 18px;
}
.howto .keys {
  list-style: none;
  padding: 0;
}
.howto .keys li {
  margin-bottom: 5px;
}
.foot {
  font-size: 12px;
  color: var(--muted);
  margin: 14px 0 0;
}

/* ---------------- dialogs ---------------- */
.dialog {
  width: min(560px, 100%);
  background: var(--cream);
  border-radius: 22px;
  padding: 24px 26px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  text-align: center;
}
.dialog h2 {
  font: 600 28px var(--display);
  margin: 4px 0 8px;
}
.dialog .btns {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 18px;
}
.toggles {
  display: flex;
  gap: 18px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 10px 0;
}
.results {
  width: min(720px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
}
.stars {
  font-size: 40px;
  letter-spacing: 6px;
  color: #f0b429;
  line-height: 1;
}
.stars .off {
  color: var(--line);
}
.res-sub {
  color: var(--muted);
  margin: 0 0 10px;
}
.res-final {
  display: inline-flex;
  align-items: baseline;
  gap: 12px;
  background: var(--sign-green);
  color: #fff;
  border-radius: 14px;
  padding: 8px 18px;
}
.res-final b {
  font: 800 34px var(--ui);
  color: #ffd84a;
}
.res-best {
  font-size: 13px;
  color: var(--accent);
  font-weight: 700;
  min-height: 1em;
}
.res-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  text-align: left;
  margin-top: 6px;
}
.res-cols h3 {
  font: 700 12px var(--ui);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 6px;
}
.res-cols ul,
.bonus {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 13.5px;
}
.res-cols li,
.bonus li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
  border-bottom: 1px dashed var(--line);
}
.res-cols li b.pos,
.bonus b {
  color: var(--accent);
}
.res-cols li b.neg {
  color: var(--bad);
}
.bonus {
  margin-top: 12px;
  text-align: left;
}

/* ---------------- loading / error ---------------- */
.loading-text {
  color: #fff;
  font: 600 20px var(--display);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}
#error {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  background: #3a0d0d;
  color: #ffd9d9;
  padding: 12px 16px;
  border-radius: 10px;
  font: 13px ui-monospace, monospace;
  white-space: pre-wrap;
}

/* ---------------- HUD ---------------- */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  color: var(--hud-ink);
  user-select: none;
}
#hud .panel {
  position: absolute;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  backdrop-filter: blur(6px);
  padding: 10px 14px;
}
#hud .label {
  font: 700 11px var(--ui);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.75;
}
#hud .sub {
  font-size: 12.5px;
  opacity: 0.85;
}
.hud-score {
  top: 14px;
  left: 14px;
  min-width: 150px;
}
.hud-score .big {
  font: 800 32px/1.05 var(--ui);
  font-variant-numeric: tabular-nums;
}
.hud-progress {
  top: 14px;
  right: 14px;
  width: 280px;
}
.hud-progress .row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font: 700 13px var(--ui);
}
.hud-progress .dest {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud-progress .time {
  font-variant-numeric: tabular-nums;
}
.hud-progress .time.late {
  color: var(--warn);
}
.track {
  position: relative;
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.18);
  margin: 8px 0 6px;
}
.track .fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #7fd18e, #3fbf62);
}
.track .car {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #3fbf62;
  transform: translate(-50%, -50%);
}
.hud-speed {
  left: 14px;
  bottom: 14px;
  min-width: 150px;
}
.speedrow {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.speed {
  font: 800 46px/1 var(--ui);
  font-variant-numeric: tabular-nums;
  min-width: 2ch;
}
.over .speed {
  color: var(--warn);
}
.unit {
  font: 700 14px var(--ui);
  opacity: 0.8;
}
.gear {
  margin-left: auto;
  font: 800 16px var(--ui);
  background: rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  padding: 1px 7px;
}
.hud-right {
  right: 14px;
  bottom: 14px;
  width: 196px;
  padding: 8px !important;
}
#minimap {
  width: 178px;
  height: 150px;
  display: block;
  border-radius: 10px;
  background: radial-gradient(circle at 50% 68%, rgba(70, 110, 60, 0.6), rgba(30, 50, 30, 0.6));
}
.cond {
  padding: 8px 4px 2px;
}
.cond .label span {
  float: right;
  margin-left: 6px;
  opacity: 1;
}
.health {
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.18);
  overflow: hidden;
  margin-top: 5px;
}
#hud-health {
  height: 100%;
  width: 100%;
  background: var(--good);
  transition: width 0.3s;
}
#toasts {
  position: absolute;
  top: 128px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: min(460px, 90vw);
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  backdrop-filter: blur(6px);
  border-radius: 999px;
  padding: 6px 16px 6px 8px;
  font: 600 14px var(--ui);
  animation: pop 0.25s ease-out;
  transition:
    opacity 0.5s,
    transform 0.5s;
}
.toast b {
  font: 800 14px var(--ui);
  border-radius: 999px;
  padding: 2px 9px;
  background: var(--good);
  color: #08260f;
}
.toast.bad b {
  background: var(--bad);
  color: #fff;
}
.toast.info {
  padding-left: 16px;
}
.toast.warn {
  padding-left: 16px;
  background: rgba(120, 80, 0, 0.75);
}
.toast.out {
  opacity: 0;
  transform: translateY(-8px);
}
@keyframes pop {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
}
#hint {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  display: flex;
  gap: 10px;
  align-items: center;
  max-width: min(600px, calc(100vw - 32px));
  background: rgba(255, 253, 246, 0.95);
  color: #1d2420;
  border-radius: 14px;
  padding: 10px 16px;
  font: 600 14.5px/1.35 var(--ui);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transition:
    opacity 0.3s,
    transform 0.3s;
}
#hint.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
#hint.urgent {
  background: #fff4cf;
  box-shadow:
    0 0 0 3px #f0b429,
    0 6px 24px rgba(0, 0, 0, 0.25);
}
#hint-icon {
  font-size: 22px;
}
#prompt {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%) scale(0.9);
  background: rgba(31, 90, 51, 0.92);
  border: 2px solid #fff;
  border-radius: 16px;
  padding: 12px 18px 10px;
  text-align: center;
  opacity: 0;
  transition:
    opacity 0.2s,
    transform 0.2s;
  max-width: calc(100vw - 32px);
}
#prompt.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.prompt-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font: 600 15px var(--ui);
}
.prompt-key {
  font: 800 17px var(--ui);
  color: #ffd84a;
}
.prompt-key kbd {
  color: #111;
}
.prompt-track {
  height: 4px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}
#prompt-bar {
  height: 100%;
  background: #ffd84a;
  transform-origin: left;
}
#wave-hand {
  position: absolute;
  right: 24%;
  bottom: 18%;
  font-size: 90px;
  opacity: 0;
}
#wave-hand.go {
  animation: wave 1.1s ease-out;
}
@keyframes wave {
  0% {
    opacity: 0;
    transform: translateY(40px) rotate(0);
  }
  20% {
    opacity: 1;
    transform: translateY(0) rotate(-15deg);
  }
  40% {
    transform: rotate(15deg);
  }
  60% {
    transform: rotate(-15deg);
  }
  80% {
    opacity: 1;
    transform: rotate(10deg);
  }
  100% {
    opacity: 0;
    transform: translateY(20px);
  }
}
#banner {
  position: absolute;
  left: 50%;
  top: 36%;
  transform: translate(-50%, -50%);
  text-align: center;
  opacity: 0;
  text-shadow: 0 3px 14px rgba(0, 0, 0, 0.55);
}
#banner.show {
  animation: banner 4s ease-out forwards;
}
.banner-title {
  font: 700 46px var(--display);
}
.banner-sub {
  font: 600 18px var(--ui);
  color: #ffd84a;
}
@keyframes banner {
  0% {
    opacity: 0;
    transform: translate(-50%, -40%);
  }
  15%,
  70% {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -60%);
  }
}
.cam-label {
  position: absolute;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  background: var(--panel);
  padding: 4px 12px;
  border-radius: 999px;
  font: 700 13px var(--ui);
  opacity: 0;
}
.cam-label.show {
  animation: fadeinout 1.6s;
}
@keyframes fadeinout {
  15%,
  70% {
    opacity: 1;
  }
}
.icon-btn {
  position: absolute;
  top: 14px;
  /* just left of the rear-view mirror, whose width game.js sets to min(380px, 42vw) */
  right: calc(50% + min(190px, 21vw) + 14px);
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--panel-line);
  background: var(--panel);
  color: #fff;
  font: 800 14px var(--ui);
  pointer-events: auto;
}

/* touch controls only on touch devices */
#touch {
  display: none;
}
@media (pointer: coarse) {
  #touch {
    display: flex;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    justify-content: space-between;
    align-items: flex-end;
    padding: 12px max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    pointer-events: none;
  }
  #touch .pad {
    display: flex;
    gap: 10px;
    pointer-events: auto;
  }
  #touch .mid {
    flex-direction: column;
    gap: 6px;
  }
  #touch button {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.4);
    background: rgba(16, 22, 18, 0.45);
    color: #fff;
    font-size: 26px;
    touch-action: none;
  }
  #touch .mid button {
    width: 48px;
    height: 48px;
    font-size: 20px;
  }
  #touch button.down {
    background: rgba(63, 191, 98, 0.6);
  }
  #touch .left button {
    width: 80px;
    height: 80px;
  }
  /* controller-style pedals: tall, grippy, and easy to find without looking */
  #touch .pedal {
    width: 80px;
    border-radius: 24px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0 0 12px;
    font: 800 13px var(--ui);
    letter-spacing: 0.08em;
    background-image: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.1) 0 3px, transparent 3px 11px);
    transition: transform 0.05s;
  }
  #touch .pedal.brake {
    height: 100px;
    background-color: rgba(150, 34, 34, 0.5);
    border-color: rgba(255, 150, 150, 0.6);
  }
  #touch .pedal.gas {
    height: 128px;
    background-color: rgba(28, 120, 58, 0.55);
    border-color: rgba(150, 255, 180, 0.6);
  }
  #touch .pedal.brake.down {
    background-color: rgba(214, 52, 52, 0.75);
  }
  #touch .pedal.gas.down {
    background-color: rgba(52, 190, 92, 0.75);
  }
  #touch .pedal.down {
    transform: scale(0.95);
  }
  #touch,
  #touch * {
    touch-action: none;
  }
  .hud-speed {
    bottom: 152px;
  }
  .hud-right {
    bottom: 152px;
  }
  /* horn, wave and camera sit in a row between the steering buttons and the pedals */
  #touch .mid {
    flex-direction: row;
    gap: 10px;
  }
  #hint {
    bottom: 76px;
  }
}

/* ---------------- small screens ---------------- */
@media (max-width: 760px) {
  #menu {
    padding: 12px;
  }
  .menu-card {
    padding: 18px 16px 14px;
  }
  .sign {
    font-size: 26px;
  }
  .sign span + span {
    font-size: 21px;
  }
  .cards.regions {
    grid-template-columns: 1fr;
  }
  .cards.vehicles {
    grid-template-columns: 1fr 1fr;
  }
  .howto-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .res-cols {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 700px) {
  .hud-score {
    top: 8px;
    left: 8px;
    min-width: 0;
    max-width: calc(50vw - 34px);
    padding: 6px 10px !important;
  }
  .hud-score .big {
    font-size: 22px;
  }
  .hud-progress {
    top: 8px;
    right: 8px;
    width: calc(50vw - 34px);
    padding: 6px 10px !important;
  }
  .hud-progress .row {
    flex-direction: column;
    gap: 0;
    font-size: 12px;
  }
  #hint,
  #hint.show {
    top: 136px;
    bottom: auto;
    left: 8px;
    right: 8px;
    max-width: none;
    transform: none;
    font-size: 13px;
    padding: 8px 12px;
  }
  .icon-btn {
    top: 8px;
    right: auto;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 36px;
  }
  #toasts {
    top: 214px;
  }
  .hud-speed {
    left: 8px;
    min-width: 0;
    padding: 6px 10px !important;
  }
  .speed {
    font-size: 32px;
  }
  .hud-right {
    right: 8px;
    width: 128px;
  }
  #minimap {
    width: 110px;
    height: 90px;
  }
  #banner .banner-title {
    font-size: 30px;
  }
}

/* keep "Set off" in reach while scrolling the menu on small screens */
@media (max-width: 760px), (max-height: 500px) {
  .go-row {
    position: sticky;
    bottom: -14px;
    z-index: 2;
    margin: 20px -16px 0;
    padding: 12px 16px 14px;
    background: var(--cream);
    border-top: 1px solid rgba(127, 127, 127, 0.25);
  }
}

/* phones on their side: the mirror shrinks (game.js), panels tuck in, touch buttons sit in a row */
@media (max-height: 500px) and (orientation: landscape) {
  .hud-score,
  .hud-progress {
    top: 8px;
    padding: 6px 10px !important;
  }
  .hud-score {
    left: 8px;
  }
  .hud-score .big {
    font-size: 22px;
  }
  .hud-progress {
    right: 8px;
    width: min(220px, calc(36vw - 24px));
  }
  .hud-progress .row {
    font-size: 12px;
  }
  .icon-btn {
    top: 8px;
    left: calc(50% - 14vw - 52px);
    right: auto;
    transform: none;
    width: 36px;
    height: 36px;
  }
  #toasts {
    top: 86px;
  }
  .hud-speed {
    left: 8px;
    min-width: 0;
    padding: 6px 10px !important;
  }
  .speed {
    font-size: 30px;
  }
  .hud-right {
    right: 8px;
    width: 138px;
  }
  #minimap {
    width: 120px;
    height: 72px;
  }
  #hint,
  #hint.show {
    top: auto;
    bottom: 14px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    max-width: calc(100vw - 340px);
    font-size: 13px;
    padding: 8px 12px;
  }
  #banner .banner-title {
    font-size: 30px;
  }
}
@media (max-height: 500px) and (orientation: landscape) and (pointer: coarse) {
  #touch .mid {
    flex-direction: row;
    gap: 10px;
  }
  #touch .left button {
    width: 72px;
    height: 72px;
  }
  #touch .pedal.brake {
    height: 84px;
  }
  #touch .pedal.gas {
    height: 108px;
  }
  .hud-speed,
  .hud-right {
    bottom: 130px;
  }
  #hint,
  #hint.show {
    bottom: 76px;
  }
}

/* feedback links (hidden until a form is set in config.js) */
a.ghost {
  display: inline-block;
  text-decoration: none;
  text-align: center;
}
a[hidden] {
  display: none !important;
}
.foot-link {
  color: inherit;
  font-weight: 700;
}

/* phones held upright: everything has to fit across about 360px */
@media (max-width: 700px) and (orientation: portrait) and (pointer: coarse) {
  #touch {
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }
  #touch .pad {
    gap: 8px;
  }
  #touch .mid {
    flex-direction: column;
    gap: 6px;
  }
  #touch .left button {
    width: 62px;
    height: 62px;
  }
  #touch .mid button {
    width: 44px;
    height: 44px;
    font-size: 18px;
  }
  #touch .pedal {
    width: 66px;
    font-size: 12px;
  }
  #touch .pedal.brake {
    height: 92px;
  }
  #touch .pedal.gas {
    height: 116px;
  }
  .hud-speed,
  .hud-right {
    bottom: 140px;
  }
}

/* ---------------- how to play ---------------- */
.dialog.intro {
  width: min(780px, 100%);
  text-align: left;
}
.dialog.intro h2,
.intro-sub,
.intro-foot {
  text-align: center;
}
.intro-sub {
  margin: 0 0 14px;
  color: var(--muted);
}
.intro-grid {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 8px 26px;
}
.intro-grid h3 {
  font: 600 17px var(--display);
  margin: 4px 0 8px;
}
.intro-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 7px;
  font-size: 14.5px;
  line-height: 1.35;
}
.intro-list li {
  display: flex;
  align-items: center;
  gap: 10px;
}
.intro-list.rules li {
  align-items: flex-start;
}
.intro-list .ic {
  flex: 0 0 auto;
  min-width: 58px;
  text-align: center;
  font-size: 17px;
}
.intro-list .ic kbd {
  font-size: 12px;
  margin: 0 1px;
}
.intro-list .ic.gas,
.intro-list .ic.brake {
  font: 800 11px var(--ui);
  letter-spacing: 0.06em;
  color: #fff;
  border-radius: 9px;
  padding: 7px 0;
}
.intro-list .ic.gas {
  background: #1f8a47;
}
.intro-list .ic.brake {
  background: #b23030;
}
.intro-foot {
  margin: 16px 0 0;
  font-size: 13px;
  color: var(--muted);
}
.for-touch {
  display: none !important;
}
@media (pointer: coarse) {
  .for-touch {
    display: grid !important;
  }
  .for-keys {
    display: none !important;
  }
}
@media (max-width: 640px) {
  .intro-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-height: 500px) {
  .dialog.intro {
    padding: 14px 18px;
  }
  .dialog.intro h2 {
    font-size: 22px;
    margin: 0 0 2px;
  }
  .intro-sub {
    margin-bottom: 6px;
  }
  .intro-list {
    gap: 3px;
    font-size: 13px;
  }
  .intro-foot {
    margin-top: 8px;
  }
  .dialog.intro .btns {
    margin-top: 8px;
  }
}

/* results: ask for feedback while the run is fresh */
.res-ask {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
  line-height: 1.35;
}
.res-ask[hidden] {
  display: none;
}
.res-ask .ghost {
  flex: 0 0 auto;
  padding: 9px 16px;
  font-size: 14px;
}
@media (max-width: 560px) {
  .res-ask {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }
}

/* ---------------- world leaderboard ---------------- */
input {
  -webkit-user-select: text;
  user-select: text;
}
.board {
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  text-align: left;
}
.board[hidden],
.board-post[hidden] {
  display: none;
}
.board h3 {
  font: 600 16px var(--display);
  margin: 0 0 8px;
}
.board ol {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 13.5px;
  counter-reset: rank;
}
.board li {
  display: grid;
  grid-template-columns: 2em 1fr auto auto;
  gap: 8px;
  align-items: baseline;
  padding: 3px 0;
  border-bottom: 1px dashed var(--line);
  counter-increment: rank;
}
.board li::before {
  content: counter(rank);
  font-weight: 800;
  color: var(--muted);
}
.board li .who {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}
.board li .car {
  color: var(--muted);
  font-size: 12px;
}
.board li b {
  font-variant-numeric: tabular-nums;
}
.board li.me {
  background: rgba(63, 191, 98, 0.16);
  border-radius: 6px;
}
.board-post {
  margin-top: 10px;
  font-size: 14px;
}
.board-row {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.board-row input {
  flex: 1;
  min-width: 0;
  font: 600 16px var(--ui); /* 16px stops iOS zooming in on focus */
  padding: 9px 12px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--cream);
  color: var(--ink);
}
.board-row .go {
  padding: 9px 18px;
  font-size: 15px;
}
.board-msg {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--muted);
  min-height: 1em;
}
.card .world {
  font-size: 12px;
  color: var(--muted);
  min-height: 1.2em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
