/* Melbourne Train Roulette. One dark theme, built to be read on a phone on a
   station concourse: big type, high contrast, nothing that needs a hover.
   The same page is laid out again for a desk at the end of this file. */

@font-face {
  font-family: "Barlow Condensed";
  src: url("fonts/barlow-condensed-600.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: "Barlow Condensed";
  src: url("fonts/barlow-condensed-800.woff2") format("woff2");
  font-weight: 800;
  font-display: swap;
}

:root {
  --bg: #0b1016;
  --bg-glow: #152233;
  --panel: #141b25;
  --panel-raised: #1b2531;
  --rule: #2b3847;
  --text: #f3f6f9;
  --muted: #a3b1c2;
  --amber: #ffb81c;
  --amber-deep: #e09a00;
  --amber-ink: #191200;
  --paper: #f4efe4;
  --paper-ink: #17202b;
  --paper-muted: #5b6673;
  --paper-rule: #cfc7b6;
  --good: #7ee0a1;
  --bad: #ff6b6b;
  --line: #8892a0;
  --line-ink: #ffffff;

  --display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", system-ui, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --gutter: 20px;
}

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

html {
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(120% 70% at 50% -10%, var(--bg-glow) 0%, transparent 62%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 400 1rem/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

/* What is on show. The script sets data-stage on <main> to "wheel", "ticket"
   or "landed". A phone shows the wheel or the ticket, never both; wide
   screens arrange things differently, further down. */
main[data-stage="wheel"] > .ticket-view,
main:not([data-stage="wheel"]) > .play {
  display: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

a {
  color: inherit;
  text-underline-offset: 0.18em;
}

:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
  border-radius: 6px;
}

.app {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right))
    max(28px, env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
}

/* ---- Masthead ---------------------------------------------------------- */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0 14px;
}

.wordmark {
  display: grid;
  text-decoration: none;
  font-family: var(--display);
  text-transform: uppercase;
  line-height: 1;
}

.wordmark-city {
  color: var(--amber);
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.34em;
}

.wordmark-name {
  margin-top: 3px;
  font-weight: 800;
  font-size: 1.7rem;
  letter-spacing: 0.02em;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.icon-button:active {
  background: var(--panel-raised);
}

/* Spelled out only where there is room for it. */
.icon-button-label {
  display: none;
}

/* ---- Buttons ----------------------------------------------------------- */

.button {
  display: block;
  width: 100%;
  min-height: 60px;
  padding: 12px 20px;
  border: 0;
  border-radius: 16px;
  font: 800 1.45rem/1.1 var(--display);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.button.primary {
  background: var(--amber);
  color: var(--amber-ink);
  box-shadow: 0 5px 0 var(--amber-deep), 0 14px 28px -12px rgb(255 184 28 / 55%);
  transition: transform 80ms ease, box-shadow 80ms ease;
}

.button.primary:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--amber-deep);
}

.button.primary:disabled {
  background: #4b4a44;
  color: #a9a69b;
  box-shadow: 0 5px 0 #33322e;
  cursor: default;
}

.button.quiet {
  min-height: 52px;
  margin-top: 12px;
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  font-weight: 600;
  font-size: 1.15rem;
  opacity: 0.86;
}

.link-button {
  padding: 8px 0;
  border: 0;
  background: none;
  color: var(--amber);
  font: 600 0.95rem var(--body);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

/* ---- Challenge banner (opened from a shared link) ---------------------- */

.challenge {
  margin: 0 0 16px;
  padding: 14px 16px 8px;
  border: 1px dashed var(--amber);
  border-radius: 14px;
  background: rgb(255 184 28 / 8%);
}

.challenge p {
  margin: 0;
}

/* ---- The wheel --------------------------------------------------------- */

.lede {
  margin: 4px 0 18px;
  font: 800 2.15rem/1.02 var(--display);
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.lede-go {
  color: var(--amber);
}

.hubs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--rule);
  border-radius: 16px;
  background: var(--panel);
}

.hub {
  min-height: 48px;
  padding: 6px 8px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font: 600 1.2rem/1.1 var(--display);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
}

.hub[aria-checked="true"] {
  background: var(--text);
  color: var(--bg);
  font-weight: 800;
}

.wheel-wrap {
  position: relative;
  width: min(100%, 380px);
  margin: 30px auto 12px;
  aspect-ratio: 1;
}

.wheel {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  filter: drop-shadow(0 18px 26px rgb(0 0 0 / 55%));
  will-change: transform;
}

.wheel-pointer {
  position: absolute;
  z-index: 1;
  top: -16px;
  left: 50%;
  width: 34px;
  height: 40px;
  transform: translateX(-50%);
  background: var(--amber);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  filter: drop-shadow(0 3px 0 rgb(0 0 0 / 55%));
  transform-origin: 50% 0;
}

.wheel-pointer.ticking {
  animation: tick 150ms ease-in-out infinite alternate;
}

@keyframes tick {
  from { transform: translateX(-50%) rotate(-9deg); }
  to { transform: translateX(-50%) rotate(7deg); }
}

.wheel .seg {
  stroke: var(--bg);
  stroke-width: 1.3;
}

.wheel .seg-label {
  font-family: var(--display);
  font-weight: 800;
  text-anchor: middle;
  dominant-baseline: central;
}

.wheel .seg-sub {
  font-family: var(--display);
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: central;
  letter-spacing: 0.04em;
}

.wheel .slot {
  transition: opacity 300ms ease;
}

.wheel.has-winner .slot:not(.win) {
  opacity: 0.28;
}

/* The light that runs round a still wheel: no fading between steps, and the
   unlit segments stay readable. */
.wheel.chasing .slot {
  transition: none;
}

.wheel.chasing .slot:not(.win) {
  opacity: 0.4;
}

.wheel .rim {
  fill: none;
  stroke: #dfe5ec;
  stroke-width: 5;
}

.wheel .rim-tick {
  stroke: var(--bg);
  stroke-width: 1.1;
}

.wheel .hub-cap {
  fill: var(--bg);
  stroke: var(--amber);
  stroke-width: 2.5;
}

.wheel .hub-dot {
  fill: var(--amber);
}

.wheel .blank {
  fill: var(--panel);
  stroke: var(--rule);
  stroke-width: 1.3;
}

.status {
  min-height: 3em;
  margin: 14px 0;
  color: var(--muted);
  text-align: center;
  text-wrap: balance;
}

.status strong {
  color: var(--text);
  font-weight: 600;
}

.live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--good);
  font: 800 0.95rem/1 var(--display);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}

