/* Game Night by Giggle — sticker-party arcade.
 * Raspberry primary, sunshine supporting blocks, ink outlines, small hard
 * offset shadows, fresh white / pale blush ground. Chunky Baloo 2 display
 * type + readable Nunito body. Two coherent looks: Day (default) and Night
 * (near-black + pink/yellow, never purple). Old stored ids (dark/light/
 * arcade/lounge) migrate to day/night in app.js.
 * Baloo 2 + Nunito are self-hosted variable woff2 (latin + latin-ext,
 * SIL OFL — see public/fonts/README.md), so the party look never falls
 * back to a corporate system font when a CDN is blocked. */
@font-face {
  font-family: "Baloo 2"; font-style: normal; font-weight: 400 800;
  font-display: swap; src: url("/fonts/baloo2-latin.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: "Baloo 2"; font-style: normal; font-weight: 400 800;
  font-display: swap; src: url("/fonts/baloo2-latin-ext.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: "Nunito"; font-style: normal; font-weight: 400 800;
  font-display: swap; src: url("/fonts/nunito-latin.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: "Nunito"; font-style: normal; font-weight: 400 800;
  font-display: swap; src: url("/fonts/nunito-latin-ext.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;
}
:root {
  --bg: #fdf3f6;
  --card: #ffffff;
  --well: #f9e7ef;
  --chip: #ffffff;
  --ink: #2b1220;
  --ink-dim: #8a6172;
  --edge: #2b1220;
  --hard: #2b1220;
  --line: #2b122022;
  --line-strong: #2b122055;
  --accent: #de1e6a;
  --accent-deep: #8f0f42;
  --accent-soft: #fde3ee;
  --accent-ink: #ffffff;
  --sun: #ffb020;
  --sun-soft: #ffe9be;
  --sun-ink: #3d2a00;
  --melon: #f2545b;
  --melon-deep: #b92a35;
  --melon-soft: #ffe3e4;
  --teal: #0e9b8a;
  --teal-deep: #0a5f55;
  --sky: #3e9be0;
  --green: #1fa971;
  --signal: #f2545b;
  --signal-deep: #b92a35;
  --signal-soft: #ffe3e4;
  --input-bg: #ffffff;
  --topbar-bg: #fdf3f6;
  --shadow-card: 6px 6px 0 var(--hard);
  --shadow-btn: 4px 4px 0 var(--hard);
  --shadow-sm: 3px 3px 0 var(--hard);
  --font-display: "Baloo 2", "Nunito", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}

[data-theme="night"] {
  --bg: #150d11;
  --card: #211419;
  --well: #2b1b22;
  --chip: #2b1b22;
  --ink: #fbeff4;
  --ink-dim: #c9a9b6;
  --edge: #fbeff4;
  --hard: #000000;
  --line: #fbeff422;
  --line-strong: #fbeff455;
  --accent: #ff4f8f;
  --accent-deep: #ffa3c4;
  --accent-soft: #3a1626;
  --accent-ink: #1b0a11;
  --sun: #ffc24d;
  /* Raspberry-dark highlight: a dark-gold value here reads as brown on the
   * watcher banner and turn panels. Light text stays readable on this. */
  --sun-soft: #4a2135;
  --sun-ink: #1e1400;
  --melon: #ff7a80;
  --melon-deep: #ffb3b6;
  --melon-soft: #3a1518;
  --teal: #2bd4bd;
  --teal-deep: #9ef0e4;
  --sky: #6cb8ee;
  --green: #4ade80;
  --signal: #ff7a80;
  --signal-deep: #ffb3b6;
  --signal-soft: #3a1518;
  --input-bg: #150d11;
  --topbar-bg: #150d11;
}

* { box-sizing: border-box; }
/* Robust hidden: no authored display rule may ever reveal a [hidden]
 * element (connection banner, timers, how-to). The :not() guards below
 * are belt-and-braces so equal-specificity display rules cannot win by
 * source order. */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-soft); }

.app { max-width: 1120px; margin: 0 auto; padding: 0 20px 64px; }

h1, h2, h3, .display {
  font-family: var(--font-display);
  margin: 0 0 10px;
  line-height: 1.04;
  letter-spacing: -0.01em;
}
h1 { font-size: clamp(38px, 5.2vw, 60px); font-weight: 800; }
h2 { font-size: 26px; font-weight: 800; }
h3 { font-size: 19px; font-weight: 800; }
.muted { color: var(--ink-dim); }
.small { font-size: 13px; }
.center { text-align: center; }
.mt { margin-top: 16px; }
.only-phone { display: none !important; }

/* ---- nav: a clean branded bar, not a floating capsule ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--topbar-bg);
  border-bottom: 3px solid var(--edge);
  margin: 0 -20px 8px; padding: 12px 20px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-display); font-weight: 800; font-size: 23px;
  color: var(--ink); text-decoration: none; letter-spacing: -0.02em;
  white-space: nowrap;
}
.brand small {
  font-family: var(--font-body); font-weight: 700; font-size: 12px;
  color: var(--ink-dim); letter-spacing: 0; white-space: nowrap;
}
.brand .dot { color: var(--accent); }
.brandmark { flex: none; display: block; transform: rotate(-6deg); }
.roomchip {
  font-family: var(--font-display); font-weight: 800; font-size: 15px;
  letter-spacing: 3px; text-indent: 3px;
  background: var(--sun); color: var(--sun-ink);
  border: 2.5px solid var(--edge); border-radius: 999px;
  padding: 4px 14px; box-shadow: var(--shadow-sm);
}
.connbar:not([hidden]) {
  display: flex; gap: 10px; align-items: center; justify-content: center;
  background: var(--melon-soft); border: 2.5px solid var(--melon);
  border-radius: 14px; padding: 9px 14px; margin: 12px 0 16px;
  font-size: 14px; font-weight: 700;
}

/* ---- surfaces ---- */
.card {
  background: var(--card);
  border: 3px solid var(--edge);
  border-radius: 20px;
  box-shadow: var(--shadow-card);
  padding: 24px;
  margin-bottom: 24px;
}
/* Unboxed page band: the page itself is the fun place, not panels
 * inside panels. */
.band { padding: 26px 4px; }
.band + .band { border-top: 3px dashed var(--line-strong); }

/* ---- buttons: chunky sticker pills, level and readable ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-display); font-weight: 800; font-size: 17px;
  background: var(--accent); color: var(--accent-ink);
  border: 3px solid var(--edge); border-radius: 999px;
  padding: 10px 28px; cursor: pointer; min-height: 50px;
  box-shadow: var(--shadow-btn);
  transition: box-shadow 0.15s ease, transform 0.08s ease, background 0.15s ease;
}
/* Hover lift only where a real hover exists — touch taps must never
 * leave a stuck hover state. */
@media (hover: hover) {
  .btn:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--hard); }
  .chip:hover { color: var(--ink); }
  .howto-btn:hover:not(:disabled) { color: var(--accent-deep); }
  .howto-btn.cust:hover:not(:disabled) { color: var(--accent-deep); }
  .voteopt:hover:not(:disabled) { background: var(--accent-soft); }
}
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--hard); }
.btn.sun { background: var(--sun); color: var(--sun-ink); }
.btn.ghost {
  background: var(--card); color: var(--ink);
  border: 3px solid var(--edge);
  font-family: var(--font-body); font-weight: 800; font-size: 15px;
  padding: 8px 20px; min-height: 46px;
}
.btn.big { font-size: 19px; padding: 12px 36px; min-height: 54px; }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; box-shadow: var(--shadow-btn); }
.btn:focus-visible, .voteopt:focus-visible, .chip:focus-visible,
.gamepick:focus-visible, input[type="text"]:focus-visible,
.howto-btn:focus-visible, .swatch:focus-visible, .pick-play:focus-visible,
.invite-more:focus-visible, .sharefold summary:focus-visible {
  outline: 3px solid var(--accent-deep); outline-offset: 2px;
}

