:root {
  --ink: #141414;
  --cream: #f5eedd;
  --page-bg: #ede4d0;
  --band-dark: #e8503c;
  --band-light: #f2b705;
  --danger: #c62828;
  --danger-pale: #f6cfcf;
  --success: #2e7d32;
  --success-pale: #cde8ce;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);

  /* Espacements : échelle partagée, à utiliser pour tout margin/padding/gap plutôt qu'une valeur ad hoc */
  --space-1: 0.2rem;
  --space-2: 0.3rem;
  --space-3: 0.4rem;
  --space-4: 0.5rem;
  --space-5: 0.6rem;
  --space-6: 0.75rem;
  --space-7: 1rem;
  --space-8: 1.25rem;
  --space-9: 1.5rem;
  --space-10: 1.75rem;
  --space-11: 2rem;

  --font-label: "Archivo Black", sans-serif;
  --font-display: "Fraunces", serif;
  --font-sticker: "Alfa Slab One", "Archivo Black", sans-serif;

  font-family: system-ui, sans-serif;
  color-scheme: light;
}

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

body {
  margin: 0;
  padding: var(--space-9) var(--space-7);
  display: flex;
  justify-content: center;
  /* `100vh` first as a fallback for engines without `dvh` support — without it, this whole
     declaration is dropped and body gets no explicit height at all, so with `overflow: hidden`
     below, anything past the (undefined) fold becomes invisible and unreachable, no scroll
     possible — this is how an unsupported `dvh` silently hid the whole page on an older/niche
     browser engine (e.g. "Join" button never appearing, reported after a real game session). */
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  box-sizing: border-box;
  background: var(--page-bg);
}

/* Author rules that set `display` (e.g. `button { display: inline-flex }`) otherwise
   always win over the browser default for the `hidden` attribute, regardless of
   selector specificity, because author declarations outrank user-agent ones. */
[hidden] {
  display: none !important;
}

main {
  width: 100%;
  max-width: 560px;
  height: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  /* position: relative, not overflow-clipped — the host/room-code badges and .pot-seal are
     positioned against main directly (not .pot-clip below) specifically so they can poke out
     past .pot-band's top edge instead of being clipped by the scroll fallback that .pot-clip
     needs for its own content (see .pot-clip). */
  position: relative;
  background: var(--cream);
  border: 4px solid var(--ink);
  border-radius: 16px;
}

main.wide {
  max-width: 1200px;
}

/* Wraps everything except the badges/.pot-seal above (the band, halftone, confetti, the actual
   screens) so it alone carries the rounded-corner clipping and scroll fallback that main itself
   used to have — moved here so that main can stay overflow-visible and let the badges/button
   poke out past .pot-band's top edge without being cut off. 12px = main's own 16px border-radius
   minus its 4px border, so the clipped corner lines up with the card's visible rounded edge. */
.pot-clip {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  /* Last-resort fallback, same reasoning as .pot-content > section below: if this box's own
     height (inherited from body's vh/dvh) ever ends up shorter than its content — e.g. a
     browser's "Desktop site" mode simulating a different viewport than the physical screen,
     reported on Vivaldi mobile during a real game session — a hard `overflow: hidden` here
     would clip content with zero way to reach it, since .pot-content's own scroll fallback
     only helps if ITS box is the one that's too short, not if .pot-clip itself is. Never engages
     in the normal case. overflow-x stays hidden so it doesn't also turn into a sideways
     scroll (see the longer explanation below for why that pairing matters). */
  overflow-x: hidden;
  overflow-y: auto;
}

/* Entrance for whichever screen showScreen() just switched to — replayed only on an
   actual screen change (see client.ts), never on the repeated same-screen calls that
   happen many times per turn, so it never fights the "don't animate high-frequency
   events" rule. */
@keyframes screen-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.screen-enter {
  animation: screen-enter 240ms var(--ease-out);
}

.pot-band {
  height: 14px;
  border-bottom: 4px solid var(--ink);
  background: var(--band-dark);
}

/* Slightly bigger than before and pulled up to -8px, centered on .pot-band (main itself no longer
   clips — see .pot-clip) instead of hanging mostly below it. Taller than the smaller pills below
   (.top-left-badges/.room-code-badge), so it needs a bigger pull-up to land on the same center. */
.pot-seal {
  position: absolute;
  top: -8px;
  right: 14px;
  z-index: 3;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  background: var(--band-dark);
  border: 3px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font: inherit;
}

.pot-seal-menu {
  position: absolute;
  top: 32px;
  right: 14px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 2px 3px 0 var(--ink);
}

.pot-seal-menu-item {
  padding: var(--space-5) 1.1rem;
  border: none;
  background: transparent;
  font-family: var(--font-label);
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--ink);
  white-space: nowrap;
  cursor: pointer;
}

.pot-seal-menu-item:hover,
.pot-seal-menu-item:focus-visible {
  background: var(--band-light);
}

.pot-seal-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--band-light);
}

/* Shown to the host only, on every screen (see client.ts' isHost) — mirrors .pot-seal's edge spacing
   but on the left, same row. Pulled up to -4px (nudged from -3px on 2026-11-29, on user feedback
   that it read as sitting low on the band), centered on .pot-band (main itself no longer clips
   — see .pot-clip) instead of hanging mostly below it. */
/* Wraps .host-badge and .pseudo-chip so the two sit side by side, same row, instead of each
   claiming the same top-left spot with its own position: absolute (they can both be visible at
   once — a host on the themes/cards screen gets both). */
.top-left-badges {
  position: absolute;
  top: -4px;
  left: 14px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Shared pill shape for small badges (.host-badge/.room-code-badge/.pseudo-chip below) — each keeps
   this class plus its own for the colors (and, for .room-code-badge, its absolute positioning). */
.pill-badge {
  padding: var(--space-2) 0.55rem;
  border-radius: 999px;
  border: 2px solid;
  font-family: var(--font-label);
  font-size: 0.65rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 1;
}

.host-badge {
  background: var(--band-light);
  border-color: var(--ink);
  color: var(--ink);
}

/* Shown on the avatar/themes/teams screens (see client.ts' currentScreen), in the spot .host-badge used to
   sit in: just left of .pot-seal, same row — pulled up like .top-left-badges above. */
.room-code-badge {
  position: absolute;
  top: -4px;
  right: 54px;
  z-index: 3;
  background: var(--band-light);
  border-color: var(--ink);
  color: var(--ink);
  white-space: nowrap;
}

/* One-shot attention pop for the host, right as they land on the avatar screen — a nudge to go share the
   room code, since they're the only one who needs to hand it out. A single eased pass from oversized back
   down to normal over 3.5s — no bounce/overshoot on the way. Starts nudged left/down so the oversized
   badge clears the pot-seal button to its right and stays inside the card's frame instead of poking out
   over the top-right corner. */
@keyframes room-code-badge-host-pop {
  0% {
    transform: translate(-27px, 10px) scale(1.6);
  }
  100% {
    transform: translate(0, 0) scale(1);
  }
}

.room-code-badge.host-pop {
  transform-origin: center;
  animation: room-code-badge-host-pop 3.5s cubic-bezier(0.16, 1, 0.3, 1) 1;
}

/* Shown whenever the socket connection drops (see client.ts' "disconnect"/"connect" handlers) —
   centered at the top so it reads as a global status, distinct from .host-badge/.room-code-badge
   which sit left/right and are about the room, not the connection. Pulled up like the other
   un-clipped top badges (see .top-left-badges above). */
.offline-badge {
  position: absolute;
  top: -3px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--danger);
  border-color: var(--ink);
  color: var(--cream);
  white-space: nowrap;
}

.offline-badge-icon {
  font-size: 0.75rem;
}

/* While offline, block every action that would need the server (drawing/clicking/submitting on any
   screen, plus the kick/rename overlays) instead of letting Socket.IO silently queue the emit and
   fire it later on reconnect (see CLAUDE.md, "block actions while logged out"). The pot-seal menu
   itself (Log out/Mute) stays usable — those are local-only and need no connection. */
body.offline .pot-content,
body.offline .modal-overlay {
  pointer-events: none;
  opacity: 0.6;
}

.halftone {
  position: absolute;
  inset: 14px 0 0 0;
  width: 100%;
  height: calc(100% - 14px);
  z-index: 0;
  pointer-events: none;
}

/* Flex column so each screen section can flex:1 and fill the remaining height
   below the logo (see ".pot-content > section" rule below) — this is what lets
   the canvas occupy almost the full screen. */
.pot-content {
  position: relative;
  z-index: 1;
  padding: var(--space-8) var(--space-8) var(--space-9);
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* Only ever holds .logo now (join/avatar) — themes/cards replace it with .pseudo-chip up in
   .top-left-badges instead (see showScreen), and the cards screen's own progress bar/counter
   live inside #cards-screen itself (.cards-progress-row), not here — so on those two screens
   this row is collapsed entirely rather than left empty (see further down). */
.logo-row {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  margin: 0 0 var(--space-7);
}

.logo-row:has(> .logo.hero) {
  margin: var(--space-4) 0 var(--space-9);
}

.logo {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-family: var(--font-display);
  font-weight: 900;
  font-style: italic;
  font-size: 1.9rem;
  color: var(--ink);
}

/* Shown on the join screen only: GUSMAN front and center, styled like a card sticker —
   since no player color is assigned yet at this stage, it borrows the top bar's two
   colors (--band-dark/--band-light) as a diagonal split background instead. The white
   text-shadow pairs build a thin outline around the letters (card-sticker lettering).
   The box border + box-shadow echo the same "stuck-on card" look. */
.logo.hero {
  /* .logo's own flex: 1 (meant for the pseudo-chip truncation case elsewhere in .logo-row)
     would otherwise stretch this into a full-width banner — margin: 0 auto only centers it
     once flex-grow/shrink are turned off, so it hugs the text like an actual sticker. */
  flex: 0 0 auto;
  margin: 0 auto;
  padding: var(--space-2) var(--space-8) 0.45rem;
  border: 4px solid var(--ink);
  border-radius: 10px;
  background: linear-gradient(135deg, var(--band-dark) 55%, var(--band-light) 55%);
  box-shadow: 4px 4px 0 var(--ink);
  font-size: 3rem;
  text-align: center;
  text-transform: uppercase;
  color: var(--ink);
  text-shadow:
    -2px -2px 0 #fff,
    2px -2px 0 #fff,
    -2px 2px 0 #fff,
    2px 2px 0 #fff,
    0 -2px 0 #fff,
    0 2px 0 #fff,
    -2px 0 0 #fff,
    2px 0 0 #fff;
}

/* Shown on the avatar/themes/cards screens, in .top-left-badges next to .host-badge (replacing
   .logo there entirely on those three screens — see showScreen) — same pill shape/size as
   .host-badge, but recolored to the player's own dark color (white fill instead of the light
   band, dark-colored border/text instead of plain ink) so it reads as "whose screen this is"
   without the big logo-sized pseudo eating into the row .cards-progress-track needs on the
   cards screen. The fixed max-width + ellipsis keep a max-length pseudo from running into
   .room-code-badge/.pot-seal on the right, since it's no longer sized against a flex sibling
   that would otherwise absorb the overflow (.cards-progress-track, now in a different row). */
.pseudo-chip {
  max-width: 7.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  background: #fff;
  border-color: var(--band-dark);
  color: var(--band-dark);
  white-space: nowrap;
}

/* Shown on the cards screen only, in its own row right below the step-progress line (see
   .cards-progress-row) — same idea as .theme-progress-track/.theme-progress-fill on the themes
   screen. flex: 1 lets it claim all the row's width the counter badge next to it doesn't need. */
.cards-progress-track {
  flex: 1;
  height: 0.5rem;
  border-radius: 999px;
  background: rgba(20, 20, 20, 0.12);
  overflow: hidden;
}

.cards-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--band-dark);
  border-radius: 999px;
  transition: width 320ms var(--ease-out);
}

/* Shown on the cards screen only, next to the progress bar in .cards-progress-row — deliberately
   not the host-badge/room-code-badge pill style (light pill, thin border, full rounding) so it
   doesn't read as another one of those chrome badges: a plain dark tag instead, closer to the
   drawing frame's own theme banner just below it. */
.cards-progress-badge {
  flex-shrink: 0;
  padding: 0.25rem var(--space-5);
  border-radius: 6px;
  background: var(--ink);
  font-family: var(--font-label);
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  color: var(--cream);
  line-height: 1;
  white-space: nowrap;
}

h2 {
  font-family: var(--font-label);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink);
}

.join-tagline {
  margin: 0 0 var(--space-8);
  text-align: center;
  font-family: var(--font-label);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
  opacity: 0.85;
}

.join-tagline-sep {
  color: var(--band-dark);
  margin: 0 0.15em;
}

.step-progress {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: 0 0 var(--space-5);
  font-family: var(--font-label);
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
}

.step-progress-item {
  opacity: 0.4;
}

.step-progress-item.is-current {
  opacity: 1;
}

.step-progress-item.is-done {
  opacity: 0.7;
}

.step-progress-sep {
  flex: 1;
  height: 2px;
  background: currentColor;
  opacity: 0.25;
  border-radius: 1px;
}

/* Cards screen only, right under its own .step-progress line (see index.html) — holds
   .cards-progress-track/.cards-progress-badge, moved here from the shared .logo-row on
   2026-11-28 so the step-progress line reads first on this screen, like on avatar/themes,
   instead of sitting below the counter. */
.cards-progress-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin: 0 0 var(--space-5);
}

.screen-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-6);
  /* Tighter than the generic 0.5rem below — this header only ever holds the avatar screen's
     one-line hint, so the drawing frame right under it (already flex:1, filling whatever's
     left) can start higher and read as bigger. */
  margin: 0 0 0.1rem;
}

.avatar-screen-hint {
  font-style: italic;
}

.screen-header > * {
  margin: 0;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: var(--space-7);
  font-size: 0.9rem;
  color: var(--ink);
}

input {
  padding: 0.55rem 0.7rem;
  font-size: 1rem;
  font-family: inherit;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

input:focus-visible {
  outline: 3px solid var(--band-dark);
  outline-offset: 1px;
}

.join-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-7);
}

