/*
 * TenToWork — "Gantry Sign".
 * The road canvas is the stage; the UI is the road-sign system hanging over it:
 * green direction signs, brown tourist sign (theme), blue motorway sign (route),
 * amber LED variable-message signs (timer, totals), yellow warning diamonds.
 */

:root {
  /* sign colours (real-world roles) */
  --green: #00704a;
  --brown: #774425;
  --blue: #1d4f9e;
  --yellow: #ffcc00;
  --red: #d7262e;
  --white: #ffffff;
  --sign-ink: #ffffff;
  --green-ink-soft: #c9eadb; /* secondary text on green */
  --blue-ink-soft: #cfdcf3; /* secondary text on blue */

  /* VMS (LED variable message sign) */
  --vms-bg: #0c0d10;
  --vms-housing: #3b4048;
  --led: #ffb21a;
  --led-off: #2a2216;

  /* ground: dusk asphalt and steel */
  --asphalt: #25252c; /* dusk asphalt: the road's own violet-grey, darker */
  --kerb: #18181d;
  --steel: #7e8690;
  --steel-dark: #4b525c;
  --muted: #aeb6c1;

  --sign-font: 'Overpass', 'Segoe UI', system-ui, sans-serif;
  --led-font: 'Doto', 'Overpass', monospace;

  --app-h: 100dvh;
  --gutter: 16px;
  --radius-sign: 12px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--asphalt);
  color: var(--white);
  font-family: var(--sign-font);
  font-weight: 600;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  overflow: hidden;
  overscroll-behavior: none;
}

::selection {
  background: var(--yellow);
  color: #111;
}

[hidden] {
  display: none !important;
}

.defs {
  position: absolute;
}

button,
input {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
}

.app {
  height: var(--app-h);
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ------------------------------------------------------------------ boot screen */

/* While the boot screen is up, the half-loaded game underneath stays invisible. */
.boot:not([hidden]) ~ .app {
  visibility: hidden;
}

.boot {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 28px;
  background: var(--asphalt);
  transition: opacity 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

.boot.is-done {
  opacity: 0;
  pointer-events: none;
}

.vms--boot {
  flex-direction: row;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
}

.vms--boot .vms-msg {
  font-size: 24px;
  opacity: 1;
}

.boot-dots {
  display: inline-flex;
  gap: 6px;
}

.boot-dots i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--led);
  animation: led-step 0.9s steps(1, end) infinite;
}

.boot-dots i:nth-child(2) {
  animation-delay: 0.3s;
}

.boot-dots i:nth-child(3) {
  animation-delay: 0.6s;
}

/* a short stretch of lane markings sliding past, like driving */
.boot-road {
  width: min(320px, 70vw);
  height: 6px;
  background: repeating-linear-gradient(90deg, #f2d14b 0 28px, transparent 28px 56px);
  animation: lane 0.6s linear infinite;
  opacity: 0.85;
}

@keyframes led-step {
  0%,
  66% {
    background: var(--led);
  }
  33% {
    background: var(--led-off);
  }
}

@keyframes lane {
  to {
    background-position: -56px 0;
  }
}

/* ------------------------------------------------------------------ the sign family */

.sign {
  position: relative;
  color: var(--sign-ink);
  background: var(--sign-bg, var(--green));
  border-radius: var(--radius-sign);
  padding: 14px 18px;
  /* real sign build: coloured edge, white border line, then a soft drop shadow */
  box-shadow:
    inset 0 0 0 3px var(--sign-bg, var(--green)),
    inset 0 0 0 5px var(--white),
    0 8px 18px rgba(0, 0, 0, 0.38);
}

.sign--green {
  --sign-bg: var(--green);
}

.sign--brown {
  --sign-bg: var(--brown);
}

.sign--blue {
  --sign-bg: var(--blue);
}

/* hangers connecting a sign to the beam above it */
.gantry .sign::before,
.gantry .sign::after,
.gantry .vms::before,
.gantry .vms::after {
  content: '';
  position: absolute;
  top: -12px;
  width: 4px;
  height: 12px;
  background: var(--steel-dark);
}

.gantry .sign::before,
.gantry .vms::before {
  left: 18%;
}

.gantry .sign::after,
.gantry .vms::after {
  right: 18%;
}

.arrow {
  width: 1em;
  height: 1em;
  fill: currentColor;
  flex-shrink: 0;
}

/* ------------------------------------------------------------------ VMS (LED message sign) */

.vms {
  position: relative;
  background: var(--vms-bg);
  border: 4px solid var(--vms-housing);
  border-radius: 6px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.38);
}

