:root {
  --bg-top: #14100c;
  --bg-bottom: #0a0806;
  --text: #e9d9b5;
  --text-dim: #9a8f78;
  --accent: #c9a35c;
  --card-bg: linear-gradient(160deg, #241a11, #16110b);
  --card-border: rgba(201, 163, 92, 0.25);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 50% 0%, var(--bg-top), var(--bg-bottom) 65%);
  color: var(--text);
  font-family: system-ui, sans-serif;
}

a { color: inherit; text-decoration: none; }

.back-link {
  display: inline-block;
  margin: calc(16px + env(safe-area-inset-top)) 0 0 16px;   /* below the iPhone clock when the page is installed (viewport-fit=cover) */
  font-family: system-ui, sans-serif;
  font-size: 13px;
  letter-spacing: 0.05em;
  color: var(--accent);
  opacity: 0.85;
}
.back-link:hover { opacity: 1; text-decoration: underline; }

.site-footer {
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--card-border);
  font-size: 12px;
  color: var(--text-dim);
}
.foot .site-footer { margin-top: 0; padding-top: 0; border-top: 0; }
.foot .site-footer-brand,
.foot .site-footer-links { justify-content: flex-start; }
.site-footer-note { margin: 0 0 10px; }
.site-footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 18px;
}
.site-footer-links a { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.site-footer-links a:hover { text-decoration-thickness: 2px; }
.site-footer-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0 0 8px;
}
.site-footer-brand svg { flex-shrink: 0; }
.site-footer-brand a { display: inline-block; padding: 15px 0; margin: -15px 0; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.site-footer-brand a:hover { text-decoration-thickness: 2px; }

/* ===== UI kit (docs/ui.md): tokens, components and the shared look of every page. Folded in from games/ui/ui.css; the :root prefix
   keeps the weight the old opt-in attribute scope had, so it overrides the legacy page rules exactly as before. Dark is the default
   look; light follows prefers-color-scheme: light; [data-theme="dark|light"] forces one (used by the style guide only). ===== */
:root:root {
  --ui-bg: #14100c; --ui-surface: #201811; --ui-chip: #2b2117; --ui-line: #4a3d27;
  --ui-ink: #f1e6cc; --ui-dim: #b3a88f; --ui-accent: #d4b06a; --ui-primary: #c9a35c; --ui-on: #1a1209;
  --ui-field: #0a100b; --ui-felt: #1f3b2c; --ui-scrim: rgba(0, 0, 0, .55); --ui-ok: #7fc98f; --ui-err: #f0a394;
  --ui-serif: 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --ui-sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --ui-r-s: 10px; --ui-r-m: 14px; --ui-r-l: 18px; --ui-gutter: 20px;
  --ui-ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:root:not([data-theme="dark"]) {
    --ui-bg: #f5ecda; --ui-surface: #fffaf0; --ui-chip: #eadcbc; --ui-line: #d9c7a3;
    --ui-ink: #3b2a1c; --ui-dim: #6b5842; --ui-accent: #7a5a0a; --ui-primary: #4a2f1c; --ui-on: #f5ecda;
    --ui-field: #efe6cf; --ui-felt: #2f4d3a; --ui-scrim: rgba(40, 28, 12, .4); --ui-ok: #1b6b2c; --ui-err: #a3271a;
    color-scheme: light;
  }
}
:root:root[data-theme="light"] {
  --ui-bg: #f5ecda; --ui-surface: #fffaf0; --ui-chip: #eadcbc; --ui-line: #d9c7a3;
  --ui-ink: #3b2a1c; --ui-dim: #6b5842; --ui-accent: #7a5a0a; --ui-primary: #4a2f1c; --ui-on: #f5ecda;
  --ui-field: #efe6cf; --ui-felt: #2f4d3a; --ui-scrim: rgba(40, 28, 12, .4); --ui-ok: #1b6b2c; --ui-err: #a3271a;
  color-scheme: light;
}

/* the old shell tokens (style.css) follow the theme too, so page-local rules that still use them stay readable */
:root:root { --text: var(--ui-ink); --text-dim: var(--ui-dim); --card-bg: var(--ui-surface); --card-border: var(--ui-line); }
:root body { background: var(--ui-bg); color: var(--ui-ink); font-family: var(--ui-sans); }
:root :focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }
:root .ui-serif { font-family: var(--ui-serif); }
:root .ui-label { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--ui-dim); font-weight: 600; }
:root .ui-dim { color: var(--ui-dim); }
:root .ui-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* top bar: back, title, language button, pause / menu */
:root .ui-topbar { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: calc(4px + env(safe-area-inset-top)) var(--ui-gutter) 4px; }
:root .ui-topbar .ui-title { flex: 1; min-width: 0; margin: 0; font-family: var(--ui-serif); font-size: 22px; font-weight: 700; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:root .ui-back { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; color: var(--ui-accent); font-size: 17px; }

/* buttons */
:root .ui-ibtn { width: 44px; height: 44px; flex: none; display: inline-grid; place-items: center; padding: 0; border-radius: 50%; background: var(--ui-surface); border: 1px solid var(--ui-line); color: var(--ui-accent); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
:root .ui-ibtn svg { width: 20px; height: 20px; }
:root .ui-pill { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 52px; padding: 0 24px; border-radius: 26px; border: 1px solid transparent; font: inherit; font-size: 17px; font-weight: 600; cursor: pointer; background: var(--ui-primary); color: var(--ui-on); }
:root .ui-pill.secondary { background: transparent; color: var(--ui-ink); border-color: var(--ui-line); }
:root .ui-pill:disabled, :root .ui-pill[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
:root .ui-text-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 12px; background: none; border: 0; color: var(--ui-accent); font: inherit; font-size: 16px; font-weight: 600; cursor: pointer; }
:root .ui-chip { display: inline-block; padding: 3px 8px; border-radius: 999px; background: var(--ui-chip); color: var(--ui-dim); font-size: 12px; font-weight: 600; white-space: nowrap; }

/* search field */
:root .ui-search { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; border-radius: 12px; background: var(--ui-chip); color: var(--ui-dim); }
:root .ui-search:focus-within { box-shadow: 0 0 0 2px var(--ui-accent); }
:root .ui-search svg { width: 18px; height: 18px; flex: none; }
:root .ui-search input { flex: 1; min-width: 0; min-height: 44px; background: transparent; border: 0; outline: 0; color: var(--ui-ink); font: inherit; font-size: 16px; }
:root .ui-search input::placeholder { color: var(--ui-dim); }

/* grouped list and rows */
:root .ui-group { list-style: none; margin: 0; padding: 0; background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-r-m); overflow: hidden; }
:root .ui-group > li + li { border-top: 1px solid var(--ui-line); }
:root .ui-row { display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 10px 14px; width: 100%; color: inherit; background: none; border: 0; font: inherit; text-align: start; cursor: pointer; }
:root a.ui-row:hover, :root button.ui-row:hover { background: var(--ui-chip); }
:root .ui-tile { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 11px; background: var(--ui-chip); color: var(--ui-accent); font-size: 22px; }
:root .ui-row-body { flex: 1; min-width: 0; }
:root .ui-row-title { margin: 0; font-size: 17px; font-weight: 600; }
:root .ui-row-sub { margin: 2px 0 0; font-size: 14px; line-height: 1.35; color: var(--ui-dim); text-wrap: pretty; white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
:root .ui-chev { width: 16px; height: 16px; flex: none; color: var(--ui-dim); }
:root .ui-check { width: 22px; height: 22px; flex: none; border-radius: 50%; border: 2px solid var(--ui-line); }
:root [aria-checked="true"] > .ui-check { border-color: var(--ui-accent); background: radial-gradient(circle, var(--ui-accent) 0 45%, transparent 50%); }

/* segmented control */
:root .ui-seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; padding: 3px; border-radius: var(--ui-r-s); background: var(--ui-chip); }
:root .ui-seg button { min-height: 44px; border: 0; border-radius: 8px; background: transparent; color: var(--ui-dim); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
:root .ui-seg button[aria-pressed="true"] { background: var(--ui-surface); color: var(--ui-ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .25); }

/* toggle row */
:root .ui-toggle { position: relative; width: 52px; height: 32px; flex: none; border-radius: 16px; background: var(--ui-chip); border: 1px solid var(--ui-line); transition: background 150ms; }
:root .ui-toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--ui-dim); transition: transform 150ms var(--ui-ease), background 150ms; }
:root [aria-checked="true"] > .ui-toggle { background: var(--ui-primary); border-color: var(--ui-primary); }
:root [aria-checked="true"] > .ui-toggle::after { transform: translateX(20px); background: var(--ui-on); }

/* stepper */
:root .ui-stepper { display: inline-flex; align-items: center; gap: 4px; }
:root .ui-stepper output { min-width: 32px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }

/* mode card (landing of a game) */
:root .ui-mode { display: flex; align-items: center; gap: 14px; min-height: 76px; padding: 14px; border-radius: var(--ui-r-l); background: var(--ui-surface); border: 1px solid var(--ui-line); color: inherit; }
:root .ui-mode.primary { background: var(--ui-primary); border-color: var(--ui-primary); color: var(--ui-on); }

/* sheet and scrim */
:root .ui-scrim { position: fixed; inset: 0; z-index: 50; background: var(--ui-scrim); opacity: 0; pointer-events: none; transition: opacity 250ms; }
:root .ui-scrim.open { opacity: 1; pointer-events: auto; }
:root .ui-sheet { position: fixed; z-index: 51; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto; max-height: 85vh; overflow: auto; padding: 8px var(--ui-gutter) calc(20px + env(safe-area-inset-bottom)); border-radius: 22px 22px 0 0; background: var(--ui-bg); border: 1px solid var(--ui-line); border-bottom: 0; color: var(--ui-ink); transform: translateY(105%); visibility: hidden; transition: transform 250ms var(--ui-ease), visibility 0s 250ms; }
:root .ui-sheet.open { transform: none; visibility: visible; transition: transform 250ms var(--ui-ease), visibility 0s; }
:root .ui-sheet-grip { width: 40px; height: 4px; margin: 4px auto 12px; border-radius: 2px; background: var(--ui-line); }
:root .ui-sheet h2 { margin: 0 0 12px; font-family: var(--ui-serif); font-size: 26px; }

/* toast */
:root .ui-toast { position: fixed; z-index: 60; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); padding: 12px 18px; border-radius: 999px; background: var(--ui-ink); color: var(--ui-bg); font-size: 15px; font-weight: 600; }

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

/* ===== game pages: HUD, d-pad, result card, language picker inside the top bar ===== */
:root .ui-hud { display: flex; justify-content: space-between; align-items: flex-end; padding: 4px var(--ui-gutter) 12px; max-width: 480px; margin: 0 auto; }
:root .ui-hud .k { display: block; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--ui-dim); font-weight: 600; }
:root .ui-hud .v { display: block; font-size: 40px; font-weight: 700; line-height: 1.05; color: var(--ga, var(--ui-accent)); font-variant-numeric: tabular-nums; }
:root .ui-hud .v.q { font-size: 24px; color: var(--ui-ink); }
:root .ui-hud > div:last-child { text-align: end; }


:root .ui-dpad { display: grid; grid-template-columns: repeat(3, 64px); grid-template-rows: repeat(2, 64px); gap: 8px; justify-content: center; margin: 16px 0 0; }
:root .ui-dpad button { border-radius: 18px; background: var(--ui-surface); border: 1px solid var(--ui-line); color: var(--ga, var(--ui-accent)); font-size: 22px; touch-action: manipulation; cursor: pointer; }
:root .ui-dpad button:active { background: var(--ui-chip); }
:root .ui-dpad [data-dir="up"] { grid-column: 2; grid-row: 1; }
:root .ui-dpad [data-dir="left"] { grid-column: 1; grid-row: 2; }
:root .ui-dpad [data-dir="down"] { grid-column: 2; grid-row: 2; }
:root .ui-dpad [data-dir="right"] { grid-column: 3; grid-row: 2; }
:root .ui-hint { text-align: center; font-size: 14px; color: var(--ui-dim); margin: 12px 0 0; min-height: 20px; }

/* the shared language picker (games/i18n.js) as a round icon button in the top bar, its list as a bottom sheet */
:root .ui-topbar .lang-bar { margin: 0; padding: 0; max-width: none; }
:root .ui-topbar .lang-btn { width: 44px; height: 44px; min-height: 44px; padding: 0; justify-content: center; border-radius: 50%; background: var(--ui-surface); border-color: var(--ui-line); color: var(--ui-accent); }
:root .ui-topbar .lang-current, :root .ui-topbar .lang-caret { display: none; }
@keyframes ui-slide { from { transform: translateY(100%); } to { transform: none; } }
/* old arcade.css looks that the kit replaces on a migrated game page */
:root .ui-topbar h1 { flex: 1; min-width: 0; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--ui-serif); font-size: 22px; letter-spacing: 0; text-transform: none; color: var(--ui-ink); text-shadow: none; margin: 0; }
:root .ui-topbar .back-link { margin: 0; padding: 0; opacity: 1; font-size: 17px; letter-spacing: 0; color: var(--ui-accent); }
:root .controls .btn { min-height: 44px; padding: 0 20px; border-radius: 22px; background: transparent; color: var(--ui-accent); border: 1px solid var(--ui-line); font-size: 16px; }
:root .pitch { color: var(--ui-dim); }

/* ===== the arcade kit's shared pieces (arcade.css, modes.css) in the new look ===== */
:root .wrap { padding-inline: 0; }
:root .wrap > .pitch, :root .wrap > .resume-box, :root .wrap > .rules, :root .wrap > .game-setup, :root .wrap > .controls, :root .wrap > .box { margin-inline: var(--ui-gutter); }
:root .wrap > .field { padding: 0 var(--ui-gutter); max-width: 520px; }
:root .wrap > .field > canvas { border-radius: 16px; background: var(--field, var(--ui-field)); border: 1px solid var(--ui-line); box-shadow: none; }
:root .wrap > .field > .overlay { inset: 0 var(--ui-gutter); border-radius: 16px; background: color-mix(in srgb, var(--ui-bg) 88%, transparent); }
:root .overlay h2 { font: 700 30px var(--ui-serif); letter-spacing: 0; color: var(--ui-ink); }
:root .overlay p { color: var(--ui-dim); font-size: 16px; }
:root .overlay .actions { width: 100%; max-width: 260px; }
:root .btn { min-height: 44px; padding: 0 20px; border-radius: 22px; background: transparent; color: var(--ui-ink); border: 1px solid var(--ui-line); font-size: 16px; }
:root .btn.primary { background: var(--ui-primary); color: var(--ui-on); border-color: var(--ui-primary); }
:root .overlay .btn { min-height: 52px; border-radius: 26px; font-size: 17px; }
:root .btn:focus-visible, :root .mode-btn:focus-visible, :root .back-link:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }
:root .msg { color: var(--ui-dim); font-size: 14px; }
:root .resume-box { max-width: none; background: var(--ui-surface); box-shadow: none; border: 1px solid var(--ui-line); border-radius: var(--ui-r-l); }
:root .resume-info { color: var(--ui-dim); }
:root .hud { font-family: var(--ui-sans); color: var(--ui-dim); padding: 0 var(--ui-gutter); max-width: 520px; }
:root .hud b { color: var(--ga, var(--ui-accent)); }