/* A bit more breathing room between the nickname field and the room code / create-room section
   below it than the generic label spacing gives every other label on this screen. */
label:has(> #pseudo) {
  margin-bottom: 2.5rem;
}

.join-with-code {
  display: flex;
  gap: var(--space-4);
}

.join-with-code input {
  flex: 1;
  text-transform: uppercase;
}

.join-with-code input::placeholder {
  text-transform: none;
}

.or-divider {
  text-align: center;
  font-family: var(--font-label);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  color: var(--ink);
  opacity: 0.5;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-5) 1.1rem;
  font-family: var(--font-label);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--band-light);
  background: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 8px;
  cursor: pointer;
  transition:
    transform 140ms var(--ease-out),
    filter 140ms ease;
}

.btn-icon {
  flex-shrink: 0;
}

button:hover {
  filter: brightness(1.15);
}

button:active {
  transform: scale(0.97);
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

.error {
  font-family: var(--font-label);
  font-size: 0.8rem;
  color: var(--danger);
  min-height: 1.2em;
}

.screen-hint {
  margin: 0 0 var(--space-4);
  color: var(--ink);
}

/* .logo-row now has nothing left to show on the avatar/themes/cards screens — .logo is hidden
   there (see showScreen) and .pseudo-chip moved up into .top-left-badges, while the cards screen's
   own progress bar/counter live inside #cards-screen itself (.cards-progress-row) rather than here —
   so collapse it entirely on all three instead of leaving its margin as dead space above the
   canvas/card. */
.pot-content:has(> #avatar-screen:not([hidden])) .logo-row,
.pot-content:has(> #themes-screen:not([hidden])) .logo-row,
.pot-content:has(> #cards-screen:not([hidden])) .logo-row {
  display: none;
}

/* Every top-level screen (join/avatar/themes/cards/teams/game) is a direct
   section child of .pot-content and takes the full remaining height below
   the logo — so its own flexible content (canvas, arena, roster...) can
   size itself against a real, viewport-bounded height instead of growing
   the page. overflow-y is a last-resort fallback: it only engages if a
   screen's content still can't fit after shrinking (see the more specific
   flex:1/min-height:0 sponges below, e.g. .full-canvas, .roster), so it
   never fires in the normal case. overflow-x stays hidden explicitly: setting
   only overflow-y makes browsers coerce overflow-x to auto too (a visible/
   non-visible pair isn't allowed), which would turn any stray 1px of
   horizontal overflow into a sideways scroll that clips the screen's own
   framed boxes instead of just being invisible slack. The negative margin +
   matching padding below doesn't move any content (they cancel out) — it just
   gives this now-clipping box some slack past its children's actual edges, so
   purely decorative overflow (an input's focus outline, a selected swatch's
   ring, a card's correct/wrong flash glow) has room to render instead of
   being clipped by the rule above. Same trick applied to .game-view and
   .roster below, which clip for the same reason. */
.pot-content > section:not([hidden]) {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  margin: 0 -12px;
  padding: 0 12px;
  overflow-x: hidden;
  overflow-y: auto;
}

/* No aspect-ratio: the box takes whatever shape the available space allows,
   and that becomes the drawing's native resolution (see sizeCanvasToDisplay
   in client.ts) — not a fixed ratio stretched to fit. border-box so the 3px
   border sits inside the 100% width instead of adding to it (content-box,
   the default, was pushing the canvas 6px past its container — see the
   overflow-x note above for why that showed up as a cut-off edge). */
.full-canvas {
  flex: 1 1 auto;
  min-height: 0;
  box-sizing: border-box;
  width: 100%;
  border: 3px solid var(--ink);
  border-radius: 10px;
  background: #fff;
  touch-action: none;
  display: block;
  margin: 0 auto var(--space-7);
}

#card-title {
  margin-bottom: var(--space-7);
}

/* Shared frame look for every "card" on screen: the illustration screen's own drawing surface
   (.card-draw-frame, grouped with .game-card here so the look stays in sync) and the live round's
   card shown everywhere else (.game-card below, which also sizes/positions/shadows itself as a flex
   child — see that rule for the extra declarations specific to it). */
.card-draw-frame,
.game-card {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  border: 4px solid var(--ink);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

/* The illustration screen's theme + drawing surface, framed together as a single card — same idea
   as the live round's card (.game-card), but keeping .full-canvas's own fill-available sizing below
   (the canvas here is actively drawn on, not a fixed drawing shrunk to fit). The player draws
   straight onto the card itself: the theme sticker (.game-card-title) is pinned on top of it near
   the bottom, not a separate bar outside the drawing area. */

/* Reserves the screen's full leftover space for the illustration screen's card — #card-flip-stage
   itself still does that job for the live round's #game-card-flip-stage, but here it's instead sized
   explicitly by fitCardDrawStage (cards.ts) to this device's own card ratio (getCardRatio,
   cardSticker.ts), so this slot just centers that card within whatever room is actually available. */
.card-draw-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  /* Not hidden: the sticker now spills a little past #card-draw-frame's own bottom edge (see its
     overflow: visible rule below) into the gap #card-flip-stage's margin-bottom reserves — still
     within this slot's own box, so nothing here needs to clip it. */
  overflow: visible;
}

/* Every card drawn ends up this viewer's own card ratio (getCardRatio, cardSticker.ts), whatever
   screen it was drawn on — avoiding the empty side/top bands that object-fit: contain
   (.game-card-canvas) had to letterbox in once differently-shaped cards were displayed together.
   flex: 0 0 auto overrides .card-flip-stage's own flex: 1 1 auto below, which would otherwise stretch this to fill
   #card-draw-slot regardless of the explicit width/height fitCardDrawStage sets on it. */
#card-flip-stage {
  flex: 0 0 auto;
}

/* Wraps a card so it can flip over — the illustration screen's at validation time (cards.ts,
   playCardFlip) and the live round's at Correct/Wrong/Pass (turn.ts, playCardOutcomeFlip): perspective
   has to live on an ancestor of the rotated element (.card-flip-inner), not on the card itself, or it
   has no effect. Also carries the layout sizing (flex/margin) that used to sit directly on the card
   itself, now that it's absolutely positioned inside the flip (see .card-flip-face below) and can no
   longer size itself against its own flex context. */
.card-flip-stage {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  margin-bottom: var(--space-7);
  perspective: 1400px;
}

/* Tighter gap than the shared .card-flip-stage default, just for the live round: the storyteller's
   actions (Pause/Pass/Submit) sit right under the card instead of leaving the avatar/cards drawing
   screens' more generous breathing room. */
#game-card-flip-stage {
  margin-bottom: var(--space-4);
}

/* The element that actually flips — both faces (.card-flip-face below) are stacked absolutely inside
   it, so it has to be their positioned ancestor, and preserve-3d is what keeps their own rotateY in
   the same shared 3D space instead of each being flattened back into the page's plane. Unconditional
   (not scoped to .is-flipping): the back face needs this at rest too, for backface-visibility to hide
   it correctly even when nothing is animating. Also carries the card's own hard ink shadow (moved up
   from .card-draw-frame, which used to own it) and a matching border-radius just for that shadow's
   shape — not a visible border/background of its own, since one or the other face always fills it
   exactly. This rest value is also @keyframes card-flip's own 0%/100% shadow — box-shadow is a paint-
   level property, not a composited one like transform, so animating it does cost a bit more to render
   on a phone than the rotation alone; kept anyway (by request) for the "lifting off the page" look,
   with only a modest range (2px/3px resting to 5px/8px at the peak) to keep that cost down. */
.card-flip-inner {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  border-radius: 10px;
  transform-style: preserve-3d;
  /* Same hard offset shadow as .pot-seal-menu, no blur — the "bold ink" look of flat paper stacked
     on top of the page, rather than a soft/realistic drop shadow. */
  box-shadow: 2px 3px 0 var(--ink);
}

/* The flip itself: an anticipation wind-up (8%, rotating slightly *against* the turn before committing
   to it — the rotational equivalent of the scale-based squash this flip used to dip into), the turn
   itself, then a swing past the 180deg mark (78%) that eases back onto it — a real spring rebound, not
   just a deceleration. The ink shadow rides along, stretching out as the card picks up speed around the
   edge-on midpoint and pulling back in as it settles. No scale anywhere, unlike earlier versions of this
   flip: a scale bump grows the card from its own center and could poke it past its own frame (on top of
   costing a bit more to composite) — rotateY alone never does either, since foreshortening only ever
   shrinks the card toward its edge-on midpoint, never past its resting width/height. Overshooting to
   192deg is safe here (unlike the old single-face jump-trick this flip used to use): .card-flip-back
   stays correctly oriented and visible — not culled, not mirrored — anywhere within +/-90deg of its own
   180deg rest position, which both -8deg and 192deg are comfortably inside. `forwards` holds the final
   (100%) state once the animation finishes — both callers use that held instant to swap the real front
   face's content back in sync with what the back face has been showing (cards.ts's prepareFlipBack, or
   turn.ts's own withFlipSettle for the next card's content once it arrives from the server), *then*
   remove this class to snap back to flat, so the sync itself is never seen. Re-triggered on each flip
   by removing and re-adding this class — always separated by either the player drawing the next card
   (cards.ts) or a full server round-trip (turn.ts), so there's no risk of the browser coalescing the
   remove/re-add into a no-op the way an immediate same-tick toggle would. */
@keyframes card-flip {
  0% {
    transform: rotateY(0deg);
    box-shadow: 2px 3px 0 var(--ink);
  }
  8% {
    transform: rotateY(-8deg);
    box-shadow: 1px 2px 0 var(--ink);
  }
  50% {
    transform: rotateY(95deg);
    box-shadow: 5px 8px 0 var(--ink);
  }
  78% {
    transform: rotateY(192deg);
    box-shadow: 3px 4px 0 var(--ink);
  }
  100% {
    transform: rotateY(180deg);
    box-shadow: 2px 3px 0 var(--ink);
  }
}

.card-flip-inner.is-flipping {
  /* Hints the browser to promote this to its own compositor layer up front, instead of doing it (and
     dropping a frame) the instant the animation actually starts moving it. */
  will-change: transform;
  animation: card-flip 260ms ease-in-out forwards;
}

/* Wrong-only mirror of @keyframes card-flip above (turn.ts, playCardOutcomeFlip's `reverse` flag): same
   anticipation/overshoot shape, every rotateY negated, so a Wrong turns the opposite way from Correct/Pass
   — a hinge-on-the-other-side feel on top of the shake/flash it already gets, rather than the identical
   flip for all three outcomes. Ending at -180deg instead of +180deg still lands on the same final
   orientation (+/-180deg are the same angle), so .card-flip-back's own fixed rotateY(180deg) still faces
   the viewer once this settles, exactly as it does after the forward flip. */
@keyframes card-flip-reverse {
  0% {
    transform: rotateY(0deg);
    box-shadow: 2px 3px 0 var(--ink);
  }
  8% {
    transform: rotateY(8deg);
    box-shadow: 1px 2px 0 var(--ink);
  }
  50% {
    transform: rotateY(-95deg);
    box-shadow: 5px 8px 0 var(--ink);
  }
  78% {
    transform: rotateY(-192deg);
    box-shadow: 3px 4px 0 var(--ink);
  }
  100% {
    transform: rotateY(-180deg);
    box-shadow: 2px 3px 0 var(--ink);
  }
}

.card-flip-inner.is-flipping-reverse {
  will-change: transform;
  animation: card-flip-reverse 260ms ease-in-out forwards;
}

/* A quick green glow around the live turn's card on "Correct" (round 1 in particular validates every
   single card through this exact path, never Pass/Wrong, so without this the flip alone gave no
   obviously different feedback from a round where nothing special happened) — on #game-card-flip-stage
   rather than #game-card-flip-inner, since the inner element's own box-shadow is already driven by the
   @keyframes card-flip rotation above and would just fight this one for the same property. */
@keyframes card-correct-glow {
  0% {
    box-shadow: inset 0 0 0 0 rgba(46, 125, 50, 0);
  }
  40% {
    box-shadow: inset 0 0 0 6px rgba(46, 125, 50, 0.6);
  }
  100% {
    box-shadow: inset 0 0 0 0 rgba(46, 125, 50, 0);
  }
}

#game-card-flip-stage.card-correct-glow {
  border-radius: 10px;
  animation: card-correct-glow 420ms var(--ease-out);
}

/* Stacked exactly on top of each other (inset: 0 inside the now book-sized .card-flip-inner), each
   visible only while facing the viewer — backface-visibility is what makes the other one disappear
   past the 90deg midpoint instead of showing through as a mirrored duplicate. */
.card-flip-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
}

/* The face the flip reveals: pre-built (cards.ts, prepareFlipBack) with the next theme + the same
   player-colored gradient *before* the flip even starts, so there's never a blank/white instant once
   it comes into view. Never drawn on directly — a disposable preview, discarded in favor of the real,
   interactive .card-draw-frame once the flip settles (see playCardFlip). rotateY(180deg) is what puts
   it on the *other* side of .card-flip-inner to begin with, facing away until the flip turns it around. */
.card-flip-back {
  transform: rotateY(180deg);
}

/* Player-colored gradient, light at the center fading out to the dark shade at the edges/corners — a
   vignette, not a top-to-bottom fade (see .game-card-canvas, the same technique shared by every other
   screen that shows a card). Set as a fully resolved inline `background` on this canvas itself, by
   applyCardBackground in cardSticker.ts, not declared here against --card-grad-* custom properties —
   see that function for why. This rule's own background is only the brief placeholder before that JS
   runs (and never in practice, since the color is applied before the card becomes visible). */
.card-draw-frame .full-canvas {
  border: none;
  /* #card-draw-frame now has overflow: visible (see that rule further down — the theme sticker spills past
     its bottom edge), so it no longer clips this canvas's square corners to its own rounded ones; rounded
     here directly instead, matching the frame's own 10px radius minus its 4px border. */
  border-radius: 6px;
  margin: 0;
  background: var(--page-bg);
}

.tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-5);
  flex-shrink: 0;
  margin-bottom: var(--space-7);
}

