/* Palette taken from the screen print: navy ink, cream paper and one amber accent. */
:root {
  color-scheme: dark;
  --bg: #121a2a;
  --panel: #18223a;
  --line: #34405c;
  --paper: #f2e7cb;
  --muted: #c4bba3;
  --accent: #f2b33d;
  --accent-ink: #1d1505;
  --alert: #ff9b85;
  --display: "Bebas Neue", "Oswald", "Avenir Next Condensed", "DIN Condensed", "Roboto Condensed", sans-serif-condensed, "Arial Narrow", sans-serif;
  --sans: "Avenir Next", "Segoe UI", Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--paper);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; }
main { min-height: inherit; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
:focus { outline: 3px solid var(--paper); outline-offset: 4px; }
:focus:not(:focus-visible) { outline: none; }
h1, h2, h3, p { margin: 0; }
.icon { flex-shrink: 0; width: 1.15em; height: 1.15em; vertical-align: middle; }
.shell { width: calc(100% - clamp(32px, 8vw, 112px)); max-width: 1440px; margin: 0 auto; }
.muted { color: var(--muted); }
.eyebrow { color: var(--accent); font-size: clamp(0.8rem, 0.95vw, 1.05rem); font-weight: 650; text-transform: uppercase; letter-spacing: 0.16em; }
.topbar { border-bottom: 1px solid var(--line); }
.topbar-inner {
  display: flex;
  width: calc(100% - clamp(32px, 8vw, 112px));
  max-width: 1440px;
  min-height: 72px;
  margin: 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: inline-flex; align-items: center; gap: 0.55em; flex-shrink: 0; font-weight: 650; font-size: clamp(1rem, 1.5vw, 1.25rem); letter-spacing: 0.01em; }
.brand-mark { width: 1.9em; height: 1.9em; }
.topbar-actions { display: flex; justify-content: flex-end; align-items: center; gap: 9px; }
.quiet, .primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  min-height: 46px;
  min-width: 46px;
  border-radius: 4px;
  white-space: nowrap;
  font-weight: 650;
}
.quiet { padding: 0 14px; background: #172036; color: var(--paper); border: 1.5px solid #4a5675; font-size: 0.95rem; }
.quiet:hover { background: #222d48; border-color: var(--muted); }
.icon-only { padding: 0; }
.primary {
  min-height: 54px;
  padding: 0 24px;
  border: 2px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 1.05rem;
}
.primary:hover { background: #ffc65e; border-color: #ffc65e; }
.primary:active { transform: translateY(1px); }
.primary:disabled { background: #283149; border-color: #3d4865; color: #b9c0d2; transform: none; }
.primary .icon { font-size: 1.2em; }

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

.library {
  --selection: var(--accent);
  --poster-gap: min(2.2vh, 1.25vw);
  /* Right-hand details column and the page margin it sits in; the scrim is measured from both. */
  /* ~430 px at 1440×810, ~440 px on a 1840×700 ultra-wide; on a 4K TV it grows with the height. */
  --sheet: clamp(360px, min(30vw, 62vh), 62vh);
  --margin-x: 4.6vw;
  --edge: calc(var(--sheet) + var(--margin-x));
  position: relative;
  isolation: isolate;
  /* On a TV the cover is exactly one screen: only the game list scrolls, never the page. */
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  overflow: clip;
  background: #0c101e;
  background: radial-gradient(110% 90% at 72% 42%, color-mix(in srgb, var(--selection) 12%, #0c101e), #0c101e 72%);
}
.wallpapers { position: absolute; z-index: -1; top: 0; right: 0; bottom: 0; left: 0; }
.wallpapers::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  /* Dark under the list, light in the middle where the characters are, dark again under the
     details. The right-hand band is a plain scrim for legibility, no blur. */
  background: linear-gradient(270deg, #070a14 0%, #070a14f5 calc(var(--edge) * 0.5), #070a14e0 calc(var(--edge) * 0.85),
      #070a14c7 var(--edge), #070a1452 calc(var(--edge) + 6vw), transparent calc(var(--edge) + 12vw)),
    linear-gradient(90deg, #060914f5 0%, #060914e0 22vw, #060914b3 32vw, #0609144d 40vw, transparent 47vw),
    linear-gradient(0deg, #060914a8, transparent 40%);
}
/* Each cover is slid left by its own amount so the characters land in the light band between
   the list and the details instead of under them; the strip it leaves is under the scrim. */
.wallpapers img {
  position: absolute;
  top: 0;
  left: calc(var(--shift, 0px) * -1);
  width: 100%;
  /* A slid cover fades out before its right edge so no vertical seam shows on wide screens. */
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - var(--shift, 0px) - 12vw), transparent calc(100% - var(--shift, 0px) * 0.4));
  mask-image: linear-gradient(90deg, #000 calc(100% - var(--shift, 0px) - 12vw), transparent calc(100% - var(--shift, 0px) * 0.4));
  height: 100%;
  object-fit: cover;
  object-position: 62% 50%;
  opacity: 0;
  transform: scale(1.035);
  transition: opacity 420ms ease, transform 1400ms cubic-bezier(.2, .7, .2, 1);
}
.wallpapers img.visible { opacity: 1; transform: none; }
.wallpapers img[data-wallpaper="atrapacometas"] { --shift: 15vw; }
.wallpapers img[data-wallpaper="orbita-expres"] { --shift: 16vw; }
/* Three tracks: the library on the left, the picture free in the middle, the chosen title's
   details in a column on the right. None of them grows into another. */
.poster {
  display: grid;
  grid-template-columns: minmax(0, min(46vw, 780px)) minmax(0, 1fr) var(--sheet);
  column-gap: 3vw;
  height: 100%;
  padding: 5.5vh var(--margin-x);
}
.poster-column { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; min-height: 0; }
.poster .brand { font-size: max(1rem, min(1.3vw, 2.35vh)); color: var(--paper); }
/* Same mark, toned to neutral on the cover so the only colour there is the game's. */
.poster .brand-mark { filter: grayscale(1) brightness(1.15); }
/* The list is its own scroller with a bounded height: twenty or thirty titles never move the
   brand, the panel or the page. Titles are sized from the column width so the usual names fit
   on one line on a 1280×720, 1440×810 or ultra-wide TV. */
.game-menu {
  container-type: inline-size;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  margin-top: clamp(10px, 2.4vh, 36px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #f2e7cb40 transparent;
  -webkit-mask-image: linear-gradient(transparent, #000 4%, #000 96%, transparent);
  mask-image: linear-gradient(transparent, #000 4%, #000 96%, transparent);
}
.game-menu ul { display: flex; flex-direction: column; gap: clamp(2px, 0.9vh, 12px); min-height: 100%; margin: 0; padding: 3vh 0; list-style: none; }
/* Centred when the list is short, top-aligned (never cut) once it overflows. */
.game-menu li:first-child { margin-top: auto; }
.game-menu li:last-child { margin-bottom: auto; }
.game-choice {
  display: flex;
  align-items: center;
  gap: 0.32em;
  width: 100%;
  min-height: 48px;
  padding: 0.04em 0.1em 0 0;
  border: 0;
  background: transparent;
  color: #e9e4d6;
  /* Regular-to-medium weight like the reference list. About 9 % of the column leaves the two
     current names with room to spare at 1280×720, 1440×810 and ultra-wide. */
  font-size: clamp(1.9rem, min(4vw, 7.6vh), 5.2rem);
  font-size: clamp(1.9rem, min(9cqi, 7.6vh), 5.2rem);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: -0.02em;
  text-align: left;
  text-shadow: 0 2px 18px #0609148c;
  opacity: 0.62;
  transform: scale(0.94);
  transform-origin: left center;
  transition: opacity 180ms ease, transform 220ms ease;
  scroll-margin-block: 0.9em;
}
/* Always one line, chosen or not; words never split. A name too long for the column is shrunk
   by app.mjs (--fit, never below 72 %) and only then ends in an ellipsis. */
.game-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  padding-bottom: 0.2em;
  font-size: calc(var(--fit, 1) * 1em);
  white-space: nowrap;
  text-overflow: ellipsis;
}
.game-emblem { display: grid; place-items: center; flex: none; width: 0.78em; height: 0.78em; margin-bottom: 0.16em; }
.game-emblem .icon { width: 100%; height: 100%; stroke-width: 1.4; }
.game-choice:hover { opacity: 0.82; }
/* The chosen title is told apart by brightness, colour and scale, not by a heavier weight. */
.game-choice[aria-current="true"] { color: #ffffff; opacity: 1; transform: none; }
.game-choice[aria-current="true"] .game-emblem { color: var(--selection); }
.game-choice:focus { outline: none; }
.game-choice:focus-visible .game-name {
  text-decoration: underline;
  text-decoration-color: var(--selection);
  text-decoration-thickness: 0.06em;
  text-underline-offset: 0.14em;
}
/* No card: the column stands on the scrim. Everything is sized from one unit that follows the
   screen (about 17 px at 1440×810, 23 px on a 1080p TV) so the details keep console scale. The
   column runs the full height; the details are pushed down onto the actions, which sit above
   a rankings block of fixed height, so the actions never move between games or states. */
.poster-panel {
  container: panel / inline-size;
  grid-column: 3;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  /* Room for focus rings inside the scroller without moving the text off the grid. */
  margin: 0 -12px;
  /* Lifts the block towards the middle of the list; the same for every game, so the
     actions stay on one fixed line. */
  padding: 12px 12px 9vh;
  overflow-y: auto;
  font-size: max(15px, min(1.2vw, 2.2vh));
  line-height: 1.4;
  text-shadow: 0 1px 12px #070a14;
  scrollbar-width: thin;
  scrollbar-color: #f2e7cb40 transparent;
}
.panel-head { margin-top: auto; }
/* On a TV the title on the left already names the game; the panel keeps it for screen readers
   and shows it only when the list had to cut the name with an ellipsis. */
.panel-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.poster-panel.full-title .panel-title {
  position: static;
  width: auto;
  height: auto;
  margin-bottom: 0.5em;
  overflow: visible;
  clip-path: none;
  white-space: normal;
  font-size: 1.5em;
  font-weight: 600;
  line-height: 1.2;
}
.panel-toggle { display: none; }
/* The three facts: format on its own line in the game colour, players and length on the next.
   The dot between those two is drawn, so it is never read aloud nor left at a line end. */
.facts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--paper);
  font-size: 1.05em;
  font-weight: 500;
}
.facts li { white-space: nowrap; }
.facts li:first-child { flex-basis: 100%; color: var(--selection); font-weight: 650; }
.facts li:nth-child(3)::before {
  content: "";
  display: inline-block;
  width: 0.24em;
  height: 0.24em;
  margin: 0 0.6em;
  border-radius: 50%;
  background: var(--muted);
  vertical-align: 0.24em;
}
.poster-copy {
  max-width: 24em;
  margin-top: 0.65em;
  color: #ece6d8;
  font-size: 1.22em;
  line-height: 1.4;
  text-wrap: pretty;
}
/* Rounds of a cup: subordinate to the pitch, numbered in play order, every name whole. */
.poster-rounds {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25em 1.1em;
  margin: 0.9em 0 0;
  padding: 0;
  list-style: none;
  color: #d3cbb6;
  font-size: 0.95em;
}
.poster-rounds li { white-space: nowrap; }
.round-number { margin-right: 0.45em; color: var(--paper); font-weight: 700; font-variant-numeric: tabular-nums; }
.poster-actions {
  display: grid;
  justify-items: start;
  gap: 0.4em;
  margin-top: 1.9em;
}
.poster-actions .primary, .poster-actions .quiet { justify-content: flex-start; gap: 0.6em; border-radius: 6px; text-shadow: none; }
/* Play is always filled with the game colour, focused or not; focus adds the white ring. Joining
   by code is a borderless secondary whose icon lines up with the one above. */
.poster-actions .primary {
  min-width: min(100%, 13em);
  min-height: max(46px, 2.9em);
  padding: 0 1.4em 0 1.05em;
  border-color: var(--selection);
  background: var(--selection);
  color: var(--accent-ink);
  font-size: 1.12em;
}
.poster-actions .primary:hover:enabled { border-color: color-mix(in srgb, var(--selection) 78%, #fff); background: color-mix(in srgb, var(--selection) 78%, #fff); }
.poster-actions .quiet {
  min-height: max(44px, 2.8em);
  padding: 0 1.2em 0 1.18em;
  border-color: #f2e7cb85;
  background: #f2e7cb0d;
  color: #ece6d8;
  font-size: 1em;
  font-weight: 550;
}
.poster-actions .quiet:hover, .poster-actions .quiet:focus-visible { border-color: #f2e7cbb3; background: #f2e7cb1f; }
.poster-actions :focus-visible { outline: 3px solid var(--paper); outline-offset: 4px; }
.poster-actions .primary:disabled { background: #283149; border-color: #3d4865; color: #b9c0d2; }
.feedback { color: var(--alert); margin: 12px 0 0; }
.feedback:empty { display: none; }
/* Rankings keep the height of their full state (stacked or side by side) so loading, empty
   and failed boards leave everything above them where it was. */
.records { margin-top: 2.4em; min-height: 14em; }
.records-note { color: var(--muted); font-size: 1.05em; }
.record-columns { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.3em 2em; max-width: 30em; }
.records h4 { margin: 0 0 0.45em; color: #c9c1ad; font-size: 0.88em; font-weight: 600; letter-spacing: 0.02em; }
/* Loading, empty and failed boards keep both headings side by side with one shared note. */
.record-columns.is-note { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.record-columns.is-note .records-note { grid-column: 1 / -1; margin-top: -0.9em; }
/* No games yet: one full-width label instead of two headings over nothing. The region keeps
   its hidden heading for screen readers, so the visible label is not read twice. */
.records-empty { width: 100%; }
.records-label { margin-bottom: 0.45em; color: #c9c1ad; font-size: 0.88em; font-weight: 600; letter-spacing: 0.02em; }
.record-columns ol { margin: 0; padding: 0; list-style: none; }
.record-columns li {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 0.8em;
  font-size: 1.05em;
  line-height: 1.5;
}
.record-name { overflow: hidden; color: #e3ddcd; font-weight: 500; white-space: nowrap; text-overflow: ellipsis; }
.record-columns li:first-child .record-name { color: var(--paper); font-weight: 600; }
.record-columns li strong { color: var(--paper); font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
/* Two columns only once a 14-letter alias and a four-digit figure fit in each. */
@container panel (min-width: 24em) {
  .record-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .records { min-height: 6.4em; }
}
@media (prefers-reduced-motion: reduce) {
  .wallpapers img, .game-choice { transition: none; transform: none; }
}
/* Short TV windows: the panel keeps its own scroll and the list just shows fewer titles. */
@media (min-aspect-ratio: 5/4) and (max-height: 560px) {
  .poster { padding-block: 3.5vh; }
  .poster-panel { padding-bottom: 2vh; }
}

.connection { padding: 10px 15px; text-align: center; color: #ffdca0; background: #33270f; font-weight: 600; font-size: 0.95rem; }
.empty { padding: 60px 0; }
.empty h1 { font-family: var(--display); font-stretch: condensed; font-weight: 700; text-transform: uppercase; font-size: clamp(2.2rem, 5vw, 4.5rem); line-height: 0.95; }
.empty p { margin: 12px 0 24px; color: var(--muted); }
.lobby { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 400px); gap: clamp(20px, 4vw, 72px); align-items: start; padding: clamp(24px, 5vh, 64px) 0 36px; }
.lobby-title { margin-bottom: clamp(18px, 3.5vh, 40px); }
.lobby h1, .results h1 {
  font-family: var(--display);
  font-stretch: condensed;
  font-size: clamp(2.6rem, 6.4vw, 7rem);
  font-weight: 700;
  line-height: 0.9;
  letter-spacing: 0.005em;
  text-transform: uppercase;
}
.lobby-title h1 { margin-top: 0.12em; }
.lobby h2 { font-size: clamp(1.1rem, 1.5vw, 1.6rem); font-weight: 650; margin-bottom: 0.7em; }
.roster { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.roster-slot {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 0.55em;
  min-height: clamp(96px, 13vh, 150px);
  padding: 10px 6px;
  text-align: center;
  overflow-wrap: anywhere;
  font-size: clamp(0.95rem, 1.15vw, 1.3rem);
  font-weight: 650;
  border-radius: 4px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--hue, var(--line));
  background: var(--panel);
}
.roster-slot .avatar { width: 2.3em; height: 2.3em; }
.roster-slot small { font-size: 0.72em; color: var(--muted); font-weight: 500; }
.roster-offline { opacity: .62; }
.empty-slot { color: var(--muted); background: transparent; border: 1px dashed #4a5675; font-weight: 500; }
.empty-avatar { display: grid; place-items: center; border-radius: 50%; border: 1px dashed #5d6a8a; width: 2.3em; height: 2.3em; color: var(--muted); }
.avatar { flex: none; display: inline-grid; place-items: center; position: relative; width: 34px; height: 34px; border-radius: 50%; background: var(--hue); }
.avatar::before { position: absolute; content: ""; width: 66%; height: 47%; background: #1b2236; border-radius: 999px; top: 27%; }
.avatar i, .avatar i::after { width: 2px; height: 4px; border-radius: 2px; background: #fbf6e9; }
.avatar i { display: block; position: relative; right: 3px; }
.avatar i::after { position: absolute; left: 6px; content: ""; }
.avatar-large { width: 100px; height: 100px; }
.avatar-large i, .avatar-large i::after { width: 6px; height: 11px; border-radius: 6px; }
.avatar-large i { right: 9px; }
.avatar-large i::after { left: 18px; }
.lobby-settings { display: flex; flex-wrap: wrap; align-items: center; gap: 0.7em; margin: 1.3em 0; font-size: clamp(1rem, 1.1vw, 1.25rem); }
.lobby-settings + .lobby-settings { margin-top: -0.5em; }
.lobby-settings label { font-weight: 650; }
.lobby-settings span { color: var(--muted); }
select, input { color: var(--paper); background: #172036; border: 1.5px solid #4a5675; border-radius: 4px; }
select { padding: 0.45em 0.7em; min-height: 46px; }
.lobby-actions { display: flex; flex-wrap: wrap; gap: 0.9em; align-items: center; font-size: clamp(1rem, 1.15vw, 1.3rem); }
.lobby-actions .primary { min-height: 2.7em; padding: 0 1.2em; font-size: inherit; }
.lobby-actions p { font-size: 0.9em; }
.invite {
  display: grid;
  justify-items: center;
  text-align: center;
  padding: clamp(18px, 3vw, 34px) 16px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.invite h2 { margin: 0.35em 0 0.9em; font-size: clamp(1.15rem, 1.6vw, 1.7rem); }
.qr-link { display: block; padding: 10px; border-radius: 4px; background: #fff; }
.qr-link img { display: block; width: clamp(165px, 17vw, 250px); height: auto; }
.invite-alt { margin: 1em 0 0.3em; color: var(--muted); font-size: clamp(0.9rem, 1vw, 1.15rem); line-height: 1.5; }
.invite-alt strong { color: var(--paper); font-weight: 650; }
.room-code {
  display: block;
  padding-left: 0.14em;
  font-family: var(--display);
  font-stretch: condensed;
  font-weight: 700;
  font-size: clamp(3rem, 5.4vw, 5.8rem);
  line-height: 1;
  letter-spacing: 0.14em;
  color: var(--accent);
}

body.playing { overflow: hidden; }
.playing .topbar {
  position: fixed;
  z-index: 3;
  top: clamp(9px, 1.8vh, 18px);
  right: clamp(10px, 2vw, 32px);
  border: none;
}
.playing .topbar-inner { display: block; width: auto; min-height: 0; }
.playing .brand { display: none; }
.playing .topbar-actions { gap: 6px; }
.playing .connection {
  position: fixed;
  z-index: 4;
  top: 50%;
  left: 50%;
  width: max-content;
  max-width: 90%;
  transform: translate(-50%, -50%);
  border: 1px solid #7a6030;
  border-radius: 4px;
}
.match { position: fixed; top: 0; right: 0; bottom: 0; left: 0; overflow: hidden; background: var(--bg); }
.arena { position: absolute; top: 0; right: 0; bottom: 0; left: 0; }
.arena canvas { display: block; width: 100%; height: 100%; }
/* Patio Cero: the 3D diorama bleeds edge to edge, so the HUD sits on compact dark plates. */
.match.engine-patio { width: 100vw; height: 100vh; height: 100dvh; background: #c9e3f6; }
.match.engine-patio .arena canvas { touch-action: none; }
/* Three separate lanes along the top: round card on the left (max 33vw), clock centred,
   the topbar's icon buttons on the right. They never meet from 1280 to 1920 px and beyond. */
.match.engine-patio .match-hud { right: auto; left: clamp(12px, 2vw, 36px); top: clamp(9px, 1.8vh, 18px); display: block; max-width: 29vw; }
.match.engine-patio .match-hud > div,
.match.engine-patio .time {
  padding: 0.3em 0.65em 0.4em;
  border-radius: 10px;
  background: #15131ccc;
  box-shadow: 0 2px 10px #15131c33;
}
.match.engine-patio .time {
  position: fixed;
  top: clamp(9px, 1.8vh, 18px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 4.2ch;
  padding: 0.12em 0.5em 0.18em;
  text-align: center;
  font-size: clamp(1.7rem, 3.3vw, 3.8rem);
}
.match.engine-patio .match-hud h1 { font-size: clamp(1.2rem, 2.2vw, 2.7rem); color: #fff; }
.match.engine-patio .round-rule { max-width: 30em; font-size: clamp(0.78rem, 0.95vw, 1.1rem); }
/* The round card lets the workshop show through a little; the clock keeps its solid plate. */
.match.engine-patio .match-hud > div { background: #15131cb8; }
/* In Patio Cero the "Juegos" link keeps its text for screen readers but shows only the icon. */
body.playing:has(.engine-patio) .topbar-actions a.quiet { font-size: 0; gap: 0; padding: 0; min-width: clamp(38px, 2.6vw, 52px); justify-content: center; }
body.playing:has(.engine-patio) .topbar-actions .icon { width: clamp(18px, 1.25vw, 26px); height: clamp(18px, 1.25vw, 26px); }
body.playing:has(.engine-patio) .topbar-actions .quiet { min-height: clamp(38px, 2.6vw, 52px); }
.match.engine-patio .score-row { background: #15131cd9; color: #fff; }
/* Medals and the Bot tag stay readable from the sofa: lighter, larger, heavier. */
.match.engine-patio .score-row small { color: #e6e0f2; font-size: 0.82em; font-weight: 600; }
.match.engine-patio .score-row b { font-size: 1.45em; }
.match.engine-patio .arena-overlay:not(.is-paused) { background: #15131c80; }
.match-hud {
  position: absolute;
  z-index: 2;
  top: clamp(12px, 2vh, 23px);
  right: clamp(201px, 18vw, 277px);
  left: clamp(13px, 2.7vw, 43px);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}
.match-hud h1 { margin-top: 0.1em; font-family: var(--display); font-stretch: condensed; font-size: clamp(1.5rem, 3.6vw, 4rem); font-weight: 700; line-height: 0.92; text-transform: uppercase; }
.time { font-family: var(--display); font-stretch: condensed; font-size: clamp(1.8rem, 4.4vw, 4.6rem); line-height: 1; font-variant-numeric: tabular-nums; font-weight: 700; color: var(--accent); }
.time.urgent { color: var(--alert); }
.round-rule { margin-top: 0.4em; max-width: 34em; font-size: clamp(0.85rem, 1.3vw, 1.35rem); line-height: 1.3; color: var(--paper); }
.arena-overlay { position: absolute; z-index: 1; top: 0; right: 0; bottom: 0; left: 0; display: grid; align-content: center; justify-items: center; gap: 0.4em; text-align: center; padding: 16px; background: #121a2ab8; pointer-events: none; }
.arena-overlay span { font-weight: 650; text-transform: uppercase; letter-spacing: 0.16em; color: var(--paper); font-size: clamp(.85rem, 1.6vw, 1.5rem); }
.arena-overlay strong { max-width: 100%; overflow-wrap: anywhere; font-family: var(--display); font-stretch: condensed; font-weight: 700; text-transform: uppercase; color: var(--accent); font-size: clamp(2.4rem, 7vw, 7.5rem); line-height: 0.95; }
.arena-overlay small { color: var(--paper); font-size: clamp(.9rem, 1.5vw, 1.4rem); }
.arena-overlay.is-paused { background: #0b1020d9; }
.arena-overlay.is-paused small { max-width: 32em; line-height: 1.35; }
.arena-overlay .primary { pointer-events: auto; margin-top: 0.7em; min-height: max(46px, 2.7em); padding: 0 1.3em; font-size: clamp(1rem, 1.5vw, 1.45rem); }
.time.is-paused { color: var(--paper); opacity: 0.7; }
.scoreboard { position: absolute; z-index: 2; bottom: clamp(8px, 1.8vh, 20px); left: 12px; right: 12px; }
.scoreboard #scores { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.score-row {
  display: grid;
  flex: 0 1 clamp(150px, 12vw, 220px);
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.45em;
  align-items: center;
  min-width: 90px;
  padding: 0.35em 0.6em;
  border: 1px solid var(--line);
  border-left: 4px solid var(--hue, var(--line));
  border-radius: 4px;
  background: #121a2ae6;
  font-size: clamp(.75rem, 1.05vw, 1.2rem);
}
.score-row div, .score-row strong { min-width: 0; }
.score-row strong, .score-row small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score-row strong { font-weight: 650; }
.score-row small { color: var(--muted); font-size: 0.72em; line-height: 1.2; }
.score-row b { font-size: 1.25em; font-weight: 700; font-variant-numeric: tabular-nums; }
.score-row .avatar { width: 1.6em; height: 1.6em; }
.results { max-width: 820px; padding: clamp(20px, 4vh, 48px) 0 26px; }
.results-title { text-align: center; margin-bottom: clamp(14px, 3vh, 30px); }
.results h1 { font-size: clamp(2.4rem, 5.6vw, 5.6rem); overflow-wrap: anywhere; margin-top: 0.12em; }
.results-title p:not(.eyebrow) { margin-top: 0.4em; font-size: clamp(1rem, 1.3vw, 1.4rem); }
.trophy { color: var(--accent); width: 1.9em; height: 1.9em; display: grid; place-items: center; margin: 0 auto 0.35em; font-size: clamp(26px, 2.4vw, 40px); }
.ranking { margin: 0; padding: 0; list-style: none; border-radius: 4px; background: var(--panel); border: 1px solid var(--line); font-size: clamp(1rem, 1.25vw, 1.4rem); }
.ranking li { display: grid; grid-template-columns: 1.4em 1.8em 1fr auto; gap: 0.7em; align-items: center; padding: 0.45em 0.9em; min-height: 2.6em; border-left: 4px solid var(--hue, transparent); }
.ranking li + li { border-top: 1px solid var(--line); }
.ranking .place { color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.ranking li:first-child .place, .ranking li:first-child .medals { color: var(--accent); }
.ranking .avatar { width: 1.8em; height: 1.8em; }
.ranking li strong { font-weight: 650; overflow-wrap: anywhere; }
.ranking li small { color: var(--muted); font-size: .7em; font-weight: 500; }
.medals { font-size: 0.9em; font-weight: 600; }
.result-actions { display: flex; justify-content: center; gap: 0.8em; margin-top: clamp(16px, 3vh, 30px); font-size: clamp(1rem, 1.15vw, 1.3rem); }
.result-actions .primary, .result-actions .quiet { min-height: 2.7em; padding: 0 1.2em; font-size: inherit; }

.controller-page { background: var(--bg); overscroll-behavior: none; }
.controller-page .topbar-inner { min-height: 60px; max-width: 610px; }
.join, .waiting { max-width: 390px; padding: clamp(22px, 8vh, 79px) 0 30px; }
.join .tile-icon { display: grid; width: 48px; height: 48px; place-items: center; border-radius: 4px; font-size: 23px; color: var(--accent-ink); background: var(--accent); }
.join h1, .waiting h1 { margin-top: 0.3em; font-family: var(--display); font-stretch: condensed; font-size: clamp(2.4rem, 11vw, 3.6rem); font-weight: 700; line-height: 0.92; text-transform: uppercase; overflow-wrap: anywhere; }
.join > p, .waiting > p:not(.eyebrow) { margin-top: 9px; line-height: 1.4; }
.join form { display: grid; gap: 8px; margin-top: 27px; }
.join label { font-weight: 650; font-size: .95rem; }
.join input { width: 100%; height: 50px; padding: 0 13px; margin-bottom: 9px; font-size: 1.05rem; }
.join input::placeholder { color: #8f97ad; }
.join #code { font-weight: 700; letter-spacing: 0.16em; }
.join .primary { justify-content: space-between; margin-top: 5px; }
.waiting { text-align: center; }
.waiting .eyebrow { margin-top: 18px; }
.waiting-hint { margin-top: 14px !important; }
.waiting-grip { max-width: 30ch; margin: 18px auto 0 !important; padding: 0.8em 1em; border: 1px dashed #4a5675; border-radius: 8px; color: var(--muted); font-size: 0.92rem; }
.waiting-actions { display: grid; gap: 10px; justify-items: center; margin-top: 24px; }
.waiting-actions .primary, .waiting-actions .quiet { width: min(100%, 280px); }
.waiting > .quiet { margin-top: 27px; }
@media (min-width: 820px) and (max-height: 780px) {
  .topbar-inner { min-height: 60px; }
  .lobby { padding-top: 23px; }
  .lobby-title { margin-bottom: 17px; }
}

/* On narrow or tall screens the illustration goes above the game list and the page scrolls.
   The chosen title lives in a compact sheet pinned to the bottom: its details open over the
   list on request instead of growing in between and pushing the titles down. */
@media (max-width: 700px), (max-aspect-ratio: 5/4) {
  .library { height: auto; min-height: 100vh; min-height: 100svh; overflow: visible; overflow-x: clip; }
  .wallpapers { position: relative; top: auto; right: auto; bottom: auto; left: auto; height: min(56.25vw, 46svh); }
  .wallpapers::after { background: linear-gradient(0deg, #0c101e, transparent 35%); }
  .wallpapers img[data-wallpaper] { left: 0; -webkit-mask-image: none; mask-image: none; }
  .poster { display: block; height: auto; padding: 12px 0 0; }
  .poster-column { width: calc(100% - clamp(32px, 8vw, 112px)); max-width: 640px; margin: 0 auto; }
  .poster .brand { font-size: 1rem; }
  .game-menu { overflow: visible; margin-top: 18px; -webkit-mask-image: none; mask-image: none; }
  .game-menu ul { min-height: 0; gap: 6px; padding: 0 0 16px; }
  .game-choice {
    font-size: clamp(1.75rem, 7.6vw, 3.4rem);
    opacity: 0.66;
    scroll-margin-top: 16px;
    scroll-margin-bottom: calc(13rem + env(safe-area-inset-bottom));
  }
  .poster-panel {
    position: sticky;
    bottom: 0;
    z-index: 2;
    display: block;
    max-height: 72svh;
    margin: 0;
    padding: 12px max(16px, calc((100% - 640px) / 2)) calc(14px + env(safe-area-inset-bottom));
    border-radius: 14px 14px 0 0;
    background: #0a0f1e;
    box-shadow: 0 -12px 32px #06091499;
    font-size: 1rem;
    text-shadow: none;
  }
  /* Open, the sheet dims the whole page behind it evenly, so a title it overlaps reads as a
     layer underneath instead of a name bitten in half. */
  .poster-panel.open { box-shadow: 0 -12px 32px #06091499, 0 0 0 100vmax #060914c7; }
  .panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 4px; }
  .poster-panel .panel-title, .poster-panel.full-title .panel-title {
    position: static;
    width: auto;
    height: auto;
    min-width: 0;
    margin: 0;
    overflow: visible;
    clip-path: none;
    white-space: normal;
    font-size: 1.25rem;
    font-weight: 650;
    line-height: 1.2;
  }
  .poster-panel .panel-toggle { display: inline-flex; flex: none; min-height: 48px; padding: 0 16px; font-size: 0.95rem; }
  .poster-panel:not(.open) .panel-more, .poster-panel:not(.open) .records { display: none; }
  .panel-more { margin-top: 10px; }
  .poster-copy { font-size: 1.12em; }
  .poster-actions { justify-items: stretch; gap: 6px; margin-top: 14px; }
  .poster-actions .primary { min-width: 0; min-height: 52px; justify-content: center; font-size: 1.06rem; }
  .poster-actions .quiet { min-height: 48px; justify-content: center; border-color: #f2e7cb85; }
  .records { min-height: 0; margin-top: 24px; }
  /* From about 390 px a name and its whole figure fit twice per row; 360 and 320 stay single. */
  @container panel (min-width: 21em) {
    .record-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 1.25em; }
    .record-columns li { gap: 0.5em; }
  }
}

@media (max-width: 779px) {
  .lobby { gap: 18px; grid-template-columns: minmax(0, 1fr) minmax(195px, 33%); }
  .roster { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .roster-slot { min-height: 76px; }
  .match-hud { right: 160px; gap: 7px; }
  .playing .topbar-actions .quiet { min-width: 35px; min-height: 35px; padding: 0 7px; }
  .score-row { flex: 0 1 calc(25% - 5px); }
}

@media (max-width: 530px) {
  .topbar-inner { min-height: 59px; }
  .topbar-actions { gap: 5px; }
  .quiet { padding: 0 9px; font-size: .85rem; }
  .icon-only { padding: 0; min-width: 40px; }
  .lobby { grid-template-columns: 1fr; }
  .lobby .invite { grid-row: 1; }
  .match-hud { right: 12px; top: 54px; }
  .scoreboard { left: 7px; right: 7px; }
  .score-row { flex: 0 1 calc(25% - 5px); min-width: 72px; gap: 4px; padding: 4px; }
  .score-row .avatar { width: 17px; height: 17px; }
  .score-row small { font-size: .56rem; }

}

@media (orientation: landscape) and (max-height: 470px) {
  .controller-page .topbar-inner { min-height: 38px; }
  .controller-page .brand { font-size: .9rem; }
}

/* Patio warm-up: one discreet panel inside the round card, no clock, no points. */
.match.engine-patio .time[hidden] { display: none; }
.practice-panel { pointer-events: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 0.35em 0.7em; margin-top: 0.55em; }
.practice-panel[hidden] { display: none; }
.practice-panel .primary { min-height: clamp(38px, 2.6vw, 52px); padding: 0.35em 0.9em; font-size: clamp(0.85rem, 1vw, 1.15rem); }
.practice-panel .primary:disabled { opacity: 1; background: #ffffff1f; color: #e6e0f2; box-shadow: inset 0 0 0 1.5px #ffffff4d; cursor: not-allowed; }
.practice-panel small { color: #e6e0f2; font-size: clamp(0.72rem, 0.85vw, 1rem); font-weight: 600; }
.match.is-practice .score-row b { visibility: hidden; }

/* Patio scoreboard on TV-sized screens: up to eight cards share a single row and long
   nicknames truncate with an ellipsis. Narrow phones keep the wrapping layout above. */
@media (min-width: 780px) {
  .match.engine-patio .scoreboard #scores { flex-wrap: nowrap; }
  .match.engine-patio .score-row { flex: 0 1 clamp(120px, 11.2vw, 215px); min-width: 0; font-size: clamp(.72rem, .95vw, 1.15rem); }
}
.practice-coach { display: flex; gap: 0.45em; margin: 0.5em 0 0; padding: 0; list-style: none; font-size: clamp(0.72rem, 0.85vw, 1rem); font-weight: 700; }
.practice-coach[hidden] { display: none; }
.practice-coach li { display: flex; align-items: center; gap: 0.4em; padding: 0.25em 0.6em 0.25em 0.3em; border-radius: 999px; background: #ffffff14; box-shadow: inset 0 0 0 1.5px #ffffff38; color: #e6e0f2; }
.coach-key { display: grid; place-items: center; width: 1.7em; height: 1.7em; border-radius: 50%; background: #ffffff26; color: #fff; font-weight: 800; }
.coach-key.stick i { width: 0.7em; height: 0.7em; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 0.22em #ffffff40; }
.coach-state { width: 1.1em; text-align: center; }
.practice-coach li.done { background: #f6c945; color: #1d1830; box-shadow: none; }
.practice-coach li.done .coach-key { background: #1d1830; color: #f6c945; }
.practice-progress { width: clamp(48px, 4.5vw, 90px); height: 0.4em; border-radius: 999px; background: #ffffff26; overflow: hidden; }
.practice-progress i { display: block; height: 100%; background: #f6c945; transform-origin: left; transform: scaleX(0); }
.practice-progress.full { display: none; }

/* Patio warm-up on TV: a slimmer card so the island and garage show through. */
@media (min-width: 780px) {
  .match.engine-patio.is-practice .match-hud { max-width: 22vw; }
  .match.engine-patio.is-practice .match-hud h1 { font-size: clamp(1rem, 1.5vw, 1.9rem); }
  .match.engine-patio.is-practice .round-rule { margin-top: 0.15em; font-size: clamp(0.8rem, 0.9vw, 1.05rem); font-weight: 600; }
  .match.engine-patio.is-practice .practice-coach { gap: 0.3em; margin-top: 0.35em; }
  .match.engine-patio.is-practice .practice-coach li { padding: 0.15em 0.45em 0.15em 0.2em; gap: 0.3em; }
  .match.engine-patio.is-practice .coach-key { width: 1.5em; height: 1.5em; }
  .match.engine-patio.is-practice .practice-panel { margin-top: 0.35em; }
}