.live::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  50% { opacity: 0.25; }
}

.fineprint {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  text-align: center;
  text-wrap: balance;
}

.fineprint:empty {
  display: none;
}

.fineprint .link-button {
  padding: 0;
  font-size: inherit;
}

/* ---- The ticket -------------------------------------------------------- */

.ticket {
  position: relative;
  border-radius: 18px;
  background: var(--paper);
  color: var(--paper-ink);
  box-shadow: 0 22px 40px -18px rgb(0 0 0 / 80%);
  animation: arrive 420ms cubic-bezier(0.2, 0.9, 0.25, 1.15) both;
}

.ticket:focus {
  outline: none;
}

@keyframes arrive {
  from { opacity: 0; transform: translateY(26px) rotate(-1.5deg) scale(0.97); }
}

.ticket-part {
  padding: 20px 20px 22px;
}

.ticket-tear {
  position: relative;
  height: 0;
  margin: 0 18px;
  border-top: 2px dashed var(--paper-rule);
}

.ticket-tear::before,
.ticket-tear::after {
  content: "";
  position: absolute;
  top: -12px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg);
}

.ticket-tear::before { left: -29px; }
.ticket-tear::after { right: -29px; }

.eyebrow {
  margin: 0 0 10px;
  color: var(--paper-muted);
  font: 600 0.95rem/1 var(--display);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.platform {
  display: flex;
  align-items: center;
  gap: 16px;
}

.platform-sign {
  display: grid;
  flex: none;
  place-items: center;
  min-width: 104px;
  height: 104px;
  padding: 0 12px;
  border-radius: 18px;
  background: var(--line);
  color: var(--line-ink);
  font: 800 4.6rem/1 var(--display);
  letter-spacing: -0.01em;
}

.platform-sign.wordy {
  font-size: 1.7rem;
  letter-spacing: 0.03em;
  text-align: center;
}

.platform-title {
  margin: 0 0 6px;
  font: 800 1.85rem/1 var(--display);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.line-badge {
  display: inline-block;
  margin: 0;
  padding: 4px 10px 5px;
  border-radius: 999px;
  background: var(--line);
  color: var(--line-ink);
  font: 600 1.05rem/1.1 var(--display);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.platform-headsign {
  margin: 6px 0 0;
  font-weight: 600;
  line-height: 1.25;
}

.departs,
.arrives {
  margin: 16px 0 0;
  font-size: 1.1rem;
  line-height: 1.35;
}

.departs strong,
.arrives strong {
  font-weight: 700;
}

.delay {
  color: #a43b00;
  font-weight: 600;
}

.gone {
  color: #9c1c1c;
  font-weight: 700;
}

.ticket .live {
  margin-left: 6px;
  color: #0b7a3b;
}

.note {
  margin: 10px 0 0;
  color: var(--paper-muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.note:empty {
  display: none;
}

.ask {
  margin: 0 0 16px;
  font-size: 1.05rem;
}

.ticket .button.primary {
  background: var(--paper-ink);
  color: var(--paper);
  box-shadow: 0 5px 0 #000, 0 14px 24px -14px rgb(0 0 0 / 70%);
}

.ticket .button.primary:active:not(:disabled) {
  box-shadow: 0 1px 0 #000;
}

.ticket .fineprint {
  color: var(--paper-muted);
}

/* ---- Split-flap board -------------------------------------------------- */

.stop-number,
.flap {
  display: grid;
  gap: 5px 3px;
  width: 100%;
  perspective: 500px;
}

.stop-number {
  grid-template-columns: repeat(2, 58px);
  margin-bottom: 10px;
}

.flap {
  grid-template-columns: repeat(var(--cols, 12), minmax(0, 1fr));
}

.flap-cell {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 0.72;
  border-radius: 4px;
  background: linear-gradient(#20252c 0 49%, #000 49% 52%, #171b21 52% 100%);
  color: #fdfcf7;
  font: 800 clamp(1rem, 6.1vw, 1.75rem)/1 var(--display);
  overflow: hidden;
  backface-visibility: hidden;
}

.stop-number .flap-cell {
  font-size: 3.6rem;
  border-radius: 8px;
  color: var(--amber);
}

.stop-number .flap-cell.spare {
  visibility: hidden;
}

/* ---- Counting the stops ------------------------------------------------ */

.count {
  margin-top: 18px;
  border-top: 1px solid var(--paper-rule);
}

.count summary {
  padding: 14px 0 4px;
  font-weight: 700;
  cursor: pointer;
}

.stops {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.stops li {
  position: relative;
  display: grid;
  grid-template-columns: 2.1em 1fr auto;
  align-items: baseline;
  gap: 4px 8px;
  padding: 6px 0 6px 22px;
  font-size: 0.97rem;
}

/* The line diagram: a rail down the left with a dot at each stop. */
.stops li::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 5px;
  width: 4px;
  background: var(--rail, var(--line));
}

.stops li:first-child::before { top: 50%; }
.stops li:last-child::before { bottom: 50%; }

.stops li::after {
  content: "";
  position: absolute;
  top: calc(50% - 6px);
  left: 0;
  width: 14px;
  height: 14px;
  border: 3px solid var(--rail, var(--line));
  border-radius: 50%;
  background: var(--paper);
}

.stops .n {
  color: var(--paper-muted);
  font-variant-numeric: tabular-nums;
}

.stops .t {
  color: var(--paper-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stops .aside {
  grid-column: 2 / -1;
  color: var(--paper-muted);
  font-size: 0.86rem;
}

.stops .yours {
  font-weight: 800;
}

.stops .yours::after {
  top: calc(50% - 9px);
  left: -3px;
  width: 20px;
  height: 20px;
  background: var(--rail, var(--line));
}

.stops .yours .n,
.stops .yours .t {
  color: inherit;
}

/* ---- Cards under the ticket -------------------------------------------- */

.card {
  margin-top: 16px;
  padding: 18px 18px 16px;
  border: 1px solid var(--rule);
  border-radius: 18px;
  background: var(--panel);
}

.card-title {
  margin: 0 0 10px;
  color: var(--amber);
  font: 800 1.25rem/1 var(--display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.about-name {
  margin: 2px 0 8px;
  font: 800 2rem/1 var(--display);
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.about-blurb {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.45;
}

.about-blurb:empty {
  display: none;
}

/* Things to do: numbered like stops on a line. */
.things {
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: thing;
}

.things:empty {
  display: none;
}

.things li {
  position: relative;
  padding: 12px 0 12px 44px;
  border-top: 1px solid var(--rule);
  line-height: 1.4;
  counter-increment: thing;
}

.things li::before {
  content: counter(thing);
  position: absolute;
  top: 11px;
  left: 0;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--amber);
  color: var(--amber-ink);
  font: 800 1.1rem/1 var(--display);
}

.thing-where {
  display: block;
  margin-top: 2px;
  color: var(--amber);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
}

.nearby {
  margin-top: 4px;
  border-top: 1px solid var(--rule);
}

.nearby summary {
  padding: 14px 0 6px;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}

.nearby[open] summary {
  margin-bottom: 6px;
}

.rerolls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.rerolls + .fineprint {
  margin-top: 10px;
}

.rerolls .button.quiet {
  margin-top: 0;
  min-height: 48px;
  padding: 8px 10px;
  font-size: 1.05rem;
}

.group-title {
  margin: 16px 0 2px;
  color: var(--muted);
  font: 600 0.92rem/1 var(--display);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.group-title:first-child {
  margin-top: 4px;
}

.places {
  margin: 0;
  padding: 0;
  list-style: none;
}

.place {
  display: grid;
  grid-template-columns: 2rem 1fr auto;
  align-items: center;
  gap: 0 8px;
  min-height: 52px;
  padding: 8px 0;
  border-top: 1px solid var(--rule);
  color: inherit;
  text-decoration: none;
}

.places li:first-child .place {
  border-top: 0;
}

.place-icon {
  font-size: 1.3rem;
  text-align: center;
}

.place-name {
  font-weight: 600;
  line-height: 1.25;
}

.place-desc {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 400;
}

.place-dist {
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.empty {
  margin: 0;
  color: var(--muted);
}

.returns {
  margin: 0;
  padding: 0;
  list-style: none;
}

.returns li {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  gap: 2px 12px;
  padding: 9px 0;
  border-top: 1px solid var(--rule);
}

.returns li:first-child {
  border-top: 0;
}

.returns .when {
  font: 800 1.35rem/1 var(--display);
  font-variant-numeric: tabular-nums;
}

.returns .what {
  line-height: 1.3;
}

.returns .detail {
  grid-column: 2;
  color: var(--muted);
  font-size: 0.88rem;
}

.returns-from {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.92rem;
}

.dot {
  display: inline-block;
  width: 0.7em;
  height: 0.7em;
  margin-right: 0.35em;
  border-radius: 50%;
  background: var(--line);
}

.last-train {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--panel-raised);
}

.last-train.soon {
  background: rgb(255 107 107 / 14%);
  color: #ffd9d9;
}

.warning {
  margin: 12px 0 0;
  color: var(--amber);
  font-size: 0.92rem;
}

.actions {
  margin-top: 22px;
}

/* ---- Footer ------------------------------------------------------------ */

.footer {
  margin-top: 40px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.footer p {
  margin: 0 0 10px;
}

.footer details {
  margin-bottom: 14px;
}

.footer summary {
  padding: 8px 0;
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
}

/* ---- Settings sheet ---------------------------------------------------- */

.sheet {
  width: min(100% - 24px, 440px);
  max-height: calc(100dvh - 24px);
  margin: auto auto 12px;
  padding: 22px 20px 20px;
  border: 1px solid var(--rule);
  border-radius: 22px;
  background: var(--panel);
  color: var(--text);
  overflow-y: auto;
}

.sheet::backdrop {
  background: rgb(4 8 12 / 72%);
}

.sheet[open] {
  animation: sheet-up 260ms cubic-bezier(0.2, 0.9, 0.3, 1) both;
}

@keyframes sheet-up {
  from { opacity: 0; transform: translateY(40px); }
}

.sheet-title {
  margin: 0 0 6px;
  font: 800 1.7rem/1 var(--display);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.sheet fieldset {
  margin: 0 0 6px;
  padding: 14px 0 4px;
  border: 0;
  border-top: 1px solid var(--rule);
}

.sheet fieldset:first-of-type {
  border-top: 0;
}

.sheet legend {
  padding: 0;
  color: var(--amber);
  font: 600 0.95rem/1 var(--display);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.check {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 12px;
  align-items: start;
  min-height: 48px;
  padding: 10px 0;
  cursor: pointer;
}

.check input {
  width: 26px;
  height: 26px;
  margin: 0;
  accent-color: var(--amber);
}

.check small,
.field small {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.35;
}

.field {
  display: grid;
  gap: 6px;
  padding: 10px 0;
  font-weight: 600;
}

.field select {
  width: 100%;
  min-height: 50px;
  padding: 0 12px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-weight: 400;
}

.sheet .button {
  margin-top: 14px;
}

/* ---- Toast and fallbacks ----------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  z-index: 10;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 16px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.noscript {
  max-width: 460px;
  margin: 0 auto;
  padding: 20px;
  text-align: center;
}

/* ---- Tablets, and windows not wide enough for two columns --------------- */

@media (min-width: 700px) {
  .app {
    max-width: 540px;
    padding-top: 36px;
  }

  .lede {
    font-size: 2.5rem;
  }

  .wheel-wrap {
    width: min(100%, 430px);
  }

  /* Settings stop being a sheet pulled up from the bottom edge. */
  .sheet {
    width: min(100% - 48px, 520px);
    margin: auto;
    padding: 28px 28px 24px;
  }

  .sheet[open] {
    animation-name: sheet-in;
  }

  @keyframes sheet-in {
    from { opacity: 0; transform: translateY(14px) scale(0.98); }
  }
}

/* ---- A desk ------------------------------------------------------------
   Two columns. The wheel keeps the right-hand one from the first spin until
   there is a stop to talk about, and never moves in that time. The left-hand
   one holds whatever the player is acting on: the controls, then the ticket.
   Once the stop is rolled, what is there takes the wheel's place.

   The page's sections become `display: contents` so that their parts can be
   placed on one grid, wherever in the markup they sit. */

@media (min-width: 960px) {
  :root {
    --gutter: 40px;
    --columns-gap: clamp(40px, 6vw, 88px);
  }

  .app {
    display: flex;
    flex-direction: column;
    max-width: 1200px;
    min-height: 100vh;
    min-height: 100dvh;
    padding-top: 28px;
  }

  .masthead {
    padding-bottom: 26px;
  }

  .wordmark-city {
    font-size: 0.95rem;
  }

  .wordmark-name {
    font-size: 2.15rem;
  }

  .icon-button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: auto;
    padding: 0 18px 0 14px;
    font: 600 1.15rem/1 var(--display);
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .icon-button-label {
    display: inline;
  }

  main {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    /* A row for each of the controls, and a spare one at either end to
       centre them against the wheel. Everything else spans the lot. */
    grid-template-rows: 1fr repeat(6, auto) 1fr;
    column-gap: var(--columns-gap);
    align-items: start;
    /* A tall window gets some air above, the same at every stage so that
       nothing shifts from one to the next. */
    margin-top: clamp(0px, (100vh - 900px) / 3, 72px);
    margin-bottom: 64px;
  }

  main > .play,
  main > .ticket-view {
    display: contents;
  }

  /* A ticket waiting for its stop: the controls go, the wheel stays. */
  main[data-stage="ticket"] > .play {
    display: contents;
  }

  main[data-stage="ticket"] > .play > :not(.wheel-wrap) {
    display: none;
  }

  .lede {
    grid-area: 2 / 1;
    margin: 0 0 26px;
    font-size: clamp(2.6rem, 3.9vw, 3.3rem);
  }

  .hubs {
    grid-area: 3 / 1;
  }

  .status {
    grid-area: 4 / 1;
    margin: 20px 0 12px;
    font-size: 1.08rem;
    text-align: left;
  }

  #spin {
    grid-area: 5 / 1;
    min-height: 68px;
    font-size: 1.65rem;
  }

  #spin-note {
    grid-area: 6 / 1;
  }

  #motion-note {
    grid-area: 7 / 1;
  }

  .play .fineprint {
    text-align: left;
  }

  /* As big as the column and the window allow, so that the whole wheel and
     the button beside it are on screen without scrolling. Anchored to the
     top: it must not shift when the ticket beside it grows. */
  .wheel-wrap {
    grid-column: 2;
    grid-row: 1 / -1;
    justify-self: center;
    width: min(100%, 540px, max(300px, 100vh - 250px));
    width: min(100%, 540px, max(300px, 100dvh - 250px));
    margin: 24px 0 8px;
  }

  .ticket {
    grid-column: 1;
    grid-row: 1 / -1;
  }

  /* With a stop rolled: the ticket, what to do with it underneath, and
     beside them both a column about where it leads. */
  main[data-stage="landed"] {
    grid-template-rows: auto auto 1fr;
  }

  main[data-stage="landed"] .ticket {
    grid-row: 1;
  }

  .actions {
    grid-column: 1;
    grid-row: 2;
  }

  .ticket-part {
    padding: 24px 26px 26px;
  }

  .ticket-tear {
    margin: 0 20px;
  }

  .ticket-tear::before { left: -31px; }
  .ticket-tear::after { right: -31px; }

  .flap-cell {
    font-size: 1.95rem;
  }

  /* Takes the wheel's place, so it eases in rather than snapping. A
     transition from a starting style, not an animation: it runs when the
     cards appear and at no other time, such as when a window is widened. */
  #after {
    grid-column: 2;
    grid-row: 1 / -1;
    transition: opacity 320ms ease-out, transform 320ms ease-out;
  }

  @starting-style {
    #after {
      opacity: 0;
      transform: translateY(12px);
    }
  }

  #after > .card:first-child {
    margin-top: 0;
  }

  .card {
    padding: 22px 24px 20px;
  }

  /* The message and its way out, on one line. */
  .challenge {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
    padding: 12px 20px;
  }

  .challenge .link-button {
    flex: none;
  }

  /* On a tall window the footer sits at the bottom rather than mid-screen. */
  .footer {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: var(--columns-gap);
    margin-top: auto;
    padding-top: 22px;
  }

  .footer details {
    grid-column: 1;
    grid-row: 1 / span 3;
    margin: 0;
  }

  .footer > p {
    grid-column: 2;
  }
}

/* ---- A mouse -----------------------------------------------------------
   Nothing needs a hover, but a pointer that can hover should see that things
   respond to it. */

@media (hover: hover) and (pointer: fine) {
  .button.primary:hover:not(:disabled) {
    filter: brightness(1.08);
  }

  .button.quiet:hover {
    background: rgb(127 127 127 / 14%);
    background: color-mix(in srgb, currentColor 11%, transparent);
    opacity: 1;
  }

  .hub:hover:not([aria-checked="true"]) {
    background: var(--panel-raised);
    color: var(--text);
  }

  .icon-button:hover {
    border-color: var(--muted);
    background: var(--panel-raised);
  }

  .place:hover .place-name,
  .thing-where:hover {
    text-decoration: underline;
    text-underline-offset: 0.2em;
  }

  .link-button:hover {
    text-decoration-thickness: 2px;
  }

  .nearby summary:hover,
  .footer summary:hover {
    color: var(--amber);
  }
}

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