#avatar-undo-button,
#avatar-clear-button,
#avatar-validate-button,
#card-undo-button,
#card-clear-button,
#card-validate-button {
  flex: 1 1 120px;
}

/* "Clear all" must be held down for HOLD_TO_CONFIRM_MS (see setupHoldToConfirm in client.ts)
   instead of a plain click, so one accidental tap never wipes a drawing — this fill sweeps across
   the button while held, giving a clear sense of progress toward the 1.5s threshold. */
.hold-to-confirm {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  /* A sustained press is exactly what triggers mobile browsers' own text-selection/copy-paste
     callout — without these, that UI fights our hold-to-confirm for the touch (see pointerdown
     handler in ui.ts). */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.hold-to-confirm::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 0%;
  background: var(--danger);
  z-index: -1;
}

.hold-to-confirm.holding::after {
  width: 100%;
  transition: width 1500ms linear;
}

.swatch {
  width: 2.1rem;
  height: 2.1rem;
  flex-shrink: 0;
  border-radius: 50%;
  border: 3px solid var(--ink);
  padding: 0;
}

.swatch.selected {
  box-shadow:
    0 0 0 3px var(--cream),
    0 0 0 6px var(--ink);
}

/* The billiard mini-game's play field: no arena chrome of its own (no border,
   background or team divider) — avatars sit directly in the screen's own card
   frame. position: relative + overflow: hidden gives teams-fling.ts a plain
   rectangular bounding box for wall collisions, and keeps a flung avatar from
   visually escaping past the field's own edges. It's a flex sibling of
   .teams-footer below (not an overlay), so the footer's own height is never
   something an avatar can be placed under or bounce into. */
.teams-field {
  position: relative;
  flex: 1;
  min-height: 280px;
  overflow: hidden;
}

/* The dashed "slingshot band" drawn from the dragged avatar's pulled-back
   position out to the raw pointer, while a player is pulling it back — see
   onDragMove in teams-fling.ts. left/top mark its start point, width is the
   drag distance, and the rotation (set inline) points it at the pointer;
   transform-origin keeps that rotation pivoting around the start point
   instead of the line's own center. */
.fling-pull-line {
  position: absolute;
  left: 0;
  top: 0;
  height: 0;
  border-top: 2px dashed var(--ink);
  opacity: 0.6;
  transform-origin: 0 0;
  pointer-events: none;
  z-index: 4;
}

.teams-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  margin-top: var(--space-6);
}

.teams-cards-badge {
  flex-shrink: 0;
  padding: 0.25rem var(--space-5);
  border-radius: 999px;
  background: var(--ink);
  font-family: var(--font-label);
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  color: var(--cream);
  line-height: 1;
  white-space: nowrap;
}

.teams-cards-badge.ready {
  background: var(--success);
}

.teams-waiting-label {
  margin: 0;
  font-family: var(--font-label);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--ink);
  opacity: 0.6;
}

.teams-figures {
  position: absolute;
  inset: 0;
}

/* Pure placement: left/top in %, centered on that point — its height is computed
   in JS (see addFigure in client.ts) to already fit the row it's in, so centering
   keeps it clear of both the crack and its own row's neighbors. */
.figure {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 2;
}

/* Physics offset from the figure's laid-out position, driven every frame by
   teams-fling.ts while that figure is coasting or being pulled back for a
   launch — translate(0, 0) at rest, so it's invisible until something throws
   it. Kept as its own layer (between .figure's placement and .figure-pose's
   rotation) so none of the three ever has to touch another's transform. */
.figure-fling {
  transform: translate(0, 0);
}

/* Per-figure decorative rotation, set inline via --rot. Kept separate from .figure
   so a future idle animation can be added to .figure-sprite without touching
   placement or this pose. */
.figure-pose {
  transform: rotate(var(--rot, 0deg));
  transform-origin: center;
  /* Gives the figure-idle-flip-y 3D rotation below a vanishing point to turn
     around, instead of just squashing flat at 90deg. No effect on the other
     idle animations, which stay 2D. */
  perspective: 400px;
}

.figure-sprite {
  position: relative;
}

.figure-sprite canvas {
  display: block;
}

/* Idle animations: a few different random behaviors so the arena doesn't look
   static or perfectly synced. Applied to .figure-sprite (not .figure itself),
   so they layer on top of the figure's fixed left/top placement and its
   .figure-pose rotation without ever touching either — each figure stays
   anchored to its own slot, only wobbling in place within a few px/deg. */
@keyframes figure-idle-tremble {
  0%,
  100% {
    transform: translate(0, 0) rotate(0deg);
  }
  20% {
    transform: translate(-1px, 0.6px) rotate(-0.6deg);
  }
  40% {
    transform: translate(1px, -0.5px) rotate(0.5deg);
  }
  60% {
    transform: translate(-0.6px, 1px) rotate(-0.5deg);
  }
  80% {
    transform: translate(0.8px, -0.8px) rotate(0.6deg);
  }
}

@keyframes figure-idle-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

@keyframes figure-idle-sway {
  0%,
  100% {
    transform: rotate(-1.6deg);
  }
  50% {
    transform: rotate(1.6deg);
  }
}

/* Mostly at rest, then a quick small hop with a tiny secondary bounce on
   landing, near the end of the cycle — the pause before/after is what reads
   as "every so often" rather than a continuous bounce. */
@keyframes figure-idle-hop {
  0%,
  60% {
    transform: translateY(0);
  }
  72% {
    transform: translateY(-9px);
  }
  84% {
    transform: translateY(0);
  }
  90% {
    transform: translateY(-2px);
  }
  100% {
    transform: translateY(0);
  }
}

/* Rest, then turn a full rotation around Y (the .figure-pose perspective above
   gives it a vanishing point) so it shows its back edge-on mid-turn, ending
   back at its normal, unflipped orientation. */
@keyframes figure-idle-flip-y {
  0%,
  70% {
    transform: rotateY(0deg);
  }
  85% {
    transform: rotateY(180deg);
  }
  100% {
    transform: rotateY(360deg);
  }
}

/* Rest, then a quick full spin around Z (flat, in the plane of the screen). */
@keyframes figure-idle-spin-z {
  0%,
  75% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.figure-idle-tremble {
  animation-name: figure-idle-tremble;
  animation-timing-function: steps(1, end);
  animation-iteration-count: infinite;
}

.figure-idle-float {
  animation-name: figure-idle-float;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
}

.figure-idle-sway {
  animation-name: figure-idle-sway;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
}

.figure-idle-hop {
  animation-name: figure-idle-hop;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
}

.figure-idle-flip-y {
  animation-name: figure-idle-flip-y;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
}

.figure-idle-spin-z {
  animation-name: figure-idle-spin-z;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
}

.figure-label {
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  margin-top: 2px;
  pointer-events: none;
  font-family: var(--font-label);
  font-size: 0.6rem;
  text-transform: uppercase;
  color: var(--ink);
  background: rgba(245, 238, 221, 0.85);
  padding: 0.1rem var(--space-3);
  border-radius: 6px;
  white-space: nowrap;
}

/* Team 2's back row sits near the arena's bottom edge: a label below the figure
   (the default, which reads fine for team 1 since "below" points inward toward
   the crack there) would get clipped by the arena's overflow/rounded corner, so
   flip it to sit above the figure instead, same as it points inward for team 1. */
#teams-figures-bottom .figure-label {
  top: auto;
  bottom: 100%;
  margin-top: 0;
  margin-bottom: 2px;
}

/* --- Game screen (the 3 Time's Up rounds) --- */

.game-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-bottom: var(--space-7);
  padding-bottom: var(--space-6);
  padding-right: 2.75rem; /* clears the .pot-seal button, which sits top-right over this bar */
  border-bottom: 3px solid var(--ink);
  font-family: var(--font-label);
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--ink);
}

.game-round-label {
  color: var(--band-dark);
}

/* The word just confirmed "Correct", shown briefly to spectators only (see
   TurnActiveSpectatorPayload.lastValidatedWord) so they can check the storyteller's call wasn't abusive —
   especially useful in rounds 2-3, where spectators otherwise never see the card's title at all. */
/* Reuses the card's own theme-sticker look (.game-card-title, cardSticker.ts's renderThemeSticker) —
   same override pattern as #theme-reveal-word above, for the same reason: a plain green-bordered box
   read as a generic alert rather than "this is the word that was on the card". Floats centered over the
   whole game screen (#game-screen, the positioned ancestor the pause overlay also anchors to) instead of
   sitting in the active view's normal flow: at this size it would otherwise land wherever the turn
   announcement/card happen to leave room above them, not necessarily the middle of the screen. */
#game-spectator-last-word.game-card-title {
  position: absolute;
  top: 50%;
  left: 50%;
  bottom: auto;
  z-index: 3;
  margin: 0;
  max-width: 90%;
  transform: translate(-50%, -50%) rotate(var(--sticker-rotate, -4deg));
}

.game-spectator-last-word.fade-out {
  animation: spectator-last-word-fade 2.6s ease forwards;
}

@keyframes spectator-last-word-fade {
  0% {
    opacity: 1;
  }
  65% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.game-cards-left {
  flex-shrink: 0;
  padding: 0.25rem 0.55rem;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: rgba(245, 238, 221, 0.85);
  font-family: var(--font-label);
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--ink);
}

/* --- Active turn screen: the storyteller's name on the left, "Cards left" boxed on the right, same height --- */
.game-active-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-7);
  width: 100%;
  margin: var(--space-2) 0 0;
}

.game-active-header .game-turn-announcement {
  margin: 0;
  justify-content: flex-start;
  /* Lets this item shrink below its text's natural width (the flex default, min-width: auto, would
     otherwise hold it at full content width and push .game-cards-left off-screen for a long pseudo) —
     paired with the ellipsis truncation below, the badge next to it always stays fully visible. */
  min-width: 0;
  flex: 1 1 auto;
}

/* On the active (timed) screen, the team badge + pseudo read as the actual label, flush with the
   card/timer-bar edges below them — the storyteller's small avatar trails after the pseudo instead
   of leading, so it never pushes that label away from the left edge. */
#game-active-avatar {
  order: 2;
  flex-shrink: 0;
}

#game-active-text {
  order: 1;
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-width: 0;
}

/* Timer bar + numeric timer, side by side at the same height — the bar takes the remaining
   width next to the timer box instead of spanning full-width on its own row. */
.game-timer-row {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  width: 100%;
  margin: var(--space-4) 0 var(--space-6);
}

.game-timer-bar {
  flex: 1 1 auto;
  min-width: 0;
  height: 6px;
  border-radius: 3px;
  background: rgba(20, 20, 20, 0.12);
  overflow: hidden;
}

.game-timer-bar-fill {
  height: 100%;
  width: 100%;
  background: var(--band-dark);
  border-radius: inherit;
  transition: width 0.25s linear;
}

.game-timer-bar-fill.low {
  background: var(--danger);
}

/* A small version of the 3-2-1 countdown circle (.game-countdown): same double ink/cream ring and
   outlined sticker digits, scaled down to sit next to the timer bar instead of center stage. */
.game-timer-row .game-timer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 50%;
  background: var(--band-dark);
  box-shadow:
    0 0 0 2px var(--ink),
    0 0 0 4px var(--cream);
  font-family: var(--font-sticker);
  font-size: 1rem;
  line-height: 1;
  color: var(--cream);
  text-shadow:
    -1px -1px 0 var(--ink),
    1px -1px 0 var(--ink),
    -1px 1px 0 var(--ink),
    1px 1px 0 var(--ink);
}

@keyframes timer-urgent {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.12);
  }
}

.game-timer.low {
  background: var(--danger);
  animation: timer-urgent 1s ease-in-out infinite;
}

/* Still needed as a positioned ancestor even though the pause overlay below no longer anchors here
   (see .game-paused-banner) — #game-spectator-last-word.game-card-title (style.css, further down) still
   centers itself against this box. */
#game-screen {
  position: relative;
}

/* A full dimming overlay over the whole card frame (band included, not just the active-round screen
   below it — see index.html, a sibling of .pot-band rather than a child of #game-screen) instead of
   just a banner squeezed into the normal flow — makes "the game is actually stopped" unmistakable at a
   glance, for every player, not just whoever notices the disabled buttons. Anchored on .pot-clip (its
   nearest positioned ancestor, already position: relative) rather than #game-screen: moved here on
   2026-11-28 after the band staying lit during a pause read as the overlay not covering "the whole
   window". */
.game-paused-banner {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
  padding: var(--space-5);
  /* Same radius as .pot-clip itself, the rounded "paper" frame this now directly sits inside — without
     it, this overlay's own square corners read as a mismatched rectangle dropped on top of that rounded
     shape. */
  border-radius: 12px;
  background: rgba(20, 20, 20, 0.6);
}

.game-paused-banner-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-6);
  padding: var(--space-6) var(--space-8);
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: var(--band-light);
  font-family: var(--font-label);
  font-size: 1.1rem;
  text-transform: uppercase;
  color: var(--ink);
  box-shadow: 2px 3px 0 var(--ink);
}

.game-paused-banner-actions {
  display: flex;
  gap: var(--space-5);
}

/* Same edge-bleed trick as ".pot-content > section" above: the negative margin +
   matching padding cancel out visually but keep decorative overflow (card flash
   glow, focus outlines) from being clipped by this view's own overflow-x. */
.game-view:not([hidden]) {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-height: 0;
  text-align: center;
  margin: 0 -12px;
  padding: 0 12px;
  overflow-x: hidden;
  overflow-y: auto;
}

.game-turn-announcement {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-5);
  margin: var(--space-5) 0;
  font-family: var(--font-display);
  font-weight: 900;
  font-style: italic;
  font-size: 1.6rem;
  color: var(--ink);
}

