/* The look every web game shares: the pixel fonts, the palette, and the base components. Loaded
   FIRST on all three pages (phones, /desk/, /draw/), so a page's own rules can build on it. This is
   the one place a colour or a button's feel is defined -- the pages used to carry a copy of these
   each, which is how two games end up disagreeing about the same thing.

   Pixels are for the UI layer only. Character art, the drawing canvas and the QR code stay at full
   resolution, and the forehead overlay opts out altogether: it is read across a dim room. */

/* Self-hosted, in two subsets each, so a page fetches only what its text uses. Their URLs are NOT
   versioned by server.js (it stamps what a page's HTML loads, not what a stylesheet loads), so a
   changed font must get a new file name: a proxy would otherwise serve the old one for hours. */
@font-face { font-family:'Press Start 2P'; font-weight:400; font-display:swap;
  src:url('/shared/fonts/press-start-2p-latin-400-normal.woff2') format('woff2');
  unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family:'Press Start 2P'; font-weight:400; font-display:swap;
  src:url('/shared/fonts/press-start-2p-latin-ext-400-normal.woff2') format('woff2');
  unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family:'Pixelify Sans'; font-weight:400; font-display:swap;
  src:url('/shared/fonts/pixelify-sans-latin-400-normal.woff2') format('woff2');
  unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family:'Pixelify Sans'; font-weight:700; font-display:swap;
  src:url('/shared/fonts/pixelify-sans-latin-700-normal.woff2') format('woff2');
  unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family:'Pixelify Sans'; font-weight:400; font-display:swap;
  src:url('/shared/fonts/pixelify-sans-latin-ext-400-normal.woff2') format('woff2');
  unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family:'Pixelify Sans'; font-weight:700; font-display:swap;
  src:url('/shared/fonts/pixelify-sans-latin-ext-700-normal.woff2') format('woff2');
  unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
/* VT323, a terminal's face, for sentences and names: the readable one of the three. It is drawn
   small in its em (x-height .40 against a sans's ~.52) and thin, so size-adjust scales it a little
   past the system face it replaced: every rem and px in the pages keeps its meaning and reads at
   least as large as before. It is wider for it (.54em a letter), which the overflow check covers. Three subsets: Latin, Latin Extended, Vietnamese. A script
   it has no glyphs for (Cyrillic, Greek, CJK...) falls through to the system faces after it in
   --font-name, glyph by glyph, so no name ever shows as boxes. One weight: bold is synthesized. */
@font-face { font-family:'VT323'; font-weight:400; font-display:swap; size-adjust:135%;
  src:url('/shared/fonts/vt323-latin-400-normal.woff2') format('woff2');
  unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family:'VT323'; font-weight:400; font-display:swap; size-adjust:135%;
  src:url('/shared/fonts/vt323-latin-ext-400-normal.woff2') format('woff2');
  unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family:'VT323'; font-weight:400; font-display:swap; size-adjust:135%;
  src:url('/shared/fonts/vt323-vietnamese-400-normal.woff2') format('woff2');
  unicode-range:U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB; }

:root {
  /* The field and what stands on it. Every surface is a token because dark mode redefines them; a
     hard-coded cream in a new rule is a bright slab in the dark. */
  --brand:#1f1a4d; --on-field:#fff6e0; --frame-ink:#0c0a24; --outline:var(--frame-ink);
  --paper:#fff6e0; --card:var(--paper); --ink:#1a1633; --muted:#5a5272; --edge:#cfc3a3;
  --soft:#f3e7c8; --chip:#f3e7c8; --chip-edge:#cfc3a3; --input:#fffdf5; --ghost-ink:var(--ink);
  --mystery-a:#ece0c2; --mystery-b:#e2d5b3; --mystery-ink:#a99c7c; --toast:#0c0a24; --link:#163f8f;
  /* An RPG text box (toasts, GTC.ask): a night-blue window, a dark pixel frame and a cream rule inside it. */
  --rpg-top:#2b2a86; --rpg-bottom:#0c0a24; --rpg-rule:#fff6e0;
  /* Four paired colours, each always beside a shape. The -d half is the button's lower edge. */
  --red:#d42a4a; --red-d:#8f1530; --blue:#2a64d6; --blue-d:#163f8f;
  --amber:#ffb000; --amber-d:#a86c00; --green:#1c8237; --green-d:#0f5c24;
  --ok:#1c8237; --off:#a69fb8; --warn:#ffb000;
  /* The title on the field, one colour per letter: each clears 3:1 against both fields. */
  --title-a:#ff6b82; --title-b:#fff6e0; --title-c:#ffb000; --title-d:#7fd6ff;

  /* Arcade: the title, room code, countdown, clock. Wide, and crisp only at multiples of 8px, so
     it is sized in px and kept to short strings. UI: buttons, labels, headings. Name: sentences and
     anything a person typed or the library holds, in a terminal's face (VT323) that still reads
     fast; the system faces behind it carry the scripts it has no glyphs for. No system face shows
     on its own anywhere, the forehead view included. */
  --font-arcade:'Press Start 2P', 'VT323', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --font-display:'Pixelify Sans', 'VT323', 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
  --font-name:'VT323', 'Trebuchet MS', 'Segoe UI', system-ui, -apple-system, sans-serif;

  --title-size:32px;
  --px:3px; /* one "pixel" of UI chrome: frames, bevels */
  /* The high-score table: an arcade screen set into a panel, the same in both themes. */
  --screen:#0c0a24; --on-screen:#fff6e0; --on-screen-soft:#b9b4d0;
  --gold:#ffb000; --silver:#d6d6e8; --bronze:#e8a36a;
}
/* A frame with its corners missing: four offset shadows and no radius, which is what reads as a
   pixel corner. Shadows rather than clip-path, because clip-path would cut off the focus ring.
   Declared on every element, not on :root: a custom property holding var() is resolved where it is
   declared, so on :root a small control's own --px or --outline would change nothing. */
*, *::before, *::after {
  --frame:0 calc(var(--px) * -1) 0 0 var(--outline), 0 var(--px) 0 0 var(--outline),
          calc(var(--px) * -1) 0 0 0 var(--outline), var(--px) 0 0 0 var(--outline);
  --drop:0 calc(var(--px) * 3) 0 calc(var(--px) * -1) rgba(0,0,0,.4);
}
@media (max-width: 560px) { :root { --title-size:24px; } }
/* A phone on its side has little height to give the title. */
@media (max-height: 500px) { :root { --title-size:16px; } }

/* Dark mode: the house lights down, a night sky. The accents are lifted to clear contrast here,
   and the frame goes lighter, because a dark frame would vanish into the field. */
:root[data-theme="dark"] {
  --brand:#0e0f1a; --frame-ink:#62629e;
  --paper:#1c1c33; --ink:#fff6e0; --muted:#aaa5c2; --edge:#3e3e66;
  --soft:#29294a; --chip:#29294a; --chip-edge:#0a0a16; --input:#12122a;
  --mystery-a:#25254a; --mystery-b:#1e1e3c; --mystery-ink:#6f6c9a; --toast:#05050c; --link:#9fc4ff;
  --rpg-top:#1d1c5e; --rpg-bottom:#05050c;
  --red-d:#7a1228; --blue-d:#12347a;
}
/* Spooky season: overrides only, switched on by the date check in <head>/season.js. */
:root[data-season="spooky"] { --brand:#cc4a0c; --blue:#6d28d9; --blue-d:#4c1d95; }
:root[data-theme="dark"][data-season="spooky"] { --brand:#2a1307; }

/* --- the field ------------------------------------------------------------------------------ */
* { box-sizing:border-box; }
/* `hidden` must win over any display rule: a flex or inline-flex rule beats the browser's own
   [hidden] style, so `hidden` on one silently did nothing. Here rather than in theme.css because
   the phones' page needs it too: its Room button showed on the home page, outside any room. */
[hidden] { display:none !important; }
body { background:var(--brand); color:var(--on-field);
       font-family:var(--font-name); }
/* Stars, tiled: still for now, and a fixed layer rather than `background-attachment:fixed`, which
   repaints on every scroll on a phone and is ignored altogether on iOS. */
body::before { content:""; position:fixed; inset:0; z-index:-1; pointer-events:none;
  image-rendering:pixelated; background-size:320px 320px;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='320' height='320' shape-rendering='crispEdges' fill='%23fff'%3E%3Crect x='18' y='34' width='2' height='2' opacity='.7'/%3E%3Crect x='92' y='12' width='2' height='2' opacity='.35'/%3E%3Crect x='146' y='66' width='3' height='3' opacity='.55'/%3E%3Crect x='214' y='28' width='2' height='2' opacity='.5'/%3E%3Crect x='288' y='82' width='2' height='2' opacity='.75'/%3E%3Crect x='40' y='118' width='2' height='2' opacity='.4'/%3E%3Crect x='118' y='152' width='2' height='2' opacity='.65'/%3E%3Crect x='196' y='126' width='2' height='2' opacity='.3'/%3E%3Crect x='262' y='170' width='3' height='3' opacity='.5'/%3E%3Crect x='70' y='204' width='3' height='3' opacity='.45'/%3E%3Crect x='158' y='236' width='2' height='2' opacity='.7'/%3E%3Crect x='236' y='254' width='2' height='2' opacity='.35'/%3E%3Crect x='12' y='272' width='2' height='2' opacity='.55'/%3E%3Crect x='104' y='298' width='2' height='2' opacity='.4'/%3E%3Crect x='300' y='306' width='2' height='2' opacity='.6'/%3E%3C/svg%3E"); }

/* --- type ----------------------------------------------------------------------------------- */
h1 { font-family:var(--font-arcade); font-size:var(--title-size); font-weight:400; line-height:1.3; letter-spacing:0;
     text-shadow:var(--px) var(--px) 0 rgba(0,0,0,.55); text-wrap:balance; }
h2 { font-family:var(--font-display); font-weight:700; }
/* One colour per letter (wobble() in the clients): the arcade marquee. */
h1 .wob.w0 { color:var(--title-a); } h1 .wob.w1 { color:var(--title-b); }
h1 .wob.w2 { color:var(--title-c); } h1 .wob.w3 { color:var(--title-d); }
.wob { display:inline-block; }
.wob-word { display:inline-block; white-space:nowrap; }
label { font-family:var(--font-display); font-weight:700; letter-spacing:.04em; }
.roomcode, .countnum, .secs { font-family:var(--font-arcade); font-weight:400; letter-spacing:0; }
.roomcode { font-size:40px; line-height:1.3; }
.roomcode .ch { display:inline-block; margin:0 .06em; }

/* --- panels --------------------------------------------------------------------------------- */
.card { background:var(--card); color:var(--ink); border:none; box-shadow:var(--frame), var(--drop); }

/* --- buttons --------------------------------------------------------------------------------
   A face, a lower edge and a highlight, inside the frame. That lower edge plus the press-down IS
   the feel, so it is not optional on a new button: set --face and --deep, not a background. */
button { --face:var(--blue); --deep:var(--blue-d); --lit:rgba(255,255,255,.28);
         font-family:var(--font-display); font-weight:700; line-height:1.15; letter-spacing:.01em;
         border:none; cursor:pointer; color:#fff; background:var(--face);
         box-shadow:var(--frame), inset 0 calc(var(--px) * -2) 0 0 var(--deep), inset 0 var(--px) 0 0 var(--lit), var(--drop);
         touch-action:manipulation; -webkit-tap-highlight-color:transparent;
         transition:transform .05s steps(1), box-shadow .05s steps(1); }
button:active { transform:translateY(var(--px));
                box-shadow:var(--frame), inset 0 var(--px) 0 0 var(--deep); }
button:disabled { opacity:.5; cursor:not-allowed; transform:none; }
button.ghost, a.linkbtn { --face:var(--paper); --deep:var(--edge); color:var(--ghost-ink); background:var(--face);
         box-shadow:var(--frame), inset 0 calc(var(--px) * -2) 0 0 var(--deep), inset 0 var(--px) 0 0 var(--lit), var(--drop); }
button.ghost:active, a.linkbtn:active { transform:translateY(var(--px)); box-shadow:var(--frame), inset 0 var(--px) 0 0 var(--deep); }
.card button.ghost { --face:var(--soft); --deep:var(--chip-edge); }
button.alt { --face:var(--amber); --deep:var(--amber-d); color:#2b1c00; }
button.good { --face:var(--green); --deep:var(--green-d); }
button.bad { --face:var(--red); --deep:var(--red-d); }

/* --- form fields ---------------------------------------------------------------------------- */
input, select, textarea { font-family:var(--font-name); font-weight:600; color:var(--ink); background-color:var(--input);
         border:var(--px) solid var(--outline); box-shadow:inset var(--px) var(--px) 0 rgba(0,0,0,.1); }
input:focus, select:focus, textarea:focus { outline:var(--px) solid var(--blue); outline-offset:2px; border-color:var(--outline); }
/* Checkboxes and radios, drawn: the browser's own are round and smooth. Checked is a mark inside,
   never only a colour. A control in a row is sized here; the row around it is the tap target. */
input[type="checkbox"], input[type="radio"] { appearance:none; -webkit-appearance:none; flex:none; width:22px; height:22px; padding:0; margin:0;
         cursor:pointer; background:var(--input) center/14px 14px no-repeat; box-shadow:none; border:var(--px) solid var(--outline); }
input[type="checkbox"]:checked { background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 7' shape-rendering='crispEdges' fill='%231c8237'%3E%3Cpath d='M6 1h1v2H6v1H5v1H4v1H2V5H1V4H0V3h2v1h1V3h1V2h1V1z'/%3E%3C/svg%3E"); }
input[type="radio"]:checked { background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 3 3' fill='%231a1633'%3E%3Crect width='3' height='3'/%3E%3C/svg%3E"); background-size:10px 10px; }
:root[data-theme="dark"] input[type="radio"]:checked { background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 3 3' fill='%23fff6e0'%3E%3Crect width='3' height='3'/%3E%3C/svg%3E"); }
input[type="checkbox"]:focus, input[type="radio"]:focus { outline:none; }
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible { outline:var(--px) dashed currentColor; outline-offset:2px; }
/* What a field is typed into must never end up under whatever is stuck to the screen's edge. */
input, textarea, select { scroll-margin-block:96px; }
/* The browser's own rounded arrow gives the field away; this one is stepped. Two copies because a
   data: image cannot read a token. */
select { appearance:none; -webkit-appearance:none; padding-right:38px; background-repeat:no-repeat; background-position:right 12px center;
         background-size:14px 10px; background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 5' shape-rendering='crispEdges' fill='%231a1633'%3E%3Cpath d='M0 0h7v1H6v1H5v1H4v1H3V3H2V2H1V1H0z'/%3E%3C/svg%3E"); }
:root[data-theme="dark"] select { background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 5' shape-rendering='crispEdges' fill='%23fff6e0'%3E%3Cpath d='M0 0h7v1H6v1H5v1H4v1H3V3H2V2H1V1H0z'/%3E%3C/svg%3E"); }
/* Sized in px for the arcade face. 16px or more everywhere, or iOS zooms the page on focus. */
#codeInput, #pcCodeInput { font-family:var(--font-arcade); font-weight:400; font-size:24px; letter-spacing:.2em; text-align:center; text-transform:uppercase; }
#codeInput::placeholder, #pcCodeInput::placeholder { color:var(--off); }

/* --- the clock: a segmented meter ------------------------------------------------------------
   The fill slides underneath, and the gaps are a stripe on top in the field's own colour. */
.clock { position:relative; height:18px; background:rgba(0,0,0,.35); overflow:hidden;
         box-shadow:var(--frame); }
.clock i { background:var(--on-field); }
.clock::after { content:""; position:absolute; inset:0; pointer-events:none;
                background:repeating-linear-gradient(90deg, transparent 0 11px, var(--outline) 11px 14px); }
.clock.crit i { background:var(--amber); }

/* --- keyboard -------------------------------------------------------------------------------
   Everything focusable shows it the same way: clear of the frame, in a colour both fields carry. */
a:focus-visible, button:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline:var(--px) dashed var(--on-field); outline-offset:calc(var(--px) * 2); }
.card a:focus-visible, .card button:focus-visible, .card summary:focus-visible, dialog button:focus-visible {
  outline-color:var(--ink); }

/* --- small controls -------------------------------------------------------------------------
   The same button at a finer pixel. Each says what its lower edge is; a page may still set its
   own background and colour. Selected is a filled face AND a tick, set by the page's own rule. */
.pp-chip, .pp-sort button, .pp-bulk button, .pp-edit, .pickclear, .backbtn, .cs-row, .rowbtn, .rmbtn, .tile button,
.viewernav button, .viewerclose, .accolades .thumbbtn { --px:2px; --deep:var(--chip-edge); }
.pp-chip.on, .pp-sort button[aria-pressed="true"] { --deep:var(--blue-d); }
.rmbtn { --deep:var(--red-d); position:relative; }
.pickclear { position:relative; }
button.ghost.backbtn, .backbtn { --deep:var(--edge); }
.pp-edit { box-shadow:var(--frame); font-family:var(--font-display); }
/* Small counts and sentences stay in the readable face: the pixel face blurs together under about 1rem. */
.pp-n, .pp-summary, .pp-or, .pp-fallback { font-family:var(--font-name); }
.pp-cat, .pickslot { box-shadow:inset 0 0 0 2px var(--edge); }
.soundtoggle[aria-checked="false"] { --deep:rgba(0,0,0,.5); --lit:transparent; }
.rowbtn { font-family:var(--font-name); }
.cs-row { font-family:var(--font-name); }
/* A list row whose whole strip is the target, in the phones' browser: names, so the readable face. */
button.tile { font-family:var(--font-display); font-size:1.05rem; box-shadow:var(--frame), inset 0 -4px 0 0 rgba(0,0,0,.25), var(--drop); --px:2px; }
button.tile:active { box-shadow:var(--frame), inset 0 2px 0 0 rgba(0,0,0,.25); }

/* --- choice tiles: colour AND shape AND a mark when chosen ------------------------------------
   Labels, not buttons, so they carry the frame and the edge themselves. */
.choice { --px:2px; --deep:rgba(0,0,0,.3); text-transform:none; letter-spacing:.01em; font-family:var(--font-display); font-weight:700; font-size:1.1rem;
          line-height:1.15; color:#fff; box-shadow:var(--frame), inset 0 calc(var(--px) * -2) 0 0 var(--deep), var(--drop); }
.choice.c0 { --deep:var(--red-d); } .choice.c1 { --deep:var(--blue-d); }
.choice:has(input:checked) { --px:3px; }
.choice:has(input:focus-visible) { outline:var(--px) dashed var(--ink); outline-offset:calc(var(--px) * 2); }
.choice .sub { font-family:var(--font-name); line-height:1.3; margin-top:2px; }

/* --- people ---------------------------------------------------------------------------------- */
/* A player's face (shared/avatars.js): its own square and colours, sized by the SVG's width and
   height at a whole multiple of its 12px grid, so every pixel lands on whole screen pixels. */
.avatar { flex:none; display:block; }

/* The lobby's face picker. Shut, it is not there at all: your own row in the roster opens it (.mine).
   Open, every face as a 44px button. Chosen is a mark inside and a heavier frame; taken is dimmed, a
   ✕, and disabled. */
.avpick .avgrid[hidden] { display:none; }
/* Padding below for the frames and their drops, which a grid would otherwise clip at its edge. */
.avgrid { display:grid; grid-template-columns:repeat(auto-fill, minmax(48px, 1fr)); gap:10px; padding:6px 3px 10px; margin-top:6px; }
.avopt { --px:2px; --face:var(--soft); --deep:var(--chip-edge); position:relative; min-width:44px; min-height:48px;
         padding:4px 0 6px; display:flex; align-items:center; justify-content:center; }
.avopt[aria-checked="true"] { --px:3px; --face:var(--amber); --deep:var(--amber-d); }
.avopt.taken { opacity:.4; }
.avmark { position:absolute; right:2px; top:0; font-family:var(--font-display); font-weight:700; font-size:.85rem; line-height:1;
          color:var(--ink); }
.avopt[aria-checked="true"] .avmark { color:#2b1c00; }
.avnote:empty { display:none; }
.avnote { color:var(--red); margin:4px 0 0; }
.pill, #roster .seat { --px:2px; box-shadow:var(--frame), var(--drop); font-family:var(--font-name); }
/* Your own row opens the face picker (shared/avatars.js): a thumb-sized target, and a visible arrow
   for it (down while the grid is shut, up while open). The arrow is CSS keyed off aria-expanded, so
   the same attribute tells a screen reader and a player what the row is doing. */
#roster .mine { cursor:pointer; min-height:44px; }
#roster .mine::after { content:'▾'; margin-left:8px; font-family:var(--font-display); font-weight:700; color:var(--link); }
#roster .mine[aria-expanded="true"]::after { content:'▴'; }
.crown { font-family:var(--font-display); letter-spacing:.06em; }
.dot { flex:none; }
.badge, .players .tag, .chat li .kind { font-family:var(--font-display); letter-spacing:.04em; }

/* --- panels within panels -------------------------------------------------------------------- */
.pcard, .tile:not(button), .players li, .toast { --px:2px; box-shadow:var(--frame), var(--drop); }
.pcard.current, .tile.current, .spotlight { --px:4px; }
/* A highlighted panel's colour and weight are for its own frame, not for what sits inside it. */
.ruling button, .spotlight button { --outline:var(--frame-ink); --px:3px; }
.canvaswrap { box-shadow:var(--frame), var(--drop); }
.toast { font-family:var(--font-name); }
dialog.card, dialog.roommenu { color:var(--ink); }
/* Character art: framed, never pixelated. The frame is a border rather than a shadow because it has
   to stay inside the fixed box that keeps a loading picture from shoving the page. */
.art, .tart, .refart, .reveal-art, .tcart, .charcard img, .charcard .noimg, .chartile img, .chartile .noimg, .pickthumb, .cs-thumb {
  border:var(--px, 3px) solid var(--outline); image-rendering:auto; }
.tart, .pickthumb, .cs-thumb, .tcart, .chartile img, .chartile .noimg { --px:2px; }
.chartile { box-shadow:inset 0 0 0 2px var(--edge); }
.chartile .cname { font-family:var(--font-name); }
#qrImg { border:var(--px) solid var(--outline); }

/* --- the high-score table: every game's results ---------------------------------------------- */
.hiscore { list-style:none; margin:0; padding:6px 12px; display:flex; flex-direction:column; background:var(--screen); color:var(--on-screen);
           box-shadow:var(--frame); }
.hs { display:flex; align-items:center; gap:10px; padding:10px 0; border-bottom:2px dashed rgba(255,255,255,.16); }
.hs:last-child { border-bottom:none; }
.hs-place { flex:none; width:3.1em; font-family:var(--font-arcade); font-size:12px; }
.hs img { flex:none; width:44px; height:44px; object-fit:cover; object-position:50% 20%; background:rgba(255,255,255,.08); border:2px solid currentColor; }
.hs-who { flex:1; min-width:0; display:flex; flex-direction:column; gap:2px; }
.hs-name { font-family:var(--font-name); font-weight:700; line-height:1.2; overflow-wrap:anywhere; }
.hs-detail { font-size:.84rem; line-height:1.25; color:var(--on-screen-soft); overflow-wrap:anywhere; }
.hs-score { flex:none; font-family:var(--font-arcade); font-size:16px; text-align:right; }
.hs-score small { display:block; margin-top:5px; font-size:8px; color:var(--on-screen-soft); text-transform:uppercase; }
.rank1 .hs-place, .rank1 .hs-score { color:var(--gold); }
.rank2 .hs-place, .rank2 .hs-score { color:var(--silver); }
.rank3 .hs-place, .rank3 .hs-score { color:var(--bronze); }

/* Telephone's first step has no canvas to measure against, and the faces are what people choose by:
   they get their own size, and the heading some room above them. */
#telPick .choosehead { margin-bottom:12px; }
#telPick .pick .art { height:clamp(5rem, 22vw, 9rem); }

/* --- wrapping --------------------------------------------------------------------------------
   Button labels in a wrapping row stay on one line: the row wraps first. */
.row > button, .telnav > button, .confirmactions > button { white-space:nowrap; }

/* --- fingers ---------------------------------------------------------------------------------
   Everything aimed at with a thumb is 44px, in one of two ways. Where the room is there, the control
   grows. Where a row has none to give (Draw's palette holds the canvas on the screen; a player row
   holds a Remove), the control keeps its size and a transparent ::before takes the taps around it;
   the gaps between them are what makes that room, so neighbours' targets do not overlap. */
@media (pointer: coarse), (max-width: 1024px) {
  .size.fill { min-width:44px; }
  .pp-chip, .pp-sort button, .pp-bulk button, .pp-cat summary, label.pp-row, .backbtn, .backlink, .cs-row, .rowbtn, .mode,
  .reactions button, .gitem .vote, .tools button.ghost, .tools button.bad, .pick button, .viewernav button, .viewerclose,
  .spellings label, #howtoToggle, .choice, .chat .giveup, button.tile, button.undo, .rmbtn:not(.icon) { min-height:44px; }
  .rmbtn:not(.icon) { display:inline-flex; align-items:center; justify-content:center; }
  .themetoggle::before, .crttoggle::before, .roombtn::before, .soundtoggle::before, .swatch::before, .size::before, .rmbtn.icon::before, .pickclear::before {
    content:""; position:absolute; }
  .themetoggle::before, .crttoggle::before { inset:-8px -2px; }
  .roombtn::before { inset:-8px 0; }
  .soundtoggle::before { inset:-8px -5px; }
  .swatch::before, .size::before { inset:-4px; }
  .rmbtn.icon::before { inset:-9px; }
  .pickclear::before { inset:-10px -6px; }
  /* The Draw search toggle's row, and any label that is a whole row with a checkbox in it. */
  label.seat { min-height:44px; }
  /* Draw's New Choices and Search, beside the drawer's three choices. */
  .choosehead button { min-height:44px; }
  /* A Telephone or Draw guess box: the keyboard opens over this, and the same 44px holds. */
  .guessbox button, .telguess button, .chat form button { min-height:44px; }
}

/* --- motion ----------------------------------------------------------------------------------
   Stepped, like a game of the era: a few hard frames rather than an ease. All of it is inside this
   block, so asking for reduced motion gets a page that simply changes. The information is never only
   in the motion: the clock's colour, the words on the page and the toasts all still say it. */
@media (prefers-reduced-motion: no-preference) {
  /* A new screen slides in. `backwards` and no forward fill: a leftover transform would make this the
     containing block for anything fixed or sticky inside it, like the compendium's bar. No fade: if
     the page stops drawing partway, as a hidden one does, a fade would leave the whole game invisible. */
  @keyframes screenIn { from { transform:translateY(12px); } to { transform:none; } }
  .screen.active { animation:screenIn .16s steps(4) backwards; }

  /* Someone joined. Only them: .new is set once per player (GTC.isNewSeat). */
  @keyframes badgePop { 0% { transform:scale(.4); opacity:0; } 60% { transform:scale(1.12); opacity:1; } 100% { transform:scale(1); } }
  .pill.new, #roster .seat.new { animation:badgePop .24s steps(4) backwards; }

  /* Tiles tip back as they are pressed and pop when chosen, on a perspective so it reads as a thing
     with depth. Hover is only ever extra: everything here also works by tapping. */
  @keyframes tilePop { 0% { transform:none; } 45% { transform:perspective(400px) rotateX(-16deg) scale(1.04); } 100% { transform:none; } }
  .choice:has(input:checked), .pp-chip.on, .mode[aria-checked="true"], .spellings label:has(input:checked) { animation:tilePop .22s steps(4); }
  .choice:active, .devicebtn:active, .pick button:active, .mode:active, button.tile:active {
    transform:perspective(400px) rotateX(14deg) translateY(var(--px)); }
  @media (hover: hover) {
    .choice:hover, .devicebtn:hover, .pick button:hover, .mode:hover, button.tile:hover { transform:translateY(-2px); }
    .choice:active, .devicebtn:active, .pick button:active, .mode:active, button.tile:active {
      transform:perspective(400px) rotateX(14deg) translateY(var(--px)); }
  }

  /* The last ten seconds: the bar alternates once a second, so two changes a second, well under the
     three a second that photosensitivity guidance draws the line at. Only the bar, never the screen. */
  @keyframes critBlink { 0%, 49% { background:var(--amber); } 50%, 100% { background:var(--red); } }
  .clock.crit i { animation:critBlink 1s steps(1) infinite; }

  /* The countdown's number stamps down. A new span each second (wobble), so this replays by itself. */
  @keyframes stamp { 0% { transform:scale(1.8); opacity:0; } 50% { transform:scale(.92); opacity:1; } 100% { transform:scale(1); } }
  .countnum .wob { animation:stamp .24s steps(4) backwards; }

  /* The high scores arrive one row at a time. Only the first eight wait: fifty players' worth of
     delays would leave the bottom of a big room's table blank for seconds. */
  @keyframes hsIn { from { opacity:0; transform:translateX(-14px); } to { opacity:1; transform:none; } }
  .hs { animation:hsIn .2s steps(4) backwards; }
  .hs:nth-child(2) { animation-delay:.12s; } .hs:nth-child(3) { animation-delay:.24s; } .hs:nth-child(4) { animation-delay:.36s; }
  .hs:nth-child(5) { animation-delay:.48s; } .hs:nth-child(6) { animation-delay:.6s; } .hs:nth-child(7) { animation-delay:.72s; }
  .hs:nth-child(8) { animation-delay:.84s; }

  /* Look here: a small marker blinks four times as it appears, then holds still. Once a second,
     like the clock's last ten, and on a glyph, never a panel. Restarts whenever its box is shown again
     (a dialog reopened), which is the point: it is for something people keep not noticing. */
  @keyframes nudgeBlink { 0%, 49% { visibility:visible; } 50%, 100% { visibility:hidden; } }
  .nudge { animation:nudgeBlink 1s steps(1) 4; }

  /* A miss in a game of fast guesses (GTC.shake). */
  @keyframes shake { 0%, 100% { transform:none; } 25% { transform:translateX(-5px); } 75% { transform:translateX(5px); } }
  .shake { animation:shake .24s steps(4); }

  /* One tint and one stamped word (GTC.flash, which keeps them apart and has the rules for it). */
  @keyframes flashTint { 0% { opacity:0; } 25%, 45% { opacity:1; } 100% { opacity:0; } }
  .flash { position:fixed; inset:0; z-index:45; pointer-events:none; display:flex; align-items:center; justify-content:center;
           animation:flashTint .6s steps(6) forwards; }
  .flash.good { background:rgba(28,130,55,.28); } .flash.bad { background:rgba(212,42,74,.22); } .flash.near { background:rgba(255,176,0,.24); }
  @keyframes flashStamp { 0% { transform:scale(1.4); } 40% { transform:scale(.9); } 60%, 100% { transform:scale(1); } }
  .flash-stamp { font-family:var(--font-arcade); font-size:32px; padding:14px 18px; color:var(--on-screen); background:var(--screen);
                 --px:4px; box-shadow:var(--frame); animation:flashStamp .3s steps(4); }
  .flash.good .flash-stamp { --outline:var(--green); } .flash.bad .flash-stamp { --outline:var(--red); } .flash.near .flash-stamp { --outline:var(--amber); }
  /* Your turn: the one flash that is meant to be bright, because it is the one that has to reach
     somebody looking elsewhere. Still one flash per turn, never a loop, and nothing at all under
     reduced motion (GTC.flash); the page says whose turn it is in words as well. */
  .flash.turn { background:rgba(255,224,102,.62); animation-duration:.9s; }
  .flash.turn .flash-stamp { --outline:var(--amber); }

  /* The CRT screen's flicker: the glass breathes by a few percent of its own faint layer, so the
     page underneath changes by under one percent. Far too small and too slow to be a flash. */
  @keyframes crtFlicker { 0%, 100% { opacity:1; } 30% { opacity:.86; } 60% { opacity:.94; } }
  /* Only between games: during play (data-playing, set from the page's own play screens) the glass
     holds still, like every other idle animation, and nothing repaints for it. */
  :root[data-crt]:not([data-playing]) body::after { animation:crtFlicker 4s steps(6) infinite; }

  /* Square confetti (GTC.confetti). */
  @keyframes confettiFall { from { transform:translateY(-20px); } to { transform:translateY(calc(100vh + 40px)); } }
  .confetti { position:fixed; inset:0; z-index:44; overflow:hidden; pointer-events:none; }
  .confetti i { position:absolute; top:0; animation:confettiFall 1.6s steps(18) backwards; }

  /* Flybys (/shared/flybys.js): two frames for the rocket's flame and the saucer's lights; floating
     things bob; rocks turn a quarter at a time, which keeps every pixel square. */
  @keyframes fbFrameA { 0%, 49% { visibility:visible; } 50%, 100% { visibility:hidden; } }
  @keyframes fbFrameB { 0%, 49% { visibility:hidden; } 50%, 100% { visibility:visible; } }
  .fb-anim .fb-f0 { animation:fbFrameA .4s steps(1) infinite; }
  .fb-anim .fb-f1 { animation:fbFrameB .4s steps(1) infinite; }
  @keyframes fbBob { 0%, 100% { transform:translateY(0); } 50% { transform:translateY(6px); } }
  .fb-bob svg { animation:fbBob 2.4s steps(4) infinite; }
  @keyframes fbTumble { to { transform:rotate(360deg); } }
  .fb-tumble svg { animation:fbTumble 3.2s steps(4) infinite; }

  /* An RPG text box's ▼, once its words are out: once a second, so well clear of a flash. Still
     during play (data-playing), where the toasts are news and not a toy. */
  @keyframes rpgBlink { 0%, 49% { opacity:1; } 50%, 100% { opacity:0; } }
  :root:not([data-playing]) .typed > .rpgtext::after, :root:not([data-playing]) .rpgtext.typed::after { animation:rpgBlink 1s steps(1) infinite; }
  /* The menu pointer taps toward what it points at, two frames, as the hand did. Not during play. */
  @keyframes gloveTap { 0%, 49% { transform:none; } 50%, 100% { transform:translateX(3px); } }
  :root:not([data-playing]) .glove svg { animation:gloveTap .8s steps(1) infinite; }
}

/* --- the CRT screen -------------------------------------------------------------------------
   The whole page as if on a tube: scanlines, a darker rim that reads as the glass curving away, and
   a glow on the arcade type. On unless someone turns it off (gtc_crt, decided before first paint by
   season.js and the phones' <head>; the switches are GTC.bindCrtToggles). One fixed layer over the
   page, never a transform of the page itself: bending the page would blur every line of text and
   make anything fixed inside it scroll away.
   Kept in check, because it lies over the panels people read. Every layer costs contrast (the
   contrast formula's flare term means even a black that darkens text and paper alike costs some),
   so each is measured against the palette, light and dark. The wash -- 7% of a phosphor green over
   everything, tinting the whites and lifting the blacks the way an old tube did -- is the look, and
   alone takes ink on cream 16.2:1 -> 13.7, muted on cream 6.8 -> 5.8, white on a blue button
   5.4 -> 4.8, the red error line 4.6 -> 4.5, dark mode's muted on --soft 5.8 -> 5.1, and white on
   a green button 5.0 -> 4.3 (bold, button-sized). The rim is kept low for that reason: nothing
   until 65% out, .2 at the very corner, where only the title row's controls sit (Room, ink on
   cream: 9.4). At the rim muted text holds 4.9 (light) and 4.0 (dark, on --soft). Raise either
   layer and the red error line and the green button go first.
   It takes no taps, and screen readers never see it (a pseudo-element with no text).
   Below the flash and confetti (44, 45), which are their own effects, and below the forehead overlay
   only by being switched off there (data-plain): that overlay sits inside main's stacking context
   (z-index 1 on the phones), so no z-index of its own could put it above a layer here.
   Everything else is under the glass alike: character art, drawings and the join QR code. Lifting
   any of them cannot work everywhere (the phones' main is a stacking context, and so is any screen
   mid-slide), and lifting some made the same drawing look different in two places. The QR code was
   checked: it still decodes with the glass over it. */
:root[data-crt] body::after { content:""; position:fixed; inset:0; z-index:40; pointer-events:none;
  background:
    radial-gradient(ellipse 120% 100% at 50% 50%, transparent 65%, rgba(0,0,0,.2) 100%),
    repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0,0,0,.16) 2px 3px),
    linear-gradient(rgba(80,255,150,.07), rgba(80,255,150,.07)); }
/* A page sets data-plain on <html> while a display surface is up (the phones' forehead view), and the
   glass steps aside. A page-set attribute rather than a selector for the surface, so this file names
   no game's elements and works without :has(). */
:root[data-plain] body::after { display:none; }
/* Asked-for contrast beats a look: no glass, and no glow (below). The switch still says on: it is a
   choice about the look, and this is the device's own setting stepping in for as long as it is set. */
@media (prefers-contrast: more) { :root[data-crt] body::after { display:none; } }
/* Phosphor glow on the dark surfaces' arcade type: the title, the clock's numbers, the high scores.
   Never on the cream panels, where a glow is only a blur round dark letters. The title keeps its
   own drop shadow underneath. Set on each letter as well as the heading: currentColor resolves where
   the shadow is declared, so the heading's alone would give every letter of the marquee a cream glow. */
@media (prefers-contrast: no-preference) {
  :root[data-crt] h1, :root[data-crt] h1 .wob { text-shadow:var(--px) var(--px) 0 rgba(0,0,0,.55), 0 0 12px color-mix(in srgb, currentColor 60%, transparent); }
  :root[data-crt] .hiscore .hs-place, :root[data-crt] .hiscore .hs-score, :root[data-crt] .flash-stamp {
    text-shadow:0 0 8px color-mix(in srgb, currentColor 55%, transparent); }
}
/* Drawings stay UNDER the glass, the canvas included. Lifting the canvas alone left the same drawing
   striped in the gallery and the Telephone chain (outside .canvaswrap, some inside stacking contexts
   no z-index escapes) and put the canvas over the toast feed (z-index 20). Under the glass, a drawing
   looks the same everywhere on this screen; the paper itself is still white in both themes. */
/* The switch: a small track and a sliding knob, like dark mode's beside it, and labelled in words
   in the row that holds it (.crtrow). Its state is aria-checked, which is also what moves the knob. */
.crttoggle { position:relative; flex:none; width:56px; height:30px; padding:0; color:#fff;
  --px:2px; --face:rgba(0,0,0,.28); --deep:transparent; --lit:transparent; --outline:rgba(255,255,255,.4); }
.crttoggle:active { transform:none; }
.crttoggle .knob { position:absolute; top:3px; left:3px; width:24px; height:24px; background:#fff; color:var(--brand);
  font-size:1rem; line-height:24px; text-align:center; }
.crttoggle[aria-checked="true"] { --face:var(--green); }
.crttoggle[aria-checked="true"] .knob { left:29px; color:var(--green-d); }
.crttoggle:focus-visible { outline:3px solid #fff; outline-offset:3px; }
.crtrow { display:flex; align-items:center; justify-content:center; gap:12px; margin:8px 0 0;
  font-family:var(--font-display); font-weight:700; color:var(--on-field); }
.crtrow .crtstate { min-width:2em; font-family:var(--font-name); font-weight:600; opacity:.85; }

/* --- 3D accents (/shared/fx3d.js) ------------------------------------------------------------
   A FIXED height, so nothing below moves when the renderer arrives, or never does. The sprite is
   there from the start and the canvas goes over it. Both are low resolution scaled up hard-edged. */
.fx3d { position:relative; width:100%; height:var(--fx-h, 120px); margin:0 auto; pointer-events:none; }
.fx3d.slim { --fx-h:88px; }
.fx3d canvas { position:absolute; top:0; left:50%; transform:translateX(-50%); height:100%; width:auto; max-width:100%;
               image-rendering:pixelated; }
.fx3d.live .fx3d-sprite { visibility:hidden; }
.screen > .fx3d { margin-bottom:12px; }
@media (min-width: 761px) {
  .fx3d { --fx-h:170px; }
  .fx3d.slim { --fx-h:120px; }
  .fx3d[data-fx="podium"] { --fx-h:250px; }
}
/* A phone on its side has no height to spare for decoration: the game comes first. */
@media (max-height: 500px) { .fx3d { display:none; } }
/* Who stands where: in HTML under the podium, because names may be in any script. A phone gets the
   trophy and no podium, and the table right below already says it. */
.fx3d-names { display:none; }
@media (min-width: 761px) {
  .fx3d-names { display:grid; grid-template-columns:repeat(3, minmax(0, 1fr)); gap:12px; max-width:34rem; margin:0 auto 14px; text-align:center;
                font-family:var(--font-name); font-weight:700; color:var(--on-field); }
  /* A tie stacks its names one per line under the place, and every line wraps: a long name is never
     cut off, and a second winner on the same step is never hidden. */
  .fx3d-names > span { min-width:0; overflow-wrap:anywhere; }
  .fx3d-names i { display:block; font-style:normal; }
  /* Each says its place, because the names cannot line up with steps that turn. */
  .fx3d-names > span:empty { visibility:hidden; }
  .fx3d-names > span::before { display:block; font-family:var(--font-arcade); font-weight:400; font-size:12px; margin-bottom:.5em; }
  [data-podium-place="1"]::before { content:"1ST"; color:var(--gold); }
  [data-podium-place="2"]::before { content:"2ND"; color:var(--silver); }
  [data-podium-place="3"]::before { content:"3RD"; color:var(--bronze); }
}

/* --- flybys (/shared/flybys.js) --------------------------------------------------------------
   Now and then something crosses the stars. Just above them (z-index -1, after body::before) and
   under everything else; no taps, nothing to read. Hidden outright for reduced motion, during play on
   any page (data-playing) and under a display surface (data-plain), whatever the script has already
   sent up. The crossing itself is the script's; the sprite's own small motions are in *motion*. */
.flybys { position:fixed; inset:0; z-index:-1; overflow:hidden; pointer-events:none; contain:strict; }
.flyby { position:absolute; top:0; left:0; opacity:.85; will-change:transform; }
.flyby svg { display:block; }
.flyby .fb-f1 { visibility:hidden; }
:root[data-playing] .flybys, :root[data-plain] .flybys { display:none; }
@media (prefers-reduced-motion: reduce) { .flybys { display:none; } }

/* --- RPG text boxes and the menu pointer ------------------------------------------------------
   Homages to the 16-bit RPGs, drawn here rather than borrowed: words that type themselves out in a
   framed window, a ▼ when they are done, and a white glove pointing at the choice. GTC.typeOut,
   GTC.toast and GTC.ask (common.js) and /shared/pointer.js; the motion itself is in *motion*. */
/* Out of sight, still read: the whole of a typed message, once (common.js). */
.sr { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
/* The untyped rest of a message holds its place, so a box is its full size from the first frame. */
.tw-rest { visibility:hidden; }
/* The ▼ is laid out from the start too (hidden until the words are out), so it never pushes a line. */
.rpgtext::after { content:"▼"; display:inline-block; margin-left:.35em; font-size:.7em; vertical-align:.1em; visibility:hidden; }
.typed > .rpgtext::after, .rpgtext.typed::after { visibility:visible; }
.toast, dialog.rpgbox { color:#fff; background:linear-gradient(var(--rpg-top), var(--rpg-bottom));
  box-shadow:var(--frame), inset 0 0 0 2px var(--rpg-rule), var(--drop); }
/* A question, at the top centre of the screen, where the eye lands first and a thumb at the bottom
   of a phone does not have to reach past it. Readable face, and big: it is read once, by someone
   deciding something. */
dialog.rpgbox { position:fixed; inset:max(24px, env(safe-area-inset-top)) 0 auto; margin:0 auto; --px:3px;
  width:min(34rem, calc(100vw - 32px)); max-width:none; max-height:calc(100dvh - 48px); overflow:auto;
  padding:18px 20px 16px; border:none; font-family:var(--font-name); }
dialog.rpgbox::backdrop { background:rgba(5,5,12,.55); }
dialog.rpgbox .rpgtext { margin:0; font-size:1.45rem; line-height:1.25; overflow-wrap:anywhere; }
/* The choices: room on each one's left for the pointer, and 44px for a thumb. */
.rpgchoices { display:flex; flex-wrap:wrap; justify-content:flex-end; gap:12px 16px; margin-top:16px; padding-left:48px; }
.rpgchoices button { min-height:44px; padding:10px 18px; font-size:1.05rem; }
dialog.rpgbox button:focus-visible { outline-color:var(--rpg-rule); }
/* The pointer itself: one fixed sprite, moved by transform. Above the page and its feed, under the
   CRT glass like everything else; never a target. */
.glove { position:fixed; top:0; left:0; z-index:30; pointer-events:none; line-height:0;
  filter:drop-shadow(0 2px 0 rgba(0,0,0,.35)); }
.glove svg { display:block; }
:root[data-plain] .glove { display:none; }