/* the VMS's own first line: an LED message, not a caption */
.vms-msg {
  font-family: var(--led-font);
  font-weight: 800;
  font-size: 18px;
  line-height: 1;
  text-transform: uppercase;
  color: var(--led);
  opacity: 0.85;
}

.vms-value,
.vms-digits {
  font-family: var(--led-font);
  font-weight: 900;
  color: var(--led);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.vms-value {
  font-size: 30px;
}

.vms-value--big {
  font-size: clamp(56px, 9vw, 104px);
}

/* ------------------------------------------------------------------ stage + gantry */

.stage {
  position: relative;
  overflow: hidden;
  background: #0f1217;
  isolation: isolate;
}

.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  z-index: -1;
}

.gantry {
  position: relative;
  padding: 0 var(--gutter);
  padding-top: max(10px, env(safe-area-inset-top));
}

.beam {
  height: 14px;
  margin: 0 calc(var(--gutter) * -1);
  border-top: 3px solid var(--steel);
  border-bottom: 3px solid var(--steel);
  background: repeating-linear-gradient(45deg, var(--steel-dark) 0 3px, transparent 3px 14px),
    repeating-linear-gradient(-45deg, var(--steel-dark) 0 3px, transparent 3px 14px), #2f343b;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}

.gantry-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 12px 16px;
  padding-top: 12px;
}

/* ------------------------------------------------------------------ start */

.stage--start {
  flex: 1 1 auto;
  min-height: 300px;
}

.sign--title {
  flex: 1 1 280px;
  max-width: 560px;
}

.logo {
  margin: 0;
  font-weight: 900;
  font-size: clamp(34px, 6vw, 64px);
  line-height: 1;
  letter-spacing: -0.02em;
}

.sign-line {
  margin: 10px 0 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: clamp(18px, 2.2vw, 26px);
}

.sign-line .arrow {
  font-size: 1.2em;
}