.game-turn-name {
  font-weight: 900;
  /* On the active header (#game-active-text), the pseudo is a flex item next to the team badge and
     timer: text-overflow on the flex container itself is a no-op (it only ellipsizes a container's own
     text, not a child's), so a long pseudo was getting hard-clipped with no "…". Ellipsizing the pseudo
     span itself fixes that; harmless elsewhere (.game-waiting-text isn't width-constrained, so this never
     triggers there). */
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Keeps the "'s turn" suffix (see renderTurnAnnouncement) from being squeezed away to nothing on the
   active header — it's short and purely grammatical, so the badge and pseudo should give way first. */
.game-turn-suffix {
  flex-shrink: 0;
}

/* --- Small avatar, reused wherever a player's name appears (turn announcements, round recap) — shown in
   transparency (no frame, no background disc): just the strokes themselves, floating over the screen. */
.small-avatar-circle {
  width: 2.6rem;
  height: 2.6rem;
  flex-shrink: 0;
}

/* The waiting screen (whose turn it is, before the storyteller starts) has little else to show, so its
   avatar goes large, stacked above the name instead of side by side. */
#game-waiting-announcement {
  flex-direction: column;
  gap: var(--space-6);
}

#game-waiting-announcement .small-avatar-circle {
  width: 6.5rem;
  height: 6.5rem;
}

/* Gives the figure-idle-flip-y idle animation (applied to the avatar below in turn.ts, same
   classes as the teams arena's figures — see .figure-pose) a vanishing point to turn around,
   instead of just squashing flat at 90deg. No effect on the other idle animations, which stay 2D. */
#game-waiting-avatar {
  perspective: 400px;
}

.small-avatar-circle canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* --- Turn screen: the active team's name, shown as a small badge to the left of the storyteller's
   pseudo in the "<pseudo>'s turn" line (waiting and active screens alike). --- */
.game-turn-team-badge {
  display: inline-block;
  margin-right: var(--space-4);
  padding: 0.25rem 0.55rem;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: var(--band-light);
  font-family: var(--font-label);
  font-size: 0.7rem;
  text-transform: uppercase;
  vertical-align: middle;
  color: var(--ink);
  /* On the active header, a long team name competes with the pseudo for the same cramped row (see
     .game-turn-name) — let this shrink and ellipsize too instead of staying rigid and starving the
     pseudo down to nothing. No-op anywhere the row isn't actually width-constrained. */
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Round rules: shown once per round, merged into the top of its first turn screen — the round's name
   gets its own small framed header, sitting above the (separately framed) rules list. --- */
.game-rules-inline {
  width: 100%;
  max-width: 420px;
  margin: 0 0 var(--space-7);
}

.game-rules-heading-box {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto var(--space-4);
  padding: var(--space-3) 0.9rem;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: #fff;
  text-align: center;
}

.game-rules-heading-box h2 {
  margin: 0;
}

.game-rules-list {
  box-sizing: border-box;
  margin: 0;
  padding: 0.7rem 0.9rem;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  text-align: left;
  width: 100%;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: #fff;
}

.game-rules-list li {
  position: relative;
  padding-left: 1.1rem;
  color: var(--ink);
  font-size: 0.9rem;
}

.game-rules-list li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--band-dark);
  font-weight: 900;
}

/* The 3-2-1-GO countdown: a circle in the same "card sticker" style as the theme label pinned on
   a card (.game-card-title) — the storyteller's own pen color as fill (--card-grad-dark, set by
   applyCardColors in turn.ts, same as the sticker reads it), double ink/cream ring, same slab font
   with its thick ink outline — but with the options popup's flat, hard-edged shadow (see
   .pot-seal-menu) instead of the sticker's own soft, blurred one. Fixed width/height (rather than
   the sticker's padding-driven box) is what keeps this a perfect circle for any of "3"/"2"/"1"/"GO!". */
.game-countdown {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 6.5rem;
  height: 6.5rem;
  margin: var(--space-7) auto;
  border-radius: 50%;
  background: var(--card-grad-dark, var(--ink));
  box-shadow:
    0 0 0 3px var(--ink),
    0 0 0 6px var(--cream),
    2px 3px 0 var(--ink);
  font-family: var(--font-sticker);
  font-size: 2.1rem;
  line-height: 1;
  color: var(--cream);
  text-shadow:
    -2px -2px 0 var(--ink),
    2px -2px 0 var(--ink),
    -2px 2px 0 var(--ink),
    2px 2px 0 var(--ink),
    0 -2px 0 var(--ink),
    0 2px 0 var(--ink),
    -2px 0 0 var(--ink),
    2px 0 0 var(--ink),
    4px 5px 0 var(--ink);
}

@keyframes countdown-beat {
  0% {
    transform: scale(0.6);
    opacity: 0;
  }
  60% {
    transform: scale(1.15);
    opacity: 1;
  }
  100% {
    transform: scale(1);
  }
}

.game-countdown.beat {
  animation: countdown-beat 260ms var(--ease-out);
}

/* Pinned to the bottom of the waiting view's flex column instead of sitting right under the
   avatar/name, so it lands in the same reachable spot regardless of how much (rules, team
   badge...) is stacked above it. Same treatment on user feedback (2026-11-30) for the host's own
   "continue" action on every other game-view that ends in one — round recap (Next round/See
   results), victory (See card highlights) — instead of it sitting right under whatever content
   (badges, player list...) happens to be above it. Each one's own .screen-hint, shown to everyone
   else in that same spot while they wait on the host, gets the identical margin: exactly one of a
   button/hint pair is ever actually in flow at a time (the other is [hidden], out of the flex
   layout entirely), so whichever one applies still lands at the bottom either way. */
#game-ready-button,
#game-next-round-button,
#game-victory-continue-button,
#game-recap-waiting-hint,
#game-cards-recap-start-button,
#game-victory-waiting-hint {
  margin-top: auto;
}

/* The theme "sticker": a rounded label stuck on top of the card's drawing near the bottom, instead
   of a flat banner outside it — see cardSticker.ts for the per-card corner radii (border-radius,
   derived from the card's own text so it's identical everywhere that card is shown again, slightly
   different from one card to the next for a hand-stuck-on rather than vector-precise look) and color
   variant (dark player color fill, or this reference's second "pastel" treatment below — the
   sticker-variant-1 class, picked once at random and kept forever on the card). Shared by every
   screen that shows a finished/live card (draw screen, live turn, cards-recap, gallery, museum): each
   just needs its own ancestor with --card-grad-dark/--card-grad-light set (see .game-card). The
   double ring (ink inner, cream outer, via stacked box-shadows since a single border can't do two
   colors — the cream has to be the outer one so it reads as the sticker's own white backing paper
   peeking out past its printed black outline, like a real sticker, rather than a white gap between
   the ink and the fill) plus the soft offset drop-shadow is what sells the "sticker stuck on top"
   look. No tilt (the var(--sticker-rotate, 0deg) fallback below) and pushed just past the card's own
   bottom edge (bottom: -2%, versus sitting inside it) on every screen alike — each one's own frame
   has overflow: visible for exactly this (see #card-draw-frame/#game-card/#cards-recap-card-frame/
   etc. below), and growToFill (cardSticker.ts's renderThemeSticker/fitStickerFontToFill) is what lets
   the sticker's own font grow to actually fill that fixed-looking footprint instead of just
   shrink-wrapping a short word. */
.game-card-title {
  position: absolute;
  left: 50%;
  bottom: -2%;
  z-index: 2;
  pointer-events: none;
  margin: 0;
  padding: 0.6rem 1.1rem;
  max-width: 90%;
  box-sizing: border-box;
  border: none;
  border-radius: 10px;
  background: var(--card-grad-dark, var(--ink));
  box-shadow:
    0 0 0 3px var(--ink),
    0 0 0 6px var(--cream),
    5px 7px 6px rgba(0, 0, 0, 0.35);
  color: var(--cream);
  font-family: var(--font-sticker);
  font-size: 1.1rem;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow:
    -2px -2px 0 var(--ink),
    2px -2px 0 var(--ink),
    -2px 2px 0 var(--ink),
    2px 2px 0 var(--ink),
    0 -2px 0 var(--ink),
    0 2px 0 var(--ink),
    -2px 0 0 var(--ink),
    2px 0 0 var(--ink),
    4px 5px 0 var(--ink);
  transform: translateX(-50%) rotate(var(--sticker-rotate, 0deg));
}

/* The 2nd reference's "pastel" sticker treatment: the illustrator's pale pen color standing in for
   the dark one, same ink/cream ring and cream text on top — alternates with the plain dark fill
   above at random (pickStickerVariant), same as the tilt is random, each pick kept forever. */
.game-card-title.sticker-variant-1 {
  background: var(--card-grad-light, var(--ink));
}

/* The live round's own sticker only (storyteller and spectator alike) — the one sticker that's ever shown
   masked, then revealed live on screen in place (see revealMaskedSticker, cardSticker.ts). Pinned to a
   fixed footprint regardless of its word: `width` (rather than the `max-width` above, which still lets a
   shorter word shrink-wrap) and a `line-height` fixed in rem rather than deriving from font-size, so
   fitCardTitle shrinking the font for a long theme can't shrink the box's height either. Elsewhere
   (draw screen, cards-recap, gallery, museum) the sticker is always already revealed, so hugging each
   word's own width is harmless flavor — only here would a size that varies by word double as a hint
   at its length, and only here does the mask have to match the revealed sticker's own size exactly for
   the reveal not to visibly resize the frame. */
#game-card-title {
  width: 70%;
  /* Tighter than the 1.1rem/0.85rem above on every side: narrower to leave the text more of that narrower
     box to fill before fitStickerFontToFill (cardSticker.ts) has to shrink a long theme, and shorter since
     the base rule's padding was sized for a bigger sticker that needed more breathing room than this one. */
  padding: 0.4rem;
  line-height: 1.3rem;
}

/* Lets every screen's sticker spill a little past the card's own bottom edge (the base .game-card-title
   rule's `bottom: -2%` above) instead of being clipped flush with it — overriding the base .card-draw-
   frame/.game-card rule's own overflow: hidden, still in effect everywhere else on these frames (e.g. to
   square off a drawing's corners to the card's rounded ones — each .game-card-canvas's own border-radius
   below takes over that one job so this override doesn't also square them off). */
#card-draw-frame,
#card-flip-back,
#game-card,
#cards-recap-card-frame,
#gallery-overlay-card-frame,
#museum-card-frame {
  overflow: visible;
}

/* Extra breathing room below the card, on top of its own default margin-bottom (.card-flip-stage's for
   the draw screen/live round, .game-card's for cards-recap): now that the sticker spills past the card's
   bottom edge (see the overflow: visible rule above), that default gap alone left it sitting right
   against the controls below (illustration screen's tools row, live round's Pause/Submit/Pass row,
   cards-recap's Next button). */
#card-flip-stage,
#game-card-flip-stage,
#cards-recap-card-frame {
  margin-bottom: calc(var(--space-7) + 1rem);
}

/* Masked sticker (see renderMaskedSticker, cardSticker.ts): same slot, size and ring as the real sticker
   above (#game-card-title's own fixed size, see that rule) — then a post-it with a strip of tape on each
   of its 4 sides sits centered on top, small enough to leave the ring visible past its own edges
   (reference: variant 19 of the masking comparison). */
.game-card-title.sticker-masked {
  /* Overrides the ellipsis-truncation overflow:hidden above — needed here so the tape strips (positioned
     slightly outside this box, overlapping the ring left visible around the post-it) aren't clipped. */
  overflow: visible;
}

/* Sized relative to the sticker (not the post-it) — everything inside it (the post-it fill and its 4
   tape strips, see below) is then positioned as a % of *this* box, so the tape hugs the post-it's own
   edges regardless of how much bigger the surrounding sticker is. */
.sticker-masked-postit-wrap {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 62%;
  height: 52%;
  transform: translate(-50%, -50%);
}

.sticker-masked-postit {
  position: absolute;
  inset: 0;
  background: #fdeea0;
  border-radius: 3px;
  box-shadow: 1px 2px 3px rgba(0, 0, 0, 0.35);
}

