:root {
  --felt: #2a160c;
  --felt-2: #3d2212;
  --felt-3: #5a3418;
  --line: #1c0e06;
  --text: #fff3d6;
  --muted: #e6cfa2;
  --gold: #ffd96b;
  --gold-ink: #3b1d05;
  --wood: repeating-linear-gradient(90deg, #8a5a34 0 22px, #7c4f2c 22px 24px, #93613a 24px 50px, #7c4f2c 50px 52px);
  --crimson: linear-gradient(#e63a43, #a3141c);
  --paper: #f3e2b6;
  --paper-line: #d6bd84;
  --ink: #3b2412;
  --red: #e63a43;
  --display: Cinzel, "DejaVu Serif", Georgia, "Times New Roman", serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --frame: linear-gradient(135deg, #7a4a24, #4a2a12 50%, #6b3f1e);
  --rail: 104px;
  --bar: 60px;
  --size: min(calc(100vh - var(--bar) - 130px), calc(100vw - var(--rail) - 470px), 780px);
}

/* Board themes. Each one only sets colours, so new themes are a few lines. */
[data-theme="kingdom"]    { --light: #f3dfb0; --dark: #8a4f2a; --pw: #fff8e6; --pw-edge: #3b2412; --pb: #3b1d12; --pb-edge: #120804; --pb-line: #b08a5c; }
[data-theme="vault"]      { --light: #d9c9a3; --dark: #1c1a17; --pw: #f3d27a; --pw-edge: #5a3f08; --pb: #0d0d10; --pb-edge: #8d8676; --pb-line: #8d8676; --dot: rgba(233, 196, 106, 0.75); --coord: #8d8676; }
[data-theme="classic"]    { --light: #f0d9b5; --dark: #b58863; --pw: #ffffff; --pw-edge: #3a2a1a; --pb: #2a2420; --pb-edge: #0c0a08; --pb-line: #8a7f76; }
[data-theme="tournament"] { --light: #eeeed2; --dark: #769656; --pw: #ffffff; --pw-edge: #2b3320; --pb: #262626; --pb-edge: #080808; --pb-line: #8c8c8c; }
[data-theme="midnight"]   { --light: #a9b8d0; --dark: #3d5a80; --pw: #ffffff; --pw-edge: #14213d; --pb: #111a33; --pb-edge: #03060f; --pb-line: #7f8db0; }
[data-theme="marble"]     { --light: #ecebe7; --dark: #8f8c87; --pw: #ffffff; --pw-edge: #3b3a38; --pb: #262626; --pb-edge: #080808; --pb-line: #8c8c8c; }
/* Futuristic boards also set a glowing grid line, a glow on the pieces and the move-dot colour. */
[data-theme="hologram"]   { --light: #1c5a78; --dark: #0c2f47; --pw: #e9fbff; --pw-edge: #0b6d8f; --pb: #06202f; --pb-edge: #5fe6ff; --pb-line: #5fe6ff; --sq-edge: rgba(95, 230, 255, 0.35); --piece-glow: drop-shadow(0 0 3px rgba(95, 230, 255, 0.75)); --dot: rgba(190, 245, 255, 0.55); --coord: #8fdcf2; }
[data-theme="synthwave"]  { --light: #4a2a7a; --dark: #24124a; --pw: #ffd36b; --pw-edge: #7a3b00; --pb: #ff4f9a; --pb-edge: #4d0b33; --pb-line: #7d1650; --sq-edge: rgba(255, 110, 200, 0.4); --piece-glow: drop-shadow(0 0 4px rgba(255, 120, 200, 0.6)); --dot: rgba(255, 220, 140, 0.6); --coord: #d8a8ff; }
[data-theme="carbon"]     { --light: #3b3f45; --dark: #1e2024; --pw: #f2f4f6; --pw-edge: #2a2d31; --pb: #0c0d0f; --pb-edge: #a6ff3d; --pb-line: #a6ff3d; --sq-edge: rgba(166, 255, 61, 0.16); --piece-glow: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6)); --dot: rgba(166, 255, 61, 0.6); --coord: #9aa3ad; }
[data-theme="plasma"]     { --light: #123a3a; --dark: #0a1f24; --pw: #7dffc8; --pw-edge: #05402f; --pb: #b388ff; --pb-edge: #2a0f5c; --pb-line: #4a1f99; --sq-edge: rgba(125, 255, 200, 0.28); --piece-glow: drop-shadow(0 0 4px rgba(125, 255, 200, 0.55)); --dot: rgba(255, 255, 255, 0.45); --coord: #7fd9b6; }
[data-theme="neon"]       { --light: #2b2b52; --dark: #15152b; --pw: #5ff4ff; --pw-edge: #063a40; --pb: #ff4fd8; --pb-edge: #4a0f3c; --pb-line: #7a1c64; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--felt) radial-gradient(110% 60% at 50% 0, #7b4a2a 0, #4a2a18 45%, #2a160c 100%) fixed;
  color: var(--text);
  font: 15px/1.5 var(--sans);
}

h1 { margin: 0; font: 700 27px/1.15 var(--display); letter-spacing: -0.2px; }
h2 { margin: 0; font: 600 14px/1.3 var(--display); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 6;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: var(--bar);
  padding: 0 20px;
  background: #2a160c;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { display: block; width: 34px; height: 34px; flex: none; }
.brand-word { font: 700 18px/1 var(--display); white-space: nowrap; }
.brand-accent { color: var(--gold);  }
.account { display: flex; align-items: center; gap: 8px; min-width: 0; }
.account-name { color: var(--muted); font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip {
  padding: 5px 12px; border-radius: 999px; border: 1px solid var(--gold);
  background: transparent; color: var(--gold);
  font: 600 13px/1.4 var(--sans); font-variant-numeric: tabular-nums; cursor: pointer; white-space: nowrap;
}
.chip.install { margin-left: auto; background: var(--gold); color: var(--gold-ink); }
.chip.install:hover { background: #e5bd63; }
.chip:not(.install):hover { background: rgba(233, 196, 106, 0.12); }

/* ---------- section tabs: a rail on wide screens, a bottom bar on phones ---------- */
.tabs {
  position: fixed; z-index: 5;
  left: 0; top: var(--bar); bottom: 0; width: var(--rail);
  display: flex; flex-direction: column; gap: 4px;
  padding: 14px 8px;
  background: #2a160c;
  border-right: 1px solid var(--line);
}
.tab {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 10px 4px;
  border: 0; border-radius: 10px;
  background: none; color: var(--muted);
  font: 600 12px/1.2 var(--sans); cursor: pointer;
}
.tab svg { width: 24px; height: 24px; }
.tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.tab[aria-current="page"] { color: var(--gold-ink); background: var(--gold); }
.tab .dot { position: absolute; top: 7px; right: 18px; width: 9px; height: 9px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px #2a160c; }
.tab:focus-visible, .btn:focus-visible, .chip:focus-visible, .swatch:focus-visible, summary:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.stage { margin-left: var(--rail); padding: 24px 32px 40px; }
.view { display: none; }
body[data-view="play"] #view-play { display: grid; }
body[data-view="tournaments"] #view-tournaments,
body[data-view="ranks"] #view-ranks,
body[data-view="boards"] #view-boards,
body[data-view="wallet"] #view-wallet { display: block; }
.view-page { max-width: 980px; margin: 0 auto; }
.view-page > .note { max-width: 62ch; margin: 8px 0 22px; font-size: 15px; }

/* ---------- play ---------- */
.view-play {
  grid-template-columns: var(--size) minmax(300px, 380px);
  gap: 16px 28px;
  justify-content: center;
  align-items: start;
}
.board-col { width: var(--size); }
.side { display: flex; flex-direction: column; gap: 12px; margin-top: 40px; min-width: 0; }

.banner {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 16px 20px;
  border-radius: 14px;
  border: 1px solid #1c0e06;
  background: var(--felt-2);
}
.banner-coin { width: 64px; height: 64px; flex: none; }
.banner-text { flex: 1 1 280px; min-width: 0; }
.banner-title { margin: 0; font: 700 19px/1.2 var(--display); }
.banner-sub { margin: 4px 0 0; color: var(--muted); max-width: 60ch; }
.banner-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.banner-actions .btn { flex: none; }

.player { display: flex; align-items: center; gap: 12px; height: 40px; }
.player-name { font-weight: 600; white-space: nowrap; }
.player-name.to-move::before {
  content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 8px;
  border-radius: 50%; background: var(--gold);
}
.captured { flex: 1; display: flex; align-items: center; height: 24px; color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden; }
.captured .lead { margin-left: 6px; }
.clock {
  min-width: 88px; padding: 3px 10px; border-radius: 6px;
  background: var(--felt-3); color: var(--muted);
  font: 600 17px/1.3 var(--display); font-variant-numeric: tabular-nums; text-align: right;
}
.clock.running { background: var(--gold); color: var(--gold-ink); }
.clock.low { background: var(--red); color: #fff; }
.clock:empty { visibility: hidden; }

.board {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  width: var(--size);
  height: var(--size);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  user-select: none;
}

.sq {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.sq.light { background: var(--light); }
.sq.dark { background: var(--dark); }
.sq { box-shadow: inset 0 0 0 1px var(--sq-edge, transparent); }
.piece svg { filter: var(--piece-glow, none); }
.sq:focus-visible { outline: 3px solid var(--gold); outline-offset: -3px; z-index: 1; }

.sq.last::before,
.sq.selected::before,
.sq.check::before {
  content: "";
  position: absolute;
  inset: 0;
}
.sq.last::before { background: rgba(246, 226, 80, 0.42); }
.sq.selected::before { background: rgba(60, 180, 110, 0.55); }
.sq.premove::before { content: ""; position: absolute; inset: 0; background: rgba(214, 72, 72, 0.5); }
.sq.check::before { background: radial-gradient(circle, rgba(230, 40, 40, 0.95) 0%, rgba(230, 40, 40, 0.55) 45%, rgba(230, 40, 40, 0) 75%); }

.sq.target::after {
  content: "";
  position: absolute;
  width: 30%; height: 30%;
  border-radius: 50%;
  background: var(--dot, rgba(20, 20, 20, 0.28));
}
.sq.capture::after {
  content: "";
  position: absolute;
  inset: 5%;
  border-radius: 50%;
  border: calc(var(--size) / 110) solid var(--dot, rgba(20, 20, 20, 0.32));
}
body[data-theme="neon"] .sq.target::after { background: rgba(255, 255, 255, 0.35); }
body[data-theme="neon"] .sq.capture::after { border-color: rgba(255, 255, 255, 0.4); }

.piece {
  position: relative;
  z-index: 1;
  display: block;
  width: 88%;
  height: 88%;
  pointer-events: none;
}
.piece svg { display: block; width: 100%; height: 100%; overflow: visible; }
.pf { stroke-width: 3.2; stroke-linejoin: round; }
.pd { fill: none; stroke-width: 2.6; stroke-linecap: round; }
.piece.w .pf { fill: var(--pw); stroke: var(--pw-edge); }
.piece.w .pd { stroke: var(--pw-edge); }
.piece.w .pe { fill: var(--pw-edge); }
.piece.b .pf { fill: var(--pb); stroke: var(--pb-edge); }
.piece.b .pd { stroke: var(--pb-line); }
.piece.b .pe { fill: var(--pb-line); }
.piece.mini { flex: none; width: 22px; height: 22px; margin-right: -5px; }
.piece.mini.b .pf { stroke: #7d8490; }

.coord {
  position: absolute;
  font-size: calc(var(--size) / 62);
  font-weight: 700;
  line-height: 1;
  opacity: 0.75;
  pointer-events: none;
}
.coord.rank { top: 4%; left: 5%; }
.coord.file { bottom: 4%; right: 6%; }
.sq.light .coord { color: var(--coord, var(--dark)); }
.sq.dark .coord { color: var(--coord, var(--light)); }
body[data-theme="neon"] .coord { color: #8f8fc7; }


.status {
  padding: 12px 14px; border-radius: 10px;
  background: var(--felt-2); border: 1px solid var(--line);
  font: 600 14px/1.35 var(--display);
}
.status.over { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }

.buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  flex: 1; padding: 9px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--felt-3); color: var(--text);
  font: 600 14px/1.3 var(--sans); cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.small { flex: none; padding: 6px 12px; font-size: 13px; }
.btn.quiet { background: transparent; }
.btn.big { padding: 13px 14px; font-size: 16px; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.btn.primary:hover { background: #e5bd63; border-color: #e5bd63; }

.card { padding: 14px; border-radius: 12px; background: var(--felt-2); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }

.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.field small { font-size: 12px; }
.field select, .field input, .chat-form input {
  padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--felt); color: var(--text); font: inherit; font-size: 15px;
}
.field input:focus-visible, .field select:focus-visible, .chat-form input:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.note { margin: 0; font-size: 13px; color: var(--muted); }
.error { margin: 0; min-height: 18px; font-size: 13px; color: #ff9d8a; }
.linklike { align-self: flex-start; padding: 0; border: 0; background: none; color: var(--gold); font: 500 13px/1.4 var(--sans); cursor: pointer; text-decoration: underline; }
.trainer { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
#trainer-note:empty { display: none; }
.sq.hint::before { content: ""; position: absolute; inset: 0; background: rgba(70, 140, 235, 0.55); }

/* The move list is a paper scoresheet, the way games are written down at a real tournament. */
.sheet { border-radius: 4px; background: var(--paper); color: var(--ink); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35); overflow: hidden; }
.sheet-head { display: grid; grid-template-columns: 1fr 86px 86px; gap: 0; padding: 8px 14px 6px; border-bottom: 2px solid var(--ink); font: 600 14px/1.3 var(--sans); }
.sheet-head span:first-child { font-style: normal; }
.moves {
  margin: 0; padding: 0 14px 6px; min-height: 96px; max-height: 236px; overflow-y: auto;
  list-style: none; counter-reset: move;
  font: 15px/1 var(--sans); font-variant-numeric: tabular-nums;
}
.moves li { counter-increment: move; display: grid; grid-template-columns: 1fr 86px 86px; align-items: center; height: 28px; border-bottom: 1px solid var(--paper-line); }
.moves li::before { content: counter(move) "."; color: #8a7d62; }
.moves .ply { font-weight: 600; }
.moves:empty::before { content: "The first move starts the sheet."; display: block; padding-top: 12px; color: #8a7d62;  }

.chat h2 { display: flex; justify-content: space-between; align-items: baseline; }
.chat-log { list-style: none; margin: 0; padding: 8px 10px; min-height: 60px; max-height: 150px; overflow-y: auto; border-radius: 8px; background: var(--felt); font-size: 14px; display: flex; flex-direction: column; gap: 3px; overflow-wrap: anywhere; }
.chat-log:empty::before { content: "No messages yet"; color: var(--muted); }
.chat-log .who { color: var(--muted); font-weight: 600; margin-right: 6px; }
.chat-log .me .who { color: var(--gold); }
.chat-form { display: flex; gap: 8px; }
.chat-form input { flex: 1; min-width: 0; }
.voice { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.voice audio { display: none; }

/* ---------- tournaments ---------- */
.hero {
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  padding: 26px 28px; margin-bottom: 20px;
  border-radius: 16px; border: 1px solid #1c0e06;
  background:
    conic-gradient(from 90deg at 50% 50%, rgba(233,196,106,0.05) 25%, transparent 0 50%, rgba(233,196,106,0.05) 0 75%, transparent 0) 100% 0 / 56px 56px,
    var(--felt-2);
}
.hero-sub { margin: 8px 0 0; max-width: 46ch; color: var(--muted); }
.hero-clock { display: flex; flex-direction: column; align-items: flex-end; padding: 10px 16px; border-radius: 10px; background: var(--paper); color: var(--ink); }
.hero-clock-label { font: 600 12px/1.3 var(--display); }
.hero-clock-time { font: 700 32px/1.05 var(--display); font-variant-numeric: tabular-nums; }
.page-lead { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.page-lead .note { flex: 1 1 320px; max-width: 62ch; font-size: 14px; }
.page-lead .btn { flex: none; }
.tourney-cols { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.tourney-cols:has(#standings-box[hidden]) { grid-template-columns: minmax(0, 1fr); }
.tourney-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.tourney-list li { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 12px; background: var(--felt-2); border: 1px solid var(--line); }
.tourney-list li.live { border-color: var(--gold); box-shadow: inset 4px 0 0 var(--gold); }
.t-info { flex: 1; min-width: 0; }
.t-name { font: 600 15px/1.25 var(--display); }
.t-when { margin-top: 2px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tourney-list .btn { flex: none; }
.chart { padding: 16px 18px; border-radius: 4px; background: var(--paper); color: var(--ink); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35); }
.chart h2 { padding-bottom: 8px; border-bottom: 2px solid var(--ink); }
.standings { margin: 0; padding: 0 0 0 26px; font: 15px/1 var(--sans); }
.standings li { padding: 9px 0; border-bottom: 1px solid var(--paper-line); }
.standings li::marker { color: #8a7d62; }
.standings li.me { font-weight: 700; }
.standings .pts { float: right; font-variant-numeric: tabular-nums; }
.standings:empty::before { content: "Nobody has joined yet."; display: block; margin-left: -26px; padding: 10px 0; color: #8a7d62;  }
.empty { margin: 0; padding: 22px; border-radius: 12px; border: 1px dashed var(--line); color: var(--muted); }

/* ---------- rankings ---------- */
.ranks { list-style: none; margin: 0; padding: 0; counter-reset: rank; border-radius: 12px; border: 1px solid var(--line); background: var(--felt-2); overflow: hidden; }
.ranks:empty { display: none; }
.ranks li { counter-increment: rank; display: grid; grid-template-columns: 44px minmax(0, 1fr) auto 64px; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.ranks li:last-child { border-bottom: 0; }
.ranks li::before { content: counter(rank); font: 600 16px/1 var(--display); color: var(--muted); text-align: center; }
.ranks li:nth-child(-n+3)::before { color: var(--gold); }
.ranks li.me { background: var(--felt-3); }
.r-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-record { font-size: 13px; color: var(--muted); white-space: nowrap; }
.r-rating { font: 600 16px/1 var(--display); font-variant-numeric: tabular-nums; text-align: right; }

/* ---------- boards ---------- */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; }
.swatch { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--felt-2); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.swatch:hover { border-color: var(--muted); }
.swatch.chosen { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
.mini-board { display: grid; grid-template-columns: repeat(4, 1fr); aspect-ratio: 1; border-radius: 6px; overflow: hidden; }
.mini-board .sq { cursor: inherit; aspect-ratio: 1; }
.swatches.wide { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.piece-strip { display: grid; grid-template-columns: repeat(3, 1fr); border-radius: 6px; overflow: hidden; }
.piece-strip .sq { cursor: inherit; aspect-ratio: 1; }
h2.section { margin: 26px 0 12px; font-size: 22px; }
h2.section:first-of-type { margin-top: 0; }
.swatch-name { font: 600 14px/1.2 var(--display); }
.swatch-state { font-size: 13px; color: var(--muted); }
.swatch.chosen .swatch-state { color: var(--gold); }
.sr-field { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* ---------- wallet ---------- */
.wallet { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 24px; align-items: start; margin-top: 18px; }
.wallet-card { display: flex; flex-direction: column; gap: 12px; padding: 22px; border-radius: 16px; border: 1px solid #1c0e06; background: var(--felt-2); }
.balance-label { font: 600 12px/1.3 var(--display); color: var(--muted); }
.balance { font: 700 42px/1 var(--display); color: var(--gold); font-variant-numeric: tabular-nums; }
.wallet-history h2 { margin-bottom: 10px; }
.wallet-log { list-style: none; margin: 0; padding: 0; border-radius: 12px; border: 1px solid var(--line); background: var(--felt-2); font-size: 14px; }
.wallet-log li { display: flex; justify-content: space-between; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.wallet-log li:last-child { border-bottom: 0; }
.wallet-log li span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; }
.wallet-log:empty::before { content: "Deposits, entries and prizes will show here."; display: block; padding: 14px; color: var(--muted); }

/* ---------- play mode switch ---------- */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 10px; background: var(--felt); border: 1px solid var(--line); }
.seg-btn { padding: 9px 8px; border: 0; border-radius: 7px; background: none; color: var(--muted); font: 600 14px/1.3 var(--sans); cursor: pointer; }
.seg-btn:hover { color: var(--text); }
.seg-btn[aria-pressed="true"] { background: var(--gold); color: var(--gold-ink); }
.seg-btn:disabled { opacity: 0.45; cursor: default; }
.seg-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.seg:has(.seg-btn[hidden]) { display: none; }
.online, .practice { display: flex; flex-direction: column; gap: 10px; }
.option { margin-top: 22px; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--felt-2); font-size: 15px; color: var(--text); max-width: 62ch; }
.option input { width: 18px; height: 18px; accent-color: var(--gold); flex: none; }

/* ---------- checkmate finishes ----------
   One overlay sits on top of the board. Each mating piece gets its own effect. */
.board-wrap { position: relative; width: var(--size); height: var(--size); margin: 9px 0; isolation: isolate; }
.board-wrap::before { content: ""; position: absolute; inset: -9px; z-index: -1; border-radius: 16px; background: var(--frame); box-shadow: 0 24px 50px rgba(0, 0, 0, 0.7); }
.fx { position: absolute; inset: 0; border-radius: 6px; overflow: hidden; pointer-events: none; z-index: 3; }
.fx i { position: absolute; display: block; }
.fx-flash { inset: 0; background: radial-gradient(circle at var(--kx) var(--ky), rgba(255, 236, 170, 0.9), rgba(255, 236, 170, 0) 55%); animation: fx-flash 0.9s ease-out both; }
.fx-ring {
  left: var(--kx); top: var(--ky); width: 12.5%; aspect-ratio: 1; margin: -6.25% 0 0 -6.25%;
  border-radius: 50%; border: 4px solid var(--gold);
  animation: fx-ring 1.1s cubic-bezier(0.1, 0.7, 0.3, 1) var(--t, 150ms) both;
}
.fx-ray {
  left: var(--px); top: var(--py); width: 160%; height: 2.2%; margin-top: -1.1%;
  transform-origin: 0 50%;
  background: linear-gradient(90deg, #fff6d0, var(--gold) 30%, rgba(233, 196, 106, 0));
  animation: fx-ray 1s cubic-bezier(0.2, 0.8, 0.2, 1) var(--t, 0ms) both;
}
.fx-beam { background: linear-gradient(90deg, rgba(255, 255, 255, 0), #fff 50%, rgba(255, 255, 255, 0)); animation: fx-beam-h 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.fx-beam.h { left: 0; right: 0; top: var(--py); height: 12.5%; margin-top: -6.25%; }
.fx-beam.v { top: 0; bottom: 0; left: var(--px); width: 12.5%; margin-left: -6.25%; background: linear-gradient(180deg, rgba(255, 255, 255, 0), #fff 50%, rgba(255, 255, 255, 0)); animation-name: fx-beam-v; }
.fx-slash {
  left: var(--kx); top: var(--ky); width: 300%; height: 1.6%; margin: -0.8% 0 0 -150%;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), #fff 35%, #9fe8ff 50%, #fff 65%, rgba(255, 255, 255, 0));
  animation: fx-slash 0.8s cubic-bezier(0.7, 0, 0.2, 1) var(--t, 0ms) both;
}
.fx-spark {
  left: var(--px); top: var(--py); width: 3.4%; aspect-ratio: 1; margin: -1.7% 0 0 -1.7%;
  background: var(--gold);
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  animation: fx-spark 1.1s cubic-bezier(0.1, 0.7, 0.3, 1) var(--t, 0ms) both;
}
.fx-card {
  left: 0; right: 0; top: 50%; transform: translateY(-50%);
  display: flex !important; flex-direction: column; align-items: center; gap: 2px;
  padding: 3.5% 4%;
  background: rgba(11, 11, 13, 0.9);
  border-top: 2px solid var(--gold); border-bottom: 2px solid var(--gold);
  color: var(--text); text-align: center;
  animation: fx-card 2.6s ease both;
}
.fx-card b { font: 700 clamp(26px, calc(var(--size) / 11), 68px)/1.05 var(--display); letter-spacing: 0.5px; color: var(--gold); }
.fx-card span { font: 700 clamp(14px, calc(var(--size) / 30), 24px)/1.3 var(--display); }

.piece.fx-fall { animation: fx-fall 0.9s cubic-bezier(0.5, 0, 0.8, 0.4) 0.35s both; transform-origin: 50% 85%; }
.piece.fx-fallen { transform: rotate(88deg) translateX(8%); transform-origin: 50% 85%; opacity: 0.6; filter: grayscale(1); }
.piece.fx-hop { animation: fx-hop 0.5s ease-out var(--t, 500ms) 2 both; }
.piece.fx-hero { z-index: 2; }
.piece.fx-hero-q { animation: fx-hero-q 1.4s ease both; }
.piece.fx-hero-r { animation: fx-hero-r 0.7s cubic-bezier(0.5, 0, 1, 0.5) both; }
.piece.fx-hero-b { animation: fx-hero-b 0.9s ease both; }
.piece.fx-hero-n { animation: fx-hero-n 1.3s ease both; }
.piece.fx-hero-p { animation: fx-hero-p 1.6s ease both; }
.piece.fx-hero-k { animation: fx-hero-q 1.4s ease both; }
.board-wrap.shake .board { animation: fx-shake 0.55s linear both; }

@keyframes fx-flash { from { opacity: 0.95; } to { opacity: 0; } }
@keyframes fx-ring { from { transform: scale(0.3); opacity: 1; } to { transform: scale(7); opacity: 0; } }
@keyframes fx-ray {
  0% { transform: rotate(var(--a)) scaleX(0); opacity: 1; }
  55% { transform: rotate(var(--a)) scaleX(1); opacity: 1; }
  100% { transform: rotate(var(--a)) scaleX(1); opacity: 0; }
}
@keyframes fx-beam-h { 0% { transform: scaleX(0); opacity: 1; } 50% { transform: scaleX(1); opacity: 0.95; } 100% { transform: scaleX(1) scaleY(0.1); opacity: 0; } }
@keyframes fx-beam-v { 0% { transform: scaleY(0); opacity: 1; } 50% { transform: scaleY(1); opacity: 0.95; } 100% { transform: scaleY(1) scaleX(0.1); opacity: 0; } }
@keyframes fx-slash {
  0% { transform: rotate(var(--a)) scaleX(0); opacity: 1; }
  45% { transform: rotate(var(--a)) scaleX(1); opacity: 1; }
  100% { transform: rotate(var(--a)) scaleX(1) scaleY(0.2); opacity: 0; }
}
@keyframes fx-spark {
  0% { transform: rotate(var(--a)) translateX(0) scale(0.4); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: rotate(var(--a)) translateX(620%) scale(1.3) rotate(180deg); opacity: 0; }
}
@keyframes fx-card {
  0%, 22% { opacity: 0; transform: translateY(-50%) scaleY(0.2); }
  32%, 82% { opacity: 1; transform: translateY(-50%) scaleY(1); }
  100% { opacity: 0; transform: translateY(-50%) scaleY(1); }
}
@keyframes fx-fall {
  0% { transform: rotate(0); opacity: 1; filter: none; }
  25% { transform: rotate(-14deg); }
  75% { transform: rotate(96deg) translateX(8%); }
  88% { transform: rotate(82deg) translateX(8%); }
  100% { transform: rotate(88deg) translateX(8%); opacity: 0.6; filter: grayscale(1); }
}
@keyframes fx-hop { 0%, 100% { transform: translateY(0); } 45% { transform: translateY(-24%); } }
@keyframes fx-hero-q {
  0% { transform: scale(1); filter: none; }
  30% { transform: scale(1.5) rotate(-6deg); filter: drop-shadow(0 0 10px #ffe9a8) drop-shadow(0 0 22px var(--gold)); }
  60% { transform: scale(1.35) rotate(5deg); filter: drop-shadow(0 0 10px #ffe9a8) drop-shadow(0 0 22px var(--gold)); }
  100% { transform: scale(1); filter: none; }
}
@keyframes fx-hero-r {
  0% { transform: translateY(0); }
  40% { transform: translateY(-55%) scale(1.15); }
  70% { transform: translateY(0) scale(1.25, 0.72); }
  85% { transform: translateY(-6%) scale(0.95, 1.08); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes fx-hero-b {
  0% { transform: rotate(0); }
  30% { transform: rotate(-38deg) scale(1.2); filter: drop-shadow(0 0 10px #9fe8ff); }
  55% { transform: rotate(32deg) scale(1.2); filter: drop-shadow(0 0 10px #9fe8ff); }
  100% { transform: rotate(0) scale(1); filter: none; }
}
@keyframes fx-hero-n {
  0%, 46%, 100% { transform: translateY(0) rotate(0); }
  20% { transform: translateY(-70%) rotate(-22deg) scale(1.2); }
  36% { transform: translateY(0) rotate(0) scale(1.1, 0.85); }
  68% { transform: translateY(-45%) rotate(-14deg) scale(1.12); }
  84% { transform: translateY(0) rotate(0) scale(1.06, 0.9); }
}
@keyframes fx-hero-p {
  0% { transform: scale(1); filter: none; }
  35% { transform: scale(2); filter: drop-shadow(0 0 12px #ffe9a8) drop-shadow(0 0 26px var(--gold)); }
  70% { transform: scale(1.8) rotate(8deg); filter: drop-shadow(0 0 12px #ffe9a8); }
  100% { transform: scale(1.25); filter: drop-shadow(0 0 8px var(--gold)); }
}
@keyframes fx-shake {
  0%, 100% { transform: translate(0, 0); }
  15% { transform: translate(-1.2%, 0.6%); } 30% { transform: translate(1%, -0.8%); }
  45% { transform: translate(-0.8%, -0.5%); } 60% { transform: translate(0.7%, 0.6%); } 80% { transform: translate(-0.3%, 0.2%); }
}

/* ---------- dialogs ---------- */
.promo { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.78); z-index: 10; }
.promo-box { padding: 18px 20px 20px; border-radius: 14px; background: var(--felt-2); border: 1px solid var(--line); text-align: center; }
.promo-box p { margin: 0 0 12px; font: 600 16px/1.3 var(--display); }
.promo-choices { display: flex; gap: 10px; }
.promo-choices button { width: 76px; height: 76px; border-radius: 10px; border: 1px solid var(--line); background: var(--dark); cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.promo-choices button:hover, .promo-choices button:focus-visible { outline: 3px solid var(--gold); }
.promo-choices .piece { width: 60px; height: 60px; }
.auth-box { width: min(380px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 12px; text-align: left; }

/* ---------- narrower screens ---------- */
@media (max-width: 1080px) {
  :root { --size: min(calc(100vw - var(--rail) - 64px), calc(100vh - var(--bar) - 130px), 720px); }
  .view-play { grid-template-columns: var(--size); }
  .side { margin-top: 0; }
  .tourney-cols, .wallet { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 720px) {
  :root { --bar: 54px; --size: min(calc(100vw - 16px), calc(100vh - 200px)); }
  .topbar { padding: 0 10px; }
  .brand-word { font-size: 18px; }
  .brand-mark { width: 28px; height: 28px; }
  .account-name { display: none; }
  .tabs {
    top: auto; left: 0; right: 0; bottom: 0; width: auto;
    flex-direction: row; gap: 0;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
    border-right: 0; border-top: 1px solid var(--line);
  }
  .tab { flex: 1; padding: 6px 2px; font-size: 11px; border-radius: 8px; min-width: 0; }
  .tab svg { width: 22px; height: 22px; }
  .tab .dot { right: calc(50% - 18px); top: 4px; }
  .stage { margin-left: 0; padding: 10px 8px calc(84px + env(safe-area-inset-bottom, 0px)); }
  .view-page { padding: 6px 6px 0; }
  h1 { font-size: 28px; }
  .hero { padding: 18px; }
  .hero-clock { align-items: flex-start; }
  .hero-clock-time { font-size: 32px; }
  .banner { padding: 14px; gap: 12px; }
  .banner-coin { width: 48px; height: 48px; }
  .banner-title { font-size: 20px; }
  .banner-actions { width: 100%; }
  .banner-actions .btn { flex: 1; }
  .ranks li { grid-template-columns: 30px minmax(0, 1fr) 56px; }
  .r-record { display: none; }
  .balance { font-size: 44px; }
  .player { height: 36px; }
}

@media (prefers-reduced-motion: no-preference) {
  .tab, .btn, .chip, .swatch { transition: background-color 0.12s, border-color 0.12s, color 0.12s; }
}

/* ---------- Kingdom: wood, parchment and banners ---------- */
h1 { color: var(--gold); text-shadow: 0 2px 0 #3b1d05; }
.topbar { background: var(--wood); border-bottom: 3px solid var(--line); box-shadow: inset 0 -6px 12px rgba(0, 0, 0, 0.35); }
.brand-word { color: #fff3d6; text-shadow: 0 2px 0 #2a160c; }
.brand-accent { color: var(--gold); }
.account-name { color: #fff3d6; text-shadow: 0 1px 0 #2a160c; }
.chip { border: 2px solid var(--line); background: #2a160c; color: var(--gold); }
.chip:not(.install):hover { background: #3d2212; }

.btn {
  border: 3px solid var(--line); border-radius: 12px; background: var(--wood); color: #fff3d6;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.18), 0 4px 0 var(--line);
}
.btn:hover { border-color: var(--line); filter: brightness(1.08); }
.btn:active { transform: translateY(2px); box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.18), 0 2px 0 var(--line); }
.btn.small { border-width: 2px; border-radius: 10px; box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.18), 0 3px 0 var(--line); }
.btn.quiet { background: #2a160c; }
.btn.primary, .btn.primary:hover {
  background: var(--crimson); border-color: var(--line); color: #ffe9b0;
  box-shadow: inset 0 0 0 2px var(--gold), 0 4px 0 #5c0a0f, 0 4px 0 3px var(--line);
}
.btn.big { font: 700 18px/1.2 var(--display); letter-spacing: 0.5px; }
.card, .tourney-list li, .ranks, .swatch, .option, .wallet-log, .status, .promo-box, .wallet-card, .hero, .banner {
  border: 3px solid var(--line); background: var(--felt-2);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.07), 0 5px 0 var(--line);
}
.status.over { background: var(--gold); border-color: var(--line); color: var(--gold-ink); }
.field select, .field input, .chat-form input, .chat-log, .seg { background: #2a160c; border: 2px solid var(--line); }
.seg-btn[aria-pressed="true"] { background: var(--gold); color: var(--gold-ink); }
.clock { background: #2a160c; border: 2px solid var(--line); }
.clock.running { background: var(--paper); color: var(--ink); }
.sheet, .chart { border: 3px solid var(--line); border-radius: 8px; box-shadow: inset 0 0 26px rgba(140, 90, 30, 0.35), 0 5px 0 var(--line); }
.hero-clock { background: var(--paper); color: var(--ink); border: 3px solid var(--line); }
.board-wrap::before { border: 3px solid var(--line); border-radius: 10px; box-shadow: 0 10px 0 #3b2110, 0 10px 0 3px var(--line), 0 30px 40px rgba(0, 0, 0, 0.55); }
.board, .fx { border-radius: 2px; }
.swatch.chosen { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold), 0 5px 0 var(--line); }
.tourney-list li.live { border-color: var(--gold); box-shadow: inset 5px 0 0 var(--gold), 0 5px 0 var(--line); }
.ranks li { border-bottom: 2px solid var(--line); }
.wallet-log li { border-bottom: 2px solid var(--line); }
.balance, .pot-amount { text-shadow: 0 3px 0 #3b1d05; }
.fx-card { background: rgba(42, 22, 12, 0.92); }

/* prize display on the Battle screen during a tournament */
.pot { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 2px; padding: 4px 2px 0; }
.pot-label { font-size: 13px; color: var(--muted); }
.pot-row { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.pot-amount { font: 900 clamp(38px, 9vw, 60px)/1 var(--display); color: var(--gold); font-variant-numeric: tabular-nums; }
.pot-side { font-size: 13px; color: var(--muted); }
.pot-bar { margin-top: 10px; height: 10px; border-radius: 5px; background: #2a160c; border: 2px solid var(--line); overflow: hidden; }
.pot-fill { height: 100%; width: 0; background: linear-gradient(#ffe27a, #d99a1f); }
.pot-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 4px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* section tabs: wooden planks, the current one a gold plate */
.tabs { background: var(--wood); border-right: 3px solid var(--line); box-shadow: inset -6px 0 12px rgba(0, 0, 0, 0.3); }
.tab { color: #fff3d6; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.7); font-weight: 700; border: 3px solid transparent; }
.tab:hover { color: #fff; background: rgba(0, 0, 0, 0.18); }
.tab[aria-current="page"] { background: linear-gradient(#ffe27a, #d99a1f); border-color: var(--line); color: var(--gold-ink); text-shadow: none; box-shadow: 0 3px 0 var(--line); }
.tab .dot { box-shadow: 0 0 0 2px var(--line); }

/* ---------- the Castle (home) ---------- */
body[data-view="home"] #view-home { display: flex; }
.view-home { flex-direction: column; gap: 16px; max-width: 520px; margin: 0 auto; }
.crest-row { display: flex; align-items: center; gap: 12px; }
.crest {
  width: 58px; height: 66px; flex: none; display: flex; align-items: center; justify-content: center;
  background: var(--crimson); border: 3px solid var(--gold); border-radius: 8px 8px 30px 30px; box-shadow: 0 4px 0 var(--line);
}
.crest svg { width: 40px; height: 40px; }
.crest .pf { fill: var(--gold); stroke: #3b1d05; stroke-width: 3.2; }
.crest .pd { stroke: #3b1d05; fill: none; stroke-width: 2.6; }
.crest .pe { fill: #3b1d05; }
.crest-text { display: flex; flex-direction: column; min-width: 0; }
.crest-name { font: 700 22px/1.2 var(--display); color: var(--gold); text-shadow: 0 2px 0 #3b1d05; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crest-sub { font-size: 14px; color: var(--muted); }
.ribbon {
  align-self: center; width: min(100%, 340px); height: 56px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(#c8232c, #8f1219);
  clip-path: polygon(0 0, 100% 0, 94% 50%, 100% 100%, 0 100%, 6% 50%);
}
.ribbon span { font: 700 22px/1 var(--display); color: var(--gold); text-shadow: 0 2px 0 #3b1d05; }
.table3d { height: clamp(210px, 62vw, 300px); display: flex; justify-content: center; perspective: 760px; }
.table3d-board {
  width: clamp(220px, 68vw, 300px); aspect-ratio: 1; align-self: flex-start;
  display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
  transform: rotateX(40deg); transform-origin: 50% 30%;
  border: 10px solid #5a3418; outline: 3px solid var(--line);
  box-shadow: 0 20px 0 #3b2110, 0 20px 0 3px var(--line), 0 46px 40px rgba(0, 0, 0, 0.6);
}
.table3d-board .sq { cursor: default; box-shadow: none; }
.scroll {
  display: grid; grid-template-columns: repeat(3, auto); justify-content: space-between; gap: 10px;
  padding: 12px 16px; border-radius: 10px; background: linear-gradient(#f6e6bd, #e6cf98); color: var(--ink);
  border: 3px solid var(--line); box-shadow: inset 0 0 30px rgba(140, 90, 30, 0.35), 0 6px 0 var(--line);
}
.scroll > div { display: flex; flex-direction: column; }
.scroll > div:nth-child(2) { align-items: center; }
.scroll > div:nth-child(3) { align-items: flex-end; }
.scroll-label { font-size: 12px; font-weight: 800; }
.scroll-value { font: 700 26px/1.15 var(--display); font-variant-numeric: tabular-nums; }
.scroll-value.gold { color: #8a5200; }
.battle {
  height: 92px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border-radius: 16px; border: 3px solid var(--line); background: var(--crimson); cursor: pointer;
  box-shadow: inset 0 0 0 3px var(--gold), 0 8px 0 #5c0a0f, 0 8px 0 3px var(--line);
}
.battle:hover { filter: brightness(1.08); }
.battle:active { transform: translateY(4px); box-shadow: inset 0 0 0 3px var(--gold), 0 4px 0 #5c0a0f, 0 4px 0 3px var(--line); }
.battle:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.battle-title { font: 900 36px/1 var(--display); color: var(--gold); text-shadow: 0 3px 0 #3b1d05; text-transform: uppercase; letter-spacing: 1px; }
.battle-sub { font: 800 13px/1.3 var(--sans); color: #ffe9b0; }
.plank-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn.plank { flex: none; min-height: 58px; white-space: normal; font: 700 16px/1.25 var(--display); }

@media (max-width: 720px) {
  :root { --size: min(calc(100vw - 36px), calc(100vh - 230px)); }
  .board-col { margin: 0 auto; }
  .tabs { border-right: 0; border-top: 3px solid var(--line); box-shadow: inset 0 6px 12px rgba(0, 0, 0, 0.3); }
  #tab-ranks { display: none; }       /* reached from the Castle on a phone */
  .stage { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
  .view-home { gap: 14px; padding: 4px 6px 0; }
  .battle-title { font-size: 32px; }
}
@media (min-width: 721px) {
  #home-heroes { display: none; }
}
html, body { overflow-x: hidden; }
@media (max-width: 720px) {
  .topbar { gap: 6px; }
  .brand { gap: 6px; flex: 1 1 auto; }
  .brand-word { font-size: 15px; overflow: hidden; text-overflow: ellipsis; }
  .account { gap: 6px; flex: none; }
  .chip { padding: 5px 9px; }
  .topbar .btn.small { padding: 5px 8px; font-size: 12px; }
}
@media (max-width: 380px) {
  .brand-word { display: none; }
}

/* ---------- focus mode: just the board, the clocks and the game buttons ---------- */
body.focus { --size: min(calc(100vw - 30px), calc(100vh - 176px), 1100px); }
body.focus .topbar, body.focus .tabs, body.focus .banner, body.focus .pot,
body.focus .side > :not(.buttons):not(.status) { display: none !important; }
body.focus .stage { margin-left: 0; padding: 6px 6px 16px; }
body.focus .view-play { grid-template-columns: var(--size); gap: 10px; }
body.focus .side { margin-top: 0; }
body.focus .status { padding: 8px 12px; }
body.focus #focus { background: var(--gold); color: var(--gold-ink); text-shadow: none; }
@media (min-width: 900px) {
  /* on a wide screen the buttons move beside the board so it can use the full height */
  body.focus { --size: min(calc(100vw - 290px), calc(100vh - 112px), 1100px); }
  body.focus .view-play { grid-template-columns: var(--size) 220px; gap: 10px 22px; }
  body.focus .side { margin-top: 40px; }
  body.focus .buttons { flex-direction: column; }
}

/* focus mode, bigger: the board runs edge to edge and the name rows shrink */
body.focus .player { height: 30px; padding: 0 8px; font-size: 14px; }
body.focus .clock { font-size: 17px; padding: 1px 8px; min-width: 70px; }
@media (max-width: 899px) {
  body.focus { --size: min(100vw, calc(100vh - 150px)); }
  body.focus .stage { padding: 0 0 12px; }
  body.focus .view-play { gap: 6px; justify-content: center; }
  body.focus .board-wrap { margin: 0; }
  body.focus .board-wrap::before { display: none; }
  body.focus .side { padding: 0 8px; }
}
@media (min-width: 900px) {
  body.focus { --size: min(calc(100vw - 270px), calc(100vh - 84px), 1400px); }
  body.focus .stage { padding: 2px 6px 6px; }
  body.focus .side { margin-top: 30px; }
}
/* a phone turned sideways: the board takes the full height, buttons sit beside it */
@media (max-width: 899px) and (orientation: landscape) {
  body.focus { --size: min(calc(100vh - 66px), calc(100vw - 200px)); }
  body.focus .view-play { grid-template-columns: var(--size) minmax(150px, 190px); gap: 6px 12px; }
  body.focus .side { margin-top: 30px; padding: 0; }
  body.focus .buttons { flex-direction: column; }
}
