:root {
  --bg: #14120e;
  --bg2: #1c1914;
  --panel: #211d17;
  --panel2: #2a251e;
  --line: #3a342a;
  --cream: #f2e6cc;
  --paper: #efe3c6;
  --ink: #1b1712;
  --muted: #9a8f7b;
  --amber: #ffb21a;
  --red: #e23a2a;
  --red-hot: #ff5a45;
  --red-deep: #7d1109;
  --hazard: #ffc21a;
  --depth: 0;
  --display: "Big Shoulders Display", Impact, "Arial Narrow", sans-serif;
  --mono: "Martian Mono", ui-monospace, Menlo, monospace;
  --text: "Archivo", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(120% 70% at 50% -10%, #2b2419 0%, transparent 60%),
    radial-gradient(90% 60% at 50% 120%, rgba(226, 58, 42, calc(0.06 + var(--depth) * 0.28)) 0%, transparent 70%),
    var(--bg);
  color: var(--cream);
  font-family: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background 0.6s;
}
body::before {
  /* film grain */
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: 0.09;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
::selection { background: var(--amber); color: var(--ink); }

#app { max-width: 1120px; margin: 0 auto; padding: 20px 16px 24px; }

.eyebrow {
  font-family: var(--mono);
  line-height: 1.4;
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}
h1, h2, h3 { font-family: var(--display); font-weight: 900; margin: 0; letter-spacing: 0.01em; text-transform: uppercase; }

/* ── Buttons & inputs ───────────────────────────────────────────── */
.btn {
  border: 1.5px solid var(--line);
  background: var(--panel2);
  border-radius: 10px;
  padding: 12px 18px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: transform 0.08s, background 0.15s, border-color 0.15s;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(2px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary {
  background: var(--amber);
  border-color: var(--amber);
  color: var(--ink);
  box-shadow: 0 4px 0 #a86f00;
}
.btn.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 #a86f00; }
.btn.red { background: var(--red); border-color: var(--red); color: #fff4ea; box-shadow: 0 4px 0 var(--red-deep); }
.btn.small { font-size: 14px; padding: 7px 12px; border-radius: 8px; }
.btn.ghost { background: transparent; }
.link {
  font-family: var(--mono);
  background: none; border: 0; padding: 0;
  color: var(--muted); text-decoration: underline; text-underline-offset: 3px;
  font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
}
.link:hover { color: var(--cream); }

.field {
  width: 100%;
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
}
.field:focus { border-color: var(--amber); }

/* ── Split-flap tiles ───────────────────────────────────────────── */
/* Lines are laid out in JS; nothing here is allowed to wrap. */
.flap {
  --t: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(var(--t) * 0.22);
}
.flap .line { display: flex; gap: calc(var(--t) * 0.4); white-space: nowrap; }
.word { display: flex; gap: calc(var(--t) * 0.08); }
.tile {
  position: relative;
  flex: none;
  width: calc(var(--t) * 0.7);
  height: var(--t);
  border-radius: calc(var(--t) * 0.09);
  background: linear-gradient(180deg, #2c2721 0%, #231f1a 49.5%, #1b1814 50.5%, #15130f 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    inset 0 -1px 0 rgba(0, 0, 0, 0.6),
    0 calc(var(--t) * 0.04) 0 #050403;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.tile::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: max(1px, calc(var(--t) * 0.022));
  background: #050403;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04);
}
.tile::before {
  /* hinge pins */
  content: "";
  position: absolute;
  top: calc(50% - var(--t) * 0.04);
  left: 0; right: 0;
  height: calc(var(--t) * 0.08);
  background:
    radial-gradient(circle at 0 50%, #000 0 40%, transparent 42%),
    radial-gradient(circle at 100% 50%, #000 0 40%, transparent 42%);
  z-index: 1;
}
.tile.blank { opacity: 0.55; }
.ch {
  font-family: var(--display);
  font-weight: 800;
  font-size: calc(var(--t) * 0.84);
  line-height: 1;
  color: var(--cream);
  transform-origin: 50% 50%;
  text-shadow: 0 0 calc(var(--t) * 0.2) rgba(242, 230, 204, 0.12);
}
.flap.red .tile { background: linear-gradient(180deg, #e84333 0%, #d93424 49.5%, #c22a1b 50.5%, #a8200f 100%); }
.flap.red .ch { color: #fff4ea; }
.flap.amber .ch { color: var(--amber); }

/* ── Home ───────────────────────────────────────────────────────── */
.home { min-height: calc(100svh - 140px); display: grid; align-items: center; }
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 470px);
  gap: clamp(32px, 6vw, 72px);
  align-items: center;
  padding: clamp(8px, 4vh, 40px) 0;
}
@media (max-width: 860px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .departures { order: 2; }
}
.hero-copy { display: grid; gap: 18px; align-content: start; }
.wordmark {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(84px, 15vw, 172px);
  line-height: 0.8;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  margin: 2px 0 6px -0.04em;
}
.wordmark span { color: var(--red); }
.lede { margin: 0; max-width: 38ch; font-size: 17px; line-height: 1.5; color: #d9ccb2; }
.entry { display: grid; gap: 10px; margin-top: 10px; max-width: 460px; padding-top: 22px; border-top: 1px solid var(--line); }
.lbl { font-family: var(--mono); font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }
.field.big { font-size: 20px; padding: 14px 16px; font-weight: 500; }
.entry-actions { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: stretch; }
.entry-actions .btn { white-space: nowrap; }
.code-join { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.field.code { font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.3em; text-align: center; font-weight: 600; font-size: 15px; padding: 0 10px; }
@media (max-width: 420px) { .entry-actions { grid-template-columns: minmax(0, 1fr); } }

.departures {
  --t: 25px;
  background: linear-gradient(180deg, #0d0c0a, #090807);
  border: 1.5px solid #2e2922;
  border-radius: 16px;
  padding: 16px 16px 12px;
  box-shadow: inset 0 2px 20px rgba(0, 0, 0, 0.9), 0 0 0 6px #1a1712, 0 0 0 7.5px #2e2922, 0 40px 80px -40px rgba(0, 0, 0, 0.9);
  font-family: var(--mono);
  min-width: 0;
}
.departures header, .departures footer, .dep-cols {
  display: flex; justify-content: space-between;
  font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase;
}
.departures header { color: var(--amber); padding-bottom: 12px; border-bottom: 1px solid #2a251e; }
.departures .clock { color: var(--cream); font-variant-numeric: tabular-nums; }
.departures footer { color: var(--muted); padding-top: 10px; border-top: 1px solid #2a251e; margin-top: 4px; }
.dep-cols { display: grid; grid-template-columns: calc(var(--t) * 0.78 * 12) 1fr auto; gap: 14px; color: #5f5646; padding: 10px 0 6px; }
.departures ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; padding-bottom: 8px; }
.departures li { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; }
.dep-name { --t: inherit; align-items: flex-start; }
.dep-stops { color: var(--cream); font-size: 13px; font-variant-numeric: tabular-nums; }
.dep-status { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: #8ac926; width: 9ch; text-align: right; }
.dep-status[data-s="boarding"] { color: var(--amber); animation: blink 1.1s steps(2) infinite; }
.dep-status[data-s="last-call"] { color: var(--red-hot); }
@media (max-width: 520px) {
  .departures { --t: calc((100vw - 32px - 32px - 74px) / (12 * 0.78)); }
  .dep-stops { display: none; }
  .departures li, .dep-cols { grid-template-columns: auto 1fr; }
  .dep-cols span:nth-child(2) { display: none; }
}

/* ── Top bar ────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.brand { font-family: var(--display); font-weight: 900; font-size: 20px; letter-spacing: 0.06em; }
.brand span { color: var(--red); }
.topbar .right { display: flex; gap: 14px; align-items: center; }
.icon-btn {
  background: var(--panel); border: 1.5px solid var(--line); border-radius: 8px;
  width: 34px; height: 34px; display: grid; place-items: center; font-size: 15px; padding: 0;
}

/* ── Lobby ──────────────────────────────────────────────────────── */
/* Desktop: the whole lobby is one viewport; the timetable and roster scroll inside. */
#app:has(.lobby) { padding-bottom: 96px; }
.lobby { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; }
@media (min-width: 860px) {
  .lobby { grid-template-columns: 250px minmax(0, 1fr); gap: 44px; height: calc(100svh - 20px - 52px - 96px); }
  .platform, .timetable { min-height: 0; }
}

.platform { display: flex; flex-direction: column; gap: 12px; }
.platform .flap { --t: 58px; align-items: flex-start; }
.code-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.roster-head { margin-top: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.roster { list-style: none; margin: 0; padding: 0; overflow-y: auto; min-height: 0; flex: 1; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.roster li {
  position: relative;
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: baseline; gap: 10px;
  padding: 8px 0 8px 14px;
  border-bottom: 1px solid #241f19;
  animation: rise 0.4s both;
}
.roster li::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 2px; background: var(--c); }
.roster li.away { opacity: 0.45; }
.roster .nm { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.roster .tags { font-family: var(--mono); font-size: 9px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--amber); }
.roster .kick {
  background: none; border: 0; padding: 0; color: var(--muted);
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase;
  opacity: 0; transition: opacity 0.15s;
}
.roster li:hover .kick, .roster .kick:focus-visible { opacity: 1; }
.roster .kick:hover { color: var(--red-hot); }
@media (hover: none) { .roster .kick { opacity: 1; } }

.timetable { display: flex; flex-direction: column; gap: 16px; }
.boarding {
  flex: none;
  background: linear-gradient(180deg, #0d0c0a, #090807);
  border: 1.5px solid #2e2922;
  border-radius: 14px;
  padding: 10px 14px 12px;
  box-shadow: inset 0 2px 16px rgba(0, 0, 0, 0.9), 0 0 0 5px #1a1712, 0 0 0 6.5px #2e2922;
  margin: 6px 6px 0;
}
.boarding-top { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px; }
.boarding-top .eyebrow:first-child { color: var(--amber); }
.boarding-top .eyebrow:last-child { text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.boarding-board { height: 64px; margin-top: 8px; }
.boarding-board .flap { width: 100%; height: 100%; align-items: flex-start; }

#setup { display: flex; flex-direction: column; gap: 14px; min-height: 0; flex: 1; }
.guest-note { margin: 4px 0 0; color: var(--muted); }
.tt-tools { flex: none; display: flex; align-items: center; gap: 18px; border-bottom: 1px solid var(--line); }
.tt-search {
  flex: 1; min-width: 0;
  background: none; border: 0; outline: none;
  padding: 10px 0;
  font-size: 16px;
}
.tt-search::placeholder { color: #6f6656; }
.tt-special {
  flex: none;
  background: none; border: 0; padding: 10px 0;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tt-special:hover { color: var(--cream); }
.tt-special.sel { color: var(--amber); border-bottom-color: var(--amber); }

.tt-cols {
  flex: 1; min-height: 0;
  overflow-y: auto;
  columns: 4 180px;
  column-gap: 28px;
  padding-right: 6px;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
.tt-group h3 {
  break-after: avoid;
  font-family: var(--mono); font-weight: 400; font-size: 9px; letter-spacing: 0.22em; color: var(--amber);
  padding: 4px 6px 6px;
}
.tt-group + .tt-group h3 { padding-top: 16px; }
.tt-group ol { list-style: none; margin: 0; padding: 0; }
.tt-row {
  width: 100%;
  display: flex; align-items: baseline; gap: 6px;
  background: none; border: 0; border-radius: 5px;
  padding: 4px 6px;
  text-align: left;
  color: #cbbfa6;
  font-size: 14px;
  line-height: 1.35;
}
.tt-row .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tt-row .lead { flex: 1; min-width: 10px; border-bottom: 1px dotted #4a4235; transform: translateY(-4px); }
.tt-row .ct { font-family: var(--mono); font-size: 10px; color: #7d7362; font-variant-numeric: tabular-nums; }
.tt-row:hover { background: #1e1a14; color: var(--cream); }
.tt-row.sel { background: var(--amber); color: var(--ink); font-weight: 600; }
.tt-row.sel .lead { border-color: rgba(27, 23, 18, 0.4); }
.tt-row.sel .ct { color: var(--ink); }
.tt-empty { color: var(--muted); padding: 8px 6px; margin: 0; }

.custom-editor { flex: none; display: grid; gap: 10px; }
.custom-editor textarea { height: 140px; resize: vertical; font-size: 14px; line-height: 1.6; }
.custom-editor .row { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.custom-editor .hint { font-family: var(--mono); color: var(--muted); font-size: 11px; }
/* While writing a list, the timetable steps aside. */
#setup:has(#custom:not([hidden])) .tt-cols { display: none; }

.opts { flex: none; display: flex; flex-wrap: wrap; gap: 10px 36px; padding-top: 12px; border-top: 1px solid var(--line); }
.opt { display: grid; gap: 4px; }
.seg { display: flex; gap: 16px; }
.seg button {
  background: none; border: 0; padding: 2px 0 4px;
  font-size: 14px; color: var(--muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.seg button small { font-family: var(--mono); font-size: 9px; color: #6f6656; margin-left: 2px; }
.seg button:hover { color: var(--cream); }
.seg button.sel { color: var(--cream); border-bottom-color: var(--amber); }

.start-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, var(--bg) 35%);
  display: flex;
  justify-content: center;
  z-index: 20;
}
.start-bar .inner { width: min(1040px, 100%); display: flex; gap: 12px; align-items: center; justify-content: flex-end; }
.start-bar .btn { font-size: 24px; padding: 12px 28px; }
.start-bar .wait { color: var(--muted); margin-right: auto; }
.start-bar .wait b { color: var(--cream); font-weight: 600; }
@media (max-width: 560px) {
  .start-bar .inner { flex-direction: column; align-items: stretch; }
  .start-bar .wait { margin: 0; text-align: center; }
  .tt-cols { columns: 1; }
}

/* ── Play ───────────────────────────────────────────────────────── */
/* Every block here has a fixed size so nothing shifts as items, stops and
   modes change. Only the riders list (last on mobile, sidebar on desktop) flows. */
.play {
  /* Sized off both axes so the STOP button stays on screen in short windows too. */
  --board-h: clamp(108px, min(26vw, 24svh), 210px);
  --btn: clamp(140px, min(44vw, 24svh), 216px);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}
.playbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 16px; height: 56px; }
.playbar > div { min-width: 0; }
.playbar .cat-name {
  font-family: var(--display); font-weight: 900; font-size: clamp(24px, 5vw, 36px); line-height: 1;
  text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.playbar .counter { text-align: right; white-space: nowrap; }
.playbar .counter .num { font-family: var(--display); font-weight: 900; font-size: clamp(30px, 6vw, 44px); line-height: 0.9; font-variant-numeric: tabular-nums; }
.playbar .counter .num small { font-size: 0.5em; color: var(--muted); font-weight: 700; }

.board-frame {
  position: relative;
  border-radius: 20px;
  padding: 12px 14px;
  background: linear-gradient(180deg, #0d0c0a, #090807);
  border: 1.5px solid #2e2922;
  box-shadow:
    inset 0 2px 20px rgba(0, 0, 0, 0.9),
    0 30px 60px -30px rgba(0, 0, 0, 0.9),
    0 0 0 6px #1a1712,
    0 0 0 7.5px #2e2922;
  margin: 0 7px;
}
.board-frame::before, .board-frame::after {
  /* bolts */
  content: "";
  position: absolute;
  top: 10px;
  width: 7px; height: 7px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #6c6253, #2a251e);
}
.board-frame::before { left: 10px; }
.board-frame::after { right: 10px; }
.board-label {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px;
  height: 22px; padding: 2px 10px 0;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--amber);
}
.board-label > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board-label .left::before {
  content: "";
  display: inline-block;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--red-hot);
  margin-right: 8px;
  vertical-align: 1px;
  box-shadow: 0 0 8px var(--red-hot);
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0.2; } }
.board { height: var(--board-h); padding: 8px 6px 12px; }
.board .flap { width: 100%; height: 100%; overflow: hidden; }
.board-frame.last .board-label { color: var(--red-hot); }
.board-frame.shake { animation: shake 0.35s; }
@keyframes shake {
  20% { transform: translateX(-6px) rotate(-0.4deg); }
  40% { transform: translateX(5px) rotate(0.3deg); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}
.timer { height: 5px; margin: 0 10px 4px; background: #1d1a15; border-radius: 4px; overflow: hidden; }
.timer-fill { height: 100%; width: 0; background: var(--amber); border-radius: 4px; }
.board-frame.last .timer-fill { background: var(--red-hot); }

.depth-wrap { height: 64px; display: grid; grid-template-rows: 46px 18px; }
.depth { display: flex; gap: 3px; align-items: end; padding: 0 2px; overflow: hidden; }
.seg-d {
  flex: 1;
  min-width: 2px;
  height: 10px;
  border-radius: 3px;
  background: #2a251e;
  position: relative;
  transition: background 0.3s, height 0.3s;
}
.seg-d.past { background: #5a4f3e; }
.seg-d.now { background: var(--amber); height: 14px; box-shadow: 0 0 12px rgba(255, 178, 26, 0.6); }
.seg-d .pins { position: absolute; bottom: calc(100% + 3px); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column-reverse; gap: 2px; align-items: center; }
.seg-d .pin { width: 8px; height: 8px; border-radius: 50%; background: var(--c); box-shadow: 0 0 6px var(--c); animation: pop 0.4s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
.depth-legend {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: end;
  font-family: var(--mono); color: var(--muted); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; white-space: nowrap;
}
.depth-legend > span { overflow: hidden; text-overflow: ellipsis; }
.depth-legend > span:nth-child(2) { text-align: center; }
.depth-legend b { color: var(--cream); font-weight: 600; }
@media (max-width: 520px) { .depth-legend > span:first-child, .depth-legend > span:last-child { display: none; } .depth-legend { grid-template-columns: minmax(0, 1fr); } }

/* The control well is the same size whether it holds the button, the ticket, or a note. */
.control {
  height: calc(var(--btn) + 104px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  overflow: hidden;
}
.hazard {
  flex: none;
  padding: 16px;
  border-radius: 50%;
  background: repeating-linear-gradient(-45deg, var(--hazard) 0 14px, #15130f 14px 28px);
  box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.9), inset 0 0 0 3px rgba(0, 0, 0, 0.4);
}
.hazard-inner { padding: 10px; border-radius: 50%; background: #0e0d0b; box-shadow: inset 0 4px 10px rgba(0, 0, 0, 0.9); }
.stop-btn {
  display: block;
  width: var(--btn);
  height: var(--btn);
  border-radius: 50%;
  border: 0;
  background: radial-gradient(circle at 38% 30%, #ff7a68 0%, #e8392a 38%, #b9200f 70%, #861308 100%);
  box-shadow:
    0 12px 0 #4e0a05,
    0 14px 24px rgba(0, 0, 0, 0.6),
    inset 0 -10px 24px rgba(0, 0, 0, 0.35),
    inset 0 8px 18px rgba(255, 255, 255, 0.28);
  color: #fff4ea;
  font-family: var(--display);
  font-weight: 900;
  font-size: calc(var(--btn) * 0.32);
  letter-spacing: 0.04em;
  text-shadow: 0 3px 0 rgba(90, 10, 5, 0.6);
  transform: translateY(-4px);
  transition: transform 0.05s, box-shadow 0.05s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.stop-btn:hover { filter: brightness(1.05); }
.stop-btn.down, .stop-btn:active {
  transform: translateY(8px);
  box-shadow: 0 1px 0 #4e0a05, 0 3px 8px rgba(0, 0, 0, 0.6), inset 0 -6px 18px rgba(0, 0, 0, 0.45), inset 0 8px 18px rgba(255, 255, 255, 0.2);
}
.stop-btn:disabled { cursor: default; }
.control .hint { height: 18px; font-family: var(--mono); color: var(--muted); font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; white-space: nowrap; }
.control .hint kbd { font-family: var(--mono); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 1px 6px; color: var(--cream); }
@media (hover: none) { .control .hint .kb { display: none; } }

.locked {
  flex: none;
  width: min(400px, 100%);
  height: min(196px, calc(var(--btn) + 30px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--paper);
  color: var(--ink);
  border-radius: 14px;
  padding: 16px 20px 16px;
  position: relative;
  transform: rotate(-1.5deg);
  box-shadow: 0 20px 40px -14px rgba(0, 0, 0, 0.9);
  animation: stamp 0.45s cubic-bezier(0.2, 1.5, 0.4, 1) both;
  -webkit-mask: radial-gradient(circle 9px at 0 50%, transparent 98%, #000) left / 51% 100% no-repeat,
                radial-gradient(circle 9px at 100% 50%, transparent 98%, #000) right / 51% 100% no-repeat;
          mask: radial-gradient(circle 9px at 0 50%, transparent 98%, #000) left / 51% 100% no-repeat,
                radial-gradient(circle 9px at 100% 50%, transparent 98%, #000) right / 51% 100% no-repeat;
}
@keyframes stamp { from { transform: rotate(-6deg) scale(1.4); opacity: 0; } }
.locked .eyebrow { color: #7a6a4d; }
.locked .item {
  align-self: center;
  font-family: var(--display); font-weight: 900; font-size: clamp(34px, 9vw, 50px); line-height: 0.92; text-transform: uppercase;
  padding-right: 64px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.locked .item.long { font-size: clamp(26px, 6.6vw, 36px); }
.locked .meta { display: flex; justify-content: space-between; gap: 10px; font-family: var(--mono); font-size: 11px; border-top: 1.5px dashed #b9a87f; padding-top: 10px; color: #5f523b; white-space: nowrap; }
.locked .meta span { overflow: hidden; text-overflow: ellipsis; }
.locked .stamp {
  position: absolute; right: 14px; top: 12px;
  border: 2.5px solid var(--red); color: var(--red);
  font-family: var(--display); font-weight: 900; font-size: 16px; letter-spacing: 0.1em;
  padding: 2px 8px; border-radius: 6px; transform: rotate(8deg); opacity: 0.85;
}
.after-note { color: var(--muted); font-size: 13px; text-align: center; max-width: 36ch; height: 20px; white-space: nowrap; }
.spectate { text-align: center; color: var(--muted); max-width: 40ch; }
.spectate h3 { color: var(--cream); font-size: 28px; margin-bottom: 6px; }
.countdown-note { font-family: var(--display); font-size: 20px; font-weight: 800; letter-spacing: 0.06em; color: var(--muted); text-transform: uppercase; height: 18px; line-height: 18px; }

.riders { display: grid; gap: 10px; align-content: start; }
.riders ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; }
.rider {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 10px; align-items: center;
  height: 46px;
  padding: 0 12px;
  border-radius: 12px;
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-left: 4px solid var(--c);
  transition: background 0.3s, opacity 0.3s;
}
.rider .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); grid-row: span 2; }
.rider .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; align-self: end; }
.rider .st { grid-column: 2; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; align-self: start; }
.rider.riding .st::after { content: ""; display: inline-block; width: 1.2em; text-align: left; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
.rider.off { background: var(--bg2); }
.rider.off .st { color: var(--cream); }
.rider.off .st b { font-family: var(--display); font-weight: 800; font-size: 15px; letter-spacing: 0.02em; text-transform: uppercase; }
.rider.gone { opacity: 0.4; }
.rider.just { animation: flash 0.9s; }
@keyframes flash { 0%, 30% { background: var(--c); color: var(--ink); } }

@media (min-width: 860px) {
  .play { grid-template-columns: minmax(0, 1fr) 280px; column-gap: 28px; }
  .play > .playbar, .play > .board-frame, .play > .depth-wrap { grid-column: 1 / -1; }
  .play .riders ul { grid-template-columns: minmax(0, 1fr); }
  .play .riders { padding-top: 10px; height: calc(var(--btn) + 104px); min-height: 0; grid-template-rows: auto minmax(0, 1fr); }
  .play .riders ul { overflow-y: auto; min-height: 0; padding-right: 4px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
}
@media (max-width: 520px) {
  #app:has(.play) { padding-top: 12px; }
  .play { gap: 10px; }
  .topbar { margin-bottom: 10px; }
}

.banners { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 50; display: grid; gap: 8px; width: min(520px, calc(100% - 32px)); pointer-events: none; }
.banner {
  background: var(--red);
  color: #fff4ea;
  border-radius: 12px;
  padding: 10px 14px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 16px 30px -10px rgba(0, 0, 0, 0.8), inset 0 0 0 2px rgba(255, 255, 255, 0.15);
  animation: bannerIn 0.4s cubic-bezier(0.2, 1.4, 0.4, 1) both, bannerOut 0.35s ease-in 2.4s forwards;
}
.banner > div { min-width: 0; }
.banner .oct {
  flex: none; width: 30px; height: 30px; background: #fff4ea;
  clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%);
  display: grid; place-items: center;
}
.banner .oct::after { content: ""; width: 24px; height: 24px; background: var(--c); clip-path: inherit; }
.banner .txt { font-family: var(--display); font-weight: 900; font-size: 22px; line-height: 1; text-transform: uppercase; letter-spacing: 0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.banner .sub { font-size: 12px; opacity: 0.9; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes bannerIn { from { transform: translateY(-30px) scale(0.9); opacity: 0; } }
@keyframes bannerOut { to { transform: translateY(-20px); opacity: 0; } }

/* ── Results ────────────────────────────────────────────────────── */
/* Desktop: one viewport. Picks on the left, what came by on the right; each scrolls inside. */
.results { display: grid; gap: 24px; }
@media (min-width: 860px) {
  .results {
    height: calc(100svh - 20px - 52px - 24px);
    grid-template-columns: minmax(0, 1fr) 320px;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 18px 40px;
  }
  .results-head { grid-column: 1; grid-row: 1; }
  .tickets { grid-column: 1; grid-row: 2; min-height: 0; overflow-y: auto; align-content: start; padding: 14px 6px 10px; }
  .results-actions { grid-column: 1; grid-row: 3; }
  .lineup { grid-column: 2; grid-row: 1 / -1; min-height: 0; grid-template-rows: auto minmax(0, 1fr); }
  .lineup ol { overflow-y: auto; min-height: 0; padding-right: 4px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
}
.results-head { display: grid; gap: 8px; justify-items: start; }
.results-head .flap { --t: 52px; width: 100%; height: 60px; align-items: flex-start; }
.tickets { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.ticket {
  position: relative;
  background: var(--paper);
  color: var(--ink);
  border-radius: 12px;
  padding: 12px 14px 12px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 4px;
  height: 152px;
  transform: rotate(var(--r, 0deg));
  box-shadow: 0 18px 36px -16px rgba(0, 0, 0, 0.9);
  animation: deal 0.55s cubic-bezier(0.2, 1.3, 0.4, 1) both;
  animation-delay: calc(var(--i) * 110ms);
  border-top: 7px solid var(--c);
}
@keyframes deal { from { transform: translateY(40px) rotate(calc(var(--r, 0deg) * 4)); opacity: 0; } }
.ticket .who { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; }
.ticket .who > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ticket .who .rank { font-family: var(--display); font-weight: 900; font-size: 24px; line-height: 1; color: #8b7a58; }
.ticket .item {
  align-self: center;
  font-family: var(--display); font-weight: 900; font-size: 30px; line-height: 0.92; text-transform: uppercase;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ticket .meta { font-family: var(--mono); font-size: 9px; color: #6b5d43; border-top: 1.5px dashed #c2b18a; padding-top: 7px; letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ticket .award {
  position: absolute; top: -12px; right: 12px;
  background: var(--ink); color: var(--amber);
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.16em; text-transform: uppercase;
  padding: 4px 8px; border-radius: 6px;
}
.ticket.forced { background: #d9cfb7; }
.ticket.forced .item { color: #4a4232; }

.lineup { display: grid; gap: 10px; align-content: start; }
.lineup-head { display: grid; gap: 4px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.lineup-head h2 { font-size: 26px; }
.lineup ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; align-content: start; }
.row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 6px 8px;
  border-radius: 7px;
}
.row .n { font-family: var(--mono); font-size: 10px; color: var(--muted); }
.row .it { font-family: var(--display); font-weight: 800; font-size: 17px; text-transform: uppercase; letter-spacing: 0.02em; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .who { display: flex; gap: 4px; justify-content: flex-end; }
.row .tag { width: 10px; height: 10px; border-radius: 50%; background: var(--c); box-shadow: 0 0 6px var(--c); }
.row.picked { background: var(--panel2); }

.results-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

/* ── misc ───────────────────────────────────────────────────────── */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 60; width: min(420px, calc(100% - 32px)); }
.toast { background: var(--cream); color: var(--ink); padding: 11px 14px; border-radius: 10px; font-size: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6); animation: bannerIn 0.3s both; }
.conn { font-family: var(--mono); position: fixed; top: 12px; right: 12px; z-index: 70; background: var(--red); color: #fff; padding: 6px 12px; border-radius: 999px; font-size: 11px; letter-spacing: 0.08em; }
.conn[hidden] { display: none; }
.rise { animation: rise 0.6s cubic-bezier(0.2, 0.9, 0.3, 1) both; animation-delay: calc(var(--i, 0) * 80ms); }
@keyframes rise { from { transform: translateY(16px); opacity: 0; } }

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