.sticker-masked-tape {
  position: absolute;
  background: rgba(218, 208, 188, 0.92);
  border-radius: 1px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.sticker-masked-tape--top,
.sticker-masked-tape--bottom {
  left: 50%;
  width: 37%;
  height: 35%;
  transform: translateX(-50%);
}

.sticker-masked-tape--top {
  top: -27%;
}

.sticker-masked-tape--bottom {
  bottom: -27%;
}

.sticker-masked-tape--left,
.sticker-masked-tape--right {
  top: 50%;
  width: 9%;
  height: 69%;
  transform: translateY(-50%);
}

.sticker-masked-tape--left {
  left: -7%;
}

/* revealMaskedSticker (cardSticker.ts): the post-it laid back on top of the now-correct sticker, shrunk
   away in place to reveal it — the same translate(-50%, -50%) centering as the base rule above has to be
   restated here since an animated `transform` replaces the whole property, not just the parts it sets. */
.sticker-masked-postit-wrap--peel {
  animation: sticker-masked-postit-peel 380ms ease-in forwards;
}

@keyframes sticker-masked-postit-peel {
  0% {
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(0.15) rotate(20deg);
    opacity: 0;
  }
}

.sticker-masked-tape--right {
  right: -7%;
}

/* The live round's theme + drawing, wrapped together in a single frame so the whole thing reads as
   one physical card: the player-colored gradient fills it edge to edge, with the theme sticker
   (.game-card-title) pinned on top near the bottom — reused as-is for every other screen that shows
   a finished card (cards-recap, gallery, museum), each wrapping its own title+canvas pair in a
   `.game-card` with --card-grad-light/--card-grad-dark set from that card's illustrator colors. */
.game-card {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  margin-bottom: var(--space-7);
  /* Same hard offset shadow as .pot-seal-menu, no blur — the "bold ink" look of flat paper stacked
     on top of the page, rather than a soft/realistic drop shadow. */
  box-shadow: 2px 3px 0 var(--ink);
}

.game-card-canvas {
  flex: 1 1 auto;
  min-height: 0;
  box-sizing: border-box;
  max-width: 100%;
  width: auto;
  height: auto;
  /* object-fit: contain is the safety net for .gallery-overlay-card below, whose
     align-items: stretch forces this canvas's box to the popup's full width regardless
     of the drawing's own aspect ratio — without it, a card drawn tall/narrow (typically
     a phone, whose drawing area follows the screen's own shape — see .full-canvas) gets
     stretched sideways to fill that box instead of staying letterboxed at its real shape. */
  object-fit: contain;
  border: none;
  margin: 0;
  /* Now that every .game-card/.card-draw-frame instance has overflow: visible (so the theme sticker can
     spill past its bottom edge), this frame no longer clips the canvas's square corners to its own
     rounded ones — rounded here directly instead, so a drawing's corners stay rounded everywhere.
     6px (not the frame's own 10px): the canvas sits inset by the frame's 4px border, so matching its
     outer radius left the canvas's own corner curve pulling back further than the frame's actual inner
     curve at that inset — a sliver of the frame's white background (.game-card/.card-draw-frame) showing
     through at each corner, reported as "petits coins blancs" on every live game/recap/gallery/museum
     card. Same 10-4=6 reasoning as .card-draw-frame .full-canvas below, just computed from .game-card's
     radius instead of .full-canvas's own 3px-bordered frame. */
  border-radius: 6px;
  /* Set as a fully resolved inline `background` by applyCardBackground (cardSticker.ts) — see the
     matching comment on .card-draw-frame .full-canvas above for why not a var()-based rule here. */
  background: var(--page-bg);
}

/* The live round's card (#game-card) is wrapped in the same flip rig as the illustration screen's
   (.card-flip-stage/.card-flip-inner/.card-flip-face/.card-flip-back, all generic — see cards.ts/
   style.css for the full mechanics) so it can physically turn over on Correct/Wrong/Pass instead of
   just flashing in place. Nested inside that rig, .game-card itself no longer needs its own
   margin-bottom — that spacing now lives on .card-flip-stage, same as .card-draw-frame's own.
   position: absolute also has to be repeated here: .game-card alone sets position: relative (it's
   reused as a normal flex child on the recap/gallery/museum screens, declared later in this file),
   which otherwise wins the cascade over .card-flip-face's own position: absolute at equal
   specificity — leaving #game-card sized by its own content (the canvas's full intrinsic pixel size)
   instead of filling .card-flip-inner, and overflowing straight over .game-storyteller-actions below
   it. The combined selector's higher specificity is what makes absolute win here regardless of
   source order. */
.card-flip-face.game-card {
  position: absolute;
  margin-bottom: 0;
}

/* The back face turn.ts reveals mid-flip (playCardOutcomeFlip): plain and blank, unlike the
   illustration screen's flip, since the next card isn't known yet at the moment this flip starts (it
   only comes back from the server after the Correct/Wrong/Pass itself is sent) — there's nothing real
   to preview, so it just falls back to .game-card's own default look until the real content swaps in. */

/* Same correct/wrong feedback, echoed on the page background behind the app's framed window itself
   (body, outside the rounded <main> card) rather than inside it — reusing the exact gradient
   format --page-bg itself gets set to once in a room (join.ts, "room:joined"): a vertical band,
   the main color top and bottom with a cream stripe at 66%. Only that main color changes
   (green/red here, the player's own light color normally); the cream stripe stays put, and only
   opacity animates, so it still reads as the same gradient throughout, not a flat wash. */
@keyframes page-flash {
  0%,
  100% {
    opacity: 0;
  }
  30% {
    opacity: 1;
  }
}

/* Fixed, pointer-events:none layer behind <main> (negative z-index) — not body itself. Reaches the
   true bottom edge (no safe-area inset there) so the flash's gradient runs all the way behind a
   phone's translucent system/gesture navigation bar instead of stopping short of it — only the top
   stays inset, there being no equivalent translucent bar to bleed behind up there. */
.screen-flash-layer {
  position: fixed;
  top: env(safe-area-inset-top, 0px);
  right: 0;
  bottom: 0;
  left: 0;
  /* `bottom: 0` alone leaves a gap at the very bottom on some mobile browsers, which don't reliably
     re-run a fixed element's layout against the live viewport as their own address bar collapses/
     expands mid-session — an explicit height, like body's own 100vh/100dvh fallback pair above, tracks
     that live viewport directly instead of depending on that recalculation. */
  height: 100vh;
  height: 100dvh;
  z-index: -1;
  pointer-events: none;
  opacity: 0;
}

.screen-flash-layer.screen-flash-correct {
  background: linear-gradient(180deg, var(--success), var(--cream) 66%, var(--success));
  animation: page-flash 320ms var(--ease-out);
}

.screen-flash-layer.screen-flash-negative {
  background: linear-gradient(180deg, var(--danger), var(--cream) 66%, var(--danger));
  animation: page-flash 320ms var(--ease-out);
}

/* A Wrong confirmation also rattles the app's own framed window (main#app) — Correct and Pass never
   do, so a shake alone is enough to tell a Wrong apart from a Pass even with sound off. */
@keyframes app-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-6px);
  }
  40% {
    transform: translateX(5px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(3px);
  }
}

main.shake-wrong {
  animation: app-shake 320ms ease-in-out;
}

.game-storyteller-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-5);
  width: 100%;
  flex-shrink: 0;
}

.game-storyteller-actions button {
  flex: 1 1 100px;
}

/* Button text defaults to --band-light, overridden to the player's own identity color once the
   game starts (can land on a reddish tone that reads as a warning) — Pass/Submit opt back into the
   neutral cream instead, and Pause gets its own fully distinct frame (cream background, black
   border and text) to stand out from the other two actions. */
.game-storyteller-actions #game-pass-button,
.game-storyteller-actions #game-validate-button {
  color: var(--cream);
}

/* Round 1's "Correct" (see gameValidateButton.classList.toggle("theme-reveal-correct", ...) in
   client.ts) reuses the rounds 2-3 modal button's green styling — needs the extra class to beat
   the cream color above on specificity. */
.game-storyteller-actions #game-validate-button.theme-reveal-correct {
  color: var(--success);
}

.game-storyteller-actions #game-pause-button {
  color: var(--ink);
  background: var(--cream);
  border: 3px solid var(--ink);
}
/* --- Theme reveal: the storyteller's check, in rounds 2-3, of their team's guess against the real theme
   behind the current card (see "game:card-submit"/"game:card-revealed" in client.ts) --- */
/* --- Modal (shared overlay backdrop, bordered panel, corner close button) ---
   Reused by theme-reveal (below), kick/rename (.kick-overlay further down) and how-to-play — each
   keeps its own class in the HTML too, both for the JS that selects it (always by id, never by
   these classes) and for the size/padding deltas kept on that class below. */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-9);
  background: rgba(20, 20, 20, 0.55);
}

.modal-panel {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: var(--cream);
}

.modal-close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 1.2rem;
  line-height: 1;
}

.modal-close:hover {
  filter: none;
  opacity: 0.6;
}

.theme-reveal-panel {
  max-width: 320px;
  padding: var(--space-10) var(--space-8) var(--space-9);
  text-align: center;
}

.theme-reveal-hint {
  margin: 0 0 var(--space-3);
  font-family: var(--font-label);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink);
  opacity: 0.7;
}

/* Reuses the live card's own theme-sticker look (.game-card-title, cardSticker.ts's renderThemeSticker)
   instead of plain text — same chrome the word already wears everywhere else it's shown. Overrides the
   base rule's position: absolute (meant for pinning over a .game-card) back to a normal static chip,
   centered in this plain modal panel instead. The ID+class pairing is what beats .game-card-title's own
   specificity for position/margin/display without having to touch that shared rule itself. */
#theme-reveal-word.game-card-title {
  position: static;
  display: inline-block;
  margin: 0 0 var(--space-8);
  max-width: 100%;
  transform: rotate(var(--sticker-rotate, -4deg));
}

.theme-reveal-actions {
  display: flex;
  gap: var(--space-5);
}

.theme-reveal-actions button {
  flex: 1 1 auto;
}

/* Light tint fills (not the solid colors other buttons use) so "Wrong"/"Correct" read as a pale
   red/green accent rather than a loud alert — border keeps the strong hue for identity, and the
   dark ink text clears contrast easily against these light backgrounds. */
.theme-reveal-wrong {
  background: var(--danger-pale);
  border-color: var(--danger);
  color: var(--danger);
}

/* --- Kick player list (host-only, pot-seal menu) --- */
.kick-panel {
  max-width: 340px;
  max-height: 80vh;
  padding: var(--space-10) var(--space-8) var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.kick-panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-6);
}

.kick-panel-header h3 {
  margin: 0;
  font-family: var(--font-label);
  font-size: 0.9rem;
  text-transform: uppercase;
  color: var(--ink);
}

.kick-panel-hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--ink);
  opacity: 0.7;
}

.kick-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  overflow-y: auto;
}

.kick-row {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-3) var(--space-4);
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: var(--band-light);
}

.kick-row-pseudo {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.kick-row-button {
  flex: 0 0 auto;
  padding: 0.35rem 0.7rem;
  background: var(--danger-pale);
  border-color: var(--danger);
  color: var(--ink);
  font-size: 0.7rem;
}

.kick-empty {
  margin: 0;
  font-size: 0.8rem;
  color: var(--ink);
  opacity: 0.7;
  text-align: center;
}

#rename-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.rename-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-4);
}

.rename-cancel-button {
  background: var(--band-light);
  border-color: var(--ink);
  color: var(--ink);
}

.theme-reveal-correct {
  background: var(--success-pale);
  border-color: var(--success);
  color: var(--success);
}

/* --- How to play (join screen only) --- */

/* margin-top: auto pins the pair to the bottom of the join screen's flex column (see
   .pot-content > section rule), whatever the rest of the screen's content height ends up being. */
.join-footer-actions {
  margin-top: auto;
  align-self: center;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-6);
}

/* Outline/ghost style, unlike every solid-ink button elsewhere, so it reads as a quieter, optional
   link rather than competing with "Create a room" for attention. */
.how-to-play-button {
  background: transparent;
  color: var(--ink);
  border: 2px solid var(--ink);
}

@keyframes how-to-play-pop-in {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.how-to-play-panel {
  max-width: 360px;
  padding: var(--space-10) var(--space-9) var(--space-9);
  display: flex;
  flex-direction: column;
  animation: how-to-play-pop-in 220ms var(--ease-out);
}

/* Sits above .how-to-play-track's pages, which .modal-close doesn't need elsewhere. */
.how-to-play-close {
  z-index: 1;
}

/* Clips the track to one page's width — only the active page (and its horizontal neighbours,
   mid-swipe) is ever visible. */
.how-to-play-viewport {
  overflow: hidden;
  touch-action: pan-y;
  cursor: grab;
}

.how-to-play-viewport:active {
  cursor: grabbing;
}

/* Three fixed pages (see index.html) — width is 3 viewports wide so each page's own 33.33% flex-basis
   works out to exactly one full viewport, which is what the index*(100/pageCount)% translateX in
   client.ts assumes. Hardcoded rather than computed, since the page count here is fixed content, not
   data-driven. */
.how-to-play-track {
  display: flex;
  width: 300%;
  transition: transform 320ms var(--ease-out);
}

.how-to-play-page {
  flex: 0 0 33.3334%;
  min-width: 0;
  box-sizing: border-box;
  padding: var(--space-4) 0.25rem var(--space-7);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  text-align: center;
}

.how-to-play-icon {
  font-size: 2.4rem;
  line-height: 1;
}

.how-to-play-page h3 {
  margin: 0;
  font-family: var(--font-label);
  font-size: 1rem;
  text-transform: uppercase;
  color: var(--ink);
}

.how-to-play-page p {
  margin: 0;
  color: var(--ink);
  line-height: 1.4;
}

.how-to-play-rounds {
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  text-align: left;
}

.how-to-play-rounds li {
  padding: var(--space-4) 0.7rem;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: #fff;
  line-height: 1.35;
}

.how-to-play-dots {
  display: flex;
  justify-content: center;
  gap: var(--space-3);
  margin: var(--space-4) 0 var(--space-7);
}

.how-to-play-dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--ink);
  opacity: 0.3;
  transition:
    opacity 160ms ease,
    transform 160ms var(--ease-out);
}

.how-to-play-dot.active {
  opacity: 1;
  transform: scale(1.3);
}

.how-to-play-nav {
  display: flex;
  justify-content: space-between;
  gap: var(--space-5);
}

/* Reserves its own space on page 1 instead of being removed from flow, so the "Next" button
   never jumps sides as the Previous button appears/disappears while flipping through. */
.how-to-play-prev.is-hidden {
  visibility: hidden;
  pointer-events: none;
}

.how-to-play-next {
  margin-left: auto;
}

/* Same pale-green "correct" tint as .theme-reveal-correct, on the final page — a quiet visual cue
   that this button now closes the explainer rather than advancing it. */
.how-to-play-next.how-to-play-done {
  background: var(--success-pale);
  border-color: var(--success);
  color: var(--success);
}

.how-to-play-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-9) var(--space-4);
  color: var(--success);
}

.how-to-play-success p {
  margin: 0;
  font-family: var(--font-label);
  font-size: 1rem;
  text-transform: uppercase;
  color: var(--ink);
}

.how-to-play-check-svg {
  width: 72px;
  height: 72px;
  transform: scale(0);
  animation: how-to-play-check-pop 420ms var(--ease-out) forwards;
}

.how-to-play-check-circle {
  stroke: var(--success);
}

.how-to-play-check-mark {
  stroke: var(--success);
}

/* A juicy bump instead of a stroke-draw — the whole checkmark pops in from nothing rather
   than tracing itself, which read as jerky at this size. */
@keyframes how-to-play-check-pop {
  0% {
    transform: scale(0);
  }
  70% {
    transform: scale(1.15);
  }
  100% {
    transform: scale(1);
  }
}

/* A juicy exit once "Got it!" has held its checkmark for a beat (see client.ts) — a small
   anticipatory bump before the whole panel collapses to nothing, instead of just vanishing. */
@keyframes how-to-play-pop-out {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  25% {
    transform: scale(1.08);
    opacity: 1;
  }
  100% {
    transform: scale(0);
    opacity: 0;
  }
}

.how-to-play-panel.is-closing {
  animation: how-to-play-pop-out 380ms cubic-bezier(0.47, 0, 0.75, 0.37) forwards;
}

/* --- Page 1 illustration: a little fan of phones, one per player --- */
.how-to-play-phones {
  position: relative;
  width: 100%;
  height: 64px;
  margin-bottom: 0.25rem;
}

