/* Chess Clubhouse — phone first (390 px), scales to the TV. Colours come from the active theme pack
   (client/theme.ts sets the CSS variables); nothing here encodes a rule of the game. */

:root {
  --bg: #f4f1ea; --surface: #fff; --text: #1d2321; --muted: #5b635f; --border: #cfd6cc;
  --accent: #2f6b3b; --accent-text: #fff; --accent-soft: #dfe9e1;
  --sq-light: #eeeed2; --sq-dark: #769656;
  --hl-selected: #f6c445; --hl-legal: #2d6a4f; --hl-last: #cdd26a; --hl-capture: #d1495b; --hl-check: #e63946; --hl-mate: #9d0208;
  --pw-fill: #fff; --pw-line: #1b1b1b; --pw-detail: #1b1b1b; --pb-fill: #2a2a2a; --pb-line: #0d0d0d; --pb-detail: #f2f2f2;
  --radius: 14px; --gap: 12px;
  --fam-traditional: #2f6b3b; --fam-variant: #7b4fbf; --fam-team: #2b6cb0; --fam-event: #b5651d;
  --font: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-size: 16px;
  color-scheme: light;
}
:root[data-mode="dark"] { color-scheme: dark; }
:root[data-large-text="true"] { --font-size: 19px; }

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: var(--font-size)/1.4 var(--font); -webkit-text-size-adjust: 100%; }
:root[data-table="marble"] body { background: radial-gradient(ellipse at 20% 10%, #fff8 0, transparent 40%), repeating-linear-gradient(115deg, transparent 0 22px, #0000000a 22px 23px), var(--bg); }
body { min-height: 100dvh; overflow-x: hidden; }
button, select, input { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.2; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: .35em 0; }
.muted { color: var(--muted); } .small { font-size: .85em; } .center { text-align: center; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--hl-selected); outline-offset: 2px; }

/* ------------------------------------------------------------------ layout */
#app { max-width: 760px; margin: 0 auto; padding: 8px 10px calc(16px + env(safe-area-inset-bottom)); }
body[data-view="tv"] #app { max-width: none; padding: 1.2vw 2vw; }
.stack { display: flex; flex-direction: column; gap: var(--gap); }
.tv-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 1.6vw; align-items: start; }
.loading, .center-page { min-height: 70dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 20px; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 4px solid var(--border); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.topbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 4px 0 10px; }
.topbar .spacer { flex: 1; }
.logo { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; letter-spacing: -.01em; }
.logo-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: var(--accent-text); font-size: 20px; }
.topbar .logo span:last-child { display: none; }
body[data-view="tv"] .topbar .logo span:last-child { display: inline; font-size: 1.4rem; }
.icon-btn { min-width: 44px; min-height: 44px; padding: 0; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font-size: 1.1rem; cursor: pointer; }
.conn-banner:not(:empty) { background: var(--hl-capture); color: #fff; padding: 2px 10px; border-radius: 99px; font-size: .85em; }
.paused-pill { background: var(--hl-selected); color: #000; padding: 2px 10px; border-radius: 99px; font-weight: 700; }
.me-chip .chip-label { max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mode-badge { display: inline-flex; flex-direction: column; padding: 3px 10px; border-radius: 10px; border-left: 5px solid var(--fam-variant); background: var(--surface); line-height: 1.1; }
.mode-badge.fam-traditional { border-left-color: var(--fam-traditional); }
.mode-badge.fam-team { border-left-color: var(--fam-team); }
.mode-badge.fam-event { border-left-color: var(--fam-event); }
.mode-kind { font-size: .7em; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.mode-name { font-weight: 800; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.card h2 small { font-weight: 400; }
.rules .tagline { color: var(--muted); margin-top: 6px; }
.rules.variant { border-top: 5px solid var(--fam-variant); }
.rules.std { border-top: 5px solid var(--fam-traditional); }
.variant-warning { background: var(--accent-soft); padding: 6px 10px; border-radius: 10px; font-weight: 600; }
.rule-list { padding-left: 1.2em; margin: .5em 0; } .rule-list li { margin: .3em 0; }
.notes { margin-top: 8px; padding: 8px 10px; border-radius: 10px; border: 1px dashed var(--hl-capture); }
.notes ul { margin: .3em 0 0; padding-left: 1.2em; }
.countdown { font-size: 1.2rem; font-weight: 700; text-align: center; }

/* ------------------------------------------------------------------ buttons */
.btn { min-height: 44px; padding: 8px 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--hl-capture); border-color: currentColor; }
.btn.small { min-height: 36px; padding: 4px 12px; font-size: .9em; }
.btn.tiny { min-height: 30px; padding: 2px 8px; font-size: .8em; }
.btn.big { min-height: 56px; font-size: 1.15rem; padding: 10px 28px; }
.row-buttons { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.game-actions { justify-content: flex-end; }

/* ------------------------------------------------------------------ player colours (hue + pattern + symbol) */
.chip { display: inline-flex; align-items: center; gap: 4px; vertical-align: middle; }
.chip-sym { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; font-size: 13px; color: var(--chip-text); background: var(--chip); border: 2px solid var(--text); flex: none; }
.pat-stripes .chip-sym { background: repeating-linear-gradient(45deg, var(--chip) 0 4px, color-mix(in srgb, var(--chip) 60%, #fff) 4px 7px); }
.pat-dots .chip-sym { background: radial-gradient(circle, color-mix(in srgb, var(--chip) 50%, #fff) 1.5px, transparent 2px) 0 0/6px 6px, var(--chip); }
.pat-checks .chip-sym { background: conic-gradient(var(--chip) 25%, color-mix(in srgb, var(--chip) 55%, #fff) 0 50%, var(--chip) 0 75%, color-mix(in srgb, var(--chip) 55%, #fff) 0) 0 0/8px 8px; }
.pat-waves .chip-sym { background: radial-gradient(circle at 50% 0, transparent 3px, color-mix(in srgb, var(--chip) 55%, #000) 3.5px 4px, transparent 4.5px) 0 0/8px 6px, var(--chip); }
.pat-zigzag .chip-sym { background: linear-gradient(135deg, color-mix(in srgb, var(--chip) 55%, #fff) 25%, transparent 25%) -4px 0/8px 8px, linear-gradient(225deg, color-mix(in srgb, var(--chip) 55%, #fff) 25%, transparent 25%) -4px 0/8px 8px, var(--chip); }
.pat-grid .chip-sym { background: linear-gradient(color-mix(in srgb, var(--chip) 50%, #000) 1px, transparent 1px) 0 0/6px 6px, linear-gradient(90deg, color-mix(in srgb, var(--chip) 50%, #000) 1px, transparent 1px) 0 0/6px 6px, var(--chip); }

/* ------------------------------------------------------------------ lineup */
.lineup-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.lineup-list li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 10px; background: var(--bg); }
.lineup-list li.me { outline: 2px solid var(--accent); }
.lineup-list .who { flex: 1; font-weight: 600; } .lineup-list .slot { color: var(--muted); font-size: .9em; }
.lineup-btn { display: flex; align-items: center; gap: 8px; width: 100%; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; min-height: 40px; }
.lineup-list li.picked { background: var(--accent-soft); outline: 2px dashed var(--accent); }
.away { color: var(--hl-capture); }

/* ------------------------------------------------------------------ game card */
.game-card { display: flex; flex-direction: column; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; }
.game-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag { font-size: .75em; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); font-weight: 700; }
.tag.check { background: var(--hl-check); color: #fff; }
.opening { font-style: italic; color: var(--muted); font-size: .9em; }
.player-bar { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 10px; min-height: 40px; }
.player-bar.on-turn { background: var(--accent-soft); box-shadow: inset 4px 0 0 var(--accent); }
.side-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--text); flex: none; }
.side-dot.w { background: var(--pw-fill); } .side-dot.b { background: var(--pb-fill); box-shadow: inset 0 0 0 2px var(--pb-detail); }
.pname { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.relay-now { color: var(--accent); }
.captured { display: inline-flex; align-items: center; max-width: 40%; overflow: hidden; }
.captured .pc { width: 18px; height: 18px; margin-right: -6px; }
.captured small { margin-left: 8px; color: var(--muted); }
.clock { font-variant-numeric: tabular-nums; font-weight: 800; padding: 2px 10px; border-radius: 8px; background: var(--bg); min-width: 4.2em; text-align: center; }
.clock.running { background: var(--text); color: var(--bg); }
.clock.low { background: var(--hl-capture); color: #fff; }
.clock.critical { animation: pulse .5s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.08); } }
.status { text-align: center; font-weight: 700; padding: 6px; border-radius: 10px; }
.status.yours { background: var(--accent); color: var(--accent-text); }
.status.check { background: var(--hl-check); color: #fff; animation: pulse .6s ease-in-out 3 alternate; }
.status.over { background: var(--text); color: var(--bg); }
.status.paused { background: var(--hl-selected); color: #000; }
.offer { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; padding: 6px; border-radius: 10px; background: var(--accent-soft); }
.moves-wrap summary { cursor: pointer; color: var(--muted); font-weight: 600; min-height: 32px; }
.moves { list-style: none; margin: 4px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 2px 10px; max-height: 180px; overflow: auto; font-variant-numeric: tabular-nums; }
.moves li { display: flex; gap: 6px; } .moves .mn { color: var(--muted); min-width: 2.2em; } .moves .mv { min-width: 4em; } .moves .latest { font-weight: 800; color: var(--accent); }
.partner h3 { margin: 4px 0; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.tab { flex: none; min-height: 40px; padding: 4px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600; }
.tab.active { background: var(--accent); color: var(--accent-text); }
.tab.due:not(.active) { border-color: var(--accent); }

/* ------------------------------------------------------------------ board */
.board { position: relative; width: 100%; aspect-ratio: 1; border-radius: 8px; overflow: hidden; box-shadow: 0 0 0 3px var(--border); touch-action: none; user-select: none; -webkit-user-select: none; }
.game-card.small .board { max-width: 340px; margin: 0 auto; }
.grid { display: grid; grid-template-rows: repeat(8, 1fr); width: 100%; height: 100%; }
.grid .row { display: grid; grid-template-columns: repeat(8, 1fr); }
.sq { position: relative; display: grid; place-items: center; outline: none; }
.sq.light { background: var(--sq-light); } .sq.dark { background: var(--sq-dark); }
:root[data-texture="wood"] .sq.light { background: repeating-linear-gradient(95deg, #0000 0 6px, #00000010 6px 7px), var(--sq-light); }
:root[data-texture="wood"] .sq.dark { background: repeating-linear-gradient(85deg, #0000 0 5px, #00000022 5px 6px), var(--sq-dark); }
:root[data-texture="snow"] .sq.light { background: radial-gradient(circle at 30% 30%, #fff 0 1.5px, transparent 2px) 0 0/22px 22px, var(--sq-light); }
:root[data-texture="stars"] .sq.dark { background: radial-gradient(circle at 70% 30%, #ffffff55 0 1px, transparent 1.5px) 0 0/26px 26px, var(--sq-dark); }
:root[data-texture="web"] .sq.dark { background: repeating-conic-gradient(from 0deg at 0 0, #0000 0 14deg, #ffffff14 14deg 15deg), var(--sq-dark); }
.sq .pc { width: 88%; height: 88%; z-index: 1; filter: drop-shadow(0 1px 1px #0005); pointer-events: none; }
.sq.movable { cursor: grab; }
.sq.last::before { content: ""; position: absolute; inset: 0; background: var(--hl-last); opacity: .55; }
.sq.selected::before { content: ""; position: absolute; inset: 0; background: var(--hl-selected); opacity: .7; }
.sq.check::after, .sq.mate::after { content: ""; position: absolute; inset: 4%; border-radius: 50%; background: radial-gradient(circle, var(--hl-check) 0 40%, transparent 72%); z-index: 0; }
.sq.mate::after { background: radial-gradient(circle, var(--hl-mate) 0 55%, transparent 75%); }
.sq.target::after { content: ""; position: absolute; width: 30%; height: 30%; border-radius: 50%; background: var(--hl-legal); opacity: .8; z-index: 2; box-shadow: 0 0 0 2px #fff8; }
.sq.target.capture::after { width: 92%; height: 92%; background: transparent; border: 5px solid var(--hl-capture); opacity: .9; box-shadow: none; }
.sq.target { cursor: pointer; }
.sq.hill { box-shadow: inset 0 0 0 3px var(--accent); }
.sq.hill::before { content: "⛰"; position: absolute; font-size: 40%; opacity: .35; }
.sq.fog { background-image: repeating-linear-gradient(45deg, #0000 0 6px, #00000026 6px 9px); }
.sq.fog::before { content: ""; position: absolute; inset: 0; background: color-mix(in srgb, var(--muted) 55%, transparent); }
.grid:focus-within .sq.kbd { box-shadow: inset 0 0 0 4px var(--hl-selected); }
.coord { position: absolute; font-size: 10px; font-weight: 800; opacity: .8; pointer-events: none; z-index: 1; }
.coord.rank { top: 2px; left: 3px; } .coord.file { bottom: 1px; right: 3px; }
.sq.light .coord { color: var(--sq-dark); } .sq.dark .coord { color: var(--sq-light); }
:root[data-coords="false"] .coord { display: none; }
.arrive { animation: arrive .22s ease-out; }
@keyframes arrive { from { transform: scale(.8); opacity: .4; } }
.dragging .sq .pc { opacity: .9; }
.drag-ghost { position: fixed; left: 0; top: 0; pointer-events: none; z-index: 50; }
.drag-ghost .pc { width: 100%; height: 100%; transform: scale(1.15); filter: drop-shadow(0 6px 6px #0006); }
.arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
.arrow { stroke-width: .16; stroke-linecap: round; opacity: .75; }
.arrow.suggest { stroke: var(--fam-team); } .arrow.nominate { stroke: var(--fam-variant); stroke-dasharray: .25 .15; } .arrow.vote { stroke: var(--accent); stroke-width: .22; } .arrow.hint { stroke: var(--hl-selected); }
.ah.suggest { fill: var(--fam-team); } .ah.nominate { fill: var(--fam-variant); } .ah.vote { fill: var(--accent); } .ah.hint { fill: var(--hl-selected); }
.arrow-label { font-size: .4px; font-weight: 800; fill: #fff; paint-order: stroke; stroke: #000; stroke-width: .08px; }
.promo { position: absolute; inset: 20% 8%; z-index: 10; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; background: var(--surface); border-radius: 16px; box-shadow: 0 10px 40px #0007; padding: 12px; }
.promo[hidden] { display: none; }
.promo p { width: 100%; text-align: center; font-weight: 700; margin: 0; }
.promo-btn { width: 64px; height: 64px; border-radius: 12px; border: 2px solid var(--border); background: var(--sq-light); cursor: pointer; }
.promo-btn .pc { width: 100%; height: 100%; }

/* pieces: shape from the piece set, colours from the theme */
.pc .f { stroke-width: 1.5; stroke-linejoin: round; }
.pc .d { fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.pc.w .f { fill: var(--pw-fill); stroke: var(--pw-line); } .pc.w .d { stroke: var(--pw-detail); } .pc.w .dd { fill: var(--pw-detail); }
.pc.b .f { fill: var(--pb-fill); stroke: var(--pb-line); } .pc.b .d { stroke: var(--pb-detail); } .pc.b .dd { fill: var(--pb-detail); }
.pc .mk { display: none; }
:root[data-markers="true"] .pc .mk { display: inline; stroke-width: 2; }
:root[data-markers="true"] .pc.w .mk { fill: var(--pw-fill); stroke: var(--pw-line); }
:root[data-markers="true"] .pc.b .mk { fill: var(--pb-detail); stroke: var(--pb-line); }

/* pockets (Bughouse) */
.pocket { display: flex; gap: 6px; flex-wrap: wrap; min-height: 34px; align-items: center; }
.pocket-piece { position: relative; display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); padding: 2px; }
button.pocket-piece { cursor: pointer; }
.pocket-piece.selected { border: 3px solid var(--hl-selected); background: var(--accent-soft); }
.pocket-piece .pc { width: 100%; height: 100%; }
.pocket-piece b { position: absolute; right: -4px; bottom: -4px; background: var(--text); color: var(--bg); border-radius: 99px; font-size: 11px; padding: 0 5px; }

/* cards (Card Chess) */
.cards-panel { display: flex; flex-direction: column; gap: 6px; }
.hand { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; }
.pcard { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px; min-height: 110px; border-radius: 12px; border: 2px solid var(--border); background: linear-gradient(160deg, var(--surface), var(--bg)); cursor: pointer; text-align: center; }
.pcard.playable { border-color: var(--accent); }
.pcard.selected { border-color: var(--hl-selected); box-shadow: 0 0 0 3px var(--hl-selected); transform: translateY(-3px); }
.pcard.dim { opacity: .55; }
.pcard-sym { font-size: 1.4rem; font-weight: 800; height: 36px; display: grid; place-items: center; }
.pcard-sym .pc { width: 36px; height: 36px; }
.pcard-name { font-weight: 800; } .pcard-text { font-size: .72em; color: var(--muted); }
.free-move { background: var(--hl-selected); color: #000; padding: 4px 10px; border-radius: 10px; font-weight: 700; }

/* team voting */
.team-panel { border-radius: 12px; padding: 8px 10px; background: var(--bg); }
.team-panel header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.noms { list-style: none; padding: 0; margin: 6px 0; display: flex; flex-direction: column; gap: 4px; }
.noms li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 4px 6px; border-radius: 8px; background: var(--surface); }
.noms li.mine { outline: 2px solid var(--accent); }
.noms .san { font-weight: 800; min-width: 3.5em; } .noms .votes { flex: 1; }
.reveal { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; } .rv { background: var(--surface); padding: 2px 8px; border-radius: 99px; font-size: .85em; }
.team-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.team-col ul { list-style: none; padding: 0; margin: 0; } .team-col li { padding: 3px 0; } .team-col li.me { font-weight: 800; }

/* bracket */
.rounds { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.round { flex: none; min-width: 170px; display: flex; flex-direction: column; gap: 8px; justify-content: space-around; }
.round.current h3 { color: var(--accent); }
.match { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--bg); }
.match.live { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.entrant { display: flex; align-items: center; gap: 6px; padding: 4px 8px; }
.entrant + .entrant { border-top: 1px solid var(--border); }
.entrant.won { font-weight: 800; } .entrant.lost { opacity: .55; text-decoration: line-through; } .entrant.me { background: var(--accent-soft); }
.entrant .seed { color: var(--muted); font-size: .8em; min-width: 1.2em; } .entrant .ename { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.match .btn { width: 100%; border-radius: 0; border: 0; border-top: 1px solid var(--border); }
.champ { color: var(--fam-event); }

/* tables */
.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr.me td, .tbl tr.due td { background: var(--accent-soft); }
.totals { display: flex; gap: 10px; flex-wrap: wrap; } .total { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 10px; background: var(--bg); } .total b { font-size: 1.4rem; }
.score-lines { list-style: none; padding: 0; margin: 6px 0; } .score-lines li { padding: 3px 0; border-bottom: 1px dashed var(--border); } .score-lines b { margin-left: 6px; color: var(--accent); }
.big-line { font-size: 1.2rem; font-weight: 800; } .big-line.yours { color: var(--accent); }
.solution { font-weight: 700; background: var(--accent-soft); padding: 4px 8px; border-radius: 8px; }

/* predictions */
.pq { padding: 6px 0; border-bottom: 1px dashed var(--border); }
.pq select { width: 100%; min-height: 44px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); padding: 4px 8px; }
.recent { padding-left: 1.1em; margin: 6px 0; font-size: .88em; } .pboard { margin: 6px 0 0; padding-left: 1.4em; } .pboard li.me { font-weight: 800; }

/* N-player */
.nboard { display: grid; grid-template-columns: repeat(14, 1fr); width: 100%; aspect-ratio: 1; border-radius: 8px; overflow: hidden; user-select: none; }
.nsq { position: relative; display: grid; place-items: center; outline: none; }
.nsq.void { background: transparent; }
.nsq.light { background: var(--sq-light); } .nsq.dark { background: var(--sq-dark); }
.nsq:not(.centre):not(.void) { filter: saturate(.8) brightness(.97); }
.nsq .pc { width: 92%; height: 92%; z-index: 1; filter: drop-shadow(0 1px 1px #0006); }
.nsym { position: absolute; right: 0; bottom: -1px; font-size: 8px; z-index: 2; color: var(--text); text-shadow: 0 0 2px var(--surface); }
.nsq.last::before { content: ""; position: absolute; inset: 0; background: var(--hl-last); opacity: .55; }
.nsq.selected::before { content: ""; position: absolute; inset: 0; background: var(--hl-selected); opacity: .7; }
.nsq.target::after { content: ""; position: absolute; width: 34%; height: 34%; border-radius: 50%; background: var(--hl-legal); z-index: 2; }
.nsq.target.capture::after { width: 90%; height: 90%; background: none; border: 3px solid var(--hl-capture); }
.nsq.check { box-shadow: inset 0 0 0 3px var(--hl-check); }
.nboard:focus-within .nsq.kbd { box-shadow: inset 0 0 0 3px var(--hl-selected); }
.nsq.movable { cursor: pointer; }
.np-players { list-style: none; padding: 0; margin: 0 0 6px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.np-players li { display: flex; align-items: center; gap: 4px; padding: 4px 6px; border-radius: 8px; background: var(--bg); font-size: .9em; }
.np-players li.on-turn { outline: 2px solid var(--accent); } .np-players li.out { opacity: .5; text-decoration: line-through; }
.np-log { padding-left: 1em; margin: 4px 0; }

/* results */
.results h1 { font-size: 2rem; }
.results { text-align: center; } .results .tbl { text-align: left; } .results .row-buttons { justify-content: center; margin-top: 10px; }

/* dialogs */
dialog.drawer { width: min(680px, 100vw); max-height: 92dvh; margin: auto auto 0; border: 0; border-radius: 18px 18px 0 0; padding: 14px; background: var(--surface); color: var(--text); overflow: auto; }
@media (min-width: 700px) { dialog.drawer { margin: auto; border-radius: 18px; } }
dialog::backdrop { background: #0008; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; position: sticky; top: -14px; background: var(--surface); padding: 4px 0; z-index: 1; }
.note { background: var(--accent-soft); padding: 8px 10px; border-radius: 10px; }
.preview-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; position: sticky; top: 36px; z-index: 1; }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.theme-tile { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px; border-radius: 12px; border: 2px solid var(--border); background: var(--bg); cursor: pointer; text-align: center; }
.theme-tile.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.theme-tile img { width: 96px; height: 96px; border-radius: 10px; }
.tname { font-weight: 800; } .tdesc { font-size: .75em; color: var(--muted); }
.season { color: var(--fam-event); } .a11y { color: var(--fam-team); }
.custom-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.custom { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.custom input { width: 44px; height: 36px; border: 1px solid var(--border); border-radius: 8px; padding: 0; background: none; }
.warnings { border: 2px solid var(--hl-capture); border-radius: 10px; padding: 8px 10px; margin: 8px 0; } .warnings ul { margin: 4px 0; padding-left: 1.2em; }
.ok { color: var(--accent); font-weight: 700; }
.toggle { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.toggle input { width: 22px; height: 22px; }
.auto-list { list-style: none; padding: 0; } .auto-list li { display: flex; align-items: center; gap: 8px; padding: 4px 0; } .auto-list .btn { margin-left: auto; }

/* toasts */
.toasts { position: fixed; left: 50%; top: 10px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 100; width: min(92vw, 420px); pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 12px; box-shadow: 0 6px 24px #0004; font-weight: 600; transition: opacity .4s, transform .4s; }
.toast.good { background: var(--accent); color: var(--accent-text); } .toast.bad { background: var(--hl-capture); color: #fff; }
.toast.out { opacity: 0; transform: translateY(-8px); }

/* ------------------------------------------------------------------ TV (landscape, readable from across the room) */
body[data-view="tv"] { --font-size: clamp(16px, 1.15vw, 30px); }
body[data-view="tv"] .tv-grid > .game-card .board, body[data-view="tv"] .tv-grid > .card.nplayer .nboard { max-height: 66vh; max-width: 66vh; margin: 0 auto; }
body[data-view="tv"] .tv-grid > .game-card .moves-wrap { display: none; }
.tv-moves .moves { max-height: 40vh; font-size: 1.1em; }
.tv-status { font-size: 1.6em; }
body[data-view="tv"] .tv-boards { display: grid; gap: 1vw; grid-template-columns: 1fr 1fr; }
body[data-view="tv"] .tv-boards .board { max-height: 36vh; max-width: 36vh; }
body[data-view="tv"] .tv-boards.n2 .board { max-height: 64vh; max-width: 64vh; }
body[data-view="tv"] .game-actions, body[data-view="tv"] .icon-btn { display: none; }
body[data-view="tv"] .clock { font-size: 1.5em; }
body[data-view="tv"] .ready.tv-grid .rules { font-size: 1.2em; }
body[data-view="tv"] .side { max-height: 92vh; overflow: hidden; }

@media (min-width: 900px) and (orientation: landscape) {
  body[data-view="phone"] #app { max-width: 1200px; }
  body[data-view="phone"] main.play { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: start; }
  body[data-view="phone"] main.play > .game-card:first-of-type, body[data-view="phone"] main.play > .tabs { grid-column: 1; }
}
@media (max-width: 430px) { .me-chip .chip-label { display: none; } .topbar { gap: 6px; } .mode-badge { padding: 3px 8px; } }
@media (max-width: 380px) { .pname { font-size: .9em; } .clock { min-width: 3.6em; padding: 2px 6px; } }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
:root[data-reduced-motion="true"] * { animation: none !important; transition: none !important; }