.sign-dist {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.sign--theme {
  --radius-sign: 10px;
  flex: 0 1 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px 12px 12px;
  max-width: 420px;
}

/* tourist-sign pictogram: an authored white symbol drawn directly on the sign (see #p-* in index.html) */
.pict {
  flex-shrink: 0;
  width: 1.15em;
  height: 1.15em;
  color: var(--white);
  fill: currentColor;
}

.pict--big {
  width: 44px;
  height: 44px;
}

.theme-title {
  margin: 0;
  font-size: clamp(18px, 2vw, 24px);
  font-weight: 800;
  line-height: 1.15;
}

.verge {
  flex: 0 0 auto;
  background: var(--asphalt);
  border-top: 4px solid var(--kerb);
  padding: 16px var(--gutter) max(16px, env(safe-area-inset-bottom));
}

.verge--start {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sign--route {
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 18px;
}

.route-name {
  font-weight: 800;
  font-size: 20px;
}

.route-date {
  font-size: 14px;
  color: var(--blue-ink-soft);
}

.start-fresh,
.played {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.rules {
  margin: 0;
  max-width: 52ch;
  font-size: 16px;
  line-height: 1.45;
  color: var(--muted);
}

.rules b {
  color: var(--white);
}

.played {
  align-items: flex-start;
}

.vms--wide {
  min-width: 220px;
}

.played-pct {
  margin: 0;
  font-size: 16px;
}

.played-pct b {
  color: var(--yellow);
}

.status {
  margin: 0;
  min-height: 1.2em;
  font-size: 15px;
  color: var(--muted);
}

.status.is-error {
  color: #ff8a8f;
}

/* ------------------------------------------------------------------ buttons as signs */

.go-sign {
  --sign-bg: var(--green);
  appearance: none;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 22px;
  border-radius: 10px;
  background: var(--sign-bg);
  color: var(--white);
  font-family: var(--sign-font);
  font-weight: 900;
  font-size: 18px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  box-shadow:
    inset 0 0 0 3px var(--sign-bg),
    inset 0 0 0 5px var(--white),
    0 6px 14px rgba(0, 0, 0, 0.4);
  touch-action: manipulation;
  user-select: none;
  transition: transform 90ms ease-out, box-shadow 90ms ease-out, background-color 150ms;
}

.go-sign .arrow {
  font-size: 1.15em;
}

.go-sign:active {
  transform: translateY(2px);
  box-shadow:
    inset 0 0 0 3px var(--sign-bg),
    inset 0 0 0 5px var(--white),
    0 2px 6px rgba(0, 0, 0, 0.45);
}

@media (hover: hover) {
  .go-sign:hover {
    --sign-bg: #00805a;
  }
}

.go-sign--big {
  font-size: 22px;
  padding: 18px 28px;
  align-self: flex-start;
  min-width: 220px;
}

.plate-btn {
  appearance: none;
  cursor: pointer;
  background: transparent;
  color: var(--muted);
  border: 2px solid var(--steel-dark);
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 800;
  font-size: 14px;
}

@media (hover: hover) {
  .plate-btn:hover {
    color: var(--white);
    border-color: var(--steel);
  }
}

/* ------------------------------------------------------------------ game */

.stage--game {
  flex: 1 1 auto;
  min-height: 210px;
}

.gantry-row--game {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    'timer dist'
    'q q';
  gap: 12px;
}

.sign--question {
  grid-area: q;
  padding: 12px 16px 14px;
}

.exit-tab {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
  padding: 2px 8px;
  border: 2px solid var(--white);
  border-radius: 6px;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}

.question {
  margin: 0;
  font-weight: 700;
  font-size: clamp(18px, 4.8vw, 34px);
  line-height: 1.18;
  text-wrap: balance;
}

.question.is-new {
  animation: flip-in 260ms cubic-bezier(0.16, 1, 0.3, 1);
}

.sign--distance {
  grid-area: dist;
  justify-self: end;
  min-width: 170px;
  padding: 10px 16px;
  display: grid;
  gap: 2px;
}

.sign--distance p {
  margin: 0;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 18px;
  font-size: 15px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.sign--distance span {
  color: var(--green-ink-soft);
}

.sign--distance b {
  font-size: 20px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  text-transform: none;
}

.vms--timer {
  grid-area: timer;
  align-items: center;
  min-width: 96px;
  padding: 6px 12px 8px;
}

.vms--timer .vms-digits {
  font-size: clamp(40px, 9vw, 72px);
  min-width: 2ch;
  text-align: center;
}

.vms--timer .vms-digits.is-low {
  color: #ff4a4a;
  animation: blink 0.5s steps(2, jump-none) infinite;
}

.vms-bar {
  width: 100%;
  height: 6px;
  background: radial-gradient(circle at 2px 3px, var(--led-off) 1.5px, transparent 2px) 0 0 / 6px 6px;
}

.timer-fill {
  height: 100%;
  width: 100%;
  background: radial-gradient(circle at 2px 3px, var(--led) 1.6px, transparent 2px) 0 0 / 6px 6px;
  transform-origin: left center;
  will-change: transform;
}

.timer-fill.is-mid {
  background-image: radial-gradient(circle at 2px 3px, #ff8a1a 1.6px, transparent 2px);
}

.timer-fill.is-low {
  background-image: radial-gradient(circle at 2px 3px, #ff4a4a 1.6px, transparent 2px);
}

.pop {
  position: absolute;
  right: var(--gutter);
  bottom: 14px;
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 900;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  opacity: 0;
  box-shadow: inset 0 0 0 2px currentColor, 0 4px 10px rgba(0, 0, 0, 0.4);
}

.pop.good {
  background: var(--green);
  color: var(--white);
}

.pop.bad {
  background: var(--white);
  color: var(--red);
}

.pop.is-on {
  animation: pop 1.1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.verge--game {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 14px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
}

.answer-form {
  display: flex;
  gap: 10px;
}

.answer-input {
  flex: 1;
  min-width: 0;
  height: 58px;
  padding: 0 16px;
  font-family: var(--sign-font);
  font-size: 20px; /* >= 16px stops iOS zooming */
  font-weight: 800;
  color: #111418;
  background: var(--white);
  border: 0;
  border-radius: 10px;
  box-shadow: inset 0 0 0 3px var(--white), inset 0 0 0 5px #111418;
  caret-color: var(--green);
  outline: none;
  transition: box-shadow 120ms;
}

.answer-input:focus {
  box-shadow: inset 0 0 0 3px var(--white), inset 0 0 0 5px var(--green), 0 0 0 3px var(--yellow);
}

.answer-input::placeholder {
  color: #6c7480;
  font-weight: 700;
}

.answer-input.is-wrong {
  box-shadow: inset 0 0 0 3px var(--white), inset 0 0 0 5px var(--red), 0 0 0 3px var(--red);
  animation: shake 280ms cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

.answer-input.is-right {
  box-shadow: inset 0 0 0 3px var(--white), inset 0 0 0 5px var(--green), 0 0 0 3px var(--green);
}

.go-sign--submit {
  height: 58px;
  padding: 0 18px;
}

/* the feedback line is a yellow warning sign when it has something to say */
.feedback {
  position: relative;
  margin: 0;
  min-height: 28px;
  padding-left: 36px;
  font-size: 15px;
  font-weight: 700;
  line-height: 28px;
  color: var(--muted);
}

.feedback:empty {
  padding-left: 0;
}

.feedback:not(:empty)::before {
  content: '!';
  position: absolute;
  left: 0;
  top: 1px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  line-height: 1;
  font-weight: 900;
  font-size: 15px;
  color: #111;
  background: var(--yellow);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.feedback.is-wrong {
  color: var(--white);
}

.feedback b {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  margin-left: 2px;
  background: var(--yellow);
  color: #111;
  border-radius: 4px;
  font-weight: 900;
  font-size: 17px;
}

/* ------------------------------------------------------------------ marks (result squares) */

.marks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mark {
  width: 30px;
  height: 30px;
  border-radius: 5px;
  background: var(--steel-dark);
  box-shadow: inset 0 0 0 2px var(--m, var(--steel-dark)), inset 0 0 0 4px var(--white);
}

.marks--small .mark {
  width: 22px;
  height: 22px;
  box-shadow: inset 0 0 0 2px var(--m), inset 0 0 0 3px var(--white);
}

.mark--G {
  --m: var(--green);
  background: var(--green);
}

.mark--Y {
  --m: var(--yellow);
  background: var(--yellow);
}

.mark--R {
  --m: var(--red);
  background: var(--red);
}

/* ------------------------------------------------------------------ end */

.screen--end {
  overflow-y: auto;
  scrollbar-color: var(--steel-dark) transparent;
}

.stage--end {
  flex: 0 0 clamp(250px, 42vh, 480px);
}

.results {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 22px var(--gutter) max(24px, env(safe-area-inset-bottom));
  border-top: 4px solid var(--kerb);
}

.arrival {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
}

.sign--arrived {
  padding: 16px 22px;
}

.arrived-title {
  margin: 0;
  font-weight: 900;
  font-size: clamp(30px, 6vw, 56px);
  line-height: 1;
  letter-spacing: -0.01em;
}

.arrived-theme {
  margin: 8px 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--green-ink-soft);
}

.vms--total {
  padding: 12px 18px 14px;
}

.percentile {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.35;
}

.percentile b {
  color: var(--yellow);
}

.end-side {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 18px;
}

.toast {
  margin: 0;
  font-weight: 800;
  color: #7be3b4;
}

.sign--board {
  padding: 18px 20px 14px;
}

.board-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}

.board-head h3 {
  margin: 0;
  font-weight: 900;
  font-size: 20px;
}

.board-head span {
  font-size: 15px;
  color: var(--blue-ink-soft);
  font-variant-numeric: tabular-nums;
}

.distribution svg,
.q-chart svg {
  display: block;
  max-width: 100%;
}

/* ---- question by question: a blue information board (chart) over an LED trip log (rows) */
.breakdown {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sign--qchart {
  padding: 18px 20px 12px;
}

.q-legend {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--blue-ink-soft);
}

.q-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #1fbf7a;
}

.q-legend-tick {
  width: 16px;
  height: 3px;
  margin-left: 10px;
  background: var(--white);
}

.vms--log {
  padding: 14px 18px 6px;
  gap: 8px;
}

.log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* deliberately quiet: answers are there for those who look for them */
.text-btn {
  appearance: none;
  background: none;
  border: 0;
  padding: 4px 0;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  color: var(--muted);
  text-decoration: underline;
  text-decoration-color: var(--steel-dark);
  text-underline-offset: 4px;
}

@media (hover: hover) {
  .text-btn:hover {
    color: var(--white);
    text-decoration-color: var(--white);
  }
}

.q-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
}

.q-row {
  display: grid;
  gap: 6px;
  padding: 12px 0;
  border-top: 1px solid #23252b;
}

.q-empty {
  padding: 14px 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
}

.q-head {
  display: flex;
  gap: 12px;
  align-items: baseline;
}

.q-num {
  flex-shrink: 0;
  min-width: 40px;
  font-family: var(--led-font);
  font-weight: 900;
  font-size: 18px;
  color: var(--led);
}

.q-text {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  color: #e9ecf1;
  max-width: 68ch;
}

.q-stats {
  margin: 0 0 0 52px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
}

.q-stats div {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.q-stats dt {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #8f97a3;
}

.q-stats dd {
  margin: 0;
  font-family: var(--led-font);
  font-weight: 900;
  font-size: 18px;
  color: var(--led);
  font-variant-numeric: tabular-nums;
}

.q-you--G dd {
  color: #1fbf7a;
}

.q-you--Y dd {
  color: var(--yellow);
}

.q-you--R dd {
  color: #ff4a4a;
}

/* answers stay out of the page until "Show answers" is pressed */
.q-answer {
  display: none !important;
}

.q-list.is-revealed .q-answer {
  display: flex !important;
}

.q-list.is-revealed .q-answer dd {
  color: var(--yellow);
}

.vms--small .vms-value {
  font-size: 26px;
}

/* ------------------------------------------------------------------ wider screens */

@media (min-width: 760px) {
  :root {
    --gutter: 28px;
  }

  .gantry-row--game {
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas: 'q dist timer';
    align-items: start;
  }

  .sign--question {
    padding: 16px 22px 20px;
    max-width: 980px;
  }

  .sign--distance {
    min-width: 200px;
  }

  .verge--game {
    flex-direction: row;
    align-items: center;
    gap: 24px;
    padding-top: 18px;
    padding-bottom: 18px;
  }

  .answer-form {
    flex: 0 1 640px;
  }

  .feedback {
    flex: 1;
  }

  .verge--start {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px 32px;
  }

  .start-fresh {
    flex: 1;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
  }

  .played {
    flex: 1;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px 24px;
  }

  .go-sign--big {
    align-self: center;
  }

  .status:empty {
    display: none;
  }
}

@media (min-width: 1000px) {
  /* the first viewport ends exactly under the results row, so the question
     section starts at the fold instead of being cut through */
  .stage--end {
    flex: 0 0 max(240px, calc(var(--app-h) - 396px));
  }

  .results {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      'arrival board side'
      'breakdown breakdown breakdown';
    align-items: start;
    gap: 40px;
    padding: 28px var(--gutter) 32px;
  }

  .arrival {
    grid-area: arrival;
  }

  .sign--board {
    grid-area: board;
  }

  .breakdown {
    grid-area: breakdown;
    padding-top: 12px;
  }

  .q-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 40px;
  }

  .breakdown {
    gap: 24px;
  }

  .end-side {
    grid-area: side;
    flex-direction: column;
    align-items: stretch;
    width: 260px;
  }

  .end-side .go-sign--big {
    align-self: stretch;
    min-width: 0;
  }
}

/* Phones: everything top-anchored (signs, a compact road, the answer plate), so the
   free space sits at the bottom where the on-screen keyboard opens, and the question
   stays in view while typing. The road band is sized from the width because the art's
   pixel scale is (see road.js). */
@media (max-width: 759px) {
  .stage--game {
    flex: 0 0 auto;
    min-height: 0;
    padding-bottom: var(--road-h, clamp(128px, 40vw, 200px));
  }

  /* keyboard closed (app.js sets .kb-open on <html> from visualViewport): the road takes the room */
  :root:not(.kb-open) .stage--game {
    flex: 1 1 auto;
  }

  .stage--start {
    min-height: calc(var(--app-h) * 0.5);
  }

  .screen--game {
    overflow: hidden;
  }
}

.run-marks {
  gap: 5px;
}

.run-marks .mark {
  width: 18px;
  height: 18px;
}

.run-marks .mark--now {
  box-shadow: inset 0 0 0 2px var(--yellow), inset 0 0 0 3px var(--asphalt);
}

/* Phone with the keyboard open: give the road as much room as possible. */
@media (max-height: 520px) {
  .gantry {
    padding-top: 6px;
  }
  .beam {
    height: 10px;
  }
  .gantry-row {
    padding-top: 8px;
    gap: 8px;
  }
  .sign--question {
    padding: 8px 12px 10px;
  }
  .exit-tab {
    margin-bottom: 4px;
  }
  .question {
    font-size: 17px;
  }
  .vms--timer .vms-digits {
    font-size: 34px;
  }
  .sign--distance {
    padding: 6px 12px;
  }
  .sign--distance p {
    font-size: 13px;
  }
  .sign--distance b {
    font-size: 16px;
  }
  .verge--game {
    padding-top: 8px;
    padding-bottom: 8px;
  }
  .run-marks {
    display: none;
  }
  .answer-input,
  .go-sign--submit {
    height: 50px;
  }
}

/* ------------------------------------------------------------------ motion */

@keyframes blink {
  50% {
    opacity: 0.35;
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-6px);
  }
  75% {
    transform: translateX(6px);
  }
}

/* the sign face flips like a rotating VMS panel when the question changes */
@keyframes flip-in {
  from {
    opacity: 0;
    transform: perspective(400px) rotateX(-55deg);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes pop {
  0% {
    opacity: 0;
    transform: translateY(8px);
  }
  15% {
    opacity: 1;
    transform: none;
  }
  75% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-6px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .pop.is-on {
    animation: none;
    opacity: 1;
  }
}