.how-to-play-phone {
  position: absolute;
  top: 50%;
  left: 50%;
  font-size: 2rem;
  line-height: 1;
}

.how-to-play-phone-left {
  transform: translate(-150%, -45%) rotate(-16deg);
  opacity: 0.75;
}

.how-to-play-phone-right {
  transform: translate(50%, -45%) rotate(16deg);
  opacity: 0.75;
}

.how-to-play-phone-center {
  z-index: 1;
  font-size: 2.3rem;
  transform: translate(-50%, -50%);
}

/* --- Page 2 illustration: a miniature replica of the real card-draw-frame (see .card-draw-frame/
   .card-draw-theme), with Mr. Hankey mid-sketch in a single brown stroke, looping forever while
   this page is in view — a wink at the game's own "single stroke" drawing style. --- */
.how-to-play-mini-card {
  width: 170px;
  max-width: 72%;
  margin: 0 auto 0.25rem;
  border: 3px solid var(--ink);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

/* Scoped under .how-to-play-mini-card (two classes) rather than just its own class, so this beats
   the ".how-to-play-page p" rule's higher specificity (class+type) — otherwise that generic rule
   silently wins and the title renders in ink instead of cream, invisible against the black band. */
.how-to-play-mini-card .how-to-play-mini-card-title {
  margin: 0;
  padding: var(--space-2) var(--space-5);
  background: var(--ink);
  color: var(--cream);
  font-family: var(--font-label);
  font-size: 0.65rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-align: center;
  white-space: nowrap;
}

.how-to-play-mini-card-canvas {
  display: block;
  width: 100%;
  height: auto;
}

.how-to-play-hankey-swirl {
  stroke: #8b5e34;
  stroke-width: 6;
  stroke-dasharray: 420;
  stroke-dashoffset: 420;
  animation: how-to-play-hankey-draw 4.5s ease-in-out infinite;
}

.how-to-play-hankey-eye {
  fill: var(--ink);
  opacity: 0;
  animation: how-to-play-hankey-face-in 4.5s ease-in-out infinite;
}

.how-to-play-hankey-mouth {
  stroke: var(--ink);
  stroke-width: 3.5;
  opacity: 0;
  animation: how-to-play-hankey-face-in 4.5s ease-in-out infinite;
}

.how-to-play-hankey-hat {
  transform-origin: 65px 24px;
  opacity: 0;
  animation: how-to-play-hankey-hat-in 4.5s ease-out infinite;
}

@keyframes how-to-play-hankey-draw {
  0% {
    stroke-dashoffset: 420;
  }
  55% {
    stroke-dashoffset: 0;
  }
  92% {
    stroke-dashoffset: 0;
  }
  100% {
    stroke-dashoffset: 420;
  }
}

@keyframes how-to-play-hankey-face-in {
  0%,
  58% {
    opacity: 0;
  }
  68%,
  92% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes how-to-play-hankey-hat-in {
  0%,
  62% {
    opacity: 0;
    transform: scale(0.4) rotate(-20deg);
  }
  74% {
    opacity: 1;
    transform: scale(1.15) rotate(4deg);
  }
  82%,
  92% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: scale(0.4) rotate(-20deg);
  }
}

.game-scoreboard {
  display: flex;
  justify-content: center;
  gap: var(--space-9);
  margin: var(--space-4) 0;
  padding: var(--space-4) var(--space-8);
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: #fff;
}

.game-score-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
}

.game-score-label {
  font-family: var(--font-label);
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--ink);
}

.game-score-value {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 2rem;
  color: var(--ink);
}

#game-recap-heading {
  margin: 0 0 var(--space-3);
}

.game-recap-winner {
  margin: var(--space-2) 0 var(--space-5);
  padding: var(--space-5) var(--space-8);
  border: 3px solid var(--ink);
  border-radius: 12px;
  font-family: var(--font-label);
  font-size: 1.4rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--cream);
  background: var(--ink);
}

/* The leading score bumps up and the trailing one settles slightly smaller —
   a small flourish so the recap doesn't land as a flat, static readout. */
@keyframes score-pop {
  0% {
    transform: scale(0.4);
    opacity: 0;
  }
  70% {
    transform: scale(1.15);
    opacity: 1;
  }
  100% {
    transform: scale(1);
  }
}

.game-score-value.pop {
  animation: score-pop 0.5s ease-out;
}

.game-score-column.winner .game-score-value {
  color: var(--success);
}

/* No frame/background any more — the avatars float directly over the screen, same "shown in
   transparency" convention as every other avatar (see .small-avatar-circle). nowrap keeps every
   winner on a single row: a team never has more than 6 players (12-player room, 2 teams), and
   dropping the pseudo labels (just the avatars now, see renderWinnerAvatars) is what leaves room
   for up to 6 of them to actually fit on that one line on a phone. */
.recap-winner-avatars {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 0.6rem;
  margin: 0 0 var(--space-5);
  width: 100%;
}

/* Lets each avatar shrink below its usual 3.8rem (see .small-avatar-circle--large) when up to 6 of
   them need to share one row on a narrow phone — aspect-ratio keeps each one square as flexbox
   squeezes its width down, instead of the fixed height flattening it into an oval. */
.recap-winner-avatars .small-avatar-circle--large {
  flex: 1 1 0;
  width: auto;
  max-width: 3.8rem;
  height: auto;
  aspect-ratio: 1 / 1;
}

.small-avatar-circle--large {
  width: 3.8rem;
  height: 3.8rem;
}

/* --- Round recap: humor badges awarded to individual players (see RoundBadge) --- */
.recap-badges {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: 100%;
  max-width: 420px;
  margin: 0 0 var(--space-5);
}

.recap-badge {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: 0.35rem var(--space-5);
  border: 3px solid var(--ink);
  border-radius: 10px;
  background: #fff;
  text-align: left;
}

.recap-badge-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.recap-badge-title {
  margin: 0;
  font-size: 0.8rem;
  color: var(--ink);
}

.recap-badge-label {
  font-family: var(--font-label);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.recap-badge-description {
  font-weight: normal;
  text-transform: lowercase;
}

.recap-badge-pseudo {
  font-size: 0.8rem;
}

/* --- Victory screen: the end-of-game moment, shown once after the final round's own (now total-less)
   recap — bigger and more festive than a per-round banner, since this is the one that matters. --- */
@keyframes victory-winner-in {
  0% {
    transform: scale(0.4) rotate(-6deg);
    opacity: 0;
  }
  60% {
    transform: scale(1.08) rotate(2deg);
    opacity: 1;
  }
  80% {
    transform: scale(0.97) rotate(-1deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
  }
}

.game-victory-winner {
  margin: var(--space-1) 0 0.8rem;
  padding: 0.9rem 1.6rem;
  border: 4px solid var(--ink);
  border-radius: 16px;
  font-family: var(--font-label);
  font-size: 2.1rem;
  line-height: 1.15;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--ink);
  /* A fixed gold, not --band-light/--band-dark — those track the *viewing* player's own chosen
     colors (see client.ts, "--band-light" set from the player's avatar palette), which would make
     this banner an arbitrary, inconsistent color per player instead of one shared festive look. */
  background: #f2b705;
  box-shadow: 0 0 0 6px rgba(242, 183, 5, 0.25);
  animation: victory-winner-in 0.7s var(--ease-out);
}

.game-victory-totals {
  margin: 0 0 0.9rem;
}

.game-victory-totals .game-score-value {
  font-size: 2.4rem;
}

.game-victory-players {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: 100%;
  max-width: 420px;
  margin: 0 0 0.9rem;
}

.game-victory-player-row {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-2) var(--space-5);
  border: 3px solid var(--ink);
  border-radius: 10px;
  background: #fff;
  text-align: left;
}

.game-victory-player-pseudo {
  flex: 1;
  min-width: 0;
  font-family: var(--font-label);
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-victory-player-count {
  font-size: 0.8rem;
  color: var(--ink);
  opacity: 0.75;
}

/* --- Cards recap (end of game): one past card re-shown per highlight, with its illustrator and theme
   author — see CardHighlight. --- */
.cards-recap-progress {
  margin-bottom: var(--space-2);
  font-family: var(--font-label);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink);
  opacity: 0.7;
}

/* Styled like the join screen's "GUSMAN" sticker logo (.logo.hero) — same ink-bordered badge, diagonal
   2-tone background, italic display font and white-outlined lettering — but with the two creators' own
   colors (--highlight-illustrator-color/--highlight-theme-author-color, set from CardHighlight by
   renderCardHighlight below) standing in for the logo's fixed --band-dark/--band-light split, since this
   badge is crediting them rather than being the game's own logo. */
.cards-recap-label {
  margin: 0;
  padding: var(--space-3) var(--space-8) 0.45rem;
  border: 3px solid var(--ink);
  border-radius: 10px;
  background: linear-gradient(
    135deg,
    var(--highlight-illustrator-color, var(--band-dark)) 55%,
    var(--highlight-theme-author-color, var(--band-light)) 55%
  );
  box-shadow: 3px 3px 0 var(--ink);
  font-family: var(--font-display);
  font-weight: 900;
  font-style: italic;
  font-size: 1.6rem;
  text-align: center;
  text-transform: uppercase;
  color: var(--ink);
  text-shadow:
    -2px -2px 0 #fff,
    2px -2px 0 #fff,
    -2px 2px 0 #fff,
    2px 2px 0 #fff,
    0 -2px 0 #fff,
    0 2px 0 #fff,
    -2px 0 0 #fff,
    2px 0 0 #fff;
}

/* Full-width black bar (per reference), italic white caption underneath the title badge — bled past
   both .game-view's own edge padding and .pot-content's (see #game-cards-recap-view's matching bleed
   below) so it touches the app frame's own borders instead of stopping at the screen's padded column. */
.cards-recap-description {
  margin: var(--space-4) calc(-1 * (var(--space-6) + var(--space-8))) var(--space-5);
  padding: var(--space-3) var(--space-7);
  background: var(--ink);
  font-style: italic;
  font-size: 0.95rem;
  text-transform: lowercase;
  color: var(--cream);
}

/* Capitalized despite the lowercase-by-convention description text (shared with the round-recap
   badges, see CARD_HIGHLIGHT_SPECS) — this bar reads as a headline caption, not an inline label. */
.cards-recap-description::first-letter {
  text-transform: uppercase;
}

#cards-recap-card-title {
  margin-bottom: var(--space-2);
}

#cards-recap-canvas {
  object-fit: contain;
}

/* "Next" card flip (gallery.ts): the card frame rotates edge-on then back, with the new highlight's
   content swapped in right at the edge-on midpoint — reads as turning the card over rather than a
   plain content swap. The view needs its own perspective (siblings don't rotate), and the frame
   needs backface-visibility so the edge-on moment never flashes a mirrored front face.
   The extra negative margin/padding (beyond .game-view's own -12px/12px bleed) cancels .pot-content's
   own padding too, so .cards-recap-description's matching negative margin above can bleed all the way
   to the app frame's border instead of stopping at .pot-content's padded edge. */
#game-cards-recap-view {
  perspective: 1000px;
  margin-inline: calc(-1 * (var(--space-6) + var(--space-8)));
  padding-inline: calc(var(--space-6) + var(--space-8));
}

#cards-recap-card-frame {
  backface-visibility: hidden;
}

@keyframes cards-recap-flip-out {
  from {
    transform: rotateY(0deg);
  }
  to {
    transform: rotateY(90deg);
  }
}

@keyframes cards-recap-flip-in {
  from {
    transform: rotateY(-90deg);
  }
  to {
    transform: rotateY(0deg);
  }
}

#cards-recap-card-frame.flip-out {
  animation: cards-recap-flip-out 180ms var(--ease-out);
}

#cards-recap-card-frame.flip-in {
  animation: cards-recap-flip-in 180ms var(--ease-out);
}

#game-cards-recap-next-button {
  margin-top: var(--space-4);
}

/* --- End-of-game gallery: every card made this game, as one scrollable grid (see GalleryPayload) — reached
   from the last card highlight ("See gallery"). --- */
.gallery-heading {
  margin: 0 0 var(--space-6);
  font-family: var(--font-label);
  font-size: 1.1rem;
  text-transform: uppercase;
  color: var(--ink);
}

/* The left/right edge-bleed is the same trick as ".pot-content > section" / ".roster" above (setting only
   overflow-y makes browsers coerce overflow-x to auto too, which would otherwise clip .gallery-card:hover's
   outward scale(1.03) on cards flush against the grid's own edge). Top/bottom get the same bleed on the
   axis that actually scrolls here: without it, a hovered card in the first visible row had no slack above
   it and its scale(1.03) got clipped flush against the grid's own scroll boundary. */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
  grid-auto-rows: minmax(130px, 170px);
  align-content: start;
  gap: var(--space-5);
  box-sizing: border-box;
  width: 100%;
  flex: 1;
  min-height: 0;
  /* Negative margin cancels the padding below so the grid's own position is unaffected; the two
     must stay equal in magnitude, which is why they're not expressed via --space-* (that would
     need a calc() on one side to flip the sign, for no real readability gain here). */
  margin: -0.5rem -0.75rem;
  padding: var(--space-4) var(--space-6);
  overflow-x: hidden;
  overflow-y: auto;
}

/* A card as a little collectible: title band up top, the drawing filling the rest. Overrides the base
   `button` rule's center-everything flex layout (and its padding/gap/dark fill) to stretch both children
   to the card's full width instead. */
.gallery-card {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0;
  min-height: 130px;
  padding: 0;
  border: 3px solid var(--ink);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}

.gallery-card:hover {
  filter: none;
  transform: scale(1.03);
}

.gallery-card-title {
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border-bottom: 3px solid var(--ink);
  background: var(--card-grad-dark, var(--band-light));
  font-family: var(--font-label);
  font-size: 0.6rem;
  text-transform: uppercase;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--cream);
}