/* mode cards: "how do you want to play" (Arcade.modes) */
:root .modes { grid-template-columns: 1fr; gap: 8px; padding: 0; background: none; box-shadow: none; border-radius: 0; }
:root .mode-btn { display: flex; align-items: center; gap: 14px; min-height: 68px; padding: 10px 14px; border-radius: var(--ui-r-l); background: var(--ui-surface); border: 1px solid var(--ui-line); color: var(--ui-ink); font: 400 14px var(--ui-sans); text-align: start; }
:root .mode-ico { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 11px; background: var(--ui-chip); color: var(--ui-accent); }
:root .mode-ico svg { width: 24px; height: 24px; }
:root .mode-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
:root .mode-title { font: 700 18px var(--ui-serif); }
:root .mode-sub { font-size: 14px; color: var(--ui-dim); }
:root .mode-chev { width: 16px; height: 16px; flex: none; opacity: .7; }
:root .mode-btn[aria-checked="true"] { background: var(--ui-primary); border-color: var(--ui-primary); color: var(--ui-on); }
:root .mode-btn[aria-checked="true"] .mode-sub { color: inherit; opacity: .85; }
:root .mode-btn[aria-checked="true"] .mode-ico { background: var(--ui-on); color: var(--ui-primary); }
:root .modes.levels { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px; padding: 3px; margin-top: 0; border-radius: var(--ui-r-s); background: var(--ui-chip); }
:root .modes.levels .mode-btn { justify-content: center; min-height: 44px; padding: 0 6px; border: 0; border-radius: 8px; background: transparent; color: var(--ui-dim); font: 600 14px var(--ui-sans); text-align: center; }
:root .modes.levels .mode-btn[aria-checked="true"] { background: var(--ui-surface); color: var(--ui-ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
:root .game-setup .setup-now, :root .game-setup .setup-opts { color: var(--ui-dim); }
:root .game-setup .setup-opts select { background: var(--ui-chip); color: var(--ui-ink); box-shadow: inset 0 0 0 1px var(--ui-line); }
:root .game-setup .setup-opts select option { background: var(--ui-surface); color: var(--ui-ink); }

/* "Play with a Friend" room box */
:root .box { max-width: none; background: var(--ui-surface); box-shadow: none; border: 1px solid var(--ui-line); border-radius: var(--ui-r-l); padding: 12px 14px; }
:root .online-header { color: var(--ui-dim); font-weight: 600; }
:root .online-status { color: var(--ui-dim); font-size: 14px; }
:root .online-status.error { color: var(--ui-err); } :root .online-status.ok { color: var(--ui-ok); }
:root .room-code { color: var(--ui-ink); background: var(--ui-chip); border-radius: var(--ui-r-s); font-size: 26px; }
:root #roomCodeInput { background: var(--ui-chip); color: var(--ui-ink); border: 1px solid var(--ui-line); border-radius: 12px; }
:root #roomCodeInput::placeholder { color: var(--ui-dim); }

/* how to play */
:root .rules { max-width: 520px; margin-inline: auto; }
:root .rules h2 { font-family: var(--ui-serif); font-size: 24px; color: var(--ui-ink); }
:root .rule-card { background: var(--ui-surface); border-color: var(--ui-line); border-radius: var(--ui-r-m); }
:root .rule-card h3 { color: var(--ui-accent); font-size: 15px; } :root .rule-card p { color: var(--ui-dim); font-size: 15px; } :root .rule-card b { color: var(--ui-ink); }
:root .overlay { background: color-mix(in srgb, var(--ui-bg) 90%, transparent); }
:root .tagline { color: var(--ui-dim); }

/* A game's own dark "wood" panels (side panels, board frames) stay dark in both themes: inside them the tokens are the dark set. */
:root div.table, :root .felt, :root .ui-dark {
  --ui-bg: #14100c; --ui-surface: #201811; --ui-chip: #2b2117; --ui-line: #4a3d27;
  --ui-ink: #f1e6cc; --ui-dim: #b3a88f; --ui-accent: #d4b06a; --ui-primary: #c9a35c; --ui-on: #1a1209; --ui-ok: #7fc98f; --ui-err: #f0a394;
  --text: #f1e6cc; --text-dim: #b3a88f; color: var(--ui-ink);
}
:root .pick { color: var(--ui-dim); }
:root .pick select, :root .setup-row select { background: var(--ui-chip); color: var(--ui-ink); box-shadow: inset 0 0 0 1px var(--ui-line); }
:root .pick select option, :root .setup-row select option { background: var(--ui-surface); color: var(--ui-ink); }
@media (max-width: 420px) { :root:root { --ui-gutter: 16px; } }
:root .bgk-rules { color: var(--ui-accent); }
:root .bgk-resume { background: var(--ui-surface); border: 1px solid var(--ui-line); box-shadow: none; border-radius: var(--ui-r-l); color: var(--ui-ink); }
:root .similar { color: var(--ui-dim); }
:root .choice { background: var(--ui-chip); }
:root .choice .tick { background: var(--ui-surface); }
:root .hud-row b { color: var(--ui-accent); }

/* ===== card-table games (cards/cards.css) ===== */
:root:root { --accent: var(--ui-accent); }
:root .hero h1 { font-family: var(--ui-serif); font-size: 38px; color: var(--ui-ink); text-shadow: none; }
:root .hero-pitch { color: var(--ui-dim); font-size: 16px; }
:root .hero-cta { min-height: 52px; border-radius: 26px; font-size: 17px; padding: 0 28px; display: inline-flex; align-items: center; justify-content: center; }
/* the table's own action bar stays compact: fifteen cards and the buttons must fit a phone */
:root .hand-panel .actions .btn, :root #drawnWrap .btn, :root .btn.subtle { min-height: 0; padding: 6px 10px; font-size: 13px; border-radius: 10px; }
:root .ui-topbar .back-link { display: inline-flex; align-items: center; min-height: 44px; }
:root .setup-grid select, :root .online-row input { background: var(--ui-chip); color: var(--ui-ink); border-color: var(--ui-line); min-height: 44px; }
:root .panel { box-shadow: none; border: 1px solid var(--ui-line); border-radius: var(--ui-r-l); }
:root .hand-panel { border: 0; border-radius: 14px 14px 0 0; background: var(--ui-surface); box-shadow: 0 -6px 20px rgba(0, 0, 0, .22), inset 0 1px 0 var(--ui-line); color: var(--ui-ink); }   /* follows the theme: dark brown in dark, cream in light */

/* ===== play focus: once a game is under way the landing text steps aside (no flow change, CSS only) ===== */
:root .wrap:has(.game-setup.is-started) > .pitch, :root .wrap:has(.game-setup.is-started) > .tagline,
:root .wrap:has(.field > .overlay[hidden]) > .pitch, :root .wrap:has(.field > .overlay[hidden]) > .tagline { display: none; }

/* ===== fixes from the black-box test (light theme) ===== */
:root .tower-btn { background: var(--ui-surface); color: var(--ui-ink); box-shadow: inset 0 0 0 1px var(--ui-line); }
:root .tower-btn .cost { color: var(--ui-accent); }
:root .tower-btn.selected { background: var(--ui-chip); box-shadow: inset 0 0 0 2px var(--ui-accent); }
:root button.btn.secondary { background: transparent; color: var(--ui-ink); box-shadow: none; }
:root .bgk-resume .btn:not(.secondary) { background: var(--ui-primary); color: var(--ui-on); border-color: var(--ui-primary); }
:root #selPanel { background: var(--ui-surface); }
/* top bar: a long title wraps to two lines instead of being cut; the globe is a line icon in the shell colour, as on the landing page */
:root .ui-topbar h1 { white-space: normal; line-height: 1.15; font-size: clamp(18px, 5.2vw, 22px); text-wrap: balance; }
:root .ui-topbar .lang-btn > span:first-child { display: none; }
:root .ui-topbar .lang-btn::before { content: ""; width: 20px; height: 20px; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M3 12h18M12 3c3 3 3 15 0 18M12 3c-3 3-3 15 0 18'/%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 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M3 12h18M12 3c3 3 3 15 0 18M12 3c-3 3-3 15 0 18'/%3E%3C/svg%3E") center / contain no-repeat; }
/* buttons keep their label on one line */
:root .btn { white-space: nowrap; }
/* card tables: bigger action buttons (still compact enough for fifteen cards on a phone) */
:root .hand-panel .actions .btn { min-height: 44px; padding: 6px 10px; font-size: 13px; }
/* poker action bar: labels on one line, inside the side gutters */
:root .control-set { padding-inline: var(--ui-gutter); gap: 6px; }
:root .control-set .btn { padding: 0 14px; min-width: 64px; flex: 0 0 auto; }
:root .control-set .size-btn { padding: 0 9px; font-size: 14px; min-width: 0; }
:root .control-set .step-btn { width: 40px; min-width: 0; padding: 0; }
:root body.playing .ui-topbar { min-height: 44px; padding-top: env(safe-area-inset-top); padding-bottom: 0; }
/* a saved game is offered: that box is the one start action, the "Ready? Play" card waits behind it until Resume or Discard */
:root .wrap:has(.resume-box:not([hidden])) .field > #overlay { display: none; }

/* ===== phone fit and touch targets (black-box test) ===== */
/* Hangman: every keyboard row on one line (keys share the width), so the whole keyboard fits under the gallows */
:root .keyboard { width: 100%; }
:root .kb-row { flex-wrap: nowrap; gap: 4px; width: 100%; }
:root .kb-row .key { flex: 1 1 0; min-width: 0; max-width: 44px; width: auto; height: 46px; }
/* Tank Siege: the pad keeps clear of the screen edges */
:root .touch-controls { padding-inline: var(--ui-gutter); }
/* board-first games on a phone: the pitch is repeated in "How to play", so it gives its room to the board and its controls */
@media (max-width: 480px) { :root body.ui-board-first .pitch { display: none; } }
/* card tables: a full-height target for every action */
:root .hand-panel .actions .btn { min-height: 44px; }
@media (pointer: coarse) { :root .keys { display: none; } } /* keyboard shortcuts are no use on a touch screen */

/* ===== two screens: start (how to play, settings, rules) and play (the board only); see UI.stages ===== */
:root body[data-stage="start"] .ui-play, :root body[data-stage="play"] .ui-start, :root body[data-stage="play"] .ui-start-only, :root body[data-stage="play"] .ui-startbar { display: none; }
:root body[data-stage="start"] .wrap { padding-bottom: calc(132px + env(safe-area-inset-bottom)); } /* room for the pinned bar */
:root .ui-start { display: flex; flex-direction: column; gap: 16px; }
:root .ui-start > * { margin-top: 0; margin-bottom: 0; }
/* the two sections of the start screen: "mode" and "setup". Their order is a style, so a game can swap them: style="--ui-sec: 2" */
:root .ui-start .game-setup { display: flex; flex-direction: column; gap: 16px; max-width: none; margin: 0 var(--ui-gutter); }
:root .ui-sec { display: flex; flex-direction: column; gap: 8px; order: var(--ui-sec, 0); min-width: 0; }
:root .ui-sec > .ui-label { margin: 0 4px; }
:root .ui-sec > * { margin-top: 0; margin-bottom: 0; }
:root .ui-sec:not(:has(> :not(.ui-label):not([hidden]):not([style*="display: none"]):not([style*="display:none"]))) { display: none; } /* nothing to set: no empty heading */
/* a game under way does not collapse the start screen (arcade.js: .game-setup.is-started) */
:root .ui-start .game-setup.is-started > .ui-sec { display: flex; }
:root .ui-start .game-setup .setup-now { display: none !important; }
/* the pinned bar: one primary action, always in reach */
:root .ui-startbar { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; gap: 0; padding: 8px var(--ui-gutter) calc(8px + env(safe-area-inset-bottom)); background: var(--ui-bg); border-top: 1px solid var(--ui-chip); }
:root .ui-startbar > * { width: 100%; max-width: 480px; margin-inline: auto; }
:root .ui-startbar .ui-text-btn { text-decoration: none; }
:root .ui-start .resume-box { margin-inline: var(--ui-gutter); }
:root .rules.ui-start-only { margin: 32px var(--ui-gutter) 0; scroll-margin-top: 12px; }
:root .ui-start .pitch, :root .ui-start .tagline { margin-inline: var(--ui-gutter); }
:root .ui-sec > .modes, :root .ui-sec > .box, :root .ui-sec > .online-box { margin: 0; max-width: none; width: 100%; box-sizing: border-box; }
/* settings as one grouped list: label on the left, the control on the right */
:root .ui-sec > .setup-opts { margin: 0; justify-content: stretch; background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-r-m); padding: 6px 14px; }
:root .ui-sec > .setup-opts label, :root .ui-sec > .setup-opts .pick { flex: 1; flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; font-size: 17px; font-weight: 600; color: var(--ui-ink); }
:root .ui-sec > .setup-opts select { font-size: 16px; font-weight: 400; }
:root .ui-pill[hidden] { display: none; }

/* ===== card games: the start screen is the page before "playing" (cards/ui.js swaps #setup for #game); Start is pinned ===== */
:root body:not(.playing) #startRow { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; margin: 0 !important; padding: 8px var(--ui-gutter) calc(8px + env(safe-area-inset-bottom)); background: var(--ui-bg); border-top: 1px solid var(--ui-chip); display: flex; justify-content: center; }
:root body:not(.playing) #startRow .btn { width: 100%; max-width: 480px; min-height: 52px; border-radius: 26px; font-size: 17px; }
:root body:not(.playing) #startRow.hidden { display: none; }
:root body:not(.playing) .wrap { padding-bottom: calc(112px + env(safe-area-inset-bottom)); }
:root .hero-cta[href="#setup"] { display: none; }   /* Play now: the pinned Start button replaces it */
:root #setup.panel { background: none; border: 0; box-shadow: none; padding: 0; }
:root #setup > .ui-label { margin: 16px 4px 8px; }
:root #setup > .ui-label:first-child { margin-top: 0; }
:root #setup > #modeBar { margin-bottom: 0 !important; }
:root body:not(.playing) #setup.panel { margin-inline: var(--ui-gutter); }
:root body:not(.playing) .hero { padding-inline: var(--ui-gutter); }
:root body:not(.playing) .landing-rules { margin-inline: var(--ui-gutter); }
:root .setup-grid { grid-template-columns: 1fr; gap: 8px; }
:root .setup-grid label { display: flex; flex-direction: row; text-align: start; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 4px 14px; border-radius: var(--ui-r-m); background: var(--ui-surface); border: 1px solid var(--ui-line); font-size: 17px; font-weight: 600; color: var(--ui-ink); }
/* an online room starts the game when the opponent is in: no Start button while "Play with a Friend" is chosen */
:root body:not(.bgp-hub):has(#modeBar [data-mode="online"][aria-checked="true"]) #uiStartBtn { display: none; }
:root body:not(.bgp-hub):has(#modeBar [data-mode="online"][aria-checked="true"]) .ui-startbar { padding-block: 0; border-top: 0; }

/* ===== room code as six boxes (the real input / text stays one string: tests, paste and screen readers keep working) ===== */
:root #roomCodeInput, :root #roomCodeDisplay {
  --box: 48px; --half: calc((var(--box) - .6em) / 2);
  box-sizing: content-box; width: calc(var(--box) * 6 + 3px); max-width: none; height: 60px; margin-inline: auto; padding: 0 0 0 var(--half);
  font: 700 28px/60px ui-monospace, Menlo, Consolas, monospace; letter-spacing: calc(var(--box) - .6em); text-transform: uppercase; text-align: start; white-space: nowrap; overflow: hidden;
  color: var(--ui-ink); border: 0; border-radius: 0; box-shadow: none; background-color: transparent;
  background-image: repeating-linear-gradient(90deg, transparent 0 3px, var(--ui-line) 3px 4px, var(--ui-chip) 4px calc(var(--box) - 4px), var(--ui-line) calc(var(--box) - 4px) calc(var(--box) - 3px), transparent calc(var(--box) - 3px) var(--box));
  background-size: calc(var(--box) * 6) 100%; background-repeat: no-repeat;
}
:root #roomCodeInput::placeholder { color: var(--ui-dim); opacity: .5; letter-spacing: calc(var(--box) - .6em); }
:root #roomCodeInput:focus { outline: none; background-image: repeating-linear-gradient(90deg, transparent 0 3px, var(--ui-accent) 3px 5px, var(--ui-chip) 5px calc(var(--box) - 5px), var(--ui-accent) calc(var(--box) - 5px) calc(var(--box) - 3px), transparent calc(var(--box) - 3px) var(--box)); }
@media (max-width: 340px) { :root #roomCodeInput { --box: 42px; font-size: 24px; } }

/* settings that are on / off: one row each, label left, checkbox right */
:root .ui-sec .setup-opts { flex-direction: column; align-items: stretch; gap: 0; padding: 0 14px; }
:root .ui-sec .setup-opts label:has(> input[type="checkbox"]) { display: flex; flex-direction: row; align-items: center; justify-content: space-between; gap: 16px; min-height: 52px; text-align: start; font-size: 17px; font-weight: 600; color: var(--ui-ink); }
:root .ui-sec .setup-opts label + label, :root .ui-sec .setup-opts .setting-hint + label { border-top: 1px solid var(--ui-line); }
:root .ui-sec .setup-opts input[type="checkbox"] { width: 24px; height: 24px; flex: none; accent-color: var(--ui-primary); }
:root .ui-sec .setup-opts .setting-hint { font-size: 14px; color: var(--ui-dim); padding: 0 0 8px; margin: -6px 0 0; text-align: start; }

/* ===== How to play as a sheet while a game is under way ===== */
:root .ui-helpbtn { display: inline-grid; }
/* the "?" is the one way to the rules: the other links on the start screens give way (the rules text stays in the page) */
:root .ui-startbar .ui-text-btn[data-i18n="start.how"], :root .hero-cta[href="#rules"], :root .bgk-rules, :root .ui-overlay-how { display: none !important; }
:root .ui-sheet .rule-grid { display: flex; flex-direction: column; gap: 10px; }
:root .ui-sheet .ui-sheet-body { display: flex; flex-direction: column; gap: 12px; }
:root .ui-sheet .ui-pill { margin-top: 12px; }
#uiRulesSheet { display: flex; flex-direction: column; overflow: hidden; }
#uiRulesSheet .ui-sheet-body { flex: 1; min-height: 0; overflow-y: auto; }
#uiRulesSheet h2:focus { outline: none; }
/* the room box (create / join / code / status) in the kit's look */
:root .online-box, :root .ui-sec > .box { background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-r-m); box-shadow: none; padding: 12px 14px; }
:root .online-header, :root .box-header { color: var(--ui-dim); }
:root .online-body, :root .box-body { gap: 12px; }
:root .btn-row { gap: 8px; }
:root .btn-row .btn { flex: 1; }
:root #roomCodeInput { flex: 0 0 auto; }
:root #joinRoomForm { flex-wrap: wrap; justify-content: center; }
:root #joinRoomForm #joinRoomSubmitBtn { flex: 1 0 100%; }
:root .online-row { flex-wrap: wrap; }
/* the room code shown next to its copy / share icons: the boxes shrink to share the line (320px phones too) */
:root #roomCodeDisplay { --box: clamp(22px, calc((100vw - 220px) / 6), 44px); font-size: calc(var(--box) * .58); line-height: calc(var(--box) * 1.25); height: calc(var(--box) * 1.25); margin-inline: 0; flex: 0 0 auto; }

/* ===== the waiting room (card games' lobby): seats as one grouped list, Start game as the one big action ===== */
:root #lobby .room-line { justify-content: center; gap: 10px; margin-bottom: 4px; }
:root #seatList { grid-template-columns: 1fr; gap: 0; margin: 8px 0 8px; background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-r-m); overflow: hidden; }
:root #seatList li { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 6px 14px; border-radius: 0; box-shadow: none; background: none; font-size: 17px; font-weight: 600; color: var(--ui-ink); }
:root #seatList li + li { border-top: 1px solid var(--ui-line); }
:root #seatList li::before { content: ""; width: 32px; height: 32px; flex: none; border-radius: 50%; background: var(--ui-chip); border: 1px solid var(--ui-line); box-sizing: border-box; }
:root #seatList li.empty { font-weight: 400; font-style: normal; color: var(--ui-dim); }
:root #seatList li.empty::before { background: none; border: 2px dashed var(--ui-line); }
:root #lobby .online-row { flex-direction: column; align-items: stretch; gap: 4px; }
:root #lobby .online-row .btn { width: 100%; min-height: 52px; border-radius: 26px; font-size: 17px; }
:root #lobby .online-row .btn:not(.primary) { background: none; border-color: transparent; color: var(--ui-accent); min-height: 44px; font-size: 16px; }
:root #lobby .share-note, :root #onlineStatus { color: var(--ui-dim); font-size: 14px; }
:root .icon-btn.share-btn { background: var(--ui-surface); border: 1px solid var(--ui-line); color: var(--ui-accent); border-radius: 50%; width: 44px; height: 44px; }

/* ===== start / paused / game over as a bottom sheet (Arcade.screen's .overlay): the same element, a new place ===== */
:root .field > .overlay:not([hidden]), :root .wrap > .overlay:not([hidden]) {
  position: fixed; z-index: 40; inset: auto 0 0 0; max-width: 560px; margin: 0 auto; max-height: 90vh; overflow: auto;
  padding: 12px var(--ui-gutter) calc(20px + env(safe-area-inset-bottom)); gap: 10px;
  border-radius: 22px 22px 0 0; background: var(--ui-bg); border: 1px solid var(--ui-line); border-bottom: 0;
  box-shadow: 0 0 0 100vmax var(--ui-scrim); text-align: center; align-items: center; justify-content: flex-start; /* the shadow is the scrim: it paints under the sheet's own content */
  animation: ui-slide 250ms var(--ui-ease);
}
:root .field > .overlay:not([hidden])::after { content: ""; order: -1; width: 40px; height: 4px; border-radius: 2px; background: var(--ui-line); flex: none; }
:root .field > .overlay h2 { font-size: 28px; }
:root .field > .overlay .actions { max-width: 480px; }

/* dialogs of the card games (round over, leave) are bottom sheets like every other sheet; ids and showModal() are unchanged */
:root dialog { position: fixed; inset: auto 0 0 0; width: 100%; max-width: 560px; max-height: 85vh; margin: 0 auto; overflow: auto; border: 1px solid var(--ui-line); border-bottom: 0; border-radius: 22px 22px 0 0; background: var(--ui-bg); color: var(--ui-ink); box-shadow: none; padding: 20px var(--ui-gutter) calc(20px + env(safe-area-inset-bottom)); }
:root dialog[open] { animation: ui-slide 250ms var(--ui-ease); }
:root dialog::backdrop { background: var(--ui-scrim); }
:root dialog::before { content: ""; display: block; width: 40px; height: 4px; margin: -12px auto 14px; border-radius: 2px; background: var(--ui-line); }
:root dialog h2 { margin: 0 0 12px; font-family: var(--ui-serif); font-size: 26px; }
:root dialog table { color: inherit; }
:root dialog th, :root dialog td { border-bottom-color: var(--ui-line); }
:root dialog .win { color: var(--ui-ok); }
:root dialog .actions .btn { min-height: 44px; }
@media (prefers-reduced-motion: reduce) { :root dialog[open] { animation: none; } }

/* game menu (UI.menu): a "..." button in the top bar while playing; it takes the place of the "?" button */
:root .ui-menubtn { display: none; }
:root body[data-stage="play"] .ui-menubtn, :root body.playing .ui-menubtn { display: inline-grid; }
:root body.ui-has-menu[data-stage="play"] .ui-helpbtn, :root body.ui-has-menu.playing .ui-helpbtn { display: none; } /* during play the menu has How to play */
:root .ui-row.ui-danger .ui-row-title { color: var(--ui-err); }

/* last-move line under the table status; tapping it opens the History sheet (cards/ui.js) */
:root .ui-lastmove { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; margin: 0 0 8px; padding: 6px 14px; border-radius: var(--ui-r-m); background: var(--ui-surface); border: 1px solid var(--ui-line); color: var(--ui-ink); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
:root .ui-lastmove-k { flex: none; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ui-dim); }
:root .ui-lastmove-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:root .ui-lastmove.hidden { display: none; }
:root #log.log { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:root .ui-history { list-style: none; margin: 0 0 4px; padding: 0; display: flex; flex-direction: column; }
:root .ui-history li { padding: 10px 0; border-bottom: 1px solid var(--ui-line); font-size: 14px; line-height: 1.4; }
:root .ui-history li:first-child { font-weight: 600; }
:root .ui-history-empty { color: var(--ui-dim); }

/* waiting room (card games): while a room is open and not started, the page is just the room: code, seats, the host's table settings */
:root body:not(.playing):has(#lobby:not(.hidden):not(.msg-only)) :is(.hero, #rules, #modeBar, #onlineChoice, #onlineBox > h3, #setup > .ui-label:not(.ui-label-setup), #startRow, #hostResumeBox, #rejoinBox, #resumeBox) { display: none !important; }
:root body:not(.playing):has(#lobby:not(.hidden):not(.msg-only)) #onlineBox { border: 0; background: none; padding: 0; margin-top: 8px; }

/* connection lost / a player is away: one banner style, a pulsing dot, readable in both themes */
:root .away-banner { display: flex; align-items: center; justify-content: flex-start; gap: 10px; text-align: left; min-height: 44px; margin: 0 0 8px; padding: 8px 14px; border-radius: var(--ui-r-m); background: var(--ui-surface); border: 1px solid var(--ui-line); color: var(--ui-ink); box-shadow: none; font-size: 14px; line-height: 1.35; }
:root .away-banner::before { content: ""; flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--ui-err); animation: ui-pulse 1.4s ease-in-out infinite; }
:root .away-banner.hidden { display: none; }
:root .away-banner .btn { margin-left: auto; min-height: 44px; }
@keyframes ui-pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { :root .away-banner::before { animation: none; } }

/* checkbox rows: the whole row is the 44px target */
:root .setting-row, :root .ai-toggle { min-height: 44px; }
:root .ai-toggle input { width: 22px; height: 22px; }

/* short phones in portrait: the canvas gives way so the pad and Pause / Restart stay on screen (no scrolling mid-game) */
@media (pointer: coarse) and (max-width: 520px) and (orientation: portrait) {
  :root body[data-stage="play"] .field > canvas { max-height: calc(100svh - 270px); width: auto; max-width: 100%; margin-inline: auto; display: block; }
  :root body[data-stage="play"] .wrap:has(.touch-controls, .pad) .field > canvas { max-height: 46svh; } /* an on-screen pad needs the room */
  :root body[data-stage="play"] .hint { display: none; }
}

/* ===== three screens (UI.stages with steps): mode, then settings, then play ===== */
:root body[data-flow="3"][data-stage="start"] .ui-sec[data-sec="setup"] { display: none; }
:root body[data-flow="3"][data-stage="setup"] .ui-start > :not(.game-setup):not(#gameSetup), :root body[data-flow="3"][data-stage="setup"] .ui-sec[data-sec="mode"], :root body[data-flow="3"][data-stage="setup"] .ui-start-only, :root body[data-flow="3"][data-stage="setup"] .ui-play { display: none; }
:root body[data-flow="3"][data-stage="setup"] .wrap { padding-bottom: calc(132px + env(safe-area-inset-bottom)); }
/* the mode screen has no button: pressing a mode goes on (UI.stages) */
:root body[data-flow="3"][data-stage="start"]:has(#modeBar .mode-btn) #uiStartBtn { display: none; }
:root body[data-flow="3"][data-stage="start"]:has(#modeBar .mode-btn) .ui-startbar { padding-block: 0; border-top: 0; }
:root .modes.levels:has(> :nth-child(2):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* ===== card games, three screens: body[data-step] is "mode" or "setup" while no game is on the table (cards/ui.js) ===== */
:root body[data-flow="3"][data-step="mode"]:not(.playing) :is(#onlineBox, #setup > .ui-label-setup, #setup .setup-grid, #startRow) { display: none !important; }
:root body[data-flow="3"][data-step="setup"]:not(.playing) :is(.hero, #rules, #setup > .ui-label:not(.ui-label-setup), #modeBar, #hostResumeBox, #rejoinBox, #resumeBox) { display: none !important; }
:root body[data-flow="3"][data-step="setup"]:not(.playing) #setup > .ui-label-setup { margin-top: 0; }

/* Remi 51 opening meter: points laid down against the 51 needed */
:root .ui-meter { display: block; flex: 1 0 100%; height: 8px; margin: 0 0 6px; border-radius: 4px; background: var(--ui-chip); overflow: hidden; }
:root .ui-meter > i { display: block; height: 100%; border-radius: 4px; background: var(--ui-accent); transition: width 200ms var(--ui-ease); }
:root .ui-meter.full > i { background: var(--ui-ok); }
@media (prefers-reduced-motion: reduce) { :root .ui-meter > i { transition: none; } }

/* Remi 7 plan card: what your hand can do right now */
:root .plan-card { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; margin: 0 0 8px; padding: 8px 14px; border-radius: var(--ui-r-m); background: var(--ui-surface); border: 1px solid var(--ui-line); color: var(--ui-ink); font-size: 14px; }
:root .plan-card.hidden { display: none; }
:root .plan-k { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ui-dim); }

/* Tablanet sum chip: your card's value against the picked table cards; it lights up when they make a legal capture */
:root .sum-chip { display: flex; justify-content: center; gap: 18px; margin: 8px auto 0; padding: 6px 14px; width: fit-content; max-width: 100%; border-radius: 999px; background: var(--ui-surface); border: 1px solid var(--ui-line); color: var(--ui-ink); font-size: 14px; }
:root .sum-chip.hidden { display: none; }
:root .sum-chip.match { border-color: var(--ui-ok); box-shadow: 0 0 0 1px var(--ui-ok); }
:root .sum-k { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ui-dim); }
:root .sum-chip b { font-variant-numeric: tabular-nums; }
:root #gameListBox { display: flex; flex-direction: column; gap: 8px; }
:root #gameListBox[hidden] { display: none; }
:root #gameListBox > .ui-label { margin: 8px 4px 0; }
:root #gameList a.ui-row { text-decoration: none; color: inherit; }

/* the hand magnifier (cards/ui.js): the card under the finger, enlarged above a crowded hand */
:root .hand-peek { position: fixed; z-index: 60; width: 126px; height: 176px; pointer-events: none; filter: drop-shadow(0 8px 14px rgba(0,0,0,.55)); }
:root .hand-peek[hidden] { display: none; }
:root .hand-peek .card.peek { width: 126px; height: 176px; border-radius: 12px; transform: none; box-shadow: 0 0 0 3px var(--ui-accent); }
:root .hand-peek.is-sel .card.peek { box-shadow: 0 0 0 4px #f2c14e; }

/* ===== card tables on a phone: every player is one lane (the mockup), the opponent tiles and the melds block give way to it ===== */
:root .lanes { display: none; }
@media (max-width: 760px), (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  :root .roundline { margin-bottom: 4px; font-size: 12px; }
  :root .felt { display: flex; flex-direction: column; align-items: stretch; gap: 6px; padding: 8px; border-width: 5px; border-radius: 16px; margin-bottom: 6px; }
  :root .felt .felt-side, :root #melds { display: none; }
  :root .felt-center { display: flex; flex-direction: column; gap: 6px; }
  :root .center { gap: 14px; margin: 0; }
  :root .center .card, :root .center .discard-stack { width: 44px; height: 62px; }
  :root .deck-area { margin-bottom: 14px; }
  :root .deck-area:has(#fuTag:not(.hidden)) { margin-bottom: 34px; }
  :root .pile { font-size: 11px; gap: 4px; }
  :root .lanes { display: flex; flex-direction: column; gap: 5px; }
  :root .lane { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 10px; border-radius: 12px; background: rgba(0,0,0,.22); border: 2px solid transparent; }
  :root .lane.on { background: rgba(0,0,0,.4); border-color: rgba(255,255,255,.28); }
  :root .lane .lh { flex: 0 0 40%; max-width: 160px; min-width: 0; }
  :root .lane .nm { display: flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 700; color: #fff; min-width: 0; }
  :root .lane .nm-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  :root .lane .dot { width: 10px; height: 10px; flex: none; border-radius: 50%; background: hsl(var(--hue) 60% 55%); }
  :root .lane .dealer { flex: none; width: 18px; height: 18px; border-radius: 50%; background: #f2c14e; color: #2a1d0c; font-size: 10px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
  :root .lane .tt { margin-left: auto; flex: none; padding: 0 7px; border-radius: 999px; background: rgba(0,0,0,.3); font-size: 12px; font-weight: 700; color: #f2c14e; font-variant-numeric: tabular-nums; }
  :root .lane .turn-tag { flex: none; font-size: 11px; font-weight: 700; color: #2a1d0c; background: #f2c14e; border-radius: 999px; padding: 1px 8px; }
  :root .lane .ls { display: block; margin-top: 1px; font-size: 12px; line-height: 1.25; color: rgba(255,255,255,.72); }
  :root .lane .ls .ok { color: #8be28b; }
  :root .lane .lm { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
  :root .lane .lm:empty { display: none; }
  /* a player with nothing laid down: one line, the name on the left and the cards on the right */
  :root .lane:has(.lm:empty) .lh { flex: 1; max-width: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  :root .lane:has(.lm:empty) .ls { margin: 0; text-align: right; }
  :root .lane .meld { border-radius: 8px; padding: 4px 6px 4px 3px; background: rgba(0,0,0,.18); }
  :root .lane .meld .card { width: 34px; height: 48px; margin-left: -21px; }
  :root .lane .meld .card:first-child { margin-left: 0; }
  :root .lane .meld.target { cursor: pointer; }
  /* no melds on the table (Tablanet, Makao ...): the lanes become one row of score tiles, as in the mockup (34 You | 21 Bot 1 | ...) */
  :root .lanes:not(:has(.lm)) { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; }
  :root .lanes:not(:has(.lm)) .lane { flex-direction: column; justify-content: center; gap: 0; min-height: 0; padding: 6px 4px; text-align: center; border-radius: 10px; }
  :root .lanes:not(:has(.lm)) .lane .lh, :root .lanes:not(:has(.lm)) .lane:has(.lm:empty) .lh { flex: none; display: block; width: 100%; max-width: none; }
  :root .lanes:not(:has(.lm)) .lane .nm { flex-direction: column-reverse; align-items: center; gap: 0; font-size: 12px; font-weight: 600; color: rgba(255,255,255,.8); }
  :root .lanes:not(:has(.lm)) .lane .tt { margin: 0; padding: 0; background: none; font-size: 22px; line-height: 1.1; color: #fff; }
  :root .lanes:not(:has(.lm)) .lane :is(.dot, .turn-tag, .ls, .dealer) { display: none; }
  :root .lanes:not(:has(.lm)) .lane.on { border-color: #f2c14e; }
  /* the seat strip in the hand panel is the lane above: it gives way on a phone */
  :root .hand-panel .seat.me { display: none; }
}

/* History sheet: a row per move (the colour of the player, the line, the card as a picture); tap a card to see it larger */
:root .ui-history li { display: flex; align-items: center; gap: 12px; }
:root .hist-dot { width: 10px; height: 10px; flex: none; border-radius: 50%; }
:root .hist-t { flex: 1; min-width: 0; }
:root .hist-cards { display: flex; gap: 4px; flex: none; }
:root .hist-card { width: 34px; height: 48px; padding: 0; border: 0; background: none; border-radius: 5px; cursor: zoom-in; filter: drop-shadow(0 1px 2px rgba(0,0,0,.35)); }
:root .hist-card[disabled] { cursor: default; }
:root .hist-card svg { width: 100%; height: 100%; display: block; }
:root .hist-note { margin: 10px 0 0; font-size: 13px; line-height: 1.4; color: var(--ui-dim); }
:root .hist-zoom { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; background: var(--ui-scrim); cursor: zoom-out; }
:root .hist-zoom[hidden] { display: none; }
:root .hist-zoom svg { width: min(62vw, 250px); height: auto; filter: drop-shadow(0 12px 24px rgba(0,0,0,.5)); }
:root .hist-zoom-x { position: absolute; top: 14px; right: 18px; font-size: 32px; line-height: 1; color: #fff; }
:root .ui-lastmove-t { flex: 1; }
:root .ui-lastmove-k { color: var(--ui-accent); letter-spacing: 0; text-transform: none; font-size: 14px; }
:root .ui-lastmove .ui-chev { width: auto; height: auto; font-size: 20px; line-height: 1; color: var(--ui-accent); }

/* the action bar on a phone: one tidy row (the mockup): Hint and Sort are icon buttons, the main actions share the rest;
   the move arrows appear only while a card is selected; "take the face-up card" is a row of its own */
@media (max-width: 760px), (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  :root .hand-panel .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; justify-content: stretch; }
  :root .hand-panel .actions .btn { flex: 1 1 0; min-width: 0; min-height: 48px; padding: 6px 10px; font-size: 14px; line-height: 1.15; white-space: normal; text-align: center; overflow-wrap: anywhere; }
  :root #discardBtn { background: var(--ui-primary); border-color: var(--ui-primary); color: var(--ui-on); font-weight: 700; }
  :root #hintBtn, :root #sortBtn { order: -1; flex: 0 0 48px; width: 48px; padding: 0; font-size: 0; position: relative; }
  :root #hintBtn::before, :root #sortBtn::before { content: ""; position: absolute; inset: 0; margin: auto; width: 22px; height: 22px; background: currentColor; -webkit-mask: var(--ico) center / contain no-repeat; mask: var(--ico) center / contain no-repeat; }
  :root #hintBtn { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 18h6M10 21h4M12 3a6 6 0 0 0-3.5 10.9c.6.5 1 1.2 1 2.1h5c0-.9.4-1.6 1-2.1A6 6 0 0 0 12 3z'/%3E%3C/svg%3E"); }
  :root #sortBtn { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 4v16M8 20l-3-3M8 20l3-3M16 20V4M16 4l-3 3M16 4l3 3'/%3E%3C/svg%3E"); }
  :root #moveLeftBtn, :root #moveRightBtn { display: none; }
  :root .hand-panel:has(#hand .card.sel) #moveLeftBtn, :root .hand-panel:has(#hand .card.sel) #moveRightBtn { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 44px; }
  :root #faceUpBtn { order: 9; flex: 1 0 100%; min-height: 44px; }
  /* with a card selected the move arrows join the row: the icon buttons take the first row, the main actions a row of their
     own, so a long label (Macedonian, German) is not squeezed into a column and broken in the middle of a word */
  :root .hand-panel:has(#hand .card.sel) .actions .btn:not(#hintBtn, #sortBtn, #moveLeftBtn, #moveRightBtn, #faceUpBtn) { order: 5; flex: 1 1 40%; }
  :root .hand-panel:has(#hand .card.sel) :is(#hintBtn, #sortBtn, #moveLeftBtn, #moveRightBtn) { flex: 1 1 0; width: auto; }
  :root .hand-panel .actions .btn { overflow-wrap: break-word; hyphens: auto; }
}

/* ===== Backgammon 1 to 3 (body.bgp): landing, settings and table after the UI kit mockup (docs/2026-11-redesign/artifacts/v1-ui-kit-mockup.html) ===== */
/* landing: the board and the name are the hero; the top bar keeps only the back link and the language button */
:root body.bgp #onlineBox .btn { letter-spacing: 0; }   /* the room box is the other games': Create / Join / Leave, code boxes */
:root body.bgp #onlineBox .online-status { text-align: center; }
:root body.bgp:not([data-stage="play"]) .ui-topbar h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:root body.bgp:not([data-stage="play"]) .wrap { padding-inline: 0; }
:root .bgp-hero { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 4px var(--ui-gutter) 0; }
:root .bgp-art { width: min(240px, 62vw); height: auto; border-radius: 12px; box-shadow: 0 10px 28px rgba(0,0,0,.35); }
:root .bgp-title { font-family: var(--ui-serif, 'Iowan Old Style', 'Palatino Linotype', Georgia, serif); font-size: clamp(30px, 9vw, 38px); font-weight: 700; line-height: 1.05; color: var(--ui-ink); text-wrap: balance; }
:root body.bgp .ui-start > .tagline { margin: -6px var(--ui-gutter) 0; color: var(--ui-accent); }
:root body.bgp .ui-start > .similar { margin-inline: var(--ui-gutter); }
:root body.bgp .ui-start > .bgk-rules { order: 5; align-self: center; margin: 0; font-size: 16px; font-weight: 600; color: var(--ui-accent); text-decoration: none; }
:root body.bgp[data-flow="3"][data-stage="start"] .ui-startbar { display: none; } /* one "How to play", under the mode cards */
:root body.bgp[data-flow="3"][data-stage="start"] .wrap { padding-bottom: calc(32px + env(safe-area-inset-bottom)); }
:root body.bgp:not([data-flow="3"]) .ui-start > .bgk-rules { display: none; } /* one start screen: the pinned bar has the link */
/* settings: the game first (number, name, one line, check), then the computer's level */
:root .bgp-num { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--ui-chip); color: var(--ui-accent); font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
:root body.bgp #gameList { background: none; border: 0; display: flex; flex-direction: column; gap: 8px; }
:root body.bgp #gameList > li { border: 0; }
:root body.bgp #gameList a.ui-row { gap: 10px; padding: 12px 12px; min-height: 64px; border-radius: var(--ui-r-m); background: var(--ui-surface); border: 1px solid var(--ui-line); }
:root body.bgp #gameList a.ui-row[aria-checked="true"] { border-color: var(--ui-accent); box-shadow: 0 0 0 1px var(--ui-accent); }
:root body.bgp #gameListBox > .ui-label { margin-top: 0; }
:root body.bgp #levelLabel { margin-top: 8px; }
:root body.bgp #levelLabel[hidden] { display: none; }
:root body.bgp .ui-sec, :root body.bgp #gameListBox { text-align: start; }
/* the table on a phone: turn chip, board, message, dice; Undo and Roll in a tray at the thumb */
@media (max-width: 700px) {
  :root body.bgp[data-stage="play"] .wrap { padding: 4px 8px calc(150px + env(safe-area-inset-bottom)); }
  :root body.bgp .layout { flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 12px; }
  :root body.bgp .side-panel { display: contents; }
  :root body.bgp #matchBanner { order: -3; }
  :root body.bgp #turnBadge { order: -2; align-self: center; padding: 6px 14px; border-radius: 999px; background: var(--ui-chip); color: var(--ui-ink); font-size: 12px; font-weight: 600; letter-spacing: .06em; }
  :root body.bgp .board-frame { order: 0; width: 100%; box-sizing: border-box; padding: 5px; border-radius: 12px; box-shadow: inset 0 0 0 1px var(--ui-line); }
  :root body.bgp #msgBox { order: 1; background: none; padding: 0 8px; min-height: 0; text-align: center; font-size: 15px; font-weight: 600; color: var(--ui-ink); }
  :root body.bgp #diceTray { order: 2; background: none; box-shadow: none; padding: 0; min-height: 56px; align-items: center; color: var(--ui-dim); }
  :root body.bgp #diceTray .die { width: 52px; height: 52px; border-radius: 12px; padding: 8px; background: #f6edd6; box-shadow: 0 0 0 2px var(--ui-accent), 0 4px 10px rgba(0,0,0,.35); }
  :root body.bgp #diceTray .dot.on { width: 9px; height: 9px; }
  :root body.bgp #endTurnBtn { order: 3; align-self: center; min-width: 200px; }
  :root body.bgp #newGameBtn { order: 4; align-self: center; min-width: 200px; display: none; } /* Start over is in the menu */
  :root body.bgp:has(.winner-banner) #newGameBtn { display: block; } /* a finished game offers the next one */
  :root body.bgp .side-panel > .hint { display: none; } /* the rules are one tap away in the menu */
  :root body.bgp .side-panel > .btn-row { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; flex-wrap: wrap; gap: 12px; padding: 8px var(--ui-gutter) calc(8px + env(safe-area-inset-bottom)); background: var(--ui-bg); border-top: 1px solid var(--ui-chip); }
  :root body.bgp:not([data-stage="play"]) .side-panel > .btn-row { display: none; }
  :root body.bgp .side-panel > .btn-row .btn { min-height: 52px; border-radius: 26px; font-size: 17px; letter-spacing: 0; }
  :root body.bgp .side-panel > .btn-row > .ui-lastmove { order: 0; flex: 1 0 100%; margin: 0; }   /* the last move, one line above Undo / Roll; it opens History */
  :root body.bgp #rollBtn { flex: 1; order: 2; background: var(--ui-primary); color: var(--ui-on); box-shadow: none; }
  :root body.bgp #undoBtn { flex: 0 0 auto; order: 1; padding-inline: 22px; background: var(--ui-surface); color: var(--ui-ink); box-shadow: inset 0 0 0 1px var(--ui-line); }
}
:root body.bgp:not([data-stage="play"]) .ui-topbar #langBar { margin-left: auto; }

/* a close button in the corner of a sheet (the language sheet) */
:root .ui-sheet { position: fixed; }
:root .ui-sheet-x { position: absolute; top: 14px; right: 10px; width: 44px; height: 44px; border: 0; border-radius: 0; background: none; color: var(--ui-dim); } /* a small x, no circle: the 44px box is only the touch target */
:root .ui-sheet:has(> .ui-sheet-x) > h2 { padding-right: 48px; }
/* "How to play" on the start card of the one-button games */
:root .field > .overlay .ui-overlay-how { margin-top: 4px; }
/* no pinned bar on these screens: no room kept for one, so a page that fits does not scroll */
:root body[data-stage="play"] .wrap { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
:root body[data-flow="3"][data-step="mode"]:not(.playing) .wrap { padding-bottom: calc(32px + env(safe-area-inset-bottom)); }
/* no rubber-band past the ends of the page, no double-tap zoom anywhere, no pinch zoom on a game under way */
html { overscroll-behavior: none; touch-action: manipulation; }
body[data-stage="play"], body.playing { touch-action: pan-x pan-y; }

/* ===== a phone on its side (short and wide): the start screens scroll as usual, the play screen gives its height to the field ===== */
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  :root body[data-stage="play"] .ui-topbar, :root body.playing .ui-topbar { min-height: 44px; padding-block: 0; }
  :root body[data-stage="play"] .ui-topbar h1, :root body[data-stage="play"] .ui-topbar .ui-title { font-size: 18px; }
  :root body[data-stage="play"] .wrap { padding-bottom: 4px; }
  /* canvas games: the canvas is as tall as the screen allows; the keyboard line gives way */
  :root body[data-stage="play"] .field > canvas, :root .wrap:has(> .field > .overlay[hidden]) > .field > canvas { max-height: calc(100svh - 96px); width: auto; max-width: 100%; margin-inline: auto; display: block; }
  :root body[data-stage="play"] .wrap:has(.touch-controls, .pad) .field > canvas { max-height: calc(100svh - 96px); }
  :root body[data-stage="play"] .hint, :root body[data-stage="play"] .keys { display: none; }
  /* board games: UI.fitLandscape (games/ui/ui.js) scales a board that is taller than the screen */
  /* card tables: the hand does not stay pinned over a table this short; the page scrolls from the table to the hand */
  :root body.playing .hand-panel { position: static; }
  /* Tank Siege and Tower Siege keep their own side-by-side layout: the wrapper of the play screen must not break their flex column */
  :root body[data-stage="play"]:has(#landscapeControls) .ui-play { display: contents; }
  :root body[data-stage="play"]:has(#landscapeControls) .ui-topbar { position: fixed; top: 0; right: 0; left: auto; z-index: 30; padding: 2px 6px; min-height: 0; gap: 4px; }
  :root body[data-stage="play"]:has(#landscapeControls) .ui-topbar > :not(.ui-menubtn) { display: none; }
  :root body[data-stage="play"]:has(#landscapeControls) .wrap { height: 100svh; padding: 4px 8px; }
  /* Backgammon: the board on the left, the turn, dice and buttons in a column on the right */
  :root body.bgp[data-stage="play"] .wrap { max-width: none; height: calc(100svh - 44px); box-sizing: border-box; padding: 2px 8px 4px; }
  :root body.bgp[data-stage="play"] .ui-play { height: 100%; }
  :root body.bgp[data-stage="play"] .ui-topbar h1 { display: none; }
  :root body.bgp[data-stage="play"] .ui-topbar #langBar { margin-left: auto; }
  :root body.bgp[data-stage="play"] .layout { height: 100%; flex-direction: row; flex-wrap: nowrap; align-items: stretch; gap: 8px; }
  :root body.bgp[data-stage="play"] .board-frame { flex: 1 1 auto; min-width: 0; width: auto; padding: 5px; display: flex; align-items: center; }
  :root body.bgp[data-stage="play"] .board { width: 100%; }
  :root body.bgp[data-stage="play"] .point { height: calc((100svh - 70px) / 2); }
  :root body.bgp[data-stage="play"] .checker { width: 20px; height: 20px; margin-top: -4px; }
  :root body.bgp[data-stage="play"] .off-tray { width: 26px; font-size: 9px; padding: 4px 0; gap: 2px; }
  :root body.bgp[data-stage="play"] .off-checker { width: 11px; height: 11px; }
  :root body.bgp[data-stage="play"] .point-label { font-size: 8px; }
  :root body.bgp[data-stage="play"] .side-panel { display: flex; flex-direction: column; width: 190px; flex: 0 0 190px; padding: 6px; gap: 6px; overflow-y: auto; max-height: 100%; box-sizing: border-box; background: none; box-shadow: none; }
  :root body.bgp[data-stage="play"] .side-panel > .btn-row { position: static; padding: 0; border: 0; background: none; flex-wrap: wrap; gap: 6px; }
  :root body.bgp[data-stage="play"] .side-panel > .btn-row .btn { min-height: 44px; font-size: 14px; border-radius: 22px; flex: 1 1 auto; }
  :root body.bgp[data-stage="play"] #turnBadge { order: 0; align-self: stretch; padding: 5px; font-size: 10px; }
  :root body.bgp[data-stage="play"] #msgBox { order: 0; font-size: 12px; font-weight: 400; padding: 0; }
  :root body.bgp[data-stage="play"] #diceTray { order: 0; min-height: 40px; }
  :root body.bgp[data-stage="play"] #diceTray .die { width: 34px; height: 34px; padding: 5px; border-radius: 8px; }
  :root body.bgp[data-stage="play"] .side-panel > .hint { display: none; }
  :root body.bgp[data-stage="play"] #newGameBtn { display: none; }
  :root body.bgp[data-stage="play"]:has(.winner-banner) #newGameBtn { display: block; }
}
/* rules brought into the sheet from another page (Backgammon): section headings and the board pictures */
:root .ui-sheet .rule-group { display: flex; align-items: center; gap: 10px; margin: 18px 0 8px; }
:root .ui-sheet .rule-group:first-child { margin-top: 0; }
:root .ui-sheet .rule-group h2 { margin: 0; font-family: var(--ui-serif); font-size: 20px; text-align: start; }
:root .ui-sheet .rule-group .badge { flex: none; min-width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; background: var(--ui-chip); color: var(--ui-accent); }
:root .ui-sheet .rule-group .sim { font-size: 13px; color: var(--ui-dim); }
:root .ui-sheet .figs { display: grid; gap: 10px; margin: 0 0 8px; }
:root .ui-sheet figure { margin: 0; }
:root .ui-sheet figcaption { margin-top: 4px; font-size: 13px; line-height: 1.4; color: var(--ui-dim); }
:root .ui-sheet .bgd svg { width: 100%; height: auto; display: block; border-radius: 8px; }

/* poker bet stepper: all three buttons are 44px wide */
:root .step-btn, :root #sizePotBtn { min-width: 44px !important; flex-shrink: 0; }

/* the language picker (UI.languageSheet): header with a small x, a search box, one grouped list */
:root .ui-lang-sheet { display: flex; flex-direction: column; max-height: 88svh; }
:root .ui-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
:root .ui-sheet-head h2 { margin: 0; }
:root .ui-lang-sheet .ui-sheet-x { position: static; margin-right: -10px; }
:root .ui-search { width: 100%; box-sizing: border-box; min-height: 44px; margin-bottom: 10px; padding: 0 14px; border-radius: var(--ui-r-m); border: 1px solid var(--ui-line); background: var(--ui-chip); color: var(--ui-ink); font: inherit; font-size: 16px; }
:root .ui-search::placeholder { color: var(--ui-dim); }
:root .ui-lang-sheet .ui-group { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
:root .ui-lang-sheet .ui-row { min-height: 56px; }
:root .ui-row-en { flex: none; font-size: 14px; color: var(--ui-dim); }
:root .ui-lang-none { padding: 16px 4px; text-align: center; color: var(--ui-dim); }
:root .ui-lang-none[hidden] { display: none; }

/* the top-bar menu (UI.menu) replaces the in-table Menu button on the poker games and Solitaire */
:root body.ui-has-menu #menuBtn { display: none; }
/* a game under way shows the game: the rules below it are one tap away in the "?" / menu (the text stays in the page for search) */
:root body:has(.field > .overlay:first-of-type:last-of-type[hidden]) :is(.rules, .landing-rules, #rules), :root body.playing :is(.rules, .landing-rules, #rules) { display: none; }

/* ===== the first screen of a game, after the Backgammon app: big title, Single Player first and large, the rest grouped, a How to play row ===== */
:root .ui-hero-head { text-align: center; padding: 8px var(--ui-gutter) 0; }
:root .ui-hero-title { font-family: var(--ui-serif); font-size: clamp(32px, 9.5vw, 42px); font-weight: 700; line-height: 1.05; color: var(--ui-ink); text-wrap: balance; }
:root body:has(.ui-hero-head):not(.playing):not([data-stage="play"]) .ui-topbar :is(h1, .ui-title) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:root .ui-start > .tagline, :root .wrap > .tagline { color: var(--ui-accent); }
/* mode cards: the first is the primary card, the others sit in one group */
:root .modes:not(.levels) { gap: 0; }
:root .modes:not(.levels) > .mode-btn { border-radius: 0; }
:root .modes:not(.levels) > .mode-btn:first-child { border-radius: var(--ui-r-l); margin-bottom: 12px; min-height: 84px; background: var(--ui-primary); border-color: var(--ui-primary); color: var(--ui-on); }
:root .modes:not(.levels) > .mode-btn:first-child .mode-sub { color: inherit; opacity: .85; }
:root .modes:not(.levels) > .mode-btn:first-child .mode-ico { background: var(--ui-on); color: var(--ui-primary); }
:root .modes:not(.levels) > .mode-btn:nth-child(2) { border-top-left-radius: var(--ui-r-l); border-top-right-radius: var(--ui-r-l); }
:root .modes:not(.levels) > .mode-btn:last-child:not(:first-child) { border-bottom-left-radius: var(--ui-r-l); border-bottom-right-radius: var(--ui-r-l); }
:root .modes:not(.levels) > .mode-btn:nth-child(n+3) { border-top-width: 0; }
:root .modes:not(.levels) > .mode-btn:not(:first-child)[aria-checked="true"] { background: var(--ui-surface); border-color: var(--ui-line); color: var(--ui-ink); }
:root .modes:not(.levels) > .mode-btn:not(:first-child)[aria-checked="true"] .mode-sub { color: var(--ui-dim); opacity: 1; }
:root .modes:not(.levels) > .mode-btn:not(:first-child)[aria-checked="true"] .mode-ico { background: var(--ui-chip); color: var(--ui-accent); }
/* the How to play row */
:root .ui-how-row { display: flex; align-items: center; justify-content: space-between; width: 100%; box-sizing: border-box; min-height: 56px; margin-top: 16px; padding: 0 16px; border-radius: var(--ui-r-l); background: none; border: 1px solid var(--ui-line); color: var(--ui-accent); font: inherit; font-size: 17px; font-weight: 600; cursor: pointer; }
:root .ui-how-row:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }
:root body[data-stage="setup"] .ui-how-row, :root body[data-stage="play"] .ui-how-row, :root body.playing .ui-how-row, :root body[data-step="setup"] .ui-how-row { display: none; }
/* its rules live in the sheet: the inline copy is out of the way (it stays in the page for search) */
:root body:has(.ui-how-row) :is(.rules, .landing-rules, #rules):not(.ui-sheet *) { display: none; }
:root body:has(.ui-how-row) .hero-cta[href="#rules"] { display: none !important; }

/* the settings screen's title: the chosen mode, as in the app; only on that screen */
:root .ui-setup-head { display: none; }
:root body[data-stage="setup"] .ui-setup-head, :root body[data-step="setup"]:not(.playing) .ui-setup-head { display: block; padding: 4px 4px 12px; }
:root .ui-setup-title { font-family: var(--ui-serif); font-size: clamp(30px, 9vw, 38px); font-weight: 700; line-height: 1.08; color: var(--ui-ink); }
:root .ui-setup-sub { margin-top: 4px; font-size: 17px; line-height: 1.4; color: var(--ui-dim); }
:root body[data-stage="setup"] .ui-sec > .ui-label:first-child, :root body[data-step="setup"]:not(.playing) #setup > .ui-label-setup { display: none; }

/* ===== Play with a Friend, after the app: Create a room is the primary card, joining is a quieter row below it; no box around them ===== */
:root #onlineBox, :root .ui-sec > .online-box { background: none; border: 0; padding: 0; box-shadow: none; }
:root #onlineBox > details > summary.online-header, :root #onlineBox > h3 { display: none; }
:root #onlineBox .online-body { margin: 0; }
:root #onlineBox #onlineChoiceRow, :root #onlineBox #onlineChoice { display: flex; flex-direction: column; gap: 12px; }
:root #onlineBox #createRoomBtn { order: -1; min-height: 84px; border-radius: var(--ui-r-l); background: var(--ui-primary); border: 1px solid var(--ui-primary); color: var(--ui-on); font: 700 22px var(--ui-serif); width: 100%; }
:root #onlineBox #joinRoomBtn { min-height: 56px; border-radius: var(--ui-r-l); background: none; border: 1px solid var(--ui-line); color: var(--ui-accent); font-size: 17px; font-weight: 600; width: 100%; }
:root body[data-step="setup"]:not(.playing) :is(.ui-hero-head, .tagline, .pitch) { display: none; }
:root .ui-setup-head { text-align: start; }
:root #onlineBox .online-header { display: none; }

/* the room code, after the app: six large boxes, then Copy and Share as wide buttons; an empty code field shows empty boxes */
:root #roomCodeInput::placeholder { color: transparent; }
:root #onlineBox #joinRoomForm, :root #onlineBox #lobby .online-row:has(#roomCodeInput) { justify-content: center; }
:root .room-line { flex-wrap: wrap; justify-content: center; gap: 12px; margin-bottom: 8px; }
:root .room-line #roomCodeDisplay { flex: 0 0 auto; order: -1; margin-inline: auto; --box: clamp(44px, calc((100vw - 52px) / 6), 62px); font-size: calc(var(--box) * .62); line-height: calc(var(--box) * 1.3); height: calc(var(--box) * 1.3); }
:root .room-line .share-btn { flex: 1 1 40%; width: auto; min-height: 52px; gap: 8px; border-radius: 26px; }
:root .room-line .share-btn::after { content: attr(aria-label); font: 600 16px var(--ui-sans, system-ui); color: var(--ui-accent); }
:root .room-line .share-btn.done::after { content: ""; }
:root .room-line::before { content: ""; flex: 0 0 100%; order: 0; height: 0; } /* the code is a line of its own */
:root .room-line .share-btn { order: 1; }

/* ===== Create / Join screen of the card games, after the Backgammon app: name, Create card, "or join a friend's room", code boxes, Join ===== */
:root #onlineBox #onlineChoice > #nameInput { order: -3; width: 100%; box-sizing: border-box; min-height: 52px; padding: 0 16px; border-radius: var(--ui-r-m); font-size: 17px; text-align: start; }
:root #onlineBox #onlineChoice > #createRoomBtn { order: -2; display: flex; align-items: center; justify-content: flex-start; gap: 16px; padding: 0 20px; text-align: start; }
:root #onlineBox #onlineChoice > #createRoomBtn::before { content: "+"; flex: none; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; background: var(--ui-on); color: var(--ui-primary); font: 400 34px/1 var(--ui-sans, system-ui); }
:root #onlineChoice > .ui-or { order: -1; width: 100%; display: flex; align-items: center; gap: 14px; margin: 10px 0 2px; color: var(--ui-dim); font-size: 16px; }
:root #onlineChoice > .ui-or::before, :root #onlineChoice > .ui-or::after { content: ""; flex: 1; height: 1px; background: color-mix(in srgb, var(--ui-dim) 45%, transparent); }
:root #onlineBox #onlineChoice > #roomCodeInput { --box: clamp(44px, calc((100vw - 52px) / 6), 62px); font-size: calc(var(--box) * .62); line-height: calc(var(--box) * 1.3); height: calc(var(--box) * 1.3); align-self: center; box-sizing: border-box; width: calc(var(--box) * 6 + 3px); }
:root body[data-step="setup"]:not(.playing) #onlineBox { margin-bottom: 14px; }

/* the arcade games' room box, same look: Create card, divider, code boxes, Join (the Join Room button doubles as the submit, see online-room.js) */
:root body[data-flow="3"] #onlineBox:has(#onlineChoiceRow:not([hidden]):not([style*="none"])) .online-body { display: flex; flex-direction: column; gap: 12px; }
:root body[data-flow="3"] #onlineBox:has(#onlineChoiceRow:not([hidden]):not([style*="none"])) :is(#onlineChoiceRow, #joinRoomForm) { display: contents !important; }
:root body[data-flow="3"] #onlineBox:has(#onlineChoiceRow:not([hidden]):not([style*="none"])) #joinRoomSubmitBtn { display: none; }
:root body[data-flow="3"] #onlineBox #onlineChoiceRow ~ .ui-or, :root body[data-flow="3"] #onlineBox .online-body > .ui-or { display: none; }
:root body[data-flow="3"] #onlineBox:has(#onlineChoiceRow:not([hidden]):not([style*="none"])) .online-body > .ui-or { display: flex; order: -1; width: 100%; align-items: center; gap: 14px; margin: 10px 0 2px; color: var(--ui-dim); font-size: 16px; }
:root body[data-flow="3"] #onlineBox .online-body > .ui-or::before, :root body[data-flow="3"] #onlineBox .online-body > .ui-or::after { content: ""; flex: 1; height: 1px; background: color-mix(in srgb, var(--ui-dim) 45%, transparent); }
:root body[data-flow="3"] #onlineBox #createRoomBtn { order: -2; display: flex; align-items: center; justify-content: flex-start; gap: 16px; padding: 0 20px; text-align: start; }
:root body[data-flow="3"] #onlineBox #createRoomBtn::before { content: "+"; flex: none; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; background: var(--ui-on); color: var(--ui-primary); font: 400 34px/1 var(--ui-sans, system-ui); }
:root body[data-flow="3"] #onlineBox #onlineChoiceRow ~ * #roomCodeInput, :root body[data-flow="3"] #onlineBox .online-body #roomCodeInput { --box: clamp(44px, calc((100vw - 52px) / 6), 62px); font-size: calc(var(--box) * .62); line-height: calc(var(--box) * 1.3); height: calc(var(--box) * 1.3); align-self: center; box-sizing: border-box; width: calc(var(--box) * 6 + 3px); }
:root body[data-flow="3"] #onlineBox:has(#onlineChoiceRow:not([hidden]):not([style*="none"])) #roomCodeInput { order: 0; }
:root body[data-flow="3"] #onlineBox:has(#onlineChoiceRow:not([hidden]):not([style*="none"])) #joinRoomBtn { order: 1; }
:root body[data-flow="3"] #onlineBox:has(#onlineChoiceRow:not([hidden]):not([style*="none"])) #onlineStatus:empty { display: none; }
:root body[data-flow="3"] #onlineBox:has(#onlineChoiceRow:not([hidden]):not([style*="none"])) :is(.room-line, .share-note:empty) { display: none; }

/* ===== COMPONENTS, after the mockups (docs/2026-11-redesign/artifacts/v1-ui-kit-mockup.html). Defined once: games/ui/ui.js (UI.stepper, UI.segmented, UI.group, UI.continueRow). ===== */
:root .ui-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); border: 0; opacity: 0; }
/* a section: small heading, then one rounded group with hairlines between its rows */
:root .ui-group-wrap { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 8px; }
:root .ui-group-wrap > .ui-label { margin: 0 4px; }
:root .ui-group-wrap:not(:has(.ui-stepped:not([hidden]):not([style*="none"]))) { display: none; }
:root .ui-group { background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-r-m); overflow: hidden; }
/* stepper row: title and sub-line, then - value + */
:root .setup-grid .ui-group > label.ui-stepped { display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 10px 14px; border: 0; border-radius: 0; background: none; }
:root .setup-grid .ui-group > label.ui-stepped + label.ui-stepped { border-top: 1px solid var(--ui-line); }
:root .ui-rb { flex: 1; min-width: 0; text-align: start; }
:root .ui-rt { font-size: 17px; font-weight: 600; }
:root .ui-rs { font-size: 14px; font-weight: 400; color: var(--ui-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
:root .ui-step { flex: none; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: var(--ui-chip); color: var(--ui-accent); font: 400 26px/1 var(--ui-sans, system-ui); display: grid; place-items: center; cursor: pointer; }
:root .ui-step:disabled { opacity: .35; cursor: default; }
:root .ui-step:focus-visible, :root .ui-seg button:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }
:root .ui-val { min-width: 28px; text-align: center; font-size: 20px; font-weight: 700; color: var(--ui-ink); }
/* segmented control under a small heading */
:root .setup-grid label.ui-segged, :root .setup-opts label.ui-segged { display: flex; flex-direction: column; align-items: stretch; gap: 8px; min-height: 0; padding: 0; border: 0; background: none; font-size: 13px; }
:root .setup-grid label.ui-segged > .ui-label, :root .setup-opts label.ui-segged > .ui-label { margin: 0 4px; }
:root body[data-flow="3"] .setup-grid { gap: 16px; }
/* Continue Game: one outlined row under the mode cards; the whole row resumes, Discard stays small */
:root .resume-box.ui-continue { display: flex; flex-wrap: nowrap; align-items: center; justify-content: flex-start; gap: 12px; min-height: 56px; margin: 12px 0 0; padding: 8px 16px; border-radius: var(--ui-r-l); background: none; border: 1px solid var(--ui-line); box-shadow: none; cursor: pointer; }
:root .resume-box.ui-continue:is([hidden], .hidden) { display: none; }
:root .ui-continue > div:first-child { flex: 1; min-width: 0; }
:root .ui-continue b { font-size: 17px; font-weight: 600; }
:root .ui-continue .resume-info { font-size: 13px; }
:root .ui-continue .actions { margin: 0; flex: none; }
:root .resume-box.ui-continue { position: relative; }
:root .ui-continue .btn.primary { position: absolute; inset: 0; width: auto; height: auto; min-height: 0; margin: 0; padding: 0; border: 0; border-radius: inherit; opacity: 0; z-index: 1; font-size: 0; cursor: pointer; }   /* the row is one big button (keyboard and screen readers reach it); Discard sits above */
:root .ui-continue .btn:not(.primary) { position: relative; z-index: 2; }
:root .ui-continue .btn:not(.primary) { min-height: 32px; padding: 0 12px; font-size: 13px; }
:root .ui-continue .ui-chev-svg { flex: none; color: var(--ui-dim); }
/* How to play: a quiet text link */
:root .ui-how-row { width: auto; margin: 6px auto 0; min-height: 44px; padding: 0 16px; border: 0; justify-content: center; font-size: 16px; }
:root .ui-how-row .ui-chev-svg { display: none; }
/* the first screen is short: no heading over the cards, a two-line pitch */
:root body[data-flow="3"][data-step="mode"]:not(.playing) #setup > .ui-label:not(.ui-label-setup), :root body[data-flow="3"][data-stage="start"] .ui-sec[data-sec="mode"] > .ui-label { display: none; }
:root body[data-flow="3"]:not(.playing) :is(.pitch, .hero-pitch) { display: block; overflow: visible; font-size: 14px; line-height: 1.4; }   /* the design shows the whole line (it was cut to two) */

:root .ui-continue .resume-info { line-height: 1.3; }
:root .ui-continue .btn:not(.primary) { height: 32px; min-height: 32px; line-height: 1; border-radius: 16px; }
:root .setup-grid .ui-seg button, :root .setup-opts .ui-seg button { padding: 6px; line-height: 1.2; }   /* long words ("Everyone for themselves") wrap inside the segment */
:root #uiScoreSheet #sheet { overflow-x: auto; margin: 4px 0 12px; }

/* ===== board games with a side panel, after the mockups: the board, one status line, and a tray pinned at the thumb (Undo, then the main button).
   Backgammon has its own rules above (body.bgp); every other game with .layout > .side-panel opts in with body.ui-table. ===== */
@media (max-width: 700px) {
  :root body.ui-table[data-stage="play"] .wrap { padding: 4px 8px calc(96px + env(safe-area-inset-bottom)); }
  :root body.ui-table .layout { flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 12px; }
  :root body.ui-table .side-panel { display: contents; }
  :root body.ui-table .board-frame { order: 0; width: 100%; box-sizing: border-box; }
  :root body.ui-table #turnBadge { order: 1; align-self: center; padding: 4px 12px; border: 0; border-radius: 999px; background: none; box-shadow: none; color: var(--ui-ink); font-size: 16px; font-weight: 600; letter-spacing: 0; text-transform: none; }
  :root body.ui-table #msgBox { order: 2; min-height: 0; padding: 0 8px; border: 0; background: none; box-shadow: none; text-align: center; font-size: 14px; color: var(--ui-dim); }
  :root body.ui-table .side-panel > .hint { display: none; }   /* the rules are one tap away in the menu */
  :root body.ui-table .side-panel > .btn-row { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; display: flex; flex-wrap: nowrap; gap: 12px; padding: 8px var(--ui-gutter) calc(8px + env(safe-area-inset-bottom)); background: var(--ui-bg); border-top: 1px solid var(--ui-chip); }
  :root body.ui-table:not([data-stage="play"]) .side-panel > .btn-row { display: none; }
  :root body.ui-table .side-panel > .btn-row .btn { min-height: 52px; border-radius: 26px; font-size: 17px; letter-spacing: 0; }
  :root body.ui-table #undoBtn { flex: 0 0 auto; order: 1; padding-inline: 22px; background: var(--ui-surface); color: var(--ui-ink); box-shadow: inset 0 0 0 1px var(--ui-line); }
  :root body.ui-table #newGameBtn { flex: 1; order: 2; background: none; color: var(--ui-ink); box-shadow: inset 0 0 0 1px var(--ui-line); }
}

/* ===== card tables on a phone, fit one screen (the mockups): small piles, single-line 44px buttons, thin strips over the hand ===== */
@media (max-width: 760px) {
  :root .center { gap: 12px; }
  :root .center .card, :root .center .discard-stack { width: 40px; height: 56px; }
  :root .deck-area { margin-bottom: 4px; }
  :root .deck-area:has(#fuTag:not(.hidden)) { margin-bottom: 46px; }   /* room for the "Face-up card" tag under it */
  :root .pile { font-size: 11px; gap: 2px; }
  :root .lanes { gap: 4px; }
  :root .lane { min-height: 40px; }
  :root .hand-panel .actions { flex-wrap: nowrap; gap: 6px; }
  :root .hand-panel .actions .btn { min-height: 44px; padding: 4px 8px; font-size: 14px; line-height: 1.15; white-space: normal; overflow-wrap: break-word; }
  :root .hand-panel .actions .btn#faceUpBtn { flex: 1 1 100%; }
  :root .hand-panel .actions:has(#faceUpBtn:not(.hidden)) { flex-wrap: wrap; }
  :root .ui-lastmove { min-height: 44px; margin-bottom: 6px; padding: 4px 12px; }
  :root .staged { margin-bottom: 2px; font-size: 12px; }
}
:root #uiHistoryBack { display: none; }   /* the x in the head closes the history sheet, as in the mockup */

/* ===== round result sheet, after the mockup: small label, your change in big numbers, a tile per player, one action, then "Score sheet" ===== */
:root #roundDialog[open] { display: flex; flex-direction: column; gap: 12px; text-align: center; }
:root #roundDialog #roundBody { display: contents; }
:root #roundDialog h2 { order: 0; margin: 0; font: 600 13px var(--ui-sans, system-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--ui-dim); }
:root #roundDialog .rs-big { order: 1; font: 700 56px/1.05 var(--ui-serif); color: var(--ui-accent); }
:root #roundDialog .rs-big.neg { color: var(--ui-ink); }
:root #roundDialog .rs-tiles { order: 2; display: flex; gap: 8px; }
:root #roundDialog .rs-tile { flex: 1; min-width: 0; padding: 8px 6px; border-radius: 10px; background: var(--ui-surface); border: 1px solid var(--ui-line); }
:root #roundDialog .rs-tile.on { border: 2px solid var(--ui-accent); padding: 7px 5px; }
:root #roundDialog .rs-tile b { display: block; font-size: 20px; line-height: 1.1; }
:root #roundDialog .rs-tile span { display: block; font-size: 12px; color: var(--ui-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:root #roundDialog .log { order: 3; }
:root #roundDialog > .actions { order: 4; margin: 0; }
:root #roundDialog > .actions .btn { width: 100%; min-height: 52px; border-radius: 26px; font-size: 17px; }
:root #roundDialog .rs-more { order: 5; align-self: center; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px; border: 0; background: none; color: var(--ui-accent); font: inherit; font-size: 16px; font-weight: 600; cursor: pointer; }
:root #roundDialog .rs-more[aria-expanded="true"] .rs-chev { transform: rotate(180deg); }
:root #roundDialog .rs-table { order: 6; text-align: start; overflow-x: auto; }
:root #roundDialog .rs-table[hidden] { display: none; }
:root #roundDialog > p, :root #roundDialog #roundBody > p { order: 3; }

/* ===== poker tables on a phone (Hold'em, Omaha, Five-card draw), after the mockups: the table is the screen; bots are a row of small tiles, yours below; the actions are pinned at the thumb ===== */
:root body.playing .ui-hero-head, :root body[data-stage="play"] .ui-hero-head { display: none; }   /* the top bar already names the game */
@media (max-width: 480px) {
  :root body.playing:has(#controlsArea) .wrap { padding-bottom: calc(150px + env(safe-area-inset-bottom)); }
  :root #seats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 6px; }
  :root #seats .seat { padding: 6px 8px; }
  :root #seats .seat:not(.me) { order: 1; }
  :root #seats .seat.me { grid-column: 1 / -1; order: 2; }
  :root #seats .seat:not(.me) .seat-head { flex-direction: column; align-items: flex-start; gap: 0; margin-bottom: 2px; font-size: 13px; }
  :root #seats .seat:not(.me) .seat-state { min-height: 0; margin: 0 0 2px; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  :root #seats .seat:not(.me) .cards { display: flex; justify-content: flex-start; }
  :root #seats .seat:not(.me) .pkc { width: 26px; }
  :root #seats .seat:not(.me) .pkc + .pkc { margin-left: -12px; }
  :root body.playing #keysHint { display: none; }
  :root body.playing #controlsArea { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; margin: 0; padding: 8px var(--ui-gutter) calc(8px + env(safe-area-inset-bottom)); background: var(--ui-bg); border-top: 1px solid var(--ui-chip); }
}

/* ===== Blackjack on a phone: the table fits one screen (the mockup): thin HUD, tight dealer and hands ===== */
@media (max-width: 480px) {
  :root .table-top { margin-bottom: 0; }
  :root .table .hud { font-size: 12px; }
  :root .table { padding: 8px 10px; }
  :root .dealer { margin-bottom: 2px; }
  :root .dealer .bjc { width: 54px; }
  :root .total { margin-top: 2px; }
  :root #seats .seat.me .seat-state { min-height: 0; }
  :root #seats .seat.me .hand { padding: 2px 0; }
  :root #seats .seat .hand-info { margin-top: 2px; }
}
:root .ui-topbar #langBar { margin-left: auto; }   /* the language / help buttons stay at the right edge even when the title is hidden (start screens) */

/* board games whose side panel has just a New Game button and a stats row (Memory Cards): stats over the board, the button pinned at the thumb */
@media (max-width: 700px) {
  :root body.ui-table .side-panel > .hud { order: -1; align-self: stretch; margin: 0; padding: 0 4px; justify-content: space-between; font-size: 14px; background: none; box-shadow: none; }
  :root body.ui-table .side-panel > #newGameBtn { position: fixed; z-index: 20; left: var(--ui-gutter); right: var(--ui-gutter); bottom: calc(8px + env(safe-area-inset-bottom)); min-height: 52px; border-radius: 26px; font-size: 17px; background: var(--ui-bg); color: var(--ui-ink); box-shadow: 0 0 0 8px var(--ui-bg), inset 0 0 0 1px var(--ui-line); }
  :root body.ui-table:not([data-stage="play"]) .side-panel > #newGameBtn { display: none; }
}
@media (max-width: 700px) {
  /* the board leaves room for the status line and the tray: narrower on a short screen, never under 240px */
  :root body.ui-table:has(#movesVal) .board-frame { width: min(100%, max(240px, calc((100svh - 280px) * .78))); align-self: center; }
}
:root body[data-flow="3"] .setup-opts { display: flex; flex-direction: column; gap: 16px; margin-top: 12px; }
:root .setup-opts label.pick.ui-segged { display: flex; flex-direction: column; align-items: stretch; gap: 8px; min-height: 0; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; }
:root .ui-sec > .setup-opts:not(:has(> label:not(.ui-segged))) { background: none; border: 0; padding: 0; }   /* only segmented controls inside: no box around them */
:root .setup-opts label.ui-segged > .ui-label { text-align: start; }

/* hand actions on a phone: the four small icon buttons keep their size (they were squashed when a card was selected); Discard / Lay down share the rest */
@media (max-width: 760px) {
  :root .hand-panel .actions .btn:is(#hintBtn, #sortBtn, #moveLeftBtn, #moveRightBtn) { flex: 0 0 44px; width: 44px; min-width: 44px; padding: 0; }
  :root .hand-panel:has(#hand .card.sel) .actions .btn:not(#hintBtn, #sortBtn, #moveLeftBtn, #moveRightBtn, #faceUpBtn) { flex: 1 1 0; }
  /* a lane's name keeps its room: the "Your turn" tag drops under it instead of squeezing it */
  :root .lane .nm { flex-wrap: wrap; row-gap: 2px; }
  :root .lane .nm-t { overflow: visible; text-overflow: clip; }
}
@media (max-width: 760px) {
  :root .hand-panel .actions .btn:is(#hintBtn, #sortBtn, #moveLeftBtn, #moveRightBtn) { flex-basis: 40px; width: 40px; min-width: 40px; }
  :root .hand-panel .actions .btn { overflow-wrap: normal; word-break: keep-all; hyphens: none; padding-inline: 6px; }
}
:root .lane .lh > .turn-tag { display: inline-block; margin-top: 3px; }   /* "Your turn" sits under the card count and the open check */

/* top bar buttons (language, help, menu): smaller circles, the tap area stays 44px */
:root .ui-topbar :is(.ui-helpbtn, .ui-menubtn, .lang-btn) { position: relative; width: 44px; height: 44px; min-height: 44px; }
:root .ui-topbar :is(.ui-helpbtn, .ui-menubtn, .lang-btn)::after { content: ""; position: absolute; inset: -4px; }
:root .ui-topbar :is(.ui-helpbtn, .ui-menubtn) svg { width: 18px; height: 18px; }
:root .ui-topbar .lang-btn::before { width: 18px; height: 18px; }

/* hand actions on a phone: two rows. The main buttons (Discard / Lay down, Capture / Put down, Play card ...) first, large; then the small icon buttons and the face-up (hunt) button */
@media (max-width: 760px) {
  :root .hand-panel .actions { flex-wrap: wrap; row-gap: 6px; }
  :root .hand-panel .actions .btn:not(#hintBtn, #sortBtn, #moveLeftBtn, #moveRightBtn, #faceUpBtn) { order: 1; flex: 1 1 calc(50% - 3px); min-height: 48px; font-size: 16px; }
  :root .hand-panel .actions .btn:is(#hintBtn, #sortBtn, #moveLeftBtn, #moveRightBtn) { order: 2; }
  :root .hand-panel .actions .btn#faceUpBtn { order: 3; flex: 1 1 0; min-width: 0; }
  :root .hand-panel:has(#hand .card.sel) .actions .btn:not(#hintBtn, #sortBtn, #moveLeftBtn, #moveRightBtn, #faceUpBtn) { order: 1; flex: 1 1 calc(50% - 3px); }
}
@media (max-width: 760px) {
  :root .hand-panel:has(#hand .card.sel) .actions .btn:is(#hintBtn, #sortBtn, #moveLeftBtn, #moveRightBtn), :root .hand-panel .actions .btn:is(#hintBtn, #sortBtn, #moveLeftBtn, #moveRightBtn) { flex: 0 0 44px; width: 44px; min-width: 44px; min-height: 44px; }
  :root .hand-panel .actions .btn#faceUpBtn { min-height: 44px; font-size: 14px; }
}

/* ===== room code: six separate rounded boxes (UI.codeBoxes, after the mockup). The real input / text stays, hidden, one string. ===== */
:root .ui-code-src, :root #roomCodeInput.ui-code-src, :root #roomCodeDisplay.ui-code-src { position: absolute !important; width: 1px !important; height: 1px !important; min-height: 0 !important; margin: -1px !important; padding: 0 !important; overflow: hidden !important; clip: rect(0 0 0 0) !important; border: 0 !important; opacity: 0 !important; background: none !important; font-size: 16px; }   /* 16px: iOS does not zoom into it */
:root .ui-codeboxes { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; width: 100%; max-width: 420px; margin-inline: auto; box-sizing: border-box; cursor: text; }
:root .ui-codeboxes > span { aspect-ratio: 1 / 1.1; display: grid; place-items: center; box-sizing: border-box; border-radius: 12px; border: 1px solid var(--ui-line); background: var(--ui-surface); color: var(--ui-ink); font: 600 clamp(22px, 7vw, 28px)/1 ui-monospace, Menlo, Consolas, monospace; }
:root .ui-codeboxes > span.cur { border: 2px solid var(--ui-accent); }
:root .ui-codeboxes.big { cursor: default; }
:root .ui-codeboxes.big > span { border: 0; background: var(--ui-primary); color: var(--ui-on); font-size: clamp(24px, 8vw, 32px); }
:root .room-line > .ui-codeboxes { order: -1; flex: 1 0 100%; }
:root #onlineChoice > .ui-codeboxes { align-self: stretch; }

/* dealing: the Skip button and the status text stay above the flying cards (the cards still fly over the table and the hand) */
:root .flycard { z-index: 11; }
:root #skipDealRow { position: relative; z-index: 12; }
/* the status is above the flying cards only while dealing; the rest of the time the sticky hand panel (z-index 10) must cover it, or on a short phone screen the text is drawn over the hand and the buttons */
:root #status { position: relative; }
:root #game:has(#skipDealRow:not(.hidden)) #status { z-index: 12; }

/* HUD over a board on a phone (after the mockups): small caps label over a number, one on each side (Connect Four: Moves / You play; Checkers: You / Computer left) */
:root .ui-hud { display: none; }
@media (max-width: 700px) {
  :root body.ui-table .ui-hud { display: flex; width: 100%; box-sizing: border-box; justify-content: space-between; align-items: flex-end; gap: 12px; padding: 0 4px; text-align: start; }
  :root body.ui-table .ui-hud > div { display: flex; flex-direction: column; min-width: 0; }
  :root body.ui-table .ui-hud > .right { align-items: flex-end; text-align: end; }
  :root body.ui-table .ui-hud .k { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ui-dim); }
  :root body.ui-table .ui-hud .v { font-size: 20px; font-weight: 700; color: var(--ui-ink); line-height: 1.15; }
  :root body.ui-table .ui-hud .v.big { font: 700 34px/1.05 var(--ui-serif); color: var(--ui-accent); }
  :root body.ui-table .ui-hud[hidden], :root body.ui-table .ui-hud [hidden] { display: none; }
  /* Undo as a round icon button */
  :root body.ui-table #undoBtn { width: 52px; padding: 0; font-size: 0; display: grid; place-items: center; }
  :root body.ui-table #undoBtn::before { content: ""; width: 22px; height: 22px; background: currentColor; -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='M9 14L4 9l5-5'/><path d='M4 9h10a6 6 0 0 1 0 12h-3'/></svg>") center / contain no-repeat; mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='M9 14L4 9l5-5'/><path d='M4 9h10a6 6 0 0 1 0 12h-3'/></svg>") center / contain no-repeat; }
}

/* poker, after the mockup: the pot and street above the community cards ("FLOP - POT 180"), the label under them; the quick-bet row above Fold / Call / Raise */
@media (max-width: 480px) {
  :root #board:has(> .zone-label) { display: flex; flex-direction: column; align-items: center; }
  :root #board > .pot { order: -1; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ui-dim); }
  :root #board > .pot b { font-size: 18px; letter-spacing: 0; color: #f2c14e; }
  :root #board > .pot small { margin: 0 0 0 8px; font-size: 12px; }
  :root #board > .zone-label { order: 3; font-size: 11px; opacity: .8; }
  :root body.playing #controlsArea { display: flex; flex-direction: column; gap: 6px; }
  :root body.playing #controlsArea > #sizePanel { order: -1; }
}
@media (max-width: 760px) {
  :root .center .card, :root .center .discard-stack { width: 48px; height: 68px; }   /* the deck and discard piles: close to the mockup's, without costing the page its height */
  :root .deck-area { margin-bottom: 16px; }   /* the tilted face-up card must not cover the Deck label */
}

/* How to play on the start card of the games without mode cards (Fruit Slice, Snake, Tetris, Sokoban, Solitaire, Tower Siege), as in the mockup: a quiet text link under Play; the "?" in the bar gives way while that card is open */
:root .field > .overlay .ui-overlay-how { display: inline-flex !important; align-self: center; justify-content: center; min-height: 44px; padding: 0 16px; background: none; border: 0; color: var(--ui-accent); font: inherit; font-size: 16px; font-weight: 600; }
:root body:has(.field > .overlay:not([hidden]) .ui-overlay-how) .ui-topbar .ui-helpbtn { display: none; }

/* Blackjack: the last-move strip sits over the buttons; Hand N of M takes the bar's middle while playing */
:root .ui-bar-mid { display: none; }
:root body.playing .ui-topbar .ui-bar-mid { display: block; flex: 1; min-width: 0; text-align: center; font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:root body.playing:has(.ui-bar-mid) .ui-topbar h1 { display: none; }
@media (max-width: 480px) { :root body.playing .table-top .hud > span:first-child { display: none; } }

/* hero picture on the start screen (UI.heroArt): the design's drawings, coloured by the kit's tokens; shown on the first screen only */
:root .ui-hero-art { --m-line: var(--ui-line); --m-ink: var(--ui-ink); --m-accent: var(--ui-accent); --m-bg: var(--ui-bg); --m-chip: var(--ui-chip); --m-dim: var(--ui-dim); --m-surface: var(--ui-surface); --m-field: var(--ui-surface); --ga: var(--ui-accent); --frame: #2a1b10; --felt: #1f3b2c; --pa: #7a2231; --pb: #e9dcbc;
  height: 112px; margin: 4px var(--ui-gutter) 12px; border-radius: 16px; overflow: hidden; display: flex; align-items: center; justify-content: center; background: var(--ui-surface); border: 1px solid var(--ui-line); }
:root .ui-hero-art > svg { display: block; width: 100%; height: 112px; }
:root .ui-hero-art > div { max-height: 112px; }
:root body[data-stage="setup"] .ui-hero-art, :root body[data-stage="play"] .ui-hero-art, :root body.playing .ui-hero-art, :root body[data-step="setup"] .ui-hero-art { display: none; }

/* ===== start page of the games without mode cards (design: hero, name, line, best score, Continue Game, Play, How to play) =====
   Applies while the first card is up (data-start) and the page has the picture (Snake, Tetris, Fruit Slice). */
:root body:has(.ui-hero-art):has(.field > .overlay[data-start="1"]:not([hidden])) :is(.field > canvas, .field > .board-frame, .controls > :is(#undoBtn, #resetBtn, #levelsBtn), #raceStrip, .controls > #restart, .ui-dpad, .msg, .ui-topbar #pauseBtn, #pauseBtn, .ui-hud > div:first-child, .field > .overlay > h2) { display: none !important; }
:root body:has(.ui-hero-art):has(.field > .overlay):not(:has(#modeBar)):not(:has(.field > .overlay[data-start="1"]:not([hidden]))) :is(.ui-hero-art, .ui-hero-head) { display: none; }   /* the one-card games: the picture and name only on their start card (the mode-card games, with or without an overlay for pause and game over, keep them on the start screen) */
:root body:has(.ui-hero-art):not([data-stage="setup"]):not([data-stage="play"]):not([data-step="setup"]):not(.playing) .ui-hero-art { display: flex; }
:root body[data-stage="setup"] .ui-hero-head, :root body[data-step="setup"]:not(.playing) .ui-hero-head { display: none; }
:root body:has(.ui-hero-art):has(.field > .overlay[data-start="1"]:not([hidden])) .field { border: 0; background: none; box-shadow: none; aspect-ratio: auto; min-height: 0; padding: 0; overflow: visible; }
:root body:has(.ui-hero-art):has(.field > .overlay[data-start="1"]:not([hidden])) .field > .overlay { position: static; inset: auto; transform: none; width: 100%; max-width: none; background: none; border: 0; box-shadow: none; padding: 0 var(--ui-gutter); gap: 10px; animation: none; backdrop-filter: none; }
:root body:has(.ui-hero-art):has(.field > .overlay[data-start="1"]:not([hidden])) .ui-hud { justify-content: center; margin: 0; }
:root body:has(.ui-hero-art):has(.field > .overlay[data-start="1"]:not([hidden])) .ui-hud > div { align-items: center; text-align: center; min-width: 120px; padding: 6px 16px; border-radius: 10px; background: var(--ui-surface); border: 1px solid var(--ui-line); }
:root body:has(.ui-hero-art):has(.field > .overlay[data-start="1"]:not([hidden])) .ui-hero-head { display: block; }
:root body:has(.ui-hero-art):has(.field > .overlay[data-start="1"]:not([hidden])) .field > .overlay::before { display: none; }
:root body:has(.ui-hero-art) :is(.rules, #rules):not(.ui-sheet *) { display: none; }   /* the rules open from How to play; the text stays in the page */
:root body:has(.ui-hero-art):has(.field > .overlay[data-start="1"]:not([hidden])) :is(.wrap > .hud, .wrap > .ui-hud:not(:has(~ .field)), .board-row > .side, .wrap > .pad, .wrap > .row) { display: none !important; }
:root body:has(.ui-hero-art):has(.field > .overlay[data-start="1"]:not([hidden])) .board-row { display: block; }
:root body:has(.ui-hero-art):has(.field > .overlay[data-start="1"]:not([hidden])) :is(.board-row, .field) { width: 100%; max-width: none; }
:root body:has(.ui-hero-art):has(.field > .overlay[data-start="1"]:not([hidden])) .field > .overlay > :is(.grip, .ui-sheet-grip, i) { display: none; }
:root .wrap:has(.ui-hero-art):has(.resume-box:not([hidden])) .field > #overlay { display: flex; }   /* with a saved game: Continue Game row and Play both show */

/* Play with a Friend stays on the start page, as the quieter pill under Play (design: the second mode card) */
:root body:has(.ui-hero-art):has(.field > .overlay[data-start="1"]:not([hidden])) .controls { display: flex; padding: 0 var(--ui-gutter); margin: 0; }
:root body:has(.ui-hero-art):has(.field > .overlay[data-start="1"]:not([hidden])) .controls > #friendBtn { flex: 1; min-height: 52px; border-radius: 26px; font-size: 17px; background: none; color: var(--ui-ink); box-shadow: inset 0 0 0 1px var(--ui-line); }

/* switch rows: title, the explanation under it, a switch on the right (UI.switchRows) */
:root .ui-sec .setup-opts label.ui-switchrow:has(> input[type="checkbox"]) { display: grid; justify-content: stretch; text-align: start; grid-template-columns: 1fr auto; column-gap: 16px; row-gap: 0; align-items: center; min-height: 64px; padding: 10px 14px; }
:root .ui-switchrow > span:first-of-type { grid-column: 1; }
:root .ui-switchrow > .ui-rs { grid-column: 1; grid-row: 2; white-space: normal; font-weight: 400; font-size: 14px; line-height: 1.3; }
:root .ui-switchrow > span:first-of-type { line-height: 1.25; }
:root .ui-sec .setup-opts .ui-switchrow > input[type="checkbox"] { grid-column: 2; grid-row: 1 / span 2; appearance: none; -webkit-appearance: none; position: relative; width: 51px; height: 31px; margin: 0; border-radius: 16px; background: var(--ui-chip); border: 1px solid var(--ui-line); cursor: pointer; transition: background .15s; }
:root .ui-sec .setup-opts .ui-switchrow > input[type="checkbox"]::after { content: ""; position: absolute; top: 2px; left: 2px; width: 25px; height: 25px; border-radius: 50%; background: var(--ui-dim); transition: transform .15s, background .15s; }
:root .ui-sec .setup-opts .ui-switchrow > input[type="checkbox"]:checked { background: var(--ui-accent); border-color: transparent; }
:root .ui-sec .setup-opts .ui-switchrow > input[type="checkbox"]:checked::after { transform: translateX(20px); background: var(--ui-bg); }
:root .ui-sec .setup-opts .ui-switchrow > input[type="checkbox"]:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { :root .ui-switchrow > input[type="checkbox"], :root .ui-sec .setup-opts .ui-switchrow > input[type="checkbox"]::after { transition: none; } }
:root body:has(.ui-hero-art):has(.field > .overlay[data-start="1"]:not([hidden])) .ui-topbar h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }   /* the big title below is the visible one; the real h1 stays for screen readers */

/* ===== a phone on its side, after the v3 mockups (docs/2026-11-redesign/artifacts/v3-screens-mockup.html): nothing scrolls ===== */
/* 844 x 390: the table or field on the left, a 208px column on the right with the message and the 44px buttons. Content stays clear of the
   notch (env(safe-area-inset-*), at least 20px) and of the home bar. Height is the scarce axis: the top bar is 44px and has no title. */
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  :root { --ls-x: max(20px, env(safe-area-inset-left)); --ls-xr: max(20px, env(safe-area-inset-right)); --ls-b: max(12px, env(safe-area-inset-bottom)); --ls-col: 208px; }
  :root:has(body:is([data-stage="play"], .playing, :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))):not(.bgp):not(:has(#landscapeControls))) { overflow: hidden; }
  :root body:is([data-stage="play"], .playing, :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))):not(.bgp):not(:has(#landscapeControls)) { height: 100svh; overflow: hidden; }
  :root body:is([data-stage="play"], .playing, :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))):not(:has(#landscapeControls)) .ui-topbar { min-height: 44px; padding: 0 var(--ls-xr) 0 var(--ls-x); gap: 8px; }
  :root body:is([data-stage="play"], .playing, :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))):not(:has(#landscapeControls)) .ui-topbar :is(h1, .ui-title) { display: none; }
  :root body:is([data-stage="play"], .playing, :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))):not(:has(#landscapeControls)) .ui-topbar > :is(#langBar, .lang-bar) { margin-left: auto; }
  :root body:is([data-stage="play"], .playing, :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))):not(:has(#landscapeControls)) .ui-topbar :is(.lang-btn, .ui-ibtn) { width: 44px; height: 44px; }
  :root body:is([data-stage="play"], .playing, :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))):not(:has(#landscapeControls)) .ui-topbar #langBar { width: 44px; height: 44px; }

  /* board games with a side panel (Checkers, Connect Four, Memory Cards, Tic-Tac-Toe): the board is as tall as the screen allows */
  :root body.ui-table[data-stage="play"]:not(.bgp) { --ls-h: calc(100svh - 44px - var(--ls-b)); }
  :root body[data-stage="play"]:not(.bgp):not(:has(#landscapeControls)):not(:has(.td-side)) { --ls-h: calc(100svh - 44px - var(--ls-b)); }
  :root body[data-stage="play"]:not(.bgp):not(:has(#landscapeControls)):not(:has(.td-side)) .wrap { max-width: none; width: 100%; height: calc(100svh - 44px); box-sizing: border-box; margin: 0; padding: 0 var(--ls-xr) var(--ls-b) var(--ls-x); }
  :root body.ui-table[data-stage="play"]:not(.bgp) .ui-play { height: 100%; }
  :root body.ui-table[data-stage="play"]:not(.bgp) .layout { height: 100%; flex-wrap: nowrap; align-items: center; justify-content: center; gap: 28px; }
  :root body.ui-table[data-stage="play"]:not(.bgp) .board-frame { flex: none; box-sizing: border-box; width: var(--ls-h); height: var(--ls-h); max-width: none; padding: 6px; display: flex; align-items: center; justify-content: center; zoom: 1 !important; }
  :root body.ui-table[data-stage="play"]:not(.bgp) .board-frame > .board { width: 100%; max-width: none; zoom: 1 !important; }
  :root body.ui-table[data-stage="play"]:not(.bgp) .side-panel { --ui-bg: inherit; --ui-surface: inherit; --ui-chip: inherit; --ui-line: inherit; --ui-ink: inherit; --ui-dim: inherit; --ui-accent: inherit; --ui-primary: inherit; --ui-on: inherit; --ui-ok: inherit; --ui-err: inherit; --text: inherit; --text-dim: inherit;
    display: flex; flex-direction: column; justify-content: center; flex: 0 0 var(--ls-col); width: var(--ls-col); box-sizing: border-box; padding: 0; gap: 8px; background: none; box-shadow: none; border: 0; text-align: start; }
  :root body.ui-table[data-stage="play"]:not(.bgp) .side-panel > .hint { display: none; }
  :root body.ui-table[data-stage="play"]:not(.bgp) #turnBadge { align-self: stretch; padding: 0; border: 0; background: none; box-shadow: none; color: var(--ui-ink); font-size: 17px; font-weight: 600; letter-spacing: 0; text-transform: none; text-align: start; display: flex; align-items: center; gap: 8px; }
  :root body.ui-table[data-stage="play"]:not(.bgp) #msgBox { min-height: 0; padding: 0; border: 0; background: none; box-shadow: none; text-align: start; font-size: 14px; line-height: 1.3; color: var(--ui-dim); }
  :root body.ui-table[data-stage="play"]:not(.bgp) .side-panel > .btn-row { position: static; display: flex; flex-direction: column; flex-wrap: nowrap; gap: 8px; padding: 0; background: none; border: 0; }
  :root body.ui-table[data-stage="play"]:not(.bgp) .side-panel .btn { width: 100%; min-height: 44px; border-radius: 22px; font-size: 16px; letter-spacing: 0; padding-inline: 16px; }
  :root body.ui-table[data-stage="play"]:not(.bgp) #newGameBtn { position: static; width: 100%; order: 3; background: var(--ui-primary); color: var(--ui-on); box-shadow: none; }

  /* Connect Four: seven columns of six; the cell size follows the height */
  :root body.ui-table[data-stage="play"] .board-frame:has(.column) { width: auto; aspect-ratio: 7 / 6.6; --cs: calc((var(--ls-h) - 62px) / 6); }
  :root body.ui-table[data-stage="play"] .board:has(> .column) { width: auto; gap: 4px; padding-top: 12px; }
  :root body.ui-table[data-stage="play"] .column { gap: 4px; padding: 2px; }
  :root body.ui-table[data-stage="play"] .column .cell { width: var(--cs); height: var(--cs); }
  :root body.ui-table[data-stage="play"] .column .disc { width: 84%; height: 84%; }
  /* Memory Cards: the grid fills the square */
  :root body.ui-table[data-stage="play"] .board:has(> .card) { height: 100%; grid-auto-rows: 1fr; gap: 6px; }
  :root body.ui-table[data-stage="play"] .board > .card { aspect-ratio: auto; min-width: 0; height: 100%; }
  /* Tic-Tac-Toe: score on top of the board, the turn and the buttons in the column */
  :root body[data-stage="play"] .ui-play:has(> #turn):has(> #board) { height: 100%; display: grid; grid-template-columns: minmax(0, 1fr) var(--ls-col); grid-template-rows: auto auto minmax(0, 1fr) auto; column-gap: 28px; align-items: center; }
  :root body[data-stage="play"] .ui-play:has(> #turn) > .hud { grid-column: 1; grid-row: 1; justify-self: stretch; }
  :root body[data-stage="play"] .ui-play:has(> #turn) > #board { grid-column: 1; grid-row: 2 / span 3; width: min(100%, calc(var(--ls-h) - 36px)); height: auto; aspect-ratio: 1; max-width: none; justify-self: center; align-self: start; box-sizing: border-box; }
  :root body[data-stage="play"] .ui-play:has(> #turn) > #turn { grid-column: 2; grid-row: 2; align-self: start; justify-content: flex-start; margin: 0 0 4px; font-size: 17px; font-weight: 600; }
  :root body[data-stage="play"] .ui-play:has(> #turn) > #msg { grid-column: 2; grid-row: 3; align-self: start; margin: 0; text-align: start; }
  :root body[data-stage="play"] .ui-play:has(> #turn) > .controls { grid-column: 2; grid-row: 4; align-self: end; display: flex; flex-direction: column; gap: 8px; margin-bottom: 0; }

  /* canvas and grid games (Snake, Tetris, Fruit Slice, Sky Ace, Pong, Whack-a-Mole, Sokoban ...): score over the field on the left; the message,
     the pad and the buttons in the column on the right */
  :root body:is([data-stage="play"], :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))):not(.bgp):not(:has(#landscapeControls)) .wrap { max-width: none; width: 100%; height: calc(100svh - 44px); box-sizing: border-box; margin: 0; padding: 0 var(--ls-xr) var(--ls-b) var(--ls-x); }
  :root body:is([data-stage="play"], :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))):not(.bgp):not(.ui-table):not(:has(#landscapeControls)) :is(.wrap:not(:has(> .ui-play)), .ui-play):has(> :is(.field, .board-row)) { max-width: none; display: grid; grid-template-columns: minmax(0, 1fr) var(--ls-col); grid-template-rows: auto minmax(0, 1fr) auto auto minmax(0, 1fr); column-gap: 28px; align-items: stretch; }
  :root body:is([data-stage="play"], :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))) :is(.wrap:not(:has(> .ui-play)), .ui-play):has(> :is(.field, .board-row)) > :is(.pitch, .resume-box, .hint, .keys, .ui-hero-art, .ui-hero-head, #raceStrip:empty, .rules) { display: none; }
  :root body:is([data-stage="play"], :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))) :is(.wrap:not(:has(> .ui-play)), .ui-play):has(> :is(.field, .board-row)) > :is(.hud, .scoreboard, .ui-hud) { grid-column: 1; grid-row: 1; margin: 0; padding: 0 2px 4px; gap: 18px; justify-content: flex-start; align-items: baseline; }
  :root body:is([data-stage="play"], :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))) :is(.wrap:not(:has(> .ui-play)), .ui-play):has(> :is(.field, .board-row)) > :is(.field, .board-row) { grid-column: 1; grid-row: 2 / span 4; min-height: 0; min-width: 0; height: 100%; margin: 0; display: flex; justify-content: center; align-items: flex-start; }
  :root body:is([data-stage="play"], :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))) :is(.wrap:not(:has(> .ui-play)), .ui-play):has(> :is(.field, .board-row)) > .field > canvas { height: 100%; width: auto; max-width: 100%; max-height: 100%; margin: 0; }
  :root body:is([data-stage="play"], :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))) :is(.wrap:not(:has(> .ui-play)), .ui-play):has(> :is(.field, .board-row)) > .msg { grid-column: 2; grid-row: 2; align-self: end; margin: 0 0 6px; text-align: center; font-size: 14px; line-height: 1.3; }
  :root body:is([data-stage="play"], :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))) :is(.wrap:not(:has(> .ui-play)), .ui-play):has(> :is(.field, .board-row)) > .pad { grid-column: 2; grid-row: 3; margin: 0 0 8px; justify-self: center; }
  :root body:is([data-stage="play"], :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))) :is(.wrap:not(:has(> .ui-play)), .ui-play):has(> :is(.field, .board-row)) > .controls { grid-column: 2; grid-row: 4; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; justify-content: stretch; }
  :root body:is([data-stage="play"], :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))) :is(.wrap:not(:has(> .ui-play)), .ui-play):has(> :is(.field, .board-row)) > .controls .btn { flex: 1 1 calc(50% - 3px); min-width: 0; min-height: 44px; border-radius: 22px; font-size: 15px; padding-inline: 10px; }
  :root body:is([data-stage="play"], :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))) :is(.wrap:not(:has(> .ui-play)), .ui-play):has(> :is(.field, .board-row)) > .controls .btn:last-child:nth-child(odd) { flex-basis: 100%; }

  :root body:is([data-stage="play"], :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))) :is(.wrap:not(:has(> .ui-play)), .ui-play):has(> :is(.field, .board-row)) > .ui-hud { display: flex; max-width: none; width: auto; justify-content: flex-start; gap: 24px; align-items: baseline; }
  :root body:is([data-stage="play"], :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))) :is(.wrap:not(:has(> .ui-play)), .ui-play):has(> :is(.field, .board-row)) > .ui-hud > div { display: flex; gap: 8px; align-items: baseline; text-align: start; }
  :root body:is([data-stage="play"], :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))) :is(.wrap:not(:has(> .ui-play)), .ui-play):has(> :is(.field, .board-row)) > .ui-hud .k { display: inline; font-size: 12px; }
  :root body:is([data-stage="play"], :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))) :is(.wrap:not(:has(> .ui-play)), .ui-play):has(> :is(.field, .board-row)) > .ui-hud .v, :root body:is([data-stage="play"], :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))) :is(.wrap:not(:has(> .ui-play)), .ui-play):has(> :is(.field, .board-row)) > .ui-hud .v.q { display: inline; font-size: 17px; }
  :root body:is([data-stage="play"], :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))) :is(.wrap:not(:has(> .ui-play)), .ui-play):has(> :is(.field, .board-row)) > .hud { max-width: none; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; font-weight: 600; display: flex; }
  :root body:is([data-stage="play"], :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))) :is(.wrap:not(:has(> .ui-play)), .ui-play):has(> :is(.field, .board-row)) > .hud b { font-size: 15px; letter-spacing: 0; }
  /* Whack-a-Mole: the nine holes are a square as tall as the field */
  :root body:is([data-stage="play"], :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))) :is(.wrap:not(:has(> .ui-play)), .ui-play):has(> :is(.field, .board-row)) > .field:has(> .grid-frame) { max-width: none; }
  :root body:is([data-stage="play"], :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))) :is(.wrap:not(:has(> .ui-play)), .ui-play):has(> :is(.field, .board-row)) > .field > .grid-frame { height: 100%; aspect-ratio: 1; box-sizing: border-box; padding: 8px; display: flex; }
  :root body:is([data-stage="play"], :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))) :is(.wrap:not(:has(> .ui-play)), .ui-play):has(> :is(.field, .board-row)) > .field > .grid-frame > .grid { width: 100%; height: 100%; gap: 8px; grid-auto-rows: 1fr; }
  :root body:is([data-stage="play"], :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))) :is(.wrap:not(:has(> .ui-play)), .ui-play):has(> :is(.field, .board-row)) > .field > .grid-frame .cell { aspect-ratio: auto; min-height: 0; }
  /* Sokoban */
  :root body:is([data-stage="play"], :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))) :is(.wrap:not(:has(> .ui-play)), .ui-play):has(> :is(.field, .board-row)) > .field > .board-frame { height: 100%; aspect-ratio: 1; box-sizing: border-box; display: flex; align-items: center; justify-content: center; padding: 6px; width: auto; }
  :root body:is([data-stage="play"], :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))) :is(.wrap:not(:has(> .ui-play)), .ui-play):has(> :is(.field, .board-row)) > .field > .board-frame > .board { width: 100%; max-width: none; zoom: 1 !important; }
  :root body.playing, :root body[data-stage="play"] { --ls-uiplay: 1; }
  :root body[data-stage="play"] .wrap > .ui-play:has(> :is(.field, .board-row)) { height: 100%; }
  :root body:is([data-stage="play"], .playing):not(.bgp):not(:has(#landscapeControls)) .wrap { overflow: hidden; }
  :root body:not([data-stage]):not(.playing):has(.field > :is(.board-frame, canvas)):not(:has(.ui-hero-art)) .wrap, :root body:not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden]))) .wrap { overflow: hidden; }

  /* puzzles with a panel (Minesweeper, Sudoku, Hangman): the board or word on the left, the controls in the column; the dark panel gives way to the page */
  :root body[data-stage="play"]:not(.bgp) #uiPlay > .panel { --ui-bg: inherit; --ui-surface: inherit; --ui-chip: inherit; --ui-line: inherit; --ui-ink: inherit; --ui-dim: inherit; --ui-accent: inherit; --ui-primary: inherit; --ui-on: inherit; --ui-ok: inherit; --ui-err: inherit; --text: inherit; --text-dim: inherit; background: none; box-shadow: none; padding: 0; border: 0; color: var(--ui-ink); }
  /* Minesweeper */
  :root body[data-stage="play"]:not(.bgp) #uiPlay > .panel:has(> .board-frame) { height: 100%; display: grid; grid-template-columns: minmax(0, 1fr) var(--ls-col); grid-template-rows: auto auto minmax(0, 1fr); column-gap: 28px; row-gap: 8px; align-items: start; }
  :root body[data-stage="play"]:not(.bgp) #uiPlay > .panel > .board-frame { grid-column: 1; grid-row: 1 / span 3; height: var(--ls-h); aspect-ratio: 1; box-sizing: border-box; padding: 6px; justify-self: center; display: flex; align-items: center; justify-content: center; }
  :root body[data-stage="play"]:not(.bgp) #uiPlay > .panel > .board-frame > .minefield { width: 100%; height: 100%; zoom: 1 !important; }
  :root body[data-stage="play"]:not(.bgp) #uiPlay > .panel > .led-bar { grid-column: 2; grid-row: 1; margin: 0; }
  :root body[data-stage="play"]:not(.bgp) #uiPlay > .panel > .btn-row { grid-column: 2; grid-row: 2; }
  :root body[data-stage="play"]:not(.bgp) #uiPlay > .panel > #msgBox { grid-column: 2; grid-row: 3; font-size: 13px; text-align: center; }
  /* Sudoku: the board is square and as tall as the screen allows; the numbers and tools sit in the column */
  :root body[data-stage="play"]:not(.bgp) #uiPlay:has(> #hud) { height: 100%; display: grid; grid-template-columns: minmax(0, 1fr) var(--ls-col); grid-template-rows: auto minmax(0, 1fr); column-gap: 28px; }
  :root body[data-stage="play"]:not(.bgp) #uiPlay > #hud { grid-column: 1; grid-row: 1; margin: 0; padding: 0 2px 4px; max-width: none; justify-content: flex-start; gap: 18px; font-size: 12px; }
  :root body[data-stage="play"]:not(.bgp) #uiPlay:has(> #hud) > .board-frame { grid-column: 1; grid-row: 2; height: calc(var(--ls-h) - 26px); aspect-ratio: 1; width: auto; justify-self: center; box-sizing: border-box; padding: 4px; zoom: 1 !important; }
  :root body[data-stage="play"]:not(.bgp) #uiPlay:has(> #hud) > .board-frame > .grid { width: 100%; height: 100%; max-width: none; zoom: 1 !important; }
  :root body[data-stage="play"]:not(.bgp) #uiPlay:has(> #hud) > .panel { grid-column: 2; grid-row: 1 / span 2; align-self: end; display: flex; flex-direction: column; gap: 6px; }
  :root body[data-stage="play"]:not(.bgp) #uiPlay:has(> #hud) .numpad { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
  :root body[data-stage="play"]:has(#numpad) { --ls-col: 248px; }   /* five 44px keys in a row */
  :root body[data-stage="play"]:not(.bgp) #uiPlay:has(> #hud) .numpad .btn { min-height: 44px; height: 44px; padding: 0; border-radius: 12px; }
  :root body[data-stage="play"]:not(.bgp) #uiPlay:has(> #hud) .tools { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  :root body[data-stage="play"]:not(.bgp) #uiPlay:has(> #hud) .tools .btn, :root body[data-stage="play"]:not(.bgp) #uiPlay:has(> #hud) .setup .btn { min-height: 40px; height: 40px; width: 100%; border-radius: 20px; font-size: 14px; padding-inline: 6px; }
  :root body[data-stage="play"]:not(.bgp) #uiPlay:has(> #hud) .setup { display: flex; }
  /* Hangman: the gallows left; the word, the keyboard and New word to the right */
  :root body[data-stage="play"]:not(.bgp) #uiPlay > .panel:has(> #stage) { height: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: minmax(0, 1fr) auto; column-gap: 24px; align-items: center; }
  :root body[data-stage="play"]:not(.bgp) #stage { grid-column: 1 / span 2; grid-row: 1; display: grid; grid-template-columns: 150px minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); column-gap: 20px; row-gap: 8px; align-items: center; height: 100%; min-height: 0; }
  :root body[data-stage="play"]:not(.bgp) #stage > .category-badge { grid-column: 2; grid-row: 1; justify-self: center; }
  :root body[data-stage="play"]:not(.bgp) #stage > .gallows-box { grid-column: 1; grid-row: 1 / span 3; width: 150px; height: auto; align-self: center; }
  :root body[data-stage="play"]:not(.bgp) #stage > .gallows-box svg { width: 100%; height: auto; }
  :root body[data-stage="play"]:not(.bgp) #stage > .word-display { grid-column: 2; grid-row: 2; justify-self: center; margin: 0; }
  :root body[data-stage="play"]:not(.bgp) #stage > .keyboard { grid-column: 2; grid-row: 3; align-self: start; width: 100%; margin: 0; }
  :root body[data-stage="play"]:not(.bgp) #stage .kb-row { gap: 4px; margin-bottom: 4px; }
  :root body[data-stage="play"]:not(.bgp) #stage .key { width: 40px; height: 40px; min-width: 0; padding: 0; }
  :root body[data-stage="play"]:not(.bgp) #uiPlay > .panel:has(> #stage) > #msgBox { grid-column: 1; grid-row: 2; text-align: start; }
  :root body[data-stage="play"]:not(.bgp) #uiPlay > .panel:has(> #stage) > .btn-row { grid-column: 2; grid-row: 2; }

  /* poker (Hold'em, Omaha, Five-Card Draw): the felt on the left with the bots in a row over your own cards; the message and the buttons in the column */
  :root body.playing:not(.bgp) #game:has(> #table) { height: calc(100svh - 44px - var(--ls-b)); display: grid; grid-template-columns: minmax(0, 1fr) var(--ls-col); grid-template-rows: minmax(0, 1fr) auto auto; column-gap: 20px; row-gap: 6px; align-items: end; }
  :root body.playing:not(.bgp) #game:has(> #table) > #table { grid-column: 1; grid-row: 1 / span 3; align-self: stretch; min-height: 0; height: 100%; box-sizing: border-box; padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; overflow: hidden; }
  :root body.playing:not(.bgp) #game:has(> #table) > #table .table-top { margin: 0; }
  :root body.playing:not(.bgp) #game:has(> #table) > #table .hud { font-size: 12px; }
  :root body.playing:not(.bgp) #game:has(> #table) > #table .zone-label { display: none; }
  :root body.playing:not(.bgp) #game:has(> #table) > #table .board { padding: 0; }
  :root body.playing:not(.bgp) #game:has(> #table) > #table .board .pkc { width: 64px; }
  :root body.playing:not(.bgp) #game:has(> #table) > #table .pot { margin-top: 4px; font-size: 14px; }
  :root body.playing:not(.bgp) #game:has(> #table) > #table .seats { display: flex; gap: 6px; margin-top: auto; align-items: stretch; }
  :root body.playing:not(.bgp) #game:has(> #table) > #table .seat { flex: 1 1 0; min-width: 0; padding: 5px 6px; display: flex; flex-direction: column; align-items: center; }
  :root body.playing:not(.bgp) #game:has(> #table) > #table .seat.me { flex: 1.8 1 0; order: 9; }
  :root body.playing:not(.bgp) #game:has(> #table) > #table .seat .seat-head { width: 100%; margin: 0 0 2px; font-size: 13px; }
  :root body.playing:not(.bgp) #game:has(> #table) > #table .seat .seat-state { min-height: 0; margin: 0; font-size: 11px; }
  :root body.playing:not(.bgp) #game:has(> #table) > #table .seat .hand-info { margin-top: 2px; min-height: 0; gap: 4px; font-size: 11px; }
  :root body.playing:not(.bgp) #game:has(> #table) > #table .seat .cards { display: flex; justify-content: center; }
  :root body.playing:not(.bgp) #game:has(> #table) > #table .seat:not(.me) .pkc { width: 36px; }
  :root body.playing:not(.bgp) #game:has(> #table) > #table .seat.me .pkc { width: 76px; }
  :root body.playing:not(.bgp) #game:has(> #table) > #msg { grid-column: 2; grid-row: 1; align-self: end; margin: 0; text-align: center; font-size: 14px; line-height: 1.3; }
  :root body.playing:not(.bgp) #game:has(> #table) > #controlsArea { grid-column: 2; grid-row: 2; max-width: none; width: 100%; margin: 0; gap: 6px; align-items: stretch; }
  :root body.playing:not(.bgp) #game:has(> #table) > #controlsArea #actionPanel { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  :root body.playing:not(.bgp) #game:has(> #table) > #controlsArea #raiseBtn { grid-column: 1 / -1; order: 3; }
  :root body.playing:not(.bgp) #game:has(> #table) > #controlsArea #sizePanel { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
  :root body.playing:not(.bgp) #game:has(> #table) > #controlsArea .btn { min-width: 0; min-height: 40px; padding-inline: 6px; border-radius: 20px; font-size: 14px; }
  :root body.playing:not(.bgp) #game:has(> #table) > #controlsArea .control-set .btn { min-width: 0; }
  :root body.playing:not(.bgp) #game:has(> #table) > #table .seat.me .cards:has(.pkc:nth-child(4)) .pkc { width: 44px; }
  :root body.playing:not(.bgp) #game:has(> #table) > #table .seat.me .cards:has(.pkc:nth-child(5)) .pkc { width: 38px; }
  :root body.playing:not(.bgp) #game:has(> #table) > #table .seat:not(.me) .cards:has(.pkc:nth-child(3)) .pkc { width: 26px; }
  :root body.playing:not(.bgp) #game:has(> #table) > #table .seat:not(.me) .cards:has(.pkc:nth-child(5)) .pkc { width: 22px; }
  :root body.playing:not(.bgp) #game:has(> #table) > #table .seat .cards .pkc + .pkc { margin-left: 2px; }

  /* rummy-style card tables (Remi 51, Remi 7, Tablanet, Makao): the table on the left, your hand and the action bar on the right, nothing scrolls */
  :root body.playing:not(.bgp) #game:has(> #felt) { height: calc(100svh - 44px - var(--ls-b)); display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); grid-template-rows: auto minmax(0, 1fr) auto; column-gap: 14px; row-gap: 4px; }
  :root body.playing:not(.bgp) #game:has(> #felt) > .roundline { grid-column: 1; grid-row: 1; margin: 0; font-size: 11px; text-align: center; }
  :root body.playing:not(.bgp) #game:has(> #felt) > #felt { grid-column: 1; grid-row: 2; min-height: 0; margin: 0; overflow: hidden; align-self: stretch; padding: 6px 8px; }
  :root body.playing:not(.bgp) #game:has(> #felt) > #status { grid-column: 1; grid-row: 3; margin: 0; font-size: 13px; text-align: center; min-height: 0; }
  :root body.playing:not(.bgp) #game:has(> #felt) > .hand-panel { grid-column: 2; grid-row: 1 / span 3; position: static; min-height: 0; margin: 0; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; overflow: hidden; border-radius: 16px; }
  :root body.playing:not(.bgp) #game:has(> #felt) > .hand-panel > #handArea { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; }
  :root body.playing:not(.bgp) #game:has(> #felt) > .hand-panel > .actions { flex: none; }
  :root body.playing:not(.bgp) #game:has(> #felt) > .hand-panel .btn { min-height: 40px; }
  :root body.playing:not(.bgp) #game:has(> #felt) > :is(.away-banner, .log, #leaveGameRow) { display: none; }
  :root body.playing:not(.bgp) .wrap { max-width: none; width: 100%; height: calc(100svh - 44px); box-sizing: border-box; margin: 0; padding: 0 var(--ls-xr) var(--ls-b) var(--ls-x); overflow: hidden; }
  :root body.playing:not(.bgp) #game:has(> #felt) > .hand-panel #hand .card { width: 56px; height: 78px; }
  :root body.playing:not(.bgp) #game:has(> #felt) > .hand-panel > #handArea { align-items: flex-start; }
  :root body.playing:not(.bgp) #game:has(> #felt) > .hand-panel #faceUpBtn { min-height: 40px; }
  :root body.playing:not(.bgp) #game:has(> #felt) > .hand-panel .ui-meter { margin: 0 0 2px; }
  :root body.playing:not(.bgp) #game:has(> #felt) > .hand-panel #hand:has(.card:nth-child(11)) .card { width: 48px; height: 67px; }

  /* Solitaire: the table is held to 500px (cards about 56 x 78) on the left; score, the buttons and the message in the column; a long column scrolls inside the table */
  :root body.playing:not(.bgp) #game:has(> #board):has(> .hud-row) { height: 100%; display: grid; grid-template-columns: minmax(0, 520px) minmax(0, 1fr); grid-template-rows: auto auto 1fr auto; column-gap: 24px; justify-content: center; align-content: start; }
  :root body.playing .wrap > #game:has(> #board):has(> .hud-row) { height: 100%; }
  :root body.playing:not(.bgp) #game:has(> #board):has(> .hud-row) > #board { grid-column: 1; grid-row: 1 / span 4; max-width: none; width: 100%; height: 100%; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; }
  :root body.playing:not(.bgp) #game:has(> #board):has(> .hud-row) > .hud-row { grid-column: 2; grid-row: 1; align-items: flex-start; text-align: start; display: flex; flex-direction: column; gap: 2px; margin: 0; max-width: none; padding: 0; font-size: 14px; }
  :root body.playing:not(.bgp) #game:has(> #board):has(> .hud-row) > .toolbar { grid-column: 2; grid-row: 2; display: flex; flex-direction: column; gap: 8px; margin: 8px 0 0; max-width: none; padding: 0; }
  :root body.playing:not(.bgp) #game:has(> #board):has(> .hud-row) > .toolbar .btn { width: 100%; min-height: 44px; border-radius: 22px; }
  :root body.playing:not(.bgp) #game:has(> #board):has(> .hud-row) > #msg { grid-column: 2; grid-row: 4; align-self: end; margin: 0; text-align: start; font-size: 13px; }

  /* Blackjack: dealer cards 56 x 78, bots 38 wide, yours 62 wide, so the table fits the 334px height */
  :root body.playing:not(.bgp) #game:has(> #table #dealer) #dealer .bjc { width: 56px; }
  :root body.playing:not(.bgp) #game:has(> #table #dealer) .seat:not(.me) .bjc { width: 36px; }
  :root body.playing:not(.bgp) #game:has(> #table #dealer) .seat:not(.me) .bjc + .bjc { margin-left: -20px; }
  :root body.playing:not(.bgp) #game:has(> #table #dealer) .seat.me .bjc { width: 62px; }
  :root body.playing:not(.bgp) #game:has(> #table #dealer) .seat.me .bjc + .bjc { margin-left: -22px; }
  :root body.playing:not(.bgp) #game:has(> #table #dealer) .seats { margin-top: auto; }
  :root body.playing:not(.bgp) #game:has(> #table #dealer) .seat { padding: 5px 6px; }
  :root body.playing .ui-topbar .ui-bar-mid { display: none; } /* "Hand 1 of 10" is in the table's header line */

  /* Tower Siege keeps its own side-by-side layout; the top bar and the column are brought to the same sizes */
  :root body:has(.td-side) .ui-topbar { min-height: 44px; padding: 0 var(--ls-xr) 0 var(--ls-x); }
  :root body:has(.td-side) .ui-topbar :is(h1, .ui-title) { display: none; }
  :root body:has(.td-side) .ui-topbar > :is(#langBar, .lang-bar) { margin-left: auto; }
  :root body:has(.td-side) .wrap { max-width: none; height: calc(100svh - 44px); box-sizing: border-box; padding: 0 var(--ls-xr) var(--ls-b) var(--ls-x); overflow: hidden; }
  :root body:has(.td-side) .td-side { flex: 0 0 var(--ls-col); width: var(--ls-col); }
  :root body:has(.td-side) .td-side .controls { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 0; }
  :root body:has(.td-side) .td-side .controls .btn { min-height: 40px; height: 40px; padding-inline: 6px; font-size: 14px; border-radius: 20px; }
  :root body:has(.td-side) .td-side .controls #startWave { grid-column: 1; }
  :root body:has(.td-side) .td-side .shop { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  :root body:has(.td-side) .td-side .tower-btn { height: 56px; min-height: 0; padding: 4px; }

  /* after the black-box pass (docs/2026-11-redesign/testReports/blackbox-report-2026-11-13.md), also for a 342px-high browser window */
  :root body:is([data-stage="play"], :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))) :is(.wrap:not(:has(> .ui-play)), .ui-play):has(> :is(.field, .board-row)) > .board-row { height: 100%; min-height: 0; }
  :root body:is([data-stage="play"], :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))) :is(.wrap:not(:has(> .ui-play)), .ui-play):has(> :is(.field, .board-row)) > .board-row > .field { height: 100%; min-height: 0; flex: 0 1 auto; }
  :root body:is([data-stage="play"], :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))) :is(.wrap:not(:has(> .ui-play)), .ui-play):has(> :is(.field, .board-row)) > .board-row > .field > canvas { height: 100%; width: auto; max-height: 100%; }
  :root body:is([data-stage="play"], :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))) :is(.wrap:not(:has(> .ui-play)), .ui-play):has(> :is(.field, .board-row)) > .controls #friendBtn { flex-basis: 100%; white-space: normal; line-height: 1.15; }
  /* Minesweeper: touch-size cells (32px) do not all fit, so the board scrolls inside its frame, as it always did */
  :root body[data-stage="play"]:not(.bgp) #uiPlay > .panel > .board-frame { overflow: auto; align-items: flex-start; justify-content: flex-start; overscroll-behavior: contain; }
  :root body[data-stage="play"]:not(.bgp) #uiPlay > .panel > .board-frame > .minefield { width: max-content; height: max-content; margin: auto; }
  /* Sudoku: the digits follow the cell size; the remaining count stays small and clear of the digit */
  :root body[data-stage="play"]:not(.bgp) #uiPlay:has(> #hud) > .board-frame .cell { min-width: 0; min-height: 0; font-size: clamp(13px, calc(var(--ls-h) / 17), 22px); }
  :root body[data-stage="play"]:not(.bgp) #uiPlay:has(> #hud) .tools .btn { gap: 4px; }
  /* the column scrolls rather than clip when the window is short; buttons are 44px */
  :root body.playing:not(.bgp) #game:has(> #table) > #controlsArea, :root body.playing:not(.bgp) #game:has(> #controlsArea) > #controlsArea { max-height: 100%; overflow-y: auto; overscroll-behavior: contain; }
  :root body.playing:not(.bgp) #game:has(> #table) > #controlsArea .btn { min-height: 44px; }
  :root body.playing:not(.bgp) #game:has(> #felt) > .hand-panel .btn { min-height: 44px; }
  :root body.playing:not(.bgp) #game:has(> #felt) > .hand-panel #hintBtn, :root body.playing:not(.bgp) #game:has(> #felt) > .hand-panel #sortBtn { flex-basis: 44px; width: 44px; }
}
/* the round buttons of the top bar are 44px, as in the mockups (they were 36px with a 44px touch area) */
:root .ui-topbar :is(.ui-helpbtn, .ui-menubtn, .lang-btn) { width: 44px; height: 44px; min-height: 44px; }
:root .ui-topbar #langBar { width: 44px; height: 44px; }
/* a window only 342px high (Safari with its bars): the keyboard hint gives way to the pad and the buttons */
@media (orientation: landscape) and (max-height: 360px) and (pointer: coarse) {
  :root body:is([data-stage="play"], :not([data-stage]):has(.field > .board-frame):not(:has(.ui-hero-art)), :not([data-stage]):has(.ui-hero-art):not(:has(.field > .overlay[data-start="1"]:not([hidden])))) :is(.wrap:not(:has(> .ui-play)), .ui-play):has(> :is(.field, .board-row)) > .msg.ui-hint { display: none; }
}

/* start screens on a phone on its side: the picture gives way, so the title, the line and the first card are on the first screen */
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  :root body:not(.playing):not([data-stage="play"]) .ui-hero-art, :root body:not(.playing):not([data-stage="play"]) .hero-board { display: none !important; }
  :root body:not(.playing):not([data-stage="play"]) .hero-fan { height: 70px; margin-bottom: 4px; }
  :root body:not(.playing):not([data-stage="play"]) .hero-fan .card { width: 46px; height: 64px; margin-left: -22px; }
  :root body:not(.playing):not([data-stage="play"]) .hero { padding-block: 0 8px; }
  :root body:not(.playing):not([data-stage="play"]) .ui-hero-title { font-size: 30px; }
  :root body:not(.playing):not([data-stage="play"]) .ui-hero-head { padding-top: 0; }
}

