:root {
  --ink: #fdf6e3;
  --muted: #d9e8c8;
  --panel: rgba(22, 46, 26, 0.82);
  --panel-line: rgba(180, 230, 120, 0.35);
  --accent: #ffd447;
  --accent-ink: #2b2410;
  --leaf: #7cc04a;
  --banana: #ffe066;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #78b296;
  color: var(--ink);
  font: 16px/1.4 "Trebuchet MS", system-ui, sans-serif;
  user-select: none;
}

#view {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
}

.message {
  position: fixed;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  font-size: 1.4rem;
  text-shadow: 0 2px 4px #000;
}

/* ---- menus ---- */

.menus {
  position: fixed;
  inset: 0;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  align-items: flex-start;
  justify-content: center;
  gap: 1.5rem;
  padding: 2rem;
  pointer-events: none;
}

.menus > * { pointer-events: auto; }

/* Beside the previewed ape (Race Setup, Lobby: TRIAGE T47). The core picks
   the dock and its size from the view, and frames the ape in the open part. */
body[data-dock="side"] .menus {
  right: auto;
  width: var(--dock-w);
  padding: 1.5rem;
  align-content: flex-start;
  justify-content: flex-start;
  overflow-y: auto;
}
body[data-dock="below"] .menus {
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: center;
  align-content: center;
  justify-content: flex-start;
  padding: var(--dock-top) 1rem 1rem;
  overflow-y: auto;
}
body[data-dock="side"] .menus .panel,
body[data-dock="below"] .menus .panel { width: 25rem; max-width: 100%; min-width: 0; }
body[data-screen="race"] .menus { background: rgba(10, 24, 12, 0.35); }
body[data-screen="race"] .menus:empty { background: none; }
body[data-screen="lineup"] .menus { display: none; }

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 18px;
  padding: 1.2rem 1.4rem;
  min-width: 18rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
}

