:root {
  color-scheme: light;
  --bg: #f4efe4;
  --surface: #ffffff;
  --ink: #1f2230;
  --ink-2: #4b5066;
  --muted: #8a8fa3;
  --line: rgba(31, 34, 48, 0.1);
  --taxi: #ffc61a;
  --taxi-deep: #c99400;
  --good: #1fa85a;
  --shadow: rgba(60, 45, 10, 0.12);
  --r: 18px;
  --round: Fredoka, Nunito, ui-rounded, system-ui, sans-serif;
  --sans: "Petrov Sans", ui-rounded, system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #11141d;
    --surface: #1b2030;
    --ink: #eef1fa;
    --ink-2: #c5cbe0;
    --muted: #8990aa;
    --line: rgba(255, 255, 255, 0.09);
    --shadow: rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 500 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}
main {
  max-width: 760px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
}

header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
h1 { margin: 0; font: 700 30px/1 var(--round); letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; }
.logo {
  width: 30px; height: 20px; border-radius: 6px; background: var(--taxi);
  border: 2.5px solid var(--ink);
  background-image: repeating-linear-gradient(90deg, var(--ink) 0 4px, transparent 4px 8px);
  background-size: 100% 5px; background-repeat: no-repeat; background-position: 0 6px;
}
.sub { margin: 6px 0 0; color: var(--ink-2); font-weight: 600; }
.sub.date { margin-top: 0; color: var(--muted); font-weight: 500; font-size: 13px; }
.loading { color: var(--muted); text-align: center; margin: 60px 0; }

button { font: inherit; cursor: pointer; }
button.icon {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: 700 18px var(--round);
}
button.primary {
  border: 0; border-radius: 999px; padding: 11px 26px; background: var(--taxi); color: #1f2230;
  font: 700 16px var(--round); box-shadow: 0 3px 0 var(--taxi-deep);
}
button.primary:disabled { opacity: 0.45; box-shadow: none; cursor: default; }
button.link, a.link { border: 0; background: none; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; padding: 6px; font-size: 14px; display: inline-block; }
button[hidden], a[hidden] { display: none; }

.tries { list-style: none; display: flex; gap: 8px; padding: 0; margin: 0 0 12px; }
.tries li {
  flex: 1; text-align: center; padding: 7px 4px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--line); color: var(--muted); font-size: 13px;
}
.tries li b { font: 700 15px var(--round); color: var(--ink); margin-left: 4px; }
.tries li.current { border-color: var(--taxi); color: var(--ink); }
.tries li.best { background: color-mix(in srgb, var(--taxi) 22%, var(--surface)); }

.board { position: relative; background: var(--surface); border-radius: var(--r); box-shadow: 0 6px 22px var(--shadow); overflow: hidden; }
.readout { display: flex; justify-content: space-around; padding: 10px 8px 4px; }
.readout div { display: flex; flex-direction: column; align-items: center; min-width: 70px; }
.readout span { font: 700 24px/1.1 var(--round); }
.readout small { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }
.seats { display: flex; gap: 4px; height: 29px; align-items: center; }
.seat {
  width: 22px; height: 22px; border-radius: 6px; border: 2px dashed var(--line); display: grid; place-items: center;
  font: 700 12px var(--round); color: #fff;
}
.seat.full { border: 0; background: var(--c); }
canvas { display: block; width: 100%; touch-action: none; user-select: none; -webkit-user-select: none; }
.toast {
  position: absolute; left: 50%; top: 64px; transform: translateX(-50%); margin: 0; pointer-events: none;
  background: rgba(20, 22, 30, 0.82); color: #fff; padding: 5px 12px; border-radius: 999px; font-size: 13px; white-space: nowrap;
}
.toast:empty { display: none; }
.map-buttons { position: absolute; right: 10px; top: 70px; display: flex; flex-direction: column; gap: 6px; }
button.round {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font: 700 19px var(--round); box-shadow: 0 2px 8px var(--shadow);
}
.controls { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px 12px; border-top: 1px solid var(--line); }
.pick { margin: 0; color: var(--ink-2); font-size: 14px; min-height: 1.4em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.result { margin-top: 14px; background: var(--surface); border-radius: var(--r); padding: 16px; text-align: center; box-shadow: 0 6px 22px var(--shadow); }
.result .kicker, .fares-box .kicker { margin: 0; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; }
.score { margin: 4px 0; font: 700 44px/1.1 var(--round); }
.score small { font-size: 16px; color: var(--ink-2); font-weight: 600; }
.verdict { margin: 0 0 12px; color: var(--ink-2); }
.result button.primary { margin: 4px; }
.note { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
#share-toast, #share-now-toast { position: static; transform: none; display: block; background: none; color: var(--ink-2); }

.fares-box { margin-top: 14px; }
.fares { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; }
.fares li { display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: 12px; padding: 8px 12px; border: 1px solid var(--line); }
.fares .dot { width: 26px; height: 26px; border-radius: 50%; background: var(--c); color: #fff; display: grid; place-items: center; font: 700 14px var(--round); flex: none; }
.fares .who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.fares .who small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fares .state { font-size: 12px; color: var(--muted); flex: none; }
.fares li.aboard { border-color: var(--c); }
.fares li.aboard .state { color: var(--ink); font-weight: 700; }
.fares li.aboard .dot { border-radius: 6px; }
.fares li.delivered { opacity: 0.5; }
.fares li.delivered .state::before { content: "✓ "; color: var(--good); }

.footnote { text-align: center; margin: 10px 0 0; }
.credit { text-align: center; color: var(--muted); font-size: 12px; margin-top: 18px; }
.credit a { color: inherit; }

/* Wide screens: the map takes the window's width and height, with the
   tries, result and fares in a column beside it. Phones keep one column. */
@media (min-width: 900px) {
  main { max-width: none; padding-left: 24px; padding-right: 24px; }
  #game:not([hidden]) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    grid-template-areas: "board tries" "board result" "board fares" "board foot";
    grid-template-rows: auto auto auto 1fr;
    column-gap: 20px;
    align-items: start;
  }
  #game .board { grid-area: board; }
  #game .tries { grid-area: tries; }
  #game .result { grid-area: result; margin-top: 0; margin-bottom: 14px; }
  #game .fares-box { grid-area: fares; margin-top: 0; }
  #game .footnote { grid-area: foot; }
  .credit { margin-top: 10px; }
}

dialog { border: 0; border-radius: var(--r); padding: 20px 22px; max-width: 520px; background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); }
dialog::backdrop { background: rgba(10, 12, 20, 0.5); }
dialog h2 { margin: 0 0 8px; font: 700 22px var(--round); }
dialog li { margin-bottom: 6px; }
dialog form { text-align: center; margin-top: 12px; }