/* light theme, landscape: the hand panel and the Minesweeper panel follow the page (the felt and the board frames stay dark art, as in the mockup) */
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  :root body.playing:not(.bgp) #game:has(> #felt) > .hand-panel { --ui-bg: inherit; --ui-surface: inherit; --ui-chip: inherit; --ui-line: inherit; --ui-ink: inherit; --ui-dim: inherit; --ui-accent: inherit; --ui-primary: inherit; --ui-on: inherit; --ui-ok: inherit; --ui-err: inherit; --text: inherit; --text-dim: inherit; background: var(--ui-surface); box-shadow: inset 0 0 0 1px var(--ui-line); color: var(--ui-ink); }
  :root body[data-stage="play"]:not(.bgp) #uiPlay > .panel #msgBox { color: var(--ui-dim); }
}

/* rummy tables on a phone on its side: lanes are compact so every player, you last, stays on the felt; a long meld list scrolls inside it */
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  :root body.playing:not(.bgp) #game:has(> #felt) > #felt { overflow-y: auto; overscroll-behavior: contain; }
  :root body.playing:not(.bgp) #game:has(> #felt) .lanes { gap: 3px; }
  :root body.playing:not(.bgp) #game:has(> #felt) .lane { min-height: 34px; padding: 2px 8px; }
  :root body.playing:not(.bgp) #game:has(> #felt) .lane .nm { font-size: 14px; }
  :root body.playing:not(.bgp) #game:has(> #felt) .lane .ls { font-size: 11px; margin: 0; }
  :root body.playing:not(.bgp) #game:has(> #felt) .center .card, :root body.playing:not(.bgp) #game:has(> #felt) .center .discard-stack { width: 40px; height: 56px; }
}