.panel h2 {
  margin: 0 0 0.8rem;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.panel.title {
  flex-basis: 100%;
  background: none;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  text-align: center;
  padding: 0;
}

.panel.title h2 {
  font-size: clamp(3rem, 9vw, 6.5rem);
  letter-spacing: 0.06em;
  color: var(--banana);
  text-shadow: 0 4px 0 #6b4a18, 0 8px 18px rgba(0, 0, 0, 0.45);
  margin: 0;
  font-weight: 900;
  font-style: italic;
}

.panel.title .sub {
  font-size: 1.3rem;
  color: var(--ink);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

.panel.menu { display: flex; flex-direction: column; gap: 0.6rem; min-width: 16rem; }
.panel.overlay,
.panel.results { min-width: 22rem; display: flex; flex-direction: column; gap: 0.6rem; }

.button {
  font: inherit;
  font-weight: 700;
  font-size: 1.15rem;
  padding: 0.65rem 1.2rem;
  border-radius: 999px;
  border: 2px solid #c79a1e;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  transition: transform 0.08s, background 0.12s;
  margin-top: 0.4rem;
  width: 100%;
}

.button:hover { transform: translateY(-2px) rotate(-1deg); background: #ffe27a; }
.button:active { transform: translateY(1px); }
.button.quiet { background: transparent; color: var(--ink); border-color: var(--panel-line); }

.field { display: flex; align-items: center; gap: 0.8rem; margin: 0.5rem 0; justify-content: space-between; }
.field label { color: var(--muted); }
.field select, .field input[type="range"] { font: inherit; }
.field select {
  background: rgba(0, 0, 0, 0.3);
  color: var(--ink);
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  padding: 0.2rem 0.5rem;
}
.slider-value { min-width: 3rem; text-align: right; }

.picker { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; margin: 0.3rem 0 0.8rem; }
.picker .name { font-size: 1.6rem; font-weight: 800; color: var(--banana); text-align: center; flex: 1; }
.picker button {
  font: inherit;
  font-size: 1.4rem;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  border: 2px solid var(--panel-line);
  background: rgba(0, 0, 0, 0.25);
  color: var(--ink);
  cursor: pointer;
}

.stats { margin: 0.4rem 0 0.8rem; }
.stat { display: grid; grid-template-columns: 7rem 1fr; align-items: center; gap: 0.6rem; margin: 0.25rem 0; }
.stat .label { color: var(--muted); font-size: 0.95rem; }
.stat .pips { display: flex; gap: 4px; }
.stat .pip { flex: 1; height: 0.7rem; border-radius: 4px; background: rgba(255, 255, 255, 0.15); }
.stat .pip.on { background: var(--leaf); }

table.pairs, table.cells { border-collapse: collapse; width: 100%; }
table.pairs td { padding: 0.2rem 0.4rem; }
table.pairs td:first-child { color: var(--muted); }
table.pairs td:last-child { text-align: right; font-weight: 700; }
table.cells th { color: var(--muted); font-weight: 400; text-align: left; padding: 0.2rem 0.5rem; }
table.cells td { padding: 0.3rem 0.5rem; }
table.cells tr.me td { color: var(--banana); font-weight: 800; }

/* a count with − and + (TRIAGE T103: a tournament's races) */
.stepper { display: flex; align-items: center; justify-content: space-between; margin: 0.5rem 0; gap: 1rem; }
.stepper > span { color: var(--muted); }
.stepper-box { display: flex; align-items: center; gap: 0.5rem; }
.stepper-value { min-width: 2rem; text-align: center; font-weight: 800; color: var(--banana); }
.stepper button {
  font: inherit;
  font-size: 1.1rem;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 2px solid var(--panel-line);
  background: rgba(0, 0, 0, 0.25);
  color: var(--ink);
  cursor: pointer;
}
.stepper button:disabled { opacity: 0.4; cursor: default; }
.toggle { display: flex; align-items: center; justify-content: space-between; margin: 0.5rem 0; gap: 1rem; }
.toggle span { color: var(--muted); }
.toggle input { width: 1.2rem; height: 1.2rem; accent-color: var(--leaf); }
/* the items crates may give (TRIAGE T42). The boxes make the host's lobby
   taller: panels that do not fit scroll rather than run off the screen */
.menus { overflow-y: auto; align-content: safe center; }
.checks { margin: 0.5rem 0; }
.checks-label, .checks-note { color: var(--muted); }
.checks-row { display: flex; flex-wrap: wrap; gap: 0.3rem 0.9rem; margin-top: 0.3rem; }
.check { display: flex; align-items: center; gap: 0.3rem; font-size: 0.9rem; }
.check input { width: 1.1rem; height: 1.1rem; accent-color: var(--leaf); }
.checks-note { display: block; font-size: 0.85rem; margin-top: 0.3rem; }

/* ---- the race HUD ---- */

.hud { position: fixed; inset: 0; pointer-events: none; }

.hud-top { position: absolute; top: 1rem; left: 1rem; display: flex; gap: 0.8rem; }

.pair {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  padding: 0.35rem 0.8rem;
  display: flex;
  flex-direction: column;
  min-width: 6.5rem;
}

.pair .k { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.pair .v { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.pair[hidden] { display: none; }
/* a map's shopping list (Aisle Ape): small, the taken items struck through */
.pair.list ul.v { list-style: none; margin: 0; padding: 0; font-size: 0.85rem; line-height: 1.25; }
.pair.list li.got { text-decoration: line-through; text-decoration-thickness: 2px; opacity: 0.55; }

.item-slot {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--panel);
  border: 2px solid var(--panel-line);
  border-radius: 16px;
  padding: 0.5rem 1rem;
  min-width: 9rem;
  text-align: center;
  display: flex;
  flex-direction: column;
}
.item-slot .k { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.item-slot .v { font-size: 1.3rem; font-weight: 800; }
.item-slot.full { border-color: var(--banana); box-shadow: 0 0 18px rgba(255, 224, 102, 0.6); }

.big {
  position: absolute;
  left: 50%;
  top: 30%;
  transform: translate(-50%, -50%);
  font-size: clamp(3rem, 12vw, 8rem);
  font-weight: 900;
  font-style: italic;
  color: var(--banana);
  text-shadow: 0 5px 0 #6b4a18, 0 10px 24px rgba(0, 0, 0, 0.5);
}
/* a whole message (Floor is Lava's jaguar, TRIAGE T37): one line, smaller */
.big.message {
  top: 15%;
  font-size: clamp(1.6rem, 6vw, 4.5rem);
  white-space: nowrap;
  color: #ff9a3c;
}

.hint {
  position: absolute;
  left: 50%;
  bottom: 2rem;
  transform: translateX(-50%);
  background: var(--panel);
  padding: 0.4rem 1rem;
  border-radius: 999px;
}
.hint:empty { display: none; }

.reticle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
}
.reticle.cool { background: rgba(255, 90, 60, 0.9); }

.minimap {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  width: min(22vw, 15rem);
  height: min(22vw, 15rem);
  background: rgba(22, 46, 26, 0.6);
  border: 1px solid var(--panel-line);
  border-radius: 16px;
}

/* Online play: text fields, the room code with its Copy button, pasted codes. */
.text-field input,
.text-field textarea {
  font: inherit;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
  min-width: 12rem;
}
.text-field textarea { min-height: 4rem; width: 18rem; word-break: break-all; }
.copy-field .copy-code { font-weight: bold; letter-spacing: 0.2em; }
.button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.panel.setup .cells { margin: 0.5rem 0; }

/* ---- the speedometer: a banana on a dial ---- */

.speedo {
  position: absolute;
  left: 1rem;
  bottom: 1rem;
  width: min(26vw, 17rem);
  aspect-ratio: 1;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.45));
  transition: filter 0.2s;
}
.speedo svg { width: 100%; height: 100%; display: block; }
.speedo-rim { fill: #2a1d0e; stroke: #ffd447; stroke-width: 3; }
.speedo-face { fill: #14240f; }
.speedo .tick { stroke: rgba(255, 255, 255, 0.55); stroke-width: 1.5; }
.speedo .tick.major { stroke: #fff6d0; stroke-width: 3; }
.speedo-num { fill: #fff6d0; font: 700 11px "Trebuchet MS", sans-serif; text-anchor: middle; }
.speedo .needle {
  transform-box: view-box;
  transform-origin: 100px 100px;
  transition: transform 0.08s linear;
}
.speedo .banana { fill: #ffd93b; stroke: #a8790a; stroke-width: 1.5; }
.speedo .banana-shine { fill: none; stroke: #fff3a8; stroke-width: 2; stroke-linecap: round; opacity: 0.8; }
.speedo .banana-stem { fill: #5a3b14; }
.speedo .hub { fill: #2a1d0e; stroke: #ffd447; stroke-width: 3; }
.speedo-read {
  position: absolute;
  left: 50%;
  top: 70%;
  transform: translateX(-50%);
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
  font-variant-numeric: tabular-nums;
}
#speedo-value { font-size: 1.9rem; font-weight: 900; font-style: italic; color: #fff6d0; }
#speedo-unit { font-size: 0.8rem; color: var(--muted); }
.shout {
  position: absolute;
  left: 50%;
  top: -0.6rem;
  transform: translateX(-50%) rotate(-6deg);
  font-weight: 900;
  font-style: italic;
  font-size: 1.4rem;
  white-space: nowrap;
  color: var(--banana);
  text-shadow: 0 3px 0 #6b4a18, 0 0 12px rgba(255, 200, 60, 0.8);
}

.speedo.hype-1 { filter: drop-shadow(0 0 10px rgba(255, 220, 80, 0.55)); }
.speedo.hype-2 { filter: drop-shadow(0 0 16px rgba(255, 150, 40, 0.8)); animation: hum 0.12s infinite alternate; }
.speedo.hype-2 #speedo-value { color: #ffd447; }
.speedo.hype-3 { filter: drop-shadow(0 0 24px rgba(255, 70, 40, 0.95)); animation: shake 0.07s infinite alternate; }
.speedo.hype-3 #speedo-value { color: #ff6a3a; }
.speedo.hype-3 .shout { animation: pulse 0.35s infinite alternate; }

@keyframes hum { from { transform: translate(0, 0); } to { transform: translate(0.5px, -0.5px); } }
@keyframes shake { from { transform: translate(-1.5px, 1px) rotate(-0.6deg); } to { transform: translate(1.5px, -1px) rotate(0.6deg); } }
@keyframes pulse { from { transform: translateX(-50%) rotate(-6deg) scale(1); } to { transform: translateX(-50%) rotate(-3deg) scale(1.15); } }

/* a hype call-out's splash (TRIAGE T22): the core gives the flash's
   strength (opacity) and the level; the shout pops big while it shows */
.hype-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at 50% 85%, rgba(255, 236, 140, 0) 30%, rgba(255, 200, 60, 0.55) 75%, rgba(255, 140, 30, 0.8) 100%);
}
.hype-flash.burst-3 {
  background: radial-gradient(ellipse at 50% 85%, rgba(255, 250, 220, 0.35) 0%, rgba(255, 170, 40, 0.5) 55%, rgba(255, 70, 30, 0.85) 100%);
}
.speedo:not([data-burst="0"]) .shout {
  animation: none;
  transform: translateX(-50%) rotate(-6deg) scale(calc(1 + 0.9 * var(--flash, 0)));
  text-shadow: 0 3px 0 #6b4a18, 0 0 calc(12px + 30px * var(--flash, 0)) rgba(255, 200, 60, 1);
}

/* the setup panel keeps one width whatever the ape's name (TRIAGE T2) */
.panel.setup { width: 25rem; }
.picker .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* the held item's picture (TRIAGE T19) */
.item-slot .icon { display: block; width: 4.5rem; height: 4.5rem; margin: 0.2rem auto; }
.item-slot .icon:empty { display: none; }
.item-slot .icon svg { width: 100%; height: 100%; }
.item-slot .v { font-size: 0.9rem; }

/* TRIAGE row 15 (a try): the glow and the shake grow with the exact speed,
   through --hype (0 to 1, from the core), rather than in three steps */
.speedo.hype-1, .speedo.hype-2, .speedo.hype-3 {
  filter: drop-shadow(0 0 calc(6px + 22px * var(--hype, 0)) rgba(255, calc(220 - 160 * var(--hype, 0)), 60, calc(0.4 + 0.55 * var(--hype, 0))));
  animation: hype-shake calc(0.16s - 0.1s * var(--hype, 0)) infinite alternate;
}
@keyframes hype-shake {
  from { transform: translate(calc(-2px * var(--hype, 0)), calc(1.5px * var(--hype, 0))) rotate(calc(-0.8deg * var(--hype, 0))); }
  to { transform: translate(calc(2px * var(--hype, 0)), calc(-1.5px * var(--hype, 0))) rotate(calc(0.8deg * var(--hype, 0))); }
}

/* ---- replays (TRIAGE T15) ---- */

body[data-screen="race"] .menus:has(.panel.replay) {
  background: none;
  align-content: flex-end;
  padding-bottom: 5.5rem;
}
.panel.replay {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1rem;
  padding: 0.6rem 1rem;
}
.panel.replay .button { width: auto; margin-top: 0; font-size: 1rem; padding: 0.45rem 1rem; }
.panel.replay .field { margin: 0; }
.panel.replays { display: flex; flex-direction: column; gap: 0.3rem; max-width: 40rem; max-height: 80vh; overflow-y: auto; }
.panel.replays .button { font-size: 1rem; text-align: left; }
.button:disabled { opacity: 0.45; cursor: default; transform: none; }
.replay-bar {
  position: absolute;
  left: 50%;
  bottom: 1.6rem;
  transform: translateX(-50%);
  width: min(60vw, 40rem);
  display: flex;
  align-items: center;
  gap: 0.8rem;
  pointer-events: auto;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 4px #000;
}
.replay-bar input { flex: 1; accent-color: var(--accent); }
.replay-bar[hidden] { display: none; }
.panel.replay h2 { margin: 0 0.4rem 0 0; }

/* ---- spectating after the finish (TRIAGE T34) and the followed racer
   in a replay (T24) ---- */

/* the full results sit at the side too, with no dimming, so the finishers'
   dance shows (TRIAGE T53) */
body[data-screen="race"] .menus:has(.panel.results),
body[data-screen="race"] .menus:has(.panel.spectate) {
  background: none;
  justify-content: flex-end;
  align-content: center;
  padding: 5.5rem 1rem 16rem;
}
.panel.spectate {
  min-width: 0;
  width: min(24rem, 92vw);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.8rem 1rem;
  font-size: 0.9rem;
}
.panel.spectate h2 { font-size: 1.3rem; margin: 0; }
.panel.spectate .button { font-size: 1rem; padding: 0.4rem 0.9rem; margin-top: 0; }
.panel.spectate .picker,
.panel.replay .picker { margin: 0; }
.panel.spectate .picker .name,
.panel.replay .picker .name { font-size: 1.05rem; }
.panel.replay .picker { min-width: 15rem; }
.panel.spectate .picker button,
.panel.replay .picker button { width: 2rem; height: 2rem; font-size: 1.1rem; }
/* the replay's hint sits above its bar */
body:has(#replay-bar:not([hidden])) .hint { bottom: auto; top: 5.5rem; }

/* group K: a course reward's name (mushroom push, catch-up vine), shown
   briefly by the core above the middle */
.hint.reward { bottom: auto; top: 13%; color: var(--banana); font-weight: 800; }
/* (13%: above the countdown, where Random names its map, TRIAGE T64) */

/* the game's version, tiny in the bottom right corner (the core names it) */
.version {
  position: fixed;
  right: 0.35rem;
  bottom: 0.2rem;
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.55);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  user-select: none;
  z-index: 50;
}
/* The map grid (TRIAGE T54): a card per map, its picture and name; the
   chosen one ringed in banana yellow. Three to a row in a docked panel;
   more maps add rows. A joiner's grid is read-only: the others fade. */
.tiles-field { margin: 0.3rem 0 0.7rem; }
.tiles-label { color: var(--muted); }
.tiles { display: grid; gap: 0.45rem; margin-top: 0.35rem; }
.tile-hero { margin: 0; position: relative; border-radius: 10px; overflow: hidden; border: 2px solid var(--banana); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35); }
.tile-hero img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: rgba(0, 0, 0, 0.25); }
.tile-hero-name { position: absolute; left: 0; right: 0; bottom: 0; padding: 0.25rem 0.6rem; font-weight: 800; font-size: 1.05rem; color: var(--accent-ink); background: var(--banana); }
.tile-row { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tile {
  font: inherit;
  flex: 1 1 0;
  min-width: 0;
  padding: 0.3rem 0.5rem;
  border-radius: 999px;
  border: 2px solid var(--panel-line);
  background: rgba(0, 0, 0, 0.3);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.tile:hover:not(:disabled) { border-color: var(--muted); }
.tile:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.tile.chosen { border-color: var(--banana); background: var(--banana); color: var(--accent-ink); }
.tiles.read-only .tile { cursor: default; }
.tiles.read-only .tile:not(.chosen) { opacity: 0.4; filter: grayscale(0.6); }

/* ---- the docked setup panels: Race Setup, Time Trial, the lobby
   (TRIAGE T70, T81). Each panel fits the window's height by itself and
   scrolls inside its own frame only when it cannot; its closing buttons
   (Start, Ready, Back, Leave) sit in a bar at its foot that stays in view.
   Short settings (a select, a checkbox) pair up two to a row. ---- */
body[data-dock="side"] .menus .panel.setup {
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--panel-line) transparent;
}
body[data-dock="side"] .menus .panel.setup,
body[data-dock="below"] .menus .panel.setup {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  column-gap: 1rem;
  padding: 0.9rem 1.2rem;
}
body[data-dock="side"] .panel.setup > *,
body[data-dock="below"] .panel.setup > * { flex: 1 1 100%; min-width: 0; }
body[data-dock="side"] .panel.setup > .field:has(select),
body[data-dock="side"] .panel.setup > .toggle,
body[data-dock="below"] .panel.setup > .field:has(select),
body[data-dock="below"] .panel.setup > .toggle { flex: 1 1 40%; }
body[data-dock] .panel.setup h2 { margin-bottom: 0.4rem; }
body[data-dock] .panel.setup .field,
body[data-dock] .panel.setup .toggle { margin: 0.2rem 0; flex-wrap: wrap; row-gap: 0.15rem; }
body[data-dock] .panel.setup .field label { white-space: nowrap; }
body[data-dock] .panel.setup .tiles-field { margin: 0.1rem 0 0.3rem; }
body[data-dock] .panel.setup .tile-hero img { aspect-ratio: 3 / 1; }
/* on a short screen the picture is flatter, so the Weather row (Yeti Peak,
   the bay) fits beside Colours and Costume without a scrollbar */
@media (max-height: 760px) { body[data-dock] .panel.setup .tile-hero img { aspect-ratio: 5 / 1; } }
body[data-dock] .panel.setup .picker { margin: 0.2rem 0 0.3rem; }
body[data-dock] .panel.setup .picker .name { font-size: 1.4rem; }
body[data-dock] .panel.setup .picker button { width: 2.2rem; height: 2.2rem; font-size: 1.2rem; }
body[data-dock] .panel.setup .stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 1rem;
  margin: 0.15rem 0 0.2rem;
}
body[data-dock] .panel.setup .stat { grid-template-columns: 5.6rem 1fr; gap: 0.4rem; margin: 0.1rem 0; }
body[data-dock] .panel.setup .stat .label { font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body[data-dock] .panel.setup .stat .pip { height: 0.55rem; }
body[data-dock] .panel.setup .checks { margin: 0.2rem 0; }
body[data-dock] .panel.setup .copy-field { margin: 0.2rem 0; flex-wrap: nowrap; }
/* the room code's Copy beside the code, so the lobby is a row shorter */
body[data-dock] .panel.setup .copy-field .button { width: auto; margin-top: 0; flex: 0 0 auto; }
body[data-dock] .panel.setup .copy-field .button,
body[data-dock] .panel.setup > .button { font-size: 1rem; padding: 0.4rem 1rem; margin-top: 0.2rem; }
body[data-dock] .panel.setup table.cells { font-size: 0.86rem; }
body[data-dock] .panel.setup table.cells td,
body[data-dock] .panel.setup table.cells th { padding: 0.2rem 0.35rem; }
/* the lobby's seats keep to one line each; a long ape name with its
   colours and costume is cut short rather than wrapping */
body[data-dock] .panel.setup table.cells { table-layout: auto; width: 100%; }
body[data-dock] .panel.setup table.cells td { white-space: nowrap; }
/* the player's name takes what the panel has left and is cut short with
   an ellipsis (max-width: 0 lets an auto table shrink it); the ape kind
   always shows in full, so the panel never scrolls sideways */
body[data-dock] .panel.setup table.cells td:nth-child(1) { max-width: 0; width: 100%; overflow: hidden; text-overflow: ellipsis; }
body[data-dock] .panel.setup { overflow-x: hidden; }
.actions { display: flex; flex-direction: column; }
body[data-dock="side"] .panel.setup:has(> .actions),
body[data-dock="below"] .panel.setup:has(> .actions) { padding-bottom: 0; }
body[data-dock="side"] .panel.setup > .actions,
body[data-dock="below"] .panel.setup > .actions {
  position: sticky;
  bottom: 0;
  z-index: 1;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.4rem -1.2rem 0;
  padding: 0.45rem 1.2rem 0.75rem;
  background: rgba(22, 46, 26, 0.92);
  border-top: 1px solid var(--panel-line);
}
body[data-dock] .panel.setup > .actions .button { flex: 1 1 0; margin-top: 0; padding: 0.5rem 0.8rem; font-size: 1.05rem; white-space: nowrap; }
body[data-dock] .panel.setup > .actions .button:first-child { flex-grow: 2; }
body[data-dock] .panel.setup > .actions .button:not(:first-child) { background: transparent; color: var(--ink); border-color: var(--panel-line); }
/* two short selects fit a row with their labels; the five map names (with
   Random, TRIAGE T64) share the row under the picture */
body[data-dock] .panel.setup .field { gap: 0.15rem 0.5rem; }
body[data-dock] .panel.setup .field select { font-size: 0.95rem; padding: 0.15rem 0.3rem; }
/* the costume select (TRIAGE T89): its locked options carry their hint
   ("Beat <map>'s Author time"), shown whole in the opened list; the closed
   box stays short so it pairs with the colours on one row */
body[data-dock] .panel.setup select[id$=".costume"] { max-width: 6.2rem; font-size: 0.8rem; }
/* the colours pair with the costume the same way: each label and its
   select on one line, the select shrinking rather than dropping below */
body[data-dock] .panel.setup .field:has(select[id$=".palette"]),
body[data-dock] .panel.setup .field:has(select[id$=".costume"]) { flex-wrap: nowrap; }
body[data-dock] .panel.setup select[id$=".palette"] { max-width: 7.5rem; min-width: 0; font-size: 0.8rem; }
body[data-dock] .panel.setup .tile { flex: 1 1 auto; font-size: 0.76rem; padding: 0.25rem 0.3rem; }
body[data-dock] .panel.setup .tile-row { flex-wrap: nowrap; gap: 0.25rem; }
body[data-dock] .panel.setup .tiles { grid-template-columns: minmax(0, 1fr); }
body[data-dock="side"] .menus .panel.setup,
body[data-dock="below"] .menus .panel.setup { column-gap: 0.75rem; }
body[data-dock] .panel.setup .field label,
body[data-dock] .panel.setup .toggle span { font-size: 0.92rem; }

/* The map cards' strip above the ape (TRIAGE T82): every map in one row
   across the open part beside the docked menus. Its height with the space
   round stays above the ape, which stands lower (menu_dock.rs). */
body[data-dock="side"] .menus .panel.strip {
  position: fixed;
  top: 1.5rem;
  left: var(--dock-w);
  right: 1.5rem;
  width: auto;
  max-width: none;
  padding: 0;
  background: none;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  min-width: 0;
}
.tiles.strip { display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: center; margin: 0; }
.card {
  font: inherit;
  /* one width for every card: a seventh of the open part, between 10 and
     15 rem; when seven don't fit they wrap to a second row */
  flex: 0 0 clamp(10rem, calc((100vw - var(--dock-w) - 5.1rem) / 7), 15rem);
  min-width: 0;
  padding: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 3px solid rgba(0, 0, 0, 0.5);
  background: rgba(0, 0, 0, 0.45);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  transition: transform 0.1s;
}
.card img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.card-name { display: block; padding: 0.2rem 0.3rem; font-weight: 800; font-size: 0.84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card:hover:not(:disabled) { border-color: var(--muted); transform: translateY(-2px); }
.card:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.card.chosen { border-color: var(--banana); transform: translateY(-4px); }
.card.chosen .card-name { background: var(--banana); color: var(--accent-ink); }
.tiles.strip.read-only .card { cursor: default; }
.tiles.strip.read-only .card:not(.chosen) { opacity: 0.45; filter: grayscale(0.6); }

/* What's New: the patch notes the core lists. The list scrolls; the
   minor-patches tick and Back stay in view. A minor version is smaller. */
.panel.notes { display: flex; flex-direction: column; width: 34rem; max-width: 100%; max-height: 82vh; }
.panel.notes .notes { flex: 1 1 auto; min-height: 0; overflow-y: auto; margin: 0.2rem 0 0.8rem; padding-right: 0.5rem; user-select: text; }
.note { padding: 0.55rem 0 0.6rem; border-top: 1px solid var(--panel-line); }
.note:first-child { border-top: none; }
.note-head { display: flex; align-items: baseline; gap: 0.6rem; }
.note-version { font-weight: 800; font-size: 1.15rem; color: var(--banana); }
.note-date { color: var(--muted); font-size: 0.85rem; }
.note ul { margin: 0.3rem 0 0; padding-left: 1.2rem; }
.note li { margin: 0.15rem 0; }
.note.minor .note-version { font-size: 0.95rem; }
.note.minor ul { font-size: 0.88rem; color: var(--muted); }
/* "New" on the menu's What's New */
.button .badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0 0.45rem;
  border-radius: 999px;
  background: #e8443a;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  vertical-align: middle;
  letter-spacing: 0.04em;
}
/* the version in the corner opens the notes on the menus */
.version.opens { pointer-events: auto; cursor: pointer; }
.version.opens:hover { color: var(--banana); text-decoration: underline; }