/* ---- forms ---- */
label { display: block; font-weight: 800; font-size: 14px; margin: 14px 0 7px; }
input[type="text"], input[type="number"], select, textarea {
  background: var(--input-bg); border: 2.5px solid var(--edge);
  border-radius: 14px; color: var(--ink);
  font-size: 16px; padding: 11px 14px; width: 100%;
  font-family: var(--font-body); font-weight: 600;
}
input::placeholder, textarea::placeholder { color: var(--ink-dim); opacity: 0.85; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--edge); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-sm);
}
input[type="number"] { max-width: 220px; }
input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---- home hero: unboxed headline + sticker form + poster wall ---- */
.hero {
  display: grid; grid-template-columns: 1.02fr 0.98fr; gap: 44px; align-items: center;
  padding: 34px 4px 30px;
}
.hero-eyebrow {
  display: inline-block;
  font-size: 12.5px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--sun-ink); background: var(--sun);
  border: 2.5px solid var(--edge); border-radius: 999px;
  padding: 5px 16px; margin: 0 0 16px;
  box-shadow: var(--shadow-sm);
  transform: rotate(-2deg);
}
.hero h1 { margin-bottom: 14px; }
.hero h1 .pop { color: var(--accent); }
.hero-sub { font-size: 17px; font-weight: 600; color: var(--ink-dim); margin: 0 0 22px; max-width: 44ch; }
/* Party ticket: the name/create/join form reads as one admission
 * ticket — stub header, punched side notches, dashed tear line — with
 * the same ids and keyboard behavior as before. */
.ticket {
  position: relative;
  background: var(--card);
  border: 3px solid var(--edge); border-radius: 22px;
  box-shadow: var(--shadow-card);
  padding: 18px 20px 20px;
}
.hero-form { display: grid; gap: 10px; max-width: 400px; }
.hero-form label { margin: 0; font-size: 15px; }
.hero-form input[type="text"] { box-shadow: var(--shadow-sm); }
.ticket-head { display: flex; align-items: center; gap: 10px; margin-bottom: 2px; }
.ticket-title {
  font-family: var(--font-display); font-weight: 800; font-size: 19px;
}
.ticket-stub {
  margin-left: auto; flex: none;
  font-family: var(--font-display); font-weight: 800; font-size: 12px;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent-ink); background: var(--accent);
  border: 2.5px solid var(--edge); border-radius: 999px;
  padding: 2px 12px; transform: rotate(2deg);
  box-shadow: 2px 2px 0 var(--hard);
}
.ticket-or {
  position: relative; text-align: center; margin: 6px 0 2px;
  border-top: 2.5px dashed var(--line-strong);
}
.ticket-or span {
  position: relative; top: -13px;
  font-size: 13px; font-weight: 800; color: var(--ink-dim);
  background: var(--card); padding: 0 12px;
}
.ticket-or::before, .ticket-or::after {
  content: ""; position: absolute; top: -11px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--bg); border: 3px solid var(--edge);
}
.ticket-or::before { left: -34px; clip-path: inset(0 0 0 50%); border-left: none; }
.ticket-or::after { right: -34px; clip-path: inset(0 50% 0 0); border-right: none; }
.hero-joinrow { display: flex; gap: 10px; }
.hero-joinrow input { max-width: 132px; text-transform: uppercase; font-weight: 800; letter-spacing: 2px; }
.hero-joinrow .btn { flex: 1; white-space: nowrap; }
.hero-cta { display: flex; }
.hero-cta .btn { white-space: nowrap; }
/* Poster wall: tilted white-sticker frames with art, sticker labels, and
 * original code-native doodles. Decorative only (aria-hidden in markup). */
.hero-art { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.poster {
  background: var(--card); border: 3px solid var(--edge); border-radius: 18px;
  box-shadow: var(--shadow-card); padding: 9px 9px 12px; position: relative;
}
.poster img, .poster .art-fallback {
  width: 100%; border-radius: 10px; border: 2.5px solid var(--edge);
  object-fit: cover; aspect-ratio: 16 / 10; display: block;
}
.poster .tag {
  position: absolute; left: 14px; bottom: 16px;
  font-family: var(--font-display); font-weight: 800; font-size: 13px;
  background: var(--sun); color: var(--sun-ink);
  border: 2.5px solid var(--edge); border-radius: 999px; padding: 1px 12px;
  box-shadow: 2px 2px 0 var(--hard); transform: rotate(-3deg);
}
.poster.wide { grid-column: 1 / -1; transform: rotate(1.2deg); }
.poster.wide img, .poster.wide .art-fallback { aspect-ratio: 16 / 7.2; }
.poster.tilt-l { transform: rotate(-1.8deg); }
.poster.tilt-r { transform: rotate(1.6deg); }
.poster.alt .tag { background: var(--accent); color: var(--accent-ink); }
.doodle { position: absolute; pointer-events: none; z-index: 2; }
.doodle.star-tl { top: -22px; left: -16px; transform: rotate(-12deg); }
.doodle.star-br { bottom: -14px; right: -10px; transform: rotate(10deg); }
.doodle.squig { bottom: -24px; left: 34%; }

/* ---- home picks: art-led poster strip, honest CTAs ---- */
.sec-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.sec-head h2 { margin-bottom: 2px; }
.sec-head .muted { font-size: 14px; font-weight: 600; }
.sec-head .count-pill {
  font-family: var(--font-display); font-weight: 800; font-size: 13px;
  background: var(--accent-soft); color: var(--accent-deep);
  border: 2.5px solid var(--edge); border-radius: 999px; padding: 1px 12px;
}
.pick-grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-top: 16px; }
.pick {
  background: var(--card); border: 3px solid var(--edge);
  border-radius: 18px; overflow: hidden; padding-bottom: 14px;
  box-shadow: var(--shadow-card);
  display: flex; flex-direction: column;
}
.pick .gart { border-bottom: 3px solid var(--edge); }
.pick .t { font-family: var(--font-display); font-weight: 800; font-size: 19px; padding: 12px 16px 0; }
.pick .d { font-size: 14px; font-weight: 600; color: var(--ink-dim); padding: 2px 16px 0; }
.pick .p { font-size: 13px; color: var(--melon-deep); font-weight: 800; padding: 6px 16px 0; }
/* Actions anchor to the card foot: every pick keeps one constant compact
 * geometry whether its instructions are opened or not. */