.gallery-card-canvas-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem;
  background: linear-gradient(to bottom, var(--card-grad-light, #fff), var(--card-grad-dark, #fff));
  background-size: 100% 200%;
  background-position: top;
}

.gallery-card-canvas-wrap canvas {
  max-width: 100%;
  max-height: 100%;
}

/* Full-screen zoom: a click on a grid card (see openGalleryCard in client.ts) — sits outside <main> so its
   `position: fixed` always covers the whole viewport, whatever transforms are in play inside the board. */
.gallery-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Trimmed from --space-9 on 2026-11-28, same "give the card a bit more room" pass as the other
     card-showing screens (see the body/.pot-content rules above) — this padding is this popup's own
     whole size budget (fitPopupCardFrame, cardSticker.ts, measures it directly), so it was the single
     biggest unclaimed margin left around the gallery/museum zoom. */
  padding: var(--space-7);
  box-sizing: border-box;
  background: rgba(20, 20, 20, 0.82);
}

/* The card itself (gradient + theme sticker, same .game-card used everywhere else) fills the whole
   popup — no neutral frame/authors plate around it any more, see .overlay-card-creators below. */
.gallery-overlay-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  /* max-width (not width) — the card frame inside (sized to getCardRatio in JS, see fitCardBoxToAvailableSpace)
     is often narrower than this cap once its height is the binding constraint (a short, wide viewport), and
     a fixed width left this popup with an empty cream slab beside the card instead of hugging it. */
  max-width: min(92vw, 480px);
  width: fit-content;
  max-height: 92vh;
  box-sizing: border-box;
  border: 4px solid var(--ink);
  border-radius: 16px;
  background: var(--cream);
  overflow: hidden;
}

.gallery-overlay-close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border-radius: 50%;
  font-size: 0.9rem;
  z-index: 3;
}

/* Unlike the flex-stretched .game-card elsewhere, this one sits in a fixed-size popup — capped on
   height so a tall drawing can't push the card past the viewport, while the card's own
   object-fit: contain canvas keeps it scaled to its real aspect ratio either way. No side/top margin
   (the card fills the popup edge to edge there) and no border/shadow of its own, since the popup's
   own border (.gallery-overlay-card) already frames it — stacking both just doubled the ink line. A
   bit of bottom margin now, though: the sticker spills past this card's own bottom edge (see its
   overflow: visible rule above) and without it that overflow would immediately hit .gallery-overlay-
   card's own clipping edge (its overflow: hidden) instead of just the dark backdrop behind the popup. */
.gallery-overlay-card .game-card {
  width: auto;
  max-height: 86vh;
  margin: 0 0 1rem;
  border: none;
  box-shadow: none;
}

/* Both the gallery zoom's card frame and the museum's (see #gallery-overlay-card-frame/#museum-card-frame
   in their respective screen modules) carry the pointerdown/pointerup swipe-to-navigate handlers — without
   this, a horizontal drag on a touch device is free to be interpreted as the browser's own pan/scroll
   gesture instead, which cancels the pointer sequence (a "pointercancel" instead of the "pointerup" the
   swipe logic needs to see) before the swipe ever registers. */
#gallery-overlay-card-frame,
#museum-card-frame {
  touch-action: none;
}

/* The illustrator/theme-author attribution, now pinned over the card itself (top-left) instead of
   a plate below it — two avatar + pseudo-pill pairs (same pill look as .pseudo-chip, border color
   following the creator's own dark color via currentColor), illustrator always first/left same as
   everywhere else this pair is shown, so position alone conveys the role without needing the
   "Drawing by"/"Theme by" labels this replaces. */
.overlay-card-creators {
  position: absolute;
  top: 0.7rem;
  left: 0.7rem;
  z-index: 2;
  display: flex;
  gap: 0.5rem;
}

.overlay-card-creator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.overlay-card-creator-avatar .small-avatar-circle--large {
  width: 2.3rem;
  height: 2.3rem;
}

.overlay-card-creator-pseudo {
  max-width: 4.6rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: #fff;
  border: 2px solid currentColor;
  font-family: "Archivo Black", sans-serif;
  font-size: 0.55rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1;
}

.museum-empty {
  margin: 0;
  padding: 2.5rem var(--space-9);
  text-align: center;
  font-weight: 600;
}

/* Floats over the card's own edges (vertically centered) instead of sitting in a strip below it,
   now that the card fills the whole popup — pointer-events: none on the row so a swipe/drag over
   the middle of the card still reaches .museum-viewport, re-enabled on the buttons themselves. */
.museum-nav {
  position: absolute;
  top: 50%;
  left: 0.6rem;
  right: 0.6rem;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  transform: translateY(-50%);
  pointer-events: none;
}

.museum-nav-button {
  width: 2.6rem;
  height: 2.6rem;
  padding: 0;
  border-radius: 50%;
  font-size: 1.3rem;
  line-height: 1;
  pointer-events: auto;
}

#room-settings {
  display: flex;
  gap: var(--space-6);
  margin: 0;
  padding: 0.85rem 0.85rem 0.1rem;
  border: 3px solid var(--ink);
  border-radius: 8px;
}

#room-settings legend {
  padding: 0 var(--space-3);
  font-family: var(--font-label);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink);
}

#room-settings label {
  flex: 1;
  margin-bottom: 0.85rem;
  font-size: 0.8rem;
}

#room-settings input {
  padding: 0.45rem var(--space-5);
}

/* --- Themes screen: submission frame (bandeau header + field/button/counter) --- */

/* The bandeau label shared by the submission frame's header and the standalone
   "Teams" title below it, so both halves of the screen read as the same kind of
   section marker even though only one of them sits inside a bordered frame. */
.section-banner {
  background: var(--ink);
  color: var(--cream);
  font-family: var(--font-label);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: var(--space-3) 0.8rem;
}

.section-banner--standalone {
  border-radius: 10px;
  margin: 0 0 var(--space-5);
}

/* The "Themes" banner is the screen's one real task — bigger than the plain .section-banner
   base so it reads as the primary thing to do here, ahead of the roster below. */
.theme-submit-banner {
  font-size: 0.95rem;
  padding: var(--space-5) var(--space-7);
}

/* The standalone "Teams" title, by contrast, is just a lobby label (who else is here, not
   something to act on) — same typography as the avatar/themes/cards step tracker above it,
   instead of a bold filled banner that would make it compete with "Themes" for attention. */
.teams-banner {
  background: transparent;
  color: var(--ink);
  font-family: var(--font-label);
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0;
  opacity: 0.7;
}

.theme-submit-frame {
  border: 3px solid var(--ink);
  border-radius: 12px;
  /* Clips .section-banner's square corners to this frame's rounded ones. */
  overflow: hidden;
  /* Generous gap before the Teams banner below, so the two halves of the screen
     (submission vs. roster/status) read as clearly separate. */
  margin-bottom: var(--space-11);
  /* Without this, overflow:hidden above drops this flex item's automatic minimum height to 0
     (the flexbox spec's rule for non-"visible" overflow), so once a full room's roster needs
     more vertical room than the screen has, flex-shrink crushes this frame toward nothing
     instead of the screen just scrolling — the task card would visibly collapse to a sliver. */
  flex-shrink: 0;
}

.theme-submit-frame-body {
  padding: var(--space-6) 0.8rem var(--space-5);
}

/* Collapses smoothly to nothing once the quota is met (see themes.ts), instead of the field/
   button just vanishing outright — the "fold up" is the task's own visual sign-off, ahead of
   the success hint that replaces it. The 1fr/0fr grid-rows trick animates to the content's real
   height without having to know it in pixels; .theme-active-inner's overflow:hidden is what
   actually clips it mid-transition. */
.theme-active-wrap {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 320ms var(--ease-out);
}

.theme-active-wrap.is-collapsed {
  grid-template-rows: 0fr;
}

/* Same edge-bleed trick as ".pot-content > section" above (negative margin + matching padding,
   net zero visually): without it, the theme input's own focus-visible ring sits flush against
   this box's edges and gets clipped left/right by the overflow:hidden above, most noticeable on
   a narrow phone where the ring runs the input's full width. */
.theme-active-inner {
  overflow: hidden;
  min-height: 0;
  margin: 0 -6px;
  padding: 0 6px;
}

/* Tighter than the generic label spacing below, so the button sits right under the field it submits. */
#theme-input-label {
  margin-bottom: var(--space-3);
}

/* One line even on a narrow phone: the sentence's length barely changes with the quota digit(s), but
   the available width does — fitCardTitle (client.ts) shrinks the font-size in place until it fits,
   same trick as the card title banners. */
.theme-input-hint {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.theme-submit-row {
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

/* .test-mode-button's own margin-top is meant for stacking in a vertical flex column (see
   .themes-footer) — reset it here, where the button instead sits inline next to "Add theme". */
.theme-submit-row .test-mode-button {
  margin-top: 0;
}

.theme-counter {
  font-family: var(--font-label);
  font-size: 0.85rem;
  color: var(--ink);
  opacity: 0.7;
}

.theme-counter.done {
  color: var(--success);
  opacity: 1;
}

/* Fills from 0 to 100% of the player's own quota — the transition is what makes each "Add
   theme" tap read as progress advancing, rather than just the "x/N" counter ticking up. Stays
   visible (full) once done, as a quiet confirmation alongside the success hint below it. */
.theme-progress-track {
  height: 0.5rem;
  border-radius: 999px;
  background: rgba(20, 20, 20, 0.12);
  overflow: hidden;
  margin-top: var(--space-5);
}

.theme-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--band-dark);
  border-radius: 999px;
  transition: width 320ms var(--ease-out);
}

.theme-done-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4) 0 0.1rem;
  text-align: center;
}

.theme-done-body p {
  margin: 0;
}

/* Same pop-in checkmark as the how-to-play success page (.how-to-play-check-pop), smaller —
   reusing the same "task complete" visual language rather than inventing a second one. */
.theme-done-check-svg {
  width: 40px;
  height: 40px;
  transform: scale(0);
  animation: how-to-play-check-pop 420ms var(--ease-out) forwards;
}

.theme-done-check-circle,
.theme-done-check-mark {
  stroke: var(--success);
}

/* --- Team roster (themes screen): avatars grouped by team, live submission status --- */

/* Side by side rather than stacked, so each team box only ever grows as tall as its own
   players need (up to 6 a side) instead of being stretched to fill whatever's left of the
   screen — that stretch was what made an almost-empty team box read as a big, important slab.
   No flex/overflow of its own: this whole screen already scrolls as one (see ".pot-content >
   section" above) once a full room's two columns of avatars outgrow the viewport. */
.roster {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: var(--space-4);
  margin: var(--space-3) -12px var(--space-5);
  padding: 0 12px;
}

.roster-team {
  display: flex;
  flex-direction: column;
  border: 3px solid var(--ink);
  border-radius: 12px;
  /* Clips the header banner's square corners to this box's rounded ones, same trick as
     .theme-submit-frame above it. */
  overflow: hidden;
  background: #fff;
}

/* Full-bleed dark banner, same look as .card-draw-theme and the "Themes" section-banner, so the
   team name reads with the same weight as the game's other title banners. */
.roster-team-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  background: var(--ink);
  color: var(--cream);
}

/* No longer crops: a long team name used to ellipsis-truncate here, which on user feedback
   (2026-11-30) is never acceptable for a name the player chose themselves — it must always be
   fully readable, wrapping onto a 2nd line rather than being cut off (see .roster-team-name's own
   smaller size below, which keeps 2 lines the exception rather than the rule for a typical name). */
.roster-team-name-crop {
  display: inline-block;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: break-word;
  vertical-align: top;
}

.roster-team-name {
  font-family: var(--font-label);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: inherit;
}

/* The team name itself is the rename trigger for your own team (see renderRosterTeam in
   themes.ts, toggling :disabled) — underlined with a pencil icon beside it so the whole name
   reads as clickable, rather than a separate "Change name" button. Disabled (the other team) looks
   like plain text: no underline, no icon, default opacity despite :disabled's usual dimming.
   The underline is a border-bottom on the button itself (name + icon together), not
   text-decoration on the name alone: text-decoration is painted as "ink overflow" outside the
   text's own line box (via text-underline-offset), which several real mobile browsers clip away
   once an ancestor has overflow:hidden — no longer true here since .roster-team-name-crop dropped
   its own overflow:hidden above, but a border-bottom still reads better than an underline running
   under the icon too once the name wraps onto a 2nd line, so this stays as is. A border is part of
   the box model instead, so it's included in the button's own layout height and spans its full
   width including the icon. */
.roster-team-name-button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  max-width: 100%;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  color: inherit;
  transition: none;
}

.roster-team-name-button:hover {
  filter: none;
}

.roster-team-name-button:active {
  transform: none;
}

.roster-team-name-button:disabled {
  opacity: 1;
  cursor: default;
}

.roster-team-name-button:not(:disabled) {
  cursor: pointer;
  border-bottom: 2px solid currentColor;
  padding-bottom: 1px;
}

.roster-team-edit-icon {
  flex-shrink: 0;
  display: none;
}

.roster-team-name-button:not(:disabled) .roster-team-edit-icon {
  display: inline-flex;
}

/* Stretched to the row's full height (its sibling team boxes use align-items:start above and
   don't stretch) — a vertical "VS" bar between the two columns instead of the horizontal one
   that made sense when the teams were stacked. */
.roster-divider {
  display: flex;
  flex-direction: column;
  align-items: center;
  align-self: stretch;
  gap: var(--space-3);
  font-family: var(--font-label);
  font-size: 0.7rem;
  color: var(--ink);
  opacity: 0.6;
}

.roster-divider::before,
.roster-divider::after {
  content: "";
  flex: 1;
  width: 2px;
  background: var(--ink);
  opacity: 0.25;
}

.roster-avatars {
  display: grid;
  /* Wraps to however many columns actually fit the now-halved team box width, instead of a
     fixed 4 — avatars never shrink below their usual size (.roster-avatar's max-width) just
     because the box got narrower, they just wrap onto another row as more players join. */
  grid-template-columns: repeat(auto-fill, minmax(4.2rem, 1fr));
  gap: var(--space-4) var(--space-3);
  min-height: 2.2rem;
  /* .roster-team itself has no padding any more (its header banner needs to bleed to the
     box's edges) — this is what keeps the avatars from sitting flush against the border. */
  padding: var(--space-4) var(--space-5);
}

.roster-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
}