/* Tank Siege on its side: Back, language and menu stay reachable in the corners of the full-screen field */
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  :root body[data-stage="play"]:has(#landscapeControls) .ui-topbar { left: 0; right: 0; padding: 4px var(--ls-xr) 0 var(--ls-x); pointer-events: none; justify-content: space-between; }
  :root body[data-stage="play"]:has(#landscapeControls) .ui-topbar > * { pointer-events: auto; }
  :root body[data-stage="play"]:has(#landscapeControls) .ui-topbar > :not(.ui-menubtn):not(.ui-back):not(.back-link):not(#langBar) { display: none; }
  :root body[data-stage="play"]:has(#landscapeControls) .ui-topbar > :is(.ui-back, .back-link) { background: color-mix(in srgb, var(--ui-bg) 70%, transparent); border-radius: 22px; padding-right: 12px; }
  :root body[data-stage="play"]:has(#landscapeControls) .ui-topbar > #langBar { margin-left: auto; }
  :root body[data-stage="play"]:has(#landscapeControls) .ui-topbar > :is(.ui-back, .back-link, #langBar) { display: inline-flex; }
  :root body[data-stage="play"]:has(#landscapeControls) .ui-topbar { justify-content: flex-start; }
}

/* Blackjack, a split hand: smaller cards so both hands stay on the felt; Hangman keys are 44px */
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  :root body.playing:not(.bgp) #game:has(> #table #dealer) .seat:has(.hand + .hand) .bjc { width: 34px; }
  :root body.playing:not(.bgp) #game:has(> #table #dealer) .seat:has(.hand + .hand) .bjc + .bjc { margin-left: -18px; }
  :root body.playing:not(.bgp) #game:has(> #table #dealer) .seat:has(.hand + .hand) .hand { padding: 2px 0; }
  :root body.playing:not(.bgp) #game:has(> #table #dealer) .seat:has(.hand + .hand) .hand-info { margin-top: 2px; }
  :root body.playing:not(.bgp) #game:has(> #table #dealer) .seats { min-height: 0; overflow-y: auto; }
  :root body[data-stage="play"]:not(.bgp) #stage .key { width: 44px; height: 44px; }
}

/* Backgammon on its side, light theme: the column beside the board follows the page, so disabled buttons and the message stay readable */
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  :root body.bgp[data-stage="play"] .side-panel { --ui-bg: inherit; --ui-surface: inherit; --ui-chip: inherit; --ui-line: inherit; --ui-ink: inherit; --ui-dim: inherit; --ui-accent: inherit; --ui-primary: inherit; --ui-on: inherit; color: var(--ui-ink); }
  :root body.bgp[data-stage="play"] .side-panel .btn:disabled { opacity: .6; color: var(--ui-dim); }
  :root body.bgp[data-stage="play"] #msgBox { color: var(--ui-dim); background: none; }
  :root body.bgp[data-stage="play"] #turnBadge { color: var(--ui-ink); }
}

/* Remi 51 / Remi 7 on a phone on its side: the felt is tall enough for a row per player (name, cards, status, melds) as in the mockup, not score tiles */
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  :root body.playing:not(.bgp) #game:has(#faceUpBtn) .lanes:not(:has(.lm)) { display: flex; flex-direction: column; gap: 3px; }
  :root body.playing:not(.bgp) #game:has(#faceUpBtn) .lanes:not(:has(.lm)) .lane { flex-direction: row; justify-content: flex-start; gap: 10px; min-height: 34px; padding: 2px 8px; text-align: start; border-radius: 12px; }
  :root body.playing:not(.bgp) #game:has(#faceUpBtn) .lanes:not(:has(.lm)) .lane .lh, :root body.playing:not(.bgp) #game:has(#faceUpBtn) .lanes:not(:has(.lm)) .lane:has(.lm:empty) .lh { flex: 1; width: auto; max-width: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  :root body.playing:not(.bgp) #game:has(#faceUpBtn) .lanes:not(:has(.lm)) .lane .nm { flex-direction: row; align-items: center; gap: 6px; font-size: 14px; font-weight: 700; color: #fff; }
  :root body.playing:not(.bgp) #game:has(#faceUpBtn) .lanes:not(:has(.lm)) .lane .tt { margin: 0 0 0 4px; padding: 0 7px; background: rgba(0,0,0,.3); font-size: 12px; line-height: 1.5; color: #f2c14e; }
  :root body.playing:not(.bgp) #game:has(#faceUpBtn) .lanes:not(:has(.lm)) .lane :is(.dot, .ls, .dealer) { display: inline-flex; }
  :root body.playing:not(.bgp) #game:has(#faceUpBtn) .lanes:not(:has(.lm)) .lane .ls { display: block; font-size: 11px; color: rgba(255,255,255,.72); margin: 0; text-align: end; }
  :root body.playing:not(.bgp) #game:has(#faceUpBtn) .lanes:not(:has(.lm)) .lane :is(.turn-tag) { display: none; }
  :root body.playing:not(.bgp) #game:has(#faceUpBtn) .lanes:not(:has(.lm)) .lane.on { border-color: rgba(255,255,255,.28); background: rgba(0,0,0,.4); }
}

/* the tagline under a start screen's title and the one quiet line under the settings */
:root .ui-hero-tag { margin-top: 4px; font-family: var(--ui-serif); font-size: 15px; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--ui-accent); text-align: center; }   /* the design: a serif line in the accent colour */
:root .ui-hero-tag[hidden], :root .ui-note[hidden] { display: none; }
:root .ui-note { margin: 8px var(--ui-gutter) 0; font-size: 14px; line-height: 1.4; color: var(--ui-dim); }

/* Checkers: Offer draw and Resign are buttons beside the board on a wide screen and on a phone on its side; on an upright phone they are in the menu */
:root #offerDrawBtn, :root #resignBtn { display: none; }
@media (min-width: 701px), (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  :root #offerDrawBtn, :root #resignBtn { display: inline-flex; align-items: center; justify-content: center; }
}

/* The design's tagline under the game's name: a serif line in the accent colour (it was small capitals in a sans) */
:root body:not(.playing):not([data-stage="play"]) :is(.wrap > .tagline, .ui-start > .tagline) { font-family: var(--ui-serif); font-size: 15px; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--ui-accent); text-align: center; }
:root .ui-levellabel:has(+ #levelBar[hidden]) { display: none; }   /* the label goes with its bar (only against the computer) */
:root body.bgp #sideLabel, :root body.bgp #sideBar { display: none !important; }   /* the design's Backgammon setup has the game list and the computer level only (the side stays what it was set to: White) */
:root .ui-levellabel { text-align: start; align-self: flex-start; }

/* Landscape start card of the one-card games (Snake, Tetris, Fruit Slice): the one-line repeat of the description gives way, so Play is on the first screen */
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  :root .field > .overlay[data-start="1"] > p { display: none; }
}

/* Landscape start screens, from the live report: the picture, the 'similar to' line and the extra rows give way so the first mode card / Play is on the first screen */
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  :root body.bgp:not(.playing):not([data-stage="play"]) :is(.bgp-hero, .similar) { display: none; }
  :root body:not(.playing):not([data-stage="play"]):has(.field > .overlay[data-start="1"]:not([hidden])) .controls { display: none; }
  :root body[data-flow="3"]:not(.playing):not([data-stage="play"]) :is(.pitch, .hero-pitch) { display: none; }   /* the pitch is in the rules; on a phone on its side the first screen has no room for it (a cut line reads as a bug) */
}