.pick .row { padding: 8px 16px 0; margin-top: auto; }
.pick-play {
  background: none; border: none; padding: 2px 0; cursor: pointer;
  color: var(--accent-deep); font: inherit; font-size: 13.5px; font-weight: 800;
  font-family: var(--font-body); text-decoration: underline; text-underline-offset: 3px;
}
.catalog-list {
  display: grid; gap: 10px; grid-template-columns: 1fr 1fr; margin-top: 16px;
}
.catrow {
  display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; gap: 12px;
  align-items: center; background: var(--card);
  border: 2.5px solid var(--edge); border-radius: 14px; padding: 8px 14px 8px 8px;
  box-shadow: var(--shadow-sm);
}
.catrow .howto-btn { white-space: nowrap; }
.catrow img, .catrow .art-fallback {
  width: 76px; height: 52px; object-fit: cover; border-radius: 9px; display: block;
  border: 2px solid var(--edge);
}
.catrow .art-fallback { font-size: 22px; }
.catrow .t { font-weight: 800; font-size: 15px; line-height: 1.25; }
.catrow .d { font-size: 13px; font-weight: 600; color: var(--ink-dim); line-height: 1.35; }
.catrow .p { font-size: 12px; color: var(--melon-deep); font-weight: 800; }
.browse-wrap { display: flex; justify-content: center; margin-top: 18px; }
.giggle-strip {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-top: 22px; padding: 14px 18px;
  font-size: 14.5px; font-weight: 600; color: var(--ink-dim);
  background: var(--card); border: 2.5px dashed var(--line-strong); border-radius: 16px;
}
.giggle-strip a { color: var(--accent-deep); font-weight: 800; }

/* ---- lobby: full-width sunny party strip, catalog below ----
 * No permanent side column: one horizontal invitation band (code +
 * copy/share/QR + the real roster) sits above full-width
 * recommendations and catalog. */