.roster-avatar {
  position: relative;
  width: 100%;
  max-width: 4.2rem;
  aspect-ratio: 1;
}

.roster-avatar-circle {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
}

.roster-avatar-circle canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.roster-pseudo {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.75rem;
  color: var(--ink);
}

/* No more solid disc behind the icon (too loud sitting on top of a player's own avatar) — just
   the check / dots themselves, laid directly over the drawing in the same corner as before. The
   white drop-shadow/box-shadow halo on each (below) is what keeps them legible over a dark or
   similarly-colored stroke, in place of the opaque background that used to do that job. */
.roster-badge {
  position: absolute;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
}

.roster-badge.ready {
  color: var(--success);
  filter: drop-shadow(0 0 1.5px #fff) drop-shadow(0 0 1.5px #fff) drop-shadow(0 0 1.5px #fff);
}

.roster-badge.pending {
  gap: 2px;
}

.roster-badge.pending span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.9);
  animation: roster-dot-blink 1.1s infinite ease-in-out;
}

.roster-badge.pending span:nth-child(2) {
  animation-delay: 0.15s;
}

.roster-badge.pending span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes roster-dot-blink {
  0%,
  80%,
  100% {
    opacity: 0.25;
  }
  40% {
    opacity: 1;
  }
}

/* Warning badge shown over a player's avatar while they're disconnected — see buildNetworkTroubleBadge
   in client.ts. Positioned per context below: opposite corner from .roster-badge on the themes roster
   (which already owns the bottom-right corner), top-right on a teams-screen figure. */
.network-trouble-icon {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1;
  border: 2px solid var(--cream);
  z-index: 3;
}

.roster-avatar .network-trouble-icon {
  top: -0.2rem;
  left: -0.2rem;
}

.figure-sprite .network-trouble-icon {
  top: -0.3rem;
  right: -0.3rem;
}

/* Pins the waiting hint + Start button to the bottom of the screen (see index.html) instead of
   just trailing right after the roster — otherwise a room with only 2-3 players leaves them
   floating awkwardly high, well above the fold, with that visual gap doing double duty as
   wasted space. margin-top: auto only ever eats into real leftover room: once the roster itself
   grows enough to fill the screen, this collapses back to the normal top-to-bottom flow and the
   section's own overflow-y (see ".pot-content > section" above) takes over as usual. */
.themes-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
}

#themes-start-button {
  margin-top: var(--space-4);
}

/* Dev-only (see TEST_MODE_URL_FLAG in client.ts) — deliberately styled as a "debug" control, not part of the
   bold-ink identity, so it's obvious at a glance that it's a testing shortcut rather than a real game action. */
.test-mode-button {
  margin-top: var(--space-4);
  border: 2px dashed #888;
  background: #eee;
  color: #444;
  font-family: monospace;
}

@keyframes start-button-bump {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
  }
}

#themes-start-button.bump {
  animation: start-button-bump 0.4s ease-out;
}

/* --- Round recap: a small shower of confetti pieces, appended to .pot-clip and removed
   once their own fall animation ends (see spawnConfetti in recap.ts). Confined within
   .pot-clip's rounded border (overflow: hidden) — a "petit feu d'artifice", not a full-screen one. */
.confetti-piece {
  position: absolute;
  top: -10px;
  left: var(--confetti-left);
  width: 7px;
  height: 11px;
  border-radius: 1px;
  background: var(--confetti-color);
  opacity: 0;
  pointer-events: none;
  z-index: 5;
  animation: confetti-fall var(--confetti-duration) ease-in forwards;
  animation-delay: var(--confetti-delay);
}

@keyframes confetti-fall {
  0% {
    opacity: 0;
    transform: translate(0, 0) rotate(0deg);
  }
  10% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(var(--confetti-x), 260px) rotate(var(--confetti-rotate));
  }
}

/* Every width, not just phone portrait below: every screen that shows a card (avatar/cards' own drawing
   surface, and #game-screen's live round/cards-recap/gallery/victory — all its nested .game-view's, see
   that selector in index.html) gets back some of the side/bottom margin .pot-content otherwise reserves
   uniformly for every screen (left/right especially — a card is already capped to CARD_RATIO, a narrower
   shape than the screen itself, so the usual side padding on top of that left it visibly smaller than it
   needed to be). Widened again on 2026-11-28 (both the body and .pot-content side values below one step
   further) after still reading as too narrow on a real Galaxy S10. */
body:has(#avatar-screen:not([hidden])),
body:has(#cards-screen:not([hidden])),
body:has(#game-screen:not([hidden])) {
  padding-left: var(--space-5);
  padding-right: var(--space-5);
}

/* Bumped from --space-4 to --space-5 on 2026-11-29, on user feedback that the avatar canvas and the
   in-game card both read as too tight against the edge — one step up the shared spacing scale,
   kept identical between the two screens as it already was. #cards-screen joined this list on
   2026-11-30 (see the mobile-only override just below for why it used to sit outside it): without the
   zero-padding trick below, it's just another .full-draw-screen and wants the exact same edge
   spacing as avatar/game. */
.pot-content:has(> #game-screen:not([hidden])),
.pot-content:has(> #avatar-screen:not([hidden])),
.pot-content:has(> #cards-screen:not([hidden])) {
  padding-left: var(--space-5);
  padding-right: var(--space-5);
}

/* Cards screen widens further still on phone — NOT on desktop (see the media query wrapping this):
   on a short/wide desktop window getCardRatio pins the card to its squarest ratio (CARD_RATIO_MAX)
   rather than sizing from available phone height, so the card ends up bound by width, not height —
   zeroing .pot-content's side padding there glued the drawing card (and the step-progress/tools rows
   right along with it) flush to the app frame's own border, with nothing in between (reported
   2026-11-30, a real desktop window — not just a short test viewport). A phone is tall enough that
   height stays the binding constraint, so every mobile pixel of width genuinely helps there: zero
   this side padding for just this one screen on phone widths — then hand the exact var(--space-4)
   this removes straight back to the elements that must NOT move or get any wider (its own
   .step-progress, .cards-progress-row and .tools — all 3 direct children of #cards-screen, unlike
   .logo-row before the 2026-11-28 move that relocated the cards progress bar/counter into
   #cards-screen itself, see .cards-progress-row). All 3 had zero padding of their own before this, so
   this is a plain swap, not a stack — they land at the exact same spot they already were.
   #card-draw-slot/.full-canvas are deliberately left out of that list: losing .pot-content's padding
   with nothing handed back to them is what actually makes them (and so the card they size, via
   fitCardDrawStage/CARD_RATIO — cards.ts) wider than before, without a negative margin anywhere to
   do it. */
@media (max-width: 600px) {
  .pot-content:has(> #cards-screen:not([hidden])) {
    padding-left: 0;
    padding-right: 0;
  }

  /* Raised from var(--space-4) to the same var(--space-8) every other screen (join/themes) uses,
     on user feedback (2026-11-30) that the progress bar and buttons still read as glued to the
     frame here, right next to a card that's deliberately edge-to-edge — the two shouldn't share
     one margin just because they share one zeroed-out parent padding. */
  #cards-screen > .step-progress,
  #cards-screen > .cards-progress-row,
  #cards-screen > .tools {
    padding-left: var(--space-8);
    padding-right: var(--space-8);
  }
}

/* Same complaint, desktop side: on a wide-enough window #cards-screen doesn't zero .pot-content's
   padding above (see the media query above) — it inherits the shared --space-5 that keeps the card
   itself from touching the frame (2026-11-30, see that rule's own comment). That's still well short
   of join/themes' --space-8, so these rows add back just the difference on top of the inherited
   --space-5, landing at the same --space-8 everywhere else gets — rather than a flat --space-8
   margin, which would stack with the inherited padding and double-indent them. Avatar's own
   step-progress/screen-header/tools get the identical treatment, unconditionally: unlike cards,
   avatar never zeros/overrides .pot-content's padding on phone, so the same --space-5 baseline (and
   so the same delta) holds at every width, no media query needed here. */
#avatar-screen > .step-progress,
#avatar-screen > .screen-header,
#avatar-screen > .tools {
  margin-left: calc(var(--space-8) - var(--space-5));
  margin-right: calc(var(--space-8) - var(--space-5));
}

@media (min-width: 601px) {
  #cards-screen > .step-progress,
  #cards-screen > .cards-progress-row,
  #cards-screen > .tools {
    margin-left: calc(var(--space-8) - var(--space-5));
    margin-right: calc(var(--space-8) - var(--space-5));
  }
}

/* Same complaint, carried over to the live round screen (2026-11-30): #game-screen never zeros
   .pot-content's padding at any width (it's not in the mobile override above, only cards-screen is),
   so its round-label bar and the active turn's header/timer/action rows inherited the same bare
   --space-5 avatar/cards had before their own fix — read as glued to the frame right next to a card
   that's deliberately kept tight. .game-status-bar is a direct child of #game-screen itself (shared
   by every nested .game-view, not just the live round), so fixing it here covers all of them at
   once; the active view's own 3 full-width rows need the same delta individually since they sit one
   level deeper. #game-card-flip-stage is deliberately left out, same reasoning as avatar's
   canvas/cards' drawing surface: it should stay as large as it can, not gain the wider margin. */
#game-screen > .game-status-bar,
#game-active-view > .game-active-header,
#game-active-view > .game-timer-row,
#game-active-view > .game-storyteller-actions {
  margin-left: calc(var(--space-8) - var(--space-5));
  margin-right: calc(var(--space-8) - var(--space-5));
}

.pot-content:has(> .full-draw-screen:not([hidden])) {
  padding-bottom: var(--space-7);
}

/* #game-screen hides .logo entirely (see ui.ts' showScreen), so .pot-content's own padding-top is
   the only thing left above "Round X" — now that the top badges are pulled up onto .pot-band itself
   (see .top-left-badges/.pot-seal) instead of sitting inside .pot-content's flow, that padding can
   shrink without the round label crowding them. */
.pot-content:has(> #game-screen:not([hidden])) {
  padding-top: var(--space-6);
}

/* Themes screen only, on user feedback (2026-11-30): its own .step-progress read as glued to the band
   above even at the shared --space-8 every screen gets by default — unlike avatar/cards (see the
   .full-draw-screen phone media query below, which goes the other way and tightens *their* own
   padding-top to favor the canvas), themes has no canvas competing for that space, so it can afford
   to give its header more room instead. */
.pot-content:has(> #themes-screen:not([hidden])) {
  padding-top: var(--space-9);
}

/* Phone portrait: the avatar/card drawing screens are mostly vertical space, so give the canvas as
   much of it as possible — tighten the header above it and the margins around the tools row below
   it, instead of leaving that space idle around a canvas that's already flex:1. Scoped to just those
   two screens (via :has()) so every other screen's spacing stays exactly as it is. */
@media (max-width: 600px) {
  .pot-content:has(> .full-draw-screen:not([hidden])) {
    padding-top: var(--space-5);
    padding-bottom: var(--space-4);
  }

  .full-canvas {
    margin-bottom: var(--space-4);
  }

  .full-draw-screen .tools {
    margin-bottom: var(--space-3);
  }
}

/* Themes screen roster on a narrow phone: the two team frames only have ~half the viewport
   width each, which fits a single avatar per row at .roster-avatar's normal size — fine up to
   3 players, but a stack of 4+ turns into a lot of vertical scroll. Past that count both frames
   switch to 2 columns (see .roster-avatars.many-cols, toggled together in themes.ts), so this
   block claws back the horizontal room that needs: shrinking every bit of chrome around the
   avatars themselves (outer page margins, the frame's own padding, the VS divider) rather than
   the avatars, which the design explicitly keeps at full size. Scoped to the themes screen only,
   via :has(), so no other screen's margins move. */
@media (max-width: 600px) {
  body:has(#themes-screen:not([hidden])) {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }

  .pot-content:has(> #themes-screen:not([hidden])) {
    padding-left: var(--space-5);
    padding-right: var(--space-5);
  }

  .roster {
    gap: var(--space-2);
  }

  .roster-team-header {
    padding: var(--space-2) var(--space-3);
  }

  .roster-divider {
    gap: var(--space-1);
    font-size: 0.55rem;
  }

  .roster-avatars {
    grid-template-columns: minmax(4.2rem, 1fr);
    gap: var(--space-3) var(--space-2);
    padding: var(--space-3) var(--space-2);
  }

  .roster-avatars.many-cols {
    grid-template-columns: repeat(2, minmax(4.2rem, 1fr));
  }
}

/* A real desktop browser window rarely gives the page its full screen height (address bar, tab strip,
   bookmarks bar, OS taskbar all eat into it), so a plain "my monitor is 1080p" assumption undersells how
   short the actual viewport often is — short enough, on the join screen in particular, to fall back to
   .pot-content's scroll (see its own comment above) even though nothing about that screen looks like it
   should need to scroll. Scaling the whole spacing scale down tightens every screen's margins/padding
   together rather than hand-picking which ones to trim, same "shared scale" spirit the scale itself was
   built for — and the join screen's oversized logo badge, well past this scale, needs its own trim too.
   Deliberately kept at the very end of this file: every override below targets a selector (.logo.hero,
   label:has(> #pseudo), #room-settings, #room-settings label) whose own base rule lives earlier in this
   file at the same specificity — CSS breaks same-specificity ties by source order, not by which rule sits
   inside a (matching) @media block, so placed anywhere earlier this block would silently lose to those
   base rules and never actually shrink anything below 700px, no matter how short the viewport got (this
   is exactly what had quietly happened before: the block sat near the top of the file, right after the
   base .logo/.pot-content rules it means to override but before .logo.hero/#room-settings further down,
   which always won). */
@media (max-height: 700px) {
  :root {
    --space-6: 0.6rem;
    --space-7: 0.75rem;
    --space-8: 0.9rem;
    --space-9: 1rem;
    --space-10: 1.3rem;
    --space-11: 1.5rem;
  }

  .logo.hero {
    font-size: 2.2rem;
  }

  label:has(> #pseudo) {
    margin-bottom: 1.5rem;
  }

  #room-settings {
    padding: 0.6rem 0.6rem 0.1rem;
  }

  #room-settings label {
    margin-bottom: 0.5rem;
  }
}