/* Backgammon hub: the description shows in full (it is the page's only text before the mode cards) */
:root body.bgp-hub:not(.playing) .hero-pitch { display: block; overflow: visible; -webkit-line-clamp: none; font-size: 13.5px; }
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  :root body.bgp-hub:not(.playing):not([data-stage="play"]) :is(.hero-pitch, .hero-board) { display: none; }   /* the hub on its side: the mode cards come up */
}

/* ===== touch targets and small fixes after the 2026-11-13 live test ===== */
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  :root .pile #deck { min-width: 44px; }   /* the deck is a button: 44px wide at least */
  :root .ui-lastmove { min-height: 44px; }
}
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  :root body[data-stage="play"]:not(.bgp) #uiPlay:has(> #hud) .tools #hintBtn { font-size: 0; }   /* Sudoku: Hint is the icon alone, the label is not drawn under it */
}
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  /* the card games' first screen on a phone on its side: name, the two mode cards side by side, How to play; one screen, nothing cut */
  :root body[data-flow="3"][data-step="mode"]:not(.playing) :is(#heroFan, .hero-pitch, #setup > .ui-note) { display: none; }
  :root body[data-flow="3"][data-step="mode"]:not(.playing) .hero { padding-top: 8px; padding-bottom: 0; }
  :root body[data-flow="3"][data-step="mode"]:not(.playing) #modeBar { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; max-width: none; width: 100%; }
  :root body[data-flow="3"][data-step="mode"]:not(.playing) #modeBar > * { margin: 0; }
}
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  /* the first screen has no Start bar (pressing a mode goes on), so it keeps no room for one */
  :root body[data-flow="3"][data-stage="start"]:not(.playing) .wrap, :root body[data-flow="3"][data-step="mode"]:not(.playing) .wrap { padding-bottom: 16px; min-height: 0; }
}
@media (orientation: portrait) {
  /* card tables on a phone upright: the hand panel is pinned to the bottom of the screen, the table takes what is left (no dead space under the buttons) */
  :root body.playing:not(.bgp) #game:has(> .hand-panel) { display: flex; flex-direction: column; min-height: calc(100svh - 120px); }
  :root body.playing:not(.bgp) #game:has(> .hand-panel) > .hand-panel { margin-top: auto; }
}
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  /* Blackjack: a seat with a split hand puts its hands side by side with smaller cards, so the tile stays on the felt */
  :root body.playing .seat:has(.hand + .hand) { display: grid !important; grid-template-columns: 1fr 1fr; column-gap: 4px; align-content: start; }
  :root .seat:has(.hand + .hand) > :is(.seat-head, .seat-state) { grid-column: 1 / -1; }
  :root .seat:has(.hand + .hand) .hand + .hand { border-top: 0; }
  :root .seat:has(.hand + .hand) .hand { padding: 2px 0; min-width: 0; }
  :root .seat:has(.hand + .hand) .bjc { width: 30px; }
  :root .seat:has(.hand + .hand) .bjc + .bjc { margin-left: -18px; }
  :root .seat:has(.hand + .hand) .hand-info { flex-direction: column; gap: 1px; font-size: 10px; margin-top: 3px; }
  :root .seat:has(.hand + .hand) .hand-info .total { font-size: 11px; padding: 1px 6px; }
}
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  :root body.playing .seat:has(.hand + .hand) .cards { display: flex; flex-wrap: nowrap; justify-content: center; }
  :root body.playing .seat:has(.hand + .hand) > .seat-state { display: none; }   /* the result chips under each hand say it */
  :root body.playing .seat:has(.hand:nth-of-type(3)) .bjc { width: 24px; }
  :root body.playing .seat:has(.hand:nth-of-type(3)) .bjc + .bjc { margin-left: -14px; }
  :root body.playing .seat:has(.hand:nth-of-type(3)) .hand-info > span:nth-child(2) { display: none; }   /* the bet of each of three or four hands */
}
:root .side-panel .turn-badge { color: var(--ui-ink); background: var(--ui-chip); }   /* the side panel follows the theme now: readable in light and dark */
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  :root .td-side .controls .btn { min-height: 44px; }   /* Tower Siege: Start Wave, Speed, Pause, Levels */
}