.lobby { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; align-content: start; padding-top: 14px; }
.lobby > section { min-width: 0; }
.partystrip {
  display: flex; gap: 16px 30px; align-items: center; flex-wrap: wrap;
  background: var(--sun); color: var(--sun-ink);
  border: 3px solid var(--edge); border-radius: 20px;
  box-shadow: var(--shadow-card);
  padding: 14px 22px;
}
.ps-invite { display: flex; gap: 16px 20px; align-items: center; flex-wrap: wrap; }
.ps-codeblock { line-height: 1; }
.partystrip .roommeta { font-size: 12.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 2px; }
.roomcode {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(30px, 3.4vw, 38px);
  letter-spacing: 5px; color: var(--accent-deep); line-height: 1.05;
}
.partystrip .roomcode { color: #7a0b3d; }
[data-theme="night"] .partystrip .roomcode { color: #7a0b3d; }
/* Embedded squad rooms show a label instead of a shareable code. */
.roomcode-private { font-size: 26px; letter-spacing: 0; }
/* Embedded context stays compact (the parent already shows friends and
 * video): one host/count line plus small name chips, no avatar/points
 * rail, no share controls. */
.embedctx { display: flex; gap: 4px 14px; align-items: baseline; flex-wrap: wrap; }
.embedctx .roomcode-private { font-size: 24px; }
.embedplayers { margin: 0; gap: 6px; }
.embedplayers .player { padding: 3px 10px; font-size: 13px; }
.ps-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.ps-actions .btn { min-height: 44px; font-size: 15px; padding: 8px 20px; }
.ps-party { margin-left: auto; min-width: min(340px, 100%); flex: 1 1 340px; }
.ps-party .players { margin: 8px 0 0; }
.ps-status { font-size: 14.5px; font-weight: 800; }
.partystrip .player { background: #fff; border-color: var(--edge); color: #2b1220; box-shadow: 2px 2px 0 var(--edge); }
.partystrip .player .pts { color: #8f0f42; }
.partystrip .hosttag { background: var(--accent); color: #fff; border-color: var(--edge); }
[data-theme="night"] .partystrip .hosttag { background: #de1e6a; }
/* QR lives in a disclosure popover, never as an always-visible bar. */
.qrpop { position: relative; }
.sharefold summary {
  cursor: pointer; color: var(--sun-ink); font-weight: 800; font-size: 15px;
  background: #fff; border: 2.5px solid var(--edge); border-radius: 999px;
  padding: 8px 18px; display: inline-flex; align-items: center; box-shadow: var(--shadow-sm);
  min-height: 44px; list-style: none;
}
.sharefold summary::-webkit-details-marker { display: none; }
.sharefold summary::before { content: ""; width: 15px; height: 15px; margin-right: 8px; flex: none;
  background: var(--sun-ink);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23000' d='M1 1h6v6H1zM9 1h6v6H9zM1 9h6v6H1zM3 3v2h2V3zM11 3v2h2V3zM3 11v2h2v-2zM9 9h2v2H9zM13 9h2v2h-2zM9 13h2v2H9zM13 13h2v2h-2z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23000' d='M1 1h6v6H1zM9 1h6v6H9zM1 9h6v6H1zM3 3v2h2V3zM11 3v2h2V3zM3 11v2h2v-2zM9 9h2v2H9zM13 9h2v2h-2zM9 13h2v2H9zM13 13h2v2h-2z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.qrpop-card {
  position: absolute; top: calc(100% + 10px); left: 0; z-index: 30;
  background: #fff; border: 3px solid var(--edge); border-radius: 16px;
  box-shadow: var(--shadow-card); padding: 10px;
}
.qrpop-card img { width: 168px; height: 168px; display: block; border-radius: 8px; }
.waitpill {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 700; color: var(--ink);
  margin-top: 8px;
}
.waitpill::before {
  content: ""; width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); flex: none;
}
.partystrip .waitpill { color: var(--sun-ink); margin-top: 0; }

/* ---- recommendations: art-led strip, or one small inline hint ---- */
.rec-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.rec-head h2 { margin-bottom: 6px; }
.feat-strip {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px;
  padding: 6px 2px 4px;
}
@media (max-width: 760px) {
  /* Phones keep a one-handed snap row instead of the 3-across grid. */
  .feat-strip {
    display: flex; gap: 14px; overflow-x: auto; max-width: 100%; min-width: 0;
    padding: 6px 4px 12px; margin: 0 -4px;
    scroll-snap-type: x proximity;
  }
  .feat-strip .gamepick { flex: 0 0 250px; scroll-snap-align: start; }
}
/* Featured card: art and text are distinct grid items, so a long title can
 * never wrap around the artwork. */
.gstart.feat { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; align-items: center; text-align: left; padding: 10px; }
.feat img, .feat .art-fallback {
  width: 96px; height: 68px; object-fit: cover;
  border-radius: 10px; border: 2.5px solid var(--edge);
}
.feat .ftext { min-width: 0; display: grid; gap: 2px; align-content: center; }
.feat .ftext > span { display: block; }
.feat .t { font-family: var(--font-display); font-weight: 800; font-size: 16px; line-height: 1.15; }
.feat .d { font-size: 12.5px; font-weight: 600; color: var(--ink-dim); line-height: 1.3; }
.feat .p { font-size: 12.5px; color: var(--teal-deep); font-weight: 800; }
.invite-hint {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--sun-soft); border: 2.5px solid var(--edge); border-radius: 999px;
  padding: 8px 8px 8px 18px; font-size: 14px; font-weight: 700;
  box-shadow: var(--shadow-sm); width: fit-content; max-width: 100%;
}
.invite-hint .btn { min-height: 38px; font-size: 13.5px; padding: 5px 16px; border-width: 2.5px; }

/* ---- catalog toolbar + poster grid (straight on the page) ---- */
.catbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 0 0 10px; }
.catbar input[type="text"] { max-width: 250px; flex: 1 1 180px; border-radius: 999px; box-shadow: var(--shadow-sm); }
.catbar select {
  width: auto; flex: none; border-radius: 999px; box-shadow: var(--shadow-sm);
  font-size: 14px; font-weight: 800; padding: 9px 12px; min-height: 44px;
  max-width: 100%;
}
.catchips { display: flex; gap: 8px; align-items: center; overflow-x: auto; max-width: 100%; min-width: 0; padding: 4px 2px 8px; margin: 0 0 6px; }
.chip {
  flex: none;
  font-weight: 800; font-size: 13.5px; min-height: 44px;
  background: var(--card); color: var(--ink-dim);
  border: 2.5px solid var(--edge); border-radius: 999px;
  padding: 5px 16px; cursor: pointer; box-shadow: 2px 2px 0 var(--hard);
}
.chip.sel { background: var(--sun); color: var(--sun-ink); }
.grid-games {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.gamepick {
  position: relative;
  background: var(--card); border: 3px solid var(--edge);
  border-radius: 18px; overflow: hidden; padding-bottom: 12px;
  box-shadow: var(--shadow-card);
  display: flex; flex-direction: column;
}
.gstart {
  display: block; width: 100%; padding: 0 0 4px;
  background: none; border: none; cursor: pointer; color: var(--ink);
  font-family: var(--font-body); text-align: left;
}
.gstart:disabled { cursor: default; }
.gart { display: block; width: 100%; aspect-ratio: 16 / 8; object-fit: cover; border-bottom: 3px solid var(--edge); }
.gamepick .t { font-family: var(--font-display); font-weight: 800; font-size: 19px; padding: 12px 16px 0; }
.gamepick .d { font-size: 14px; font-weight: 600; color: var(--ink-dim); padding: 2px 16px 0; }
.gamepick .p { font-size: 13px; color: var(--melon-deep); font-weight: 800; padding: 6px 16px 0; }
.gamepick .vibe { font-size: 12.5px; font-weight: 700; color: var(--ink-dim); padding: 2px 16px 0; }
.played {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  background: var(--sun); color: var(--sun-ink);
  border: 2.5px solid var(--edge);
  font-size: 12px; font-weight: 800;
  padding: 2px 11px; border-radius: 999px;
  box-shadow: 2px 2px 0 var(--hard); transform: rotate(3deg);
}
/* Actions anchor to the card foot: instructions open in the shared
 * dialog, so card geometry never changes open vs closed. */
.card-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 16px 0; margin-top: auto; }
.howto-btn {
  font-size: 13.5px; font-weight: 800; min-height: 44px;
  display: inline-flex; align-items: center;
  background: none; border: none; color: var(--ink-dim); cursor: pointer; padding: 4px 2px;
  font-family: var(--font-body); text-decoration: underline; text-underline-offset: 3px;
}
.howto-btn:disabled { opacity: 0.5; cursor: default; }
.howto-btn.cust {
  text-decoration: none; color: var(--ink);
  border: 2.5px solid var(--edge); border-radius: 999px; padding: 3px 14px;
  background: var(--accent-soft); box-shadow: 2px 2px 0 var(--hard);
}
.invite-more {
  font-size: 13px; font-weight: 800; min-height: 44px;
  display: inline-flex; align-items: center;
  color: var(--sun-ink); background: var(--sun);
  border: 2.5px solid var(--edge); border-radius: 999px; padding: 3px 14px;
  cursor: pointer; font-family: var(--font-body); box-shadow: 2px 2px 0 var(--hard);
}
/* Below-minimum cards: the art stays fully visible and the invite
 * action stays tappable; only the start button locks. */
.gamepick.locked .gstart:disabled { opacity: 0.92; }
.gamepick.locked .gart { filter: saturate(0.75); }
.empty-note {
  border: 2.5px dashed var(--line-strong); border-radius: 16px;
  padding: 26px; text-align: center; color: var(--ink-dim); font-weight: 600;
  background: var(--card);
}

/* ---- art fallback (scaffolded games without images) ---- */
.art-fallback {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 800; color: #fff;
  text-shadow: 0 2px 12px #00000055;
}
.gart.art-fallback { aspect-ratio: 16 / 8; font-size: 44px; }
.pick .gart.art-fallback { font-size: 40px; }
.feat .art-fallback { font-size: 30px; }
.poster .art-fallback { aspect-ratio: 16 / 10; font-size: 40px; }

/* ---- players & scores ---- */
.players { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.player {
  background: var(--card); border: 2.5px solid var(--edge);
  border-radius: 999px; padding: 4px 14px 4px 5px;
  display: flex; gap: 9px; align-items: center;
  font-weight: 800; font-size: 14px; box-shadow: 2px 2px 0 var(--hard);
}
.player.off { opacity: 0.55; }
.player .pts { color: var(--melon-deep); font-size: 13px; font-weight: 800; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  font-family: var(--font-display); font-weight: 800; font-size: 14px;
  color: #141414; flex: none; border: 2px solid var(--edge);
}
.scoreboard { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.score {
  background: var(--card); border: 2.5px solid var(--edge);
  border-radius: 999px; padding: 4px 13px 4px 4px;
  font-size: 14px; font-weight: 800;
  display: inline-flex; align-items: center; gap: 8px;
  box-shadow: 2px 2px 0 var(--hard);
}
.score b { color: var(--melon-deep); font-variant-numeric: tabular-nums; }
.score.leader { background: var(--sun-soft); }
.hosttag {
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px;
  background: var(--accent); border: 2px solid var(--edge); color: var(--accent-ink);
  border-radius: 999px; padding: 1px 8px; margin-left: 2px;
}
.specbanner {
  background: var(--sun-soft); border: 2.5px solid var(--edge);
  border-radius: 14px; padding: 10px 14px; margin: 12px 0;
  font-size: 14px; font-weight: 700;
}

/* ---- game screen: compact chrome, playfield first ---- */
.gamecard { padding: 18px 20px 22px; margin-top: 14px; }
.gamehead { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.gamehead img, .gamehead .art-fallback {
  width: 46px; height: 46px; object-fit: cover; flex: none;
  border-radius: 12px; border: 2.5px solid var(--edge);
}
.gamehead .art-fallback { font-size: 22px; }
.gamehead .ginfo { flex: 1; min-width: 0; }
.gamehead h2 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 22px; }
.gamehead .sub {
  font-size: 13px; font-weight: 700; color: var(--ink-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.gamehead .btn { min-height: 42px; padding: 6px 18px; font-size: 15px; flex: none; }
.ghead {
  width: 100%; height: 120px; object-fit: cover;
  border-radius: 14px; margin-bottom: 18px; border: 2.5px solid var(--edge);
}
.timerbar { height: 10px; background: var(--well); border: 2px solid var(--edge); border-radius: 99px; overflow: hidden; margin: 12px 0 4px; }
.timerbar > div { height: 100%; background: var(--accent); border-radius: 99px; }
.timerbar.urgent { border-color: var(--melon); }
.timerbar.urgent > div { background: var(--melon); }
.timertext { font-size: 13px; font-weight: 800; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.timerbar.urgent + .timertext { color: var(--melon-deep); }
@media (prefers-reduced-motion: no-preference) {
  .timerbar.urgent { animation: pulse 1s ease-in-out infinite; }
  @keyframes pulse { 50% { transform: scaleY(1.6); } }
}

.votebtns { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; margin-top: 16px; }
@media (max-width: 560px) { .votebtns { grid-template-columns: 1fr; } }
.voteopt {
  position: relative;
  font-family: var(--font-display); font-weight: 800; font-size: 20px; line-height: 1.25;
  background: var(--card); color: var(--ink);
  border: 3px solid var(--edge); border-radius: 16px;
  box-shadow: var(--shadow-btn);
  padding: 24px 18px; cursor: pointer; min-height: 56px;
}
.voteopt.picked { border-color: var(--edge); background: var(--accent-soft); box-shadow: 1px 1px 0 var(--hard); }
.voteopt.picked::after {
  content: "✓"; position: absolute; top: 8px; right: 14px;
  color: var(--accent-deep); font-size: 18px;
}
.voteopt:disabled { cursor: default; }

.bar {
  display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto 12px;
  gap: 5px 12px; margin: 12px 0; align-items: center;
}
.bar::before {
  content: ""; grid-column: 1 / -1; grid-row: 2;
  background: var(--well); border-radius: 99px; height: 12px;
}
.bar .n { grid-column: 1; grid-row: 1; font-weight: 700; font-size: 15px; }
.bar > span:last-child { grid-column: 2; grid-row: 1; font-size: 13px; color: var(--ink-dim); text-align: right; font-weight: 700; }
.bar .fill {
  grid-column: 1 / -1; grid-row: 2; height: 12px; border-radius: 99px;
  background: var(--accent); min-width: 12px;
}
.bar .fill.win { background: var(--teal); }

/* ---- drawing ---- */
canvas.doodle {
  width: 100%; border-radius: 12px; display: block;
  background: #faf7f0; border: 3px solid var(--edge);
  touch-action: none; cursor: crosshair;
}
.toolbar { display: flex; gap: 8px; align-items: center; margin: 12px 0; flex-wrap: wrap; }
.swatch {
  width: 34px; height: 34px; border-radius: 50%;
  border: 2.5px solid var(--edge); cursor: pointer; padding: 0;
}
.swatch.sel { outline: 3px solid var(--accent-deep); outline-offset: 2px; }

/* ---- customizer dialog: pale sticker sheet ---- */
.dlg-overlay {
  position: fixed; inset: 0; z-index: 40;
  background: #0c0e13a6;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 5vh 16px 32px; overflow-y: auto;
}
.dlg {
  background: var(--card); color: var(--ink);
  border: 3px solid var(--edge); border-radius: 22px;
  box-shadow: 8px 8px 0 #00000088;
  width: min(680px, 100%); padding: 26px 26px 0;
  max-height: calc(100vh - 10vh); overflow-y: auto;
}
.dlg-head { display: flex; gap: 16px; justify-content: space-between; align-items: flex-start; }
.dlg-head h2 { margin-bottom: 4px; font-size: 28px; }
.dlg-head .ticket-head { margin-bottom: 2px; }
.dlg-head .ticket-head h2 { margin-bottom: 0; font-size: 26px; }
.dlg-head .muted { margin: 0; font-weight: 600; }
.dlg-x { flex: none; }
.dlg-sec {
  margin: 22px 0 4px; padding-top: 16px; border-top: 2.5px dashed var(--line-strong);
  font-size: 16px; font-weight: 800; font-family: var(--font-display); letter-spacing: 0;
  display: flex; align-items: center; gap: 10px;
}
/* Sticker-square bullet: the sections read as party signage, not an
 * enterprise form. Pure decoration (aria-hidden in markup order is
 * unaffected — this is a ::before on the heading itself). */
.dlg-sec::before {
  content: ""; flex: none; width: 14px; height: 14px; border-radius: 5px;
  background: var(--sun); border: 2.5px solid var(--edge);
  transform: rotate(12deg); box-shadow: 2px 2px 0 var(--hard);
}
/* List actions are chunky pill buttons with full tap targets. */
.dlg-packrow .howto-btn, .preset-btns .howto-btn {
  text-decoration: none; color: var(--ink);
  border: 2.5px solid var(--edge); border-radius: 999px; padding: 3px 14px;
  background: var(--card); box-shadow: 2px 2px 0 var(--hard);
}
.dlg-packrow .howto-btn { background: var(--sun-soft); }
label.howto-btn { cursor: pointer; }
label.howto-btn[aria-disabled="true"] { opacity: 0.5; cursor: default; }
.dlg-grid { display: grid; gap: 4px 20px; grid-template-columns: 1fr 1fr; }
@media (max-width: 560px) { .dlg-grid { grid-template-columns: 1fr; } }
.dlg-field { margin-bottom: 6px; }
.dlg textarea { resize: vertical; min-height: 88px; line-height: 1.45; }
.dlg-packmeta { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 4px; }
.dlg-packrow { margin-top: 2px; }
.dlg-packrow .howto-btn { margin-left: 0; margin-right: 0; }
.preset-list { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 8px; }
.preset-list li {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: var(--well); border: 2.5px solid var(--edge);
  border-radius: 12px; padding: 8px 8px 8px 14px;
}
.preset-name { font-weight: 800; }
.preset-btns { margin-left: auto; display: flex; gap: 4px; }
.preset-btns .howto-btn { margin: 0; }
.dlg-presetrow { margin-top: 8px; }
.dlg-foot {
  position: sticky; bottom: 0;
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: var(--card);
  border-top: 2.5px solid var(--edge);
  margin: 20px -26px 0; padding: 14px 26px 18px;
}
.conf-err {
  margin-top: 10px; padding: 10px 12px; border-radius: 10px;
  background: var(--melon-soft); border: 2.5px solid var(--melon);
  font-size: 14px; font-weight: 700;
}
.confnote { margin-top: 8px; font-size: 13px; font-weight: 700; color: var(--ink-dim); }
.conflabel { display: block; font-weight: 800; font-size: 14px; margin: 12px 0 6px; }

/* ---- how-to dialog: one compact playful instruction card ----
 * Native <dialog>: Escape, backdrop, and focus trapping are built in
 * (no JS trap, no entrance animation — static under reduced motion too).
 * Same sticker-party look as the rest: card + edge + sun/raspberry. */
dialog.howto-dlg {
  background: var(--card); color: var(--ink);
  border: 3px solid var(--edge); border-radius: 22px;
  box-shadow: 8px 8px 0 #00000088;
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100vh - 10vh);
  padding: 20px 20px 18px;
  display: flex; flex-direction: column; gap: 12px;
}
dialog.howto-dlg::backdrop { background: #0c0e13a6; }
dialog.howto-dlg:not([open]) { display: none; }
.howto-head { display: flex; gap: 12px; align-items: flex-start; }
.howto-art, img.howto-art {
  width: 64px; height: 64px; object-fit: cover; flex: none;
  border-radius: 14px; border: 2.5px solid var(--edge);
}
.howto-art.art-fallback { font-size: 28px; }
.howto-titles { flex: 1; min-width: 0; }
.howto-titles h2 { margin: 0; font-size: 24px; line-height: 1.15; }
.howto-tag { margin: 2px 0 0; font-size: 13.5px; font-weight: 600; color: var(--ink-dim); }
.howto-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.howto-pill {
  font-size: 12.5px; font-weight: 800;
  background: var(--sun-soft); color: var(--sun-ink);
  border: 2px solid var(--edge); border-radius: 999px; padding: 2px 12px;
}
.howto-pill:nth-child(2) { background: var(--accent-soft); color: var(--accent-deep); }
.howto-body { overflow-y: auto; min-height: 0; }
.howto-body p { margin: 0 0 10px; font-size: 15px; font-weight: 600; line-height: 1.55; }
.howto-body p:last-child { margin-bottom: 0; }
.howto-foot {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  border-top: 2.5px dashed var(--line-strong); padding-top: 12px;
}
.howto-note { flex: 1 1 100%; margin: 0; font-size: 13px; font-weight: 600; color: var(--ink-dim); }
@media (max-width: 560px) {
  /* Bounded bottom sheet on phones: full width, capped height, the
   * instruction text scrolls inside while the CTA stays visible. */
  dialog.howto-dlg {
    margin: auto 0 0; width: 100%; max-width: 100%;
    border-radius: 20px 20px 0 0; border-bottom: none;
    max-height: 88vh;
  }
}

/* ---- toast, confetti, transitions ---- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg);
  font-weight: 800; font-size: 15px;
  border-radius: 999px; padding: 12px 24px;
  box-shadow: var(--shadow-card); z-index: 50;
  max-width: calc(100vw - 40px); text-align: center;
}
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti i {
  position: absolute; top: -16px; width: 9px; height: 13px;
  animation-name: fall; animation-timing-function: ease-in; animation-fill-mode: forwards;
}
@keyframes fall { to { transform: translateY(105vh) rotate(540deg); } }

#app.fade { animation: fadein 0.25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(5px); } }

/* ---- motion design: low-amplitude loops + one-shot feedback ----
 * Three slow ambient loops (hero doodles), everything else fires once
 * per user-level event — never per WebSocket repaint:
 * - catalog/featured stagger runs via Web Animations only on the first
 *   lobby paint per room (see staggerIn in fx.js), so typing in search
 *   or a roster repaint never replays it;
 * - .partystrip.pop + confetti fire once on the home→lobby transition;
 * - .player.just-joined rings only chips that newly connected;
 * - #app.fade re-triggers on screen changes only (gated in render()).
 * Chess squares, the 3D playfield, and call video are never decorative
 * animation targets. The prefers-reduced-motion block at the end of
 * this file kills every animation/transition below for a static UI. */
@media (prefers-reduced-motion: no-preference) {
  .doodle.star-tl { animation: twinkle-a 5.5s ease-in-out infinite; }
  .doodle.star-br { animation: twinkle-b 6.5s ease-in-out -2s infinite; }
  .doodle.squig { animation: sway 7s ease-in-out infinite; }
  @keyframes twinkle-a {
    0%, 100% { transform: rotate(-12deg) scale(1); }
    50% { transform: rotate(-4deg) scale(1.1); }
  }
  @keyframes twinkle-b {
    0%, 100% { transform: rotate(10deg) scale(1); }
    50% { transform: rotate(2deg) scale(1.14); }
  }
  @keyframes sway {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(10px); }
  }
  /* Room-created success pop (one shot, class added on transition). */
  .partystrip.pop { animation: strip-pop 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.25); }
  @keyframes strip-pop {
    0% { transform: scale(0.96); }
    60% { transform: scale(1.01); }
    100% { transform: none; }
  }
  /* New-player spotlight: one expanding ring on the fresh chip. */
  .player.just-joined { animation: joined-ring 1.8s ease-out 1; }
  @keyframes joined-ring {
    0% { box-shadow: 0 0 0 0 var(--accent); }
    100% { box-shadow: 0 0 0 16px transparent; }
  }
  /* Toast slides up each time it appears (text swaps while visible do
   * not restart it — the node persists). */
  .toast:not([hidden]) { animation: toast-in 0.25s ease; }
  @keyframes toast-in {
    from { opacity: 0; transform: translate(-50%, 10px); }
    to { opacity: 1; transform: translate(-50%, 0); }
  }
  /* Customizer + QR popover entrances (fresh nodes animate once). */
  .dlg-overlay { animation: fadein 0.2s ease; }
  .dlg { animation: dlg-in 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.1); }
  @keyframes dlg-in {
    from { opacity: 0; transform: translateY(12px) scale(0.96); }
    to { opacity: 1; transform: none; }
  }
  .qrpop[open] .qrpop-card { animation: dlg-in 0.22s ease; }
}
/* Hidden pages produce no frames for the ambient loops. */
.page-hidden .doodle { animation-play-state: paused !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.sitefoot {
  text-align: center; font-size: 13px; font-weight: 700; color: var(--ink-dim);
  margin: 26px 0 8px;
}
.sitefoot a { color: var(--accent-deep); font-weight: 800; }

/* Chess: playful but readable. Mono (cool neutral graphite/white) is the
 * default; Blue/Green stay optional. Raspberry selection indicators.
 * Desktop: board + useful side column. Phone: board first, controls below. */
.chwrap {
  display: grid; gap: 16px; align-items: start;
  grid-template-columns: minmax(0, 480px) minmax(220px, 1fr);
  justify-content: center;
}
.chboard-col { min-width: 0; }
.chboard {
  display: grid; grid-template-columns: repeat(8, 1fr);
  /* Equal row tracks, shared by standalone + embed: auto rows size
   * piece rows taller than empty ones (Root phone QA: filled cells
   * 43.5px tall vs 13.5px empty). With aspect-ratio 1:1 this yields 64
   * equal squares everywhere. */
  grid-template-rows: repeat(8, 1fr);
  width: 100%; aspect-ratio: 1;
  border-radius: 14px; overflow: hidden;
  border: 3px solid var(--edge);
  box-shadow: var(--shadow-btn);
}
.chside-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.sq {
  position: relative; border: 0; padding: 0; cursor: pointer;
  font-size: clamp(22px, 5vw, 38px); line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.sq:focus-visible { outline: 3px solid var(--accent-deep); outline-offset: -3px; z-index: 2; }
.theme-harbor .sq.light { background: #e9eef6; }
.theme-harbor .sq.dark { background: #41619e; }
.theme-fern .sq.light { background: #e9f2e6; }
.theme-fern .sq.dark { background: #3e7c4f; }
.theme-mono .sq.light { background: #f4f4f7; }
.theme-mono .sq.dark { background: #55565e; }
.sq .pw { color: #ffffff; text-shadow: 0 0 2px #13161c, 0 2px 3px #13161ccc; }
.sq .pb { color: #10141b; text-shadow: 0 1px 0 #ffffff88; }
.sq.sel { box-shadow: inset 0 0 0 4px var(--accent); }
.sq.last { box-shadow: inset 0 0 0 4px #ffc531cc; }
.sq.sel.last { box-shadow: inset 0 0 0 4px var(--accent), inset 0 0 0 8px #ffc531cc; }
.sq.check { box-shadow: inset 0 0 0 4px var(--melon); }
.sq.dest::after {
  content: ""; position: absolute; width: 26%; height: 26%; border-radius: 50%;
  background: #de1e6a99;
}
.sq.cap::after {
  content: ""; position: absolute; inset: 6%; border-radius: 50%;
  border: 4px solid #de1e6a99;
}
.sq.src { cursor: pointer; }
.chside {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px; border-radius: 12px;
  background: var(--well); border: 2.5px solid transparent;
}
.chside.tomove { border-color: var(--edge); background: var(--sun-soft); }
.chip-side { font-weight: 800; font-size: 14px; }
.clock {
  font-variant-numeric: tabular-nums; font-weight: 800; font-size: 15px;
  background: var(--card); border: 2px solid var(--edge); border-radius: 8px; padding: 2px 10px;
}
.clock.low { color: var(--melon-deep); }
.chstatus { font-size: 14px; font-weight: 700; min-height: 20px; }
.chcontrols { justify-content: flex-start; }
.promo {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  justify-content: center; background: var(--well); border-radius: 12px;
  padding: 8px 12px; font-size: 28px;
}
.promo > span { font-size: 14px; }
.promo .btn { font-size: 20px; }
.chhist {
  max-height: 220px; overflow-y: auto;
  background: var(--well); border-radius: 12px; padding: 8px 12px;
  display: flex; flex-direction: column; gap: 2px; font-size: 14px; font-weight: 600;
}
.chhist .mv { display: grid; grid-template-columns: 34px 1fr 1fr; gap: 6px; }
.chhist .mv .n { color: var(--ink-dim); font-variant-numeric: tabular-nums; }
@media (max-width: 720px) {
  .chwrap { grid-template-columns: minmax(0, 480px); }
  .chhist { max-height: 132px; }
}
@media (max-width: 560px) {
  .sq { font-size: clamp(20px, 9vw, 30px); }
}

/* Pocket Karts: warm playful world. Raspberry HUD accents, sunshine boost. */
.pk { position: relative; }
.pk-stage {
  position: relative; width: 100%; height: min(62vh, 560px); min-height: 320px;
  border-radius: 16px; overflow: hidden; background: var(--well);
  border: 3px solid var(--edge); box-shadow: var(--shadow-btn);
}
.pk-stage canvas { display: block; width: 100% !important; height: 100% !important; }
.pk-loading { padding: 24px; text-align: center; }
.pk-fbnote { padding: 6px 12px; }
/* HUD regions flow from their real heights: chips, then standings in normal
 * flow below them, so wrapped text can never overlap at any width. Only the
 * centered overlays (countdown, result, GL note) and the corner tip stay
 * absolutely positioned. */
.pk-hud {
  position: absolute; inset: 0; padding: 10px;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-start;
  pointer-events: none;
}
.pk-top {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center; max-width: 100%;
}
.pk-chip {
  background: #10141bd9; color: #f4f6fb; border-radius: 999px;
  padding: 5px 12px; font-size: 13px; font-weight: 800;
  font-variant-numeric: tabular-nums; border: 2px solid #ffffff33;
}
.pk-chip.pk-me { background: #de1e6ae6; color: #fff; border-color: #ffffff66; }
.pk-chip.pk-boost { background: #10141bd9; }
.pk-chip.pk-boost.on { background: #ffc531e6; color: #3d2a00; border-color: #3d2a00; }
.pk-count {
  position: absolute; top: 38%; width: 100%; text-align: center;
  font-family: var(--font-display); font-size: 84px; font-weight: 800;
  color: #fff; text-shadow: 0 4px 24px #000000aa;
}
.pk-stand {
  background: #10141bb8; color: #f4f6fb; border-radius: 10px;
  padding: 6px 10px; font-size: 12px; max-width: 100%;
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
}
.pk-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.pk-sep { opacity: 0.5; }
.pk-self { font-weight: 800; }
.pk-tip {
  position: absolute; right: 10px; bottom: 10px;
  background: #10141bb8; color: #d6dce8; border-radius: 10px;
  padding: 6px 10px; font-size: 12px; max-width: 40%; text-align: right;
}
.pk-result {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: var(--card); border: 3px solid var(--edge); border-radius: 16px; padding: 14px 18px;
  box-shadow: var(--shadow-card); pointer-events: auto; min-width: 240px;
  max-width: calc(100% - 32px); max-height: calc(100% - 32px); overflow: auto;
}
.pk-result h3 { margin: 0 0 8px; font-size: 18px; text-align: center; }
.pk-result .mv { display: grid; grid-template-columns: 30px 1fr auto; gap: 6px; font-size: 14px; font-weight: 600; }
.pk-result .mv .n { color: var(--ink-dim); }
.pk-glnote {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: var(--card); border: 3px solid var(--edge); border-radius: 12px; padding: 10px 14px;
  box-shadow: var(--shadow-card); pointer-events: auto; font-size: 14px; font-weight: 700;
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  max-width: calc(100% - 32px);
}
.pk-touch { display: none; }
@media (pointer: coarse) {
  /* Touch buttons own the bottom edge; standings already flow under the
   * chips in normal flow, so no absolute docking is needed at any width. */
  .pk-touch:not([hidden]) { display: flex; }
  .pk-touch {
    position: absolute; left: 0; right: 0; bottom: 44px;
    justify-content: space-between; padding: 0 12px;
    pointer-events: none;
  }
  .pk-tleft, .pk-tright { display: flex; gap: 10px; pointer-events: auto; }
  .pk-tbtn {
    width: 64px; height: 64px; border-radius: 50%; border: 3px solid #ffffff88;
    background: #10141bb8; color: #fff; font-size: 24px; touch-action: none;
    user-select: none; -webkit-user-select: none;
  }
  .pk-tbtn.pk-gas { background: #de1e6acc; }
  .pk-tbtn.pk-boostbtn { background: #f2545bcc; }
  .pk-tip { display: none; }
}

/* ---- embedded playing: compact chrome (body.is-embed only) ----
 * The parent already shows brand/close/friends/call controls, so embedded
 * game screens render without the nested topbar (see renderGame), keep the
 * title + host-only Change game + a compact sound toggle, and tighten
 * padding so the playfield fits a phone call layout. Standalone selectors
 * above never match body.is-embed, so standalone is untouched. */
body.is-embed .app { padding-bottom: 32px; }
body.is-embed .gamecard { padding: 12px 12px 16px; margin-top: 8px; }
body.is-embed .gamehead { gap: 8px; margin-bottom: 8px; }
body.is-embed .gamehead h2 { font-size: 19px; }
body.is-embed .gamehead .sub { font-size: 12px; }
body.is-embed .gamehead .btn { min-height: 42px; padding: 6px 14px; font-size: 14px; }
.iconbtn {
  flex: none; width: 42px; height: 42px; border-radius: 12px;
  background: var(--card); color: var(--ink);
  border: 2.5px solid var(--edge); box-shadow: var(--shadow-sm);
  font-size: 18px; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.iconbtn[data-state="off"] { opacity: 0.55; }
.iconbtn:focus-visible { outline: 3px solid var(--accent-deep); outline-offset: 2px; }
/* Compact watcher status: one honest line; the full explanation sits in the
 * native Why? disclosure (keyboard + screen-reader accessible, no JS). */
.spec-compact { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; padding: 6px 8px 6px 12px; margin: 8px 0; font-size: 13px; }
/* Below-board watcher reason (embed compact chrome): nothing above the
 * playfield, the Why? disclosure rides under it before the scores. */
.spec-compact.spec-after { margin: 12px 0 2px; }
.spec-compact > span { flex: 1; min-width: 0; }
.specwhy { margin-left: auto; flex: none; }
.specwhy[open] { flex: 1 1 100%; }
.specwhy summary {
  cursor: pointer; font-weight: 800; font-size: 12.5px;
  border: 2px solid var(--edge); border-radius: 999px; padding: 4px 12px;
  background: var(--card); color: var(--ink); list-style: none;
  min-height: 32px; display: inline-flex; align-items: center; width: fit-content;
}
.specwhy summary::-webkit-details-marker { display: none; }
.specwhy summary:focus-visible { outline: 3px solid var(--accent-deep); outline-offset: 2px; }
.specwhy p { margin: 8px 2px 2px; font-size: 13px; font-weight: 600; }
/* Embedded chess: turn status + both clocks ride in one compact strip above
 * the board (same ids/classes as standalone, so selectors keep working);
 * controls + scrollable history sit below. Strip + board fit a 390px-wide
 * call frame without scrolling the board back and forth. */
.chembed { display: flex; flex-direction: column; gap: 8px; max-width: 560px; margin: 0 auto; width: 100%; align-items: stretch; }
.chembed .chtop { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: stretch; }
.chembed .chstatus { flex: 1 1 100%; font-size: 13px; min-height: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chembed .chside { flex: 1 1 0; min-width: 0; padding: 4px 8px; gap: 6px; }
.chembed .chip-side { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chembed .clock { font-size: 13px; padding: 1px 8px; flex: none; }
.chembed .chbottom { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.chembed .chhist { max-height: 76px; }
/* Row equality comes from the shared .chboard rule above (all variants). */

/* ---- responsive ---- */
@media (max-width: 900px) {
  /* The party strip stacks: invite on top, roster below. */
  .partystrip { align-items: stretch; }
  .ps-party { margin-left: 0; flex-basis: 100%; }
}
@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; gap: 20px; padding: 22px 4px 20px; }
  .hero-form { max-width: none; }
  .hero-cta .btn { flex: 1; }
  .hero-art { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .poster { padding: 5px 5px 8px; border-radius: 12px; }
  .poster img, .poster .art-fallback { aspect-ratio: 1 / 1; border-radius: 7px; }
  .poster.wide { grid-column: auto; }
  .poster.wide img, .poster.wide .art-fallback { aspect-ratio: 1 / 1; }
  .poster .tag { display: none; }
  .doodle { display: none; }
}
@media (max-width: 640px) {
  .catalog-list { grid-template-columns: 1fr; }
  .catbar { flex-wrap: wrap; }
  .catbar input[type="text"] { max-width: none; flex: 1 1 100%; }
  .catchips { flex: 1 1 100%; }
  /* Phone catalog: one-column art rows, comfortably tappable. */
  .grid-games { grid-template-columns: 1fr; gap: 12px; }
  .grid-games .gstart.artrow { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 0 12px; align-items: center; }
  .grid-games .gstart.artrow .gart { grid-row: 1 / span 4; border-bottom: none; border-right: 3px solid var(--edge); aspect-ratio: auto; height: 100%; min-height: 104px; }
  .grid-games .gstart.artrow .t, .grid-games .gstart.artrow .d,
  .grid-games .gstart.artrow .p, .grid-games .gstart.artrow .vibe { padding-left: 0; padding-right: 12px; }
  .grid-games .gstart.artrow .t { padding-top: 10px; font-size: 17px; }
  .grid-games .gstart.artrow .vibe { padding-bottom: 10px; }
}
@media (max-width: 560px) {
  .app { padding: 0 12px 56px; }
  .topbar { margin: 0 -12px 8px; padding: 10px 12px; }
  .card { padding: 18px; }
  .btn { min-height: 50px; }
  .only-desktop { display: none !important; }
  .only-phone { display: revert !important; }
  /* Compact single-row header: brand + code + two small actions. The
   * buttons keep their text (screen readers, titles) but show glyphs. */
  .topbar { gap: 8px; flex-wrap: nowrap; }
  .topbar .row { gap: 6px; margin-left: auto; flex: none; flex-wrap: nowrap; }
  .brand { font-size: 19px; overflow: hidden; text-overflow: ellipsis; }
  .brand small { display: none; }
  .brandmark { width: 24px; height: 24px; }
  .roomchip { font-size: 13px; letter-spacing: 2px; text-indent: 2px; padding: 4px 10px; }
  .topbar .btn.ghost { padding: 6px 8px !important; font-size: 0 !important; min-height: 42px; min-width: 42px; }
  .topbar .btn.ghost::after { font-size: 16px; line-height: 1; }
  #bTheme::after { content: "\25D0"; }
  #bSound::after { content: "\266A"; }
  #bSound[data-state="off"] { opacity: 0.55; }
  .partystrip { padding: 12px 14px; gap: 12px 16px; }
  .partystrip .player { font-size: 13px; }
  .ps-actions .btn { padding: 8px 16px; }
  /* Keep the QR popover inside the viewport on phones. */
  .qrpop-card { left: auto; right: 0; }
  .qrpop-card img { width: 148px; height: 148px; }
  /* Compact active-game header: small thumb + min-width text so the
   * playfield keeps the screen on phones. */
  .gamehead { gap: 10px; }
  .gamehead img, .gamehead .art-fallback { width: 40px; height: 40px; border-radius: 9px; }
  .gamehead .art-fallback { font-size: 18px; }
  .gamehead h2 { font-size: 19px; }
  .gamehead .sub { font-size: 12px; }
  .gamehead .btn { min-height: 42px; padding: 6px 14px; font-size: 14px; }
  .pk-stage { height: 52vh; min-height: 280px; }
  .pk-count { font-size: 64px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
