/* chess — phone first. The house's glass (gems' stylesheet, conquest's
 * recipe) on a warm ground: cards, buttons and segmented controls
 * translucent with a hairline edge, 18px card corners, and GOLD MEANS YOU —
 * the primary button, the supporter's mark, your row on a board, the piece
 * in your hand.
 *
 * TWO THEMES, AND LIGHT IS THE BASE. Dark is a token swap in two guarded
 * blocks — the media query for "system", the attribute for a choice.
 * Nothing outside those blocks names a literal colour. THE BOARD IS THE ONE
 * EXCEPTION: its squares are the same wood in both themes (a supporter may
 * pick another set), because a board that changes colour with the theme is
 * a board you learn twice.
 */

:root {
  --bg:       #e6e1d6;
  --panel:    #ffffff;
  --panel-2:  #f6f4ef;
  --glass:    rgba(255, 255, 255, .78);
  --glass-2:  rgba(255, 255, 255, .55);
  --heart:    #e0596e;
  --gold:     #d9a520;
  --gold-lit: #ffd45c;
  --line:     rgba(60, 60, 67, .16);
  --line-2:   rgba(60, 60, 67, .08);
  --ink:      #000000;
  --ink-2:    #3c3c43;
  --dim:      #8a8a8e;
  --dim-2:    #b0b0b6;
  --pill:     #efeff0;
  --good:     #1a9e4b;
  --warn:     #b8730a;
  --bad:      #e5322b;
  --link:     #007aff;
  --shadow:   0 1px 2px rgba(0,0,0,.04), 0 6px 20px rgba(0,0,0,.05);

  --sq-light: #f0d9b5;
  --sq-dark:  #b58863;
  --sq-last:  rgba(255, 220, 60, .55);
  --sq-sel:   rgba(217, 165, 32, .75);
  --sq-check: rgba(229, 50, 43, .7);

  --r-card: 18px;
  --r-mid:  14px;
  --r-sm:   10px;

  --font: -apple-system, BlinkMacSystemFont, system-ui, "SF Pro Text", "Helvetica Neue", sans-serif;
  --font-num: ui-rounded, -apple-system, "SF Pro Rounded", system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  /* the name, wherever it is the app's name (the sign-in wordmark, Home's
     title): New York, the phone's own serif — the owner's pick 2026-09-27 */
  --font-word: ui-serif, "New York", Georgia, serif;
  /* the wordmark's pawn: black beside black ink, white beside white */
  --wm-light: inline; --wm-dark: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1714; --panel: #1c1c1e; --glass: rgba(28, 28, 30, .86); --glass-2: rgba(44, 44, 46, .75);
    --gold: #e8c05a; --gold-lit: #ffd77a; --panel-2: #2c2c2e;
    --line: rgba(84, 84, 88, .5); --line-2: rgba(84, 84, 88, .28);
    --ink: #ffffff; --ink-2: #ebebf5; --dim: #8e8e93; --dim-2: #636366; --pill: #2c2c2e;
    --good: #30d158; --warn: #ffd60a; --bad: #ff453a; --link: #0a84ff;
    --shadow: 0 1px 2px rgba(0,0,0,.5), 0 6px 20px rgba(0,0,0,.4);
    --wm-light: none; --wm-dark: inline;
  }
}
:root[data-theme="dark"] {
  --bg: #1a1714; --panel: #1c1c1e; --glass: rgba(28, 28, 30, .86); --glass-2: rgba(44, 44, 46, .75);
  --gold: #e8c05a; --gold-lit: #ffd77a; --panel-2: #2c2c2e;
  --line: rgba(84, 84, 88, .5); --line-2: rgba(84, 84, 88, .28);
  --ink: #ffffff; --ink-2: #ebebf5; --dim: #8e8e93; --dim-2: #636366; --pill: #2c2c2e;
  --good: #30d158; --warn: #ffd60a; --bad: #ff453a; --link: #0a84ff;
  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 6px 20px rgba(0,0,0,.4);
  --wm-light: none; --wm-dark: inline;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
}
body {
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
input, textarea { -webkit-user-select: text; user-select: text; }

:root { --glass-t: 20px; }
:root { color-scheme: light dark; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }

/* ── shell ─────────────────────────────────────────────────────────────── */

main { padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
/* THE PAGE IS LOCKED WHILE A BOARD SHOWS AND SCROLLS OTHERWISE (IOS.md §15). */
html.locked, html.locked body { overflow: hidden; height: 100%; min-height: 0; overscroll-behavior: none; }
html.locked main { padding-bottom: 0; }
body:has(#sheet-menu:not([hidden])) #app { position: fixed; top: 0; left: 0; right: 0; visibility: hidden; }

.view {
  padding: calc(8px + var(--glass-t) + env(safe-area-inset-top, 0px)) 16px 24px;
  max-width: 560px;
  margin: 0 auto;
}
.view-head { padding: 12px 4px 18px; }
.view-head.bar { display: flex; align-items: center; gap: 10px; }
.bar-title { flex: 1; min-width: 0; }
.icon-btn.glass { background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: .5px solid var(--line); box-shadow: var(--shadow); }
.icon-btn svg { display: block; }
.view-head h1 { margin: 0; font-size: 34px; font-weight: 700; letter-spacing: -.6px; }
#view-home .view-head h1 { font-family: var(--font-word); font-weight: 600; letter-spacing: -.3px; }
.view-sub { margin: 4px 0 0; color: var(--dim); font-size: 15px; }

h2.sec { margin: 22px 4px 10px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--dim); }
h3.sub { margin: 18px 4px 8px; font-size: 15px; font-weight: 600; }

.card, .overlay-card, .gate-card, .icon-btn, .seg {
  background: var(--glass); backdrop-filter: blur(12px) saturate(140%); -webkit-backdrop-filter: blur(12px) saturate(140%);
  border: .5px solid var(--line); box-shadow: var(--shadow);
}
.card { border-radius: var(--r-card); overflow: hidden; }
.fineprint { margin: 14px 6px 0; color: var(--dim); font-size: 12.5px; line-height: 1.55; }
.fineprint strong { color: var(--ink-2); font-weight: 600; }

/* ── buttons ───────────────────────────────────────────────────────────── */

.btn {
  appearance: none; font: inherit; font-size: 16px; font-weight: 600;
  padding: 12px 18px; border: .5px solid var(--line); border-radius: var(--r-mid);
  background: var(--glass-2); color: var(--ink);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow); cursor: pointer;
}
.btn:active { opacity: .7; }
.btn-primary { background: var(--gold); color: #1a1200; border-color: transparent; }
.btn-quiet   { background: transparent; border-color: transparent; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; color: var(--link); }
.btn-quiet.danger { color: var(--bad); }
.btn-wide    { display: block; width: 100%; margin-top: 18px; padding: 14px; font-size: 17px; }
.btn:disabled { opacity: .4; }

.icon-btn {
  appearance: none; font: inherit; font-size: 20px; line-height: 1;
  width: 40px; height: 40px; padding: 0; display: grid; place-items: center;
  border-radius: 20px; color: var(--ink); cursor: pointer;
}
.icon-btn:active { opacity: .7; }

/* ── the gate ──────────────────────────────────────────────────────────── */

.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.gate-card { max-width: 340px; text-align: center; padding: 28px 22px; border-radius: var(--r-card); }
/* The wordmark: the icon's pawn standing beside the name on its baseline, in
 * place of the icon over the word (the owner's pick, 2026-09-27). The pawn's
 * box is its piece file's whole square; the margins take back the square's
 * empty sides, so the ink sits a letter's gap from the C. */
.wordmark { margin: 0 0 10px; font-family: var(--font-word); font-size: 46px; font-weight: 600; letter-spacing: -.01em; line-height: 1.15; white-space: nowrap; }
.wm-pawn { width: 1.435em; height: 1.435em; vertical-align: baseline; margin: 0 -.242em 0 -.371em; position: relative; top: .024em; }
.wm-pawn.on-light { display: var(--wm-light); }
.wm-pawn.on-dark { display: var(--wm-dark); }
.gate-sub { margin: 0 0 24px; color: var(--dim); font-size: 15px; line-height: 1.5; }
.gate-note { margin-top: 16px; color: var(--dim); font-size: 12.5px; line-height: 1.5; }
.gate-msg { margin: 0 0 18px; padding: 11px 13px; border-radius: var(--r-mid); background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); font-size: 13px; line-height: 1.45; text-align: left; }

.pill {
  display: block; width: 100%; margin: 0 0 12px; font: inherit; font-size: 13.5px; font-weight: 600;
  padding: 10px 14px; border: 0; border-radius: 999px;
  background: color-mix(in srgb, var(--gold) 18%, var(--panel)); color: var(--link); cursor: pointer;
}
.pwa-gate .pwa-primary, .pwa-gate .pwa-icon { background: var(--gold); color: #1a1200; }
.pwa-gate .pwa-card { box-shadow: var(--shadow); }

/* ── the home ──────────────────────────────────────────────────────────── */

.puzzle-card {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  font: inherit; color: inherit; cursor: pointer; padding: 16px 16px 16px 14px; border-radius: var(--r-card);
}
.puzzle-card:active { opacity: .8; }
.pc-art { flex: none; width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center;
  background: conic-gradient(var(--sq-dark) 25%, var(--sq-light) 0 50%, var(--sq-dark) 0 75%, var(--sq-light) 0); box-shadow: inset 0 0 0 1px var(--line-2); }
.pc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.pc-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.pc-state { font-size: 18px; font-weight: 700; letter-spacing: -.2px; }
.pc-rating { color: var(--dim); font-size: 12px; font-family: var(--font-mono); white-space: nowrap; }
.pc-cta { font-size: 13px; color: var(--link); font-weight: 600; line-height: 1.4; }
.puzzle-card.done .pc-cta { color: var(--dim); font-weight: 500; }
.puzzle-card .chev { color: var(--dim); font-size: 24px; line-height: 1; }

/* A game as a row: the opponent, what kind of game, and where it stands. */
.game-rows > .game-row {
  appearance: none; -webkit-appearance: none; display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 16px; background: none; border: 0; border-bottom: 1px solid var(--line-2);
  font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.game-rows > .game-row:last-child { border-bottom: 0; }
.game-rows > .game-row:active { background: var(--pill); }
.gr-pic { flex: none; width: 40px; height: 40px; border-radius: 50%; overflow: hidden; display: grid; place-items: center;
  background: var(--pill); color: var(--dim); font-weight: 700; font-size: 16px; }
.gr-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gr-who { flex: 1; min-width: 0; }
.gr-name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gr-bot { color: var(--dim); font-weight: 400; font-size: 13px; }
.gr-meta { font-size: 12px; color: var(--dim); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gr-right { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.gr-state { font-size: 13px; font-weight: 600; color: var(--dim); }
.gr-state.yours { color: #1a1200; background: var(--gold); padding: 3px 9px; border-radius: 999px; }
.gr-state.won { color: var(--good); } .gr-state.lost { color: var(--bad); } .gr-state.drew { color: var(--dim); }
.gr-cta { color: var(--link); font-weight: 600; font-size: 14px; }
.gr-sub { font-size: 11.5px; color: var(--dim); }

/* Play: two rows that open into forms. */
.play-card .rows, .play-card { }
.play-card > button.row-tap { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; background: none; border: 0; border-bottom: 1px solid var(--line-2); font: inherit; color: inherit; text-align: left; cursor: pointer; appearance: none; -webkit-appearance: none; }
.play-card > button.row-tap:last-child { border-bottom: 0; }
.play-card > button.row-tap:active { background: var(--pill); }
.play-card > button.row-tap[aria-expanded="true"] .chev { transform: rotate(90deg); }
.play-glyph { flex: none; display: flex; align-items: center; width: 44px; height: 34px; }
.play-glyph img + img { margin-left: -12px; }
.play-row .row-k { font-size: 16px; font-weight: 600; }
.play-row .row-v { margin-left: auto; font-size: 12.5px; color: var(--dim); font-weight: 400; text-align: right; }
.play-form { padding: 6px 16px 16px; border-bottom: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font: inherit; font-size: 14px; font-weight: 500; padding: 8px 13px; border-radius: 999px; border: .5px solid var(--line); background: var(--glass-2); color: var(--ink); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--gold); color: #1a1200; border-color: transparent; font-weight: 600; }
.form-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.form-row.form-stack { flex-direction: column; align-items: stretch; gap: 6px; }
.form-row .row-note { margin: 0; }
.play-form .btn-wide { margin-top: 4px; }
.join-code { display: flex; gap: 8px; align-items: center; }
.join-code .name-input { flex: 1; letter-spacing: .12em; text-transform: uppercase; font-family: var(--font-mono); }
.join-code .btn { padding: 10px 16px; }
.bot-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.bot-tile { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 6px; border-radius: 12px; border: .5px solid var(--line); background: var(--glass-2); font: inherit; color: inherit; cursor: pointer; }
.bot-tile img { width: 44px; height: 44px; }
.bot-name { font-size: 13px; font-weight: 600; }
.bot-trait { font-size: 10.5px; color: var(--dim); }
.bot-rec { font-size: 10px; color: var(--dim); font-variant-numeric: tabular-nums; }

/* THE SPEAKER (CLAUDE.md 5e, letters' .snd-g; chess-v25): drawn like the other glyphs,
   crossed out and a shade dimmer when off. */
.snd-g { width: 22px; height: 22px; fill: currentColor; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.snd-g .ol { fill: none; }
.sound-btn[aria-pressed="true"] .snd-off,
.sound-btn[aria-pressed="false"] .snd-on { display: none; }
.sound-btn[aria-pressed="false"] { opacity: .62; }
.sound-btn[hidden] { display: none; }
.bot-tile[aria-pressed="true"] { box-shadow: 0 0 0 2.5px var(--gold); background: color-mix(in srgb, var(--gold) 12%, var(--glass-2)); }
input[type="range"] { width: 100%; accent-color: var(--gold); }

/* ── the board screens ─────────────────────────────────────────────────── */

.view-board {
  display: flex; flex-direction: column; height: 100dvh; box-sizing: border-box;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); padding-left: 10px; padding-right: 10px; overflow: hidden;
}
.game-head { display: flex; align-items: center; gap: 8px; padding: 2px 0 8px; }
.game-status { flex: 1; min-width: 0; margin: 0; font-size: 14px; font-weight: 600; text-align: center; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pz-head { flex: 1; min-width: 0; display: flex; flex-direction: column; text-align: center; }
.pz-head strong { font-size: 15px; }
.pz-head small { font-size: 12px; color: var(--dim); line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pz-clock { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: 15px; font-weight: 600; min-width: 44px; text-align: right; }
.play { flex: 1; display: flex; flex-direction: column; justify-content: center; min-height: 0; gap: 6px; }
.board-wrap { position: relative; width: min(100%, calc(100dvh - 300px)); max-width: 560px; margin: 0 auto; }

/* The solution, move by move, under the puzzle's board; the board gives up the room. */
#view-puzzle.explaining .board-wrap { width: min(100%, calc(100dvh - 330px)); }
.pz-line { max-width: 560px; width: 100%; margin: 0 auto; flex: none; font-size: 13.5px; line-height: 1.4; }
.pz-line-cap { margin: 0 0 4px; color: var(--dim); text-align: center; font-size: 12.5px; }
.pz-moves { list-style: none; margin: 0 auto; padding: 0; display: grid; grid-template-columns: auto 1fr 1fr; column-gap: 6px; max-width: 260px; }
.pz-moves li { display: contents; }
.pz-moves span { padding: 0 5px; border-radius: 5px; }
.pz-moves .pz-cols span { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; }
.pz-n { color: var(--dim); text-align: right; font-variant-numeric: tabular-nums; }
.pz-mine { font-weight: 650; }
.pz-theirs { color: var(--ink-2); }
.pz-moves .now { background: var(--sq-last); color: #1c1c1e; }
.pz-themes { list-style: none; margin: 6px auto 0; padding: 0; max-width: 420px; color: var(--dim); font-size: 12.5px; line-height: 1.4; text-align: center; }
.pz-themes b { color: var(--ink); font-weight: 600; }

/* A player's card above and below the board. */
.side { display: flex; align-items: center; gap: 10px; padding: 2px 4px; min-height: 44px; max-width: 560px; width: 100%; margin: 0 auto; }
.side-pic { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex: none; background: var(--pill); }
.side-online { width: 8px; height: 8px; border-radius: 50%; background: var(--good); flex: none; margin-left: -6px; }
.side-who { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.side-name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-name.waiting { color: var(--dim); font-weight: 500; }
.side-sub { font-size: 12px; color: var(--dim); }
.side-clock { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 600; padding: 4px 10px; border-radius: 10px; background: var(--pill); color: var(--dim); min-width: 78px; text-align: center; }
.side-clock.running { background: var(--ink); color: var(--bg); }
.side-clock.low { color: var(--bad); }
.side-clock.running.low { background: var(--bad); color: #fff; }
.side.to-move .side-name::after { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--gold); margin-left: 6px; vertical-align: middle; }

/* THE BOARD. A square, percentage grid; the pieces fill their squares. */
.cb {
  position: relative; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
  aspect-ratio: 1; width: 100%; border-radius: 6px; overflow: hidden; touch-action: none;
  box-shadow: 0 2px 10px rgba(0,0,0,.18), 0 0 0 1px rgba(0,0,0,.12);
}
.cb.flipped { transform: rotate(180deg); }
.cb.flipped .piece, .cb.flipped .coord, .cb.flipped .promo, .cb.flipped .drag-piece { transform: rotate(180deg); }
.sq { position: relative; }
.sq.light { background: var(--sq-light); }
.sq.dark { background: var(--sq-dark); }
/* A TILED BOARD (Graphite): every square a tile with rounded corners and the
 * ground between them, the way Minesweeper lays its cells. The squares keep
 * their size — the gap is an inset ring in the ground's colour — so taps,
 * pieces and drags are the flat board's; a highlight sits inside the ring. */
:root[data-board-tiles] .cb:not(.is3d) { background: var(--sq-gap); }
:root[data-board-tiles] .cb:not(.is3d) > .sq { border-radius: 5px; box-shadow: inset 0 0 0 1.5px var(--sq-gap); }
:root[data-board-tiles] .cb:not(.is3d) > .sq::before { inset: 1.5px; border-radius: 3.5px; }
.sq.last::before, .sq.sel::before, .sq.check::before, .sq.over::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
}
.sq.last::before { background: var(--sq-last); }
.sq.sel::before { background: var(--sq-sel); }
.sq.check::before { background: radial-gradient(circle, var(--sq-check) 0%, rgba(229,50,43,.4) 45%, transparent 75%); }
.sq.over::before { box-shadow: inset 0 0 0 4px rgba(255,255,255,.65); }
.sq.dot::after { content: ''; position: absolute; left: 35%; top: 35%; width: 30%; height: 30%; border-radius: 50%; background: rgba(20, 20, 20, .22); pointer-events: none; }
.sq.cap::after { content: ''; position: absolute; inset: 0; border-radius: 50%; box-shadow: inset 0 0 0 5px rgba(20, 20, 20, .22); pointer-events: none; }
.piece { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
.piece.ghost { opacity: .3; }
.piece.shake { animation: shake 240ms ease-in-out 2; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(6%); } }
.coord { position: absolute; font-size: 9px; font-weight: 600; opacity: .55; pointer-events: none; font-family: var(--font-mono); z-index: 1; }
.coord.rank { left: 2px; top: 1px; }
.coord.file { right: 2px; bottom: 0; }
.cb:not(.flipped) .coord.for-b, .cb.flipped .coord.for-w { display: none; }
.sq.light .coord { color: var(--sq-dark); }
.sq.dark .coord { color: var(--sq-light); }
.drag-piece { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 6; filter: drop-shadow(0 6px 8px rgba(0,0,0,.35)); }
.promo { position: absolute; top: 0; width: 12.5%; z-index: 7; display: flex; flex-direction: column; background: var(--panel); box-shadow: 0 4px 16px rgba(0,0,0,.35); border-radius: 4px; }
.promo.bottom { top: auto; bottom: 0; flex-direction: column-reverse; }
.promo-pick { padding: 0; border: 0; background: transparent; aspect-ratio: 1; cursor: pointer; }
.promo-pick img { width: 100%; height: 100%; display: block; }
.promo-pick:active { background: var(--pill); }
#view-game.browsing .cb { box-shadow: 0 2px 10px rgba(0,0,0,.18), 0 0 0 2px var(--link); }
.haptic-layer { z-index: 3; }

/* THE 3D BOARD (board3d.js, a supporter's). It sits in the same square box,
 * over the flat board it replaces while it is on; the flat board's squares,
 * its haptic switches and its CSS flip step aside (the camera turns instead). */
.cb.is3d { box-shadow: none; border-radius: 0; overflow: visible; }
.cb.is3d.flipped { transform: none; }
.cb.is3d > .sq, .cb.is3d > .drag-piece, .cb.is3d > .promo, .cb.is3d > .haptic-layer { visibility: hidden; }
.b3d-host { position: absolute; inset: 0; z-index: 8; }
.b3d-promo { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; gap: 4px; padding: 6px; z-index: 9;
  background: var(--panel); border-radius: 12px; box-shadow: 0 4px 16px rgba(0,0,0,.35); }
.b3d-promo .promo-pick { width: 52px; }
.board-art.board-img { background: center / cover no-repeat; }

/* THE CHARACTER'S LINE sits in the flow above (or, flipped, below) its own
 * card, a speech bubble with a tail toward the face — never over the board,
 * which it used to cover (the owner, 2026-09-25). It stays until the next
 * line replaces it or the game is left. */
.bot-say {
  position: relative; max-width: 560px; width: 100%; margin: 0 auto; box-sizing: border-box;
  padding: 8px 12px; border-radius: 12px; background: var(--pill);
  font-size: 13px; line-height: 1.4; font-style: italic; color: var(--ink-2);
  animation: toast-in 180ms ease-out;
}
.bot-say::after {
  content: ''; position: absolute; left: 20px; bottom: -6px; width: 12px; height: 12px;
  background: var(--pill); transform: rotate(45deg); border-radius: 2px;
}
.bot-say.below::after { bottom: auto; top: -6px; }

/* The moves, one scrolling line. */
.moves-wrap { max-width: 560px; width: 100%; margin: 0 auto; }
.moves { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; padding: 4px 2px; font-family: var(--font-mono); font-size: 13px; white-space: nowrap; }
.moves::-webkit-scrollbar { display: none; }
.mv-no { color: var(--dim); padding: 4px 2px 4px 6px; }
.mv { font: inherit; color: var(--ink); background: none; border: 0; padding: 4px 5px; border-radius: 6px; cursor: pointer; }
.mv.here { background: var(--gold); color: #1a1200; font-weight: 700; }
.mv.g-blunder { color: var(--bad); font-weight: 700; }
.mv.g-mistake { color: var(--warn); font-weight: 600; }
.mv.g-inaccuracy { color: var(--warn); }
.mv-result { color: var(--dim); padding: 4px 6px; font-weight: 700; }

.analysis { max-width: 560px; width: 100%; margin: 0 auto; }
.eval-graph { display: block; width: 100%; height: 64px; border-radius: 8px; background: var(--glass-2); }
.analysis-line { display: flex; gap: 10px; align-items: baseline; padding: 4px 2px 0; font-size: 12.5px; color: var(--dim); }
.analysis-eval { font-family: var(--font-num); font-weight: 700; color: var(--ink); min-width: 40px; }

.controls { display: flex; align-items: center; justify-content: space-between; gap: 8px; max-width: 560px; width: 100%; margin: 0 auto; flex: none; }
.nav { display: flex; gap: 2px; }
.nav .icon-btn { width: 36px; height: 36px; font-size: 18px; background: transparent; border: 0; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
.actions { display: flex; gap: 2px; flex-wrap: wrap; justify-content: flex-end; }
.actions .btn { padding: 8px 10px; font-size: 14px; }
.pz-controls { justify-content: center; flex-wrap: wrap; gap: 8px; }

/* ── the end-of-game overlay ───────────────────────────────────────────── */

.overlay { position: absolute; inset: 0; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); border-radius: 6px; z-index: 8; }
.overlay-card { position: relative; width: min(320px, 92%); padding: 24px 20px; text-align: center; border-radius: var(--r-card); }
.overlay-close { position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; font-size: 15px; background: transparent; border: 0; box-shadow: none; color: var(--dim); }
.overlay-card h2 { margin: 4px 0 4px; font-size: 26px; letter-spacing: -.4px; }
.overlay-line { margin: 0; color: var(--dim); font-size: 14px; line-height: 1.5; }
.overlay-stats { display: flex; justify-content: center; gap: 20px; margin: 16px 0 0; padding: 14px 0 0; border-top: 1px solid var(--line-2); }
.overlay-stats div { display: flex; flex-direction: column; gap: 2px; }
.overlay-stats dt { font-size: 10.5px; color: var(--dim); text-transform: uppercase; letter-spacing: .4px; order: 2; }
.overlay-stats dd { margin: 0; font-family: var(--font-num); font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; order: 1; }
.overlay-btns { display: flex; gap: 10px; margin-top: 14px; }
.overlay-btns .btn { flex: 1; }
.overlay-btns + .overlay-btns { margin-top: 6px; }

/* ── segmented control ─────────────────────────────────────────────────── */

.seg { display: flex; gap: 3px; padding: 3px; background: var(--glass-2); border-radius: var(--r-sm); border-color: var(--line-2); box-shadow: none; }
.seg button { flex: 1; font: inherit; font-size: 14px; font-weight: 500; padding: 8px 6px; white-space: nowrap; border: 0; border-radius: 8px; background: transparent; color: var(--ink); cursor: pointer; }
.seg button[aria-selected="true"], .seg button.is-on { background: var(--gold); color: #1a1200; font-weight: 600; box-shadow: var(--shadow); }
.seg-sm { max-width: 250px; }

/* ── the leaderboard ───────────────────────────────────────────────────── */

.board-sec .board-list { margin-top: 0; }
.board-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line-2); }
.board-row:last-child { border-bottom: 0; }
.board-row.you { background: color-mix(in srgb, var(--gold) 14%, transparent); }
.board-rank { width: 26px; flex: none; text-align: right; font-family: var(--font-num); font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; color: var(--dim); }
.board-row.you .board-rank { color: var(--gold); }
.mark { display: inline-block; color: var(--gold); margin-left: 4px; line-height: 0; vertical-align: -0.05em; }
.mark svg { display: block; }
.board-who { flex: 1; min-width: 0; }
.board-name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board-meta { font-size: 11.5px; color: var(--dim); margin-top: 1px; }
.board-score { font-family: var(--font-num); font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.board-empty { padding: 30px 20px; text-align: center; color: var(--dim); font-size: 14px; line-height: 1.5; }

/* ── settings rows ─────────────────────────────────────────────────────── */

.rows > .row { padding: 14px 16px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.rows > .row:last-child { border-bottom: 0; }
.rows > .row.row-stack { flex-direction: column; align-items: stretch; gap: 8px; }
.row-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.btn-test { margin-left: auto; padding: 7px 14px; font-size: 14px; }
.row-k { font-size: 15px; font-weight: 500; }
.row-v { font-family: var(--font-num); font-weight: 600; font-variant-numeric: tabular-nums; }
.row-note { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--dim); }
.rows > button.row-tap { appearance: none; -webkit-appearance: none; width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line-2); font: inherit; color: inherit; text-align: left; cursor: pointer; }
.rows > button.row-tap:active { background: var(--pill); }
.row-tap .row-v { margin-left: auto; font-family: inherit; font-weight: 500; color: var(--dim); display: inline-flex; align-items: center; gap: 6px; }
.row-tap .row-v.own { color: var(--ink); }
.row-tap .row-v .mark, #support-card .row-note .mark { margin-left: 0; }
.row-tap .chev, .chev { color: var(--dim); font-size: 22px; line-height: 1; margin-top: -2px; transition: transform .15s; }
.row-tap[aria-expanded="true"] .chev { transform: rotate(90deg); }
.name-actions { display: flex; gap: 8px; align-items: center; }
.name-actions .btn { padding: 8px 14px; font-size: 14px; }
.name-input { width: 100%; box-sizing: border-box; font: inherit; font-size: 16px; padding: 10px 12px; color: var(--ink); background: var(--pill); border: 1px solid var(--line); border-radius: 10px; }
.name-input:focus { outline: 2px solid var(--gold); outline-offset: 0; border-color: transparent; }

.switch { position: relative; display: inline-block; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 2; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--pill); transition: background .2s ease; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s ease; }
.switch input:checked + span { background: var(--good); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:disabled + span { opacity: .4; }

.board-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.board-tile { position: relative; display: block; padding: 0; border: 0; border-radius: 12px; aspect-ratio: 4 / 3; overflow: hidden; cursor: pointer; background: #000; font: inherit; color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
.board-art { position: absolute; inset: 0; background: conic-gradient(var(--d) 25%, var(--l) 0 50%, var(--d) 0 75%, var(--l) 0); background-size: 50% 50%; }
.board-tile .board-name { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 8px 6px; font-size: 12px; font-weight: 600; text-align: left; background: linear-gradient(transparent, rgba(0,0,0,.55)); white-space: nowrap; overflow: visible; }
.board-tile[aria-pressed="true"] { box-shadow: 0 0 0 2.5px var(--gold), var(--shadow); }
.board-tile[aria-pressed="true"]::after { content: '✓'; position: absolute; top: 6px; right: 6px; width: 20px; height: 20px; border-radius: 50%; background: var(--gold); color: #1a1200; font-size: 12px; font-weight: 800; line-height: 20px; text-align: center; }
.board-tile[disabled] { opacity: .45; cursor: default; }
.board-cap { grid-column: 1 / -1; font-size: 12px; font-weight: 600; color: var(--dim); margin: 6px 0 -2px; }
.board-cap:first-child { margin-top: 0; }
.board-art.tiles { background: linear-gradient(90deg, var(--g) 2px, transparent 0) -1px 0 / 25% 25%, linear-gradient(var(--g) 2px, transparent 0) 0 -1px / 25% 25%, conic-gradient(var(--d) 25%, var(--l) 0 50%, var(--d) 0 75%, var(--l) 0) 0 0 / 50% 50%; }
.piece-art { display: flex; background: conic-gradient(var(--sq-dark) 25%, var(--sq-light) 0 50%, var(--sq-dark) 0 75%, var(--sq-light) 0); background-size: 100% 100%; }
.piece-art img { width: 50%; height: 100%; object-fit: contain; padding: 4px 2px 14px; box-sizing: border-box; }

.prose { padding: 16px; }
.prose p { margin: 0 0 12px; font-size: 14px; line-height: 1.6; color: var(--ink-2); }
.prose p:last-child { margin-bottom: 0; }
.prose a { color: var(--link); }

#support-card { padding: 14px 16px 0; }
#support-card .support-thanks, #support-card .support-perks { margin: 0 0 12px; }
#support-card .rows { margin: 0 -16px; }
#support-card .rows > button.row-tap { padding: 14px 16px; border-bottom: 0; border-top: 1px solid var(--line-2); }
#support-card .rows > #name-edit { border-bottom: 0; border-top: 1px solid var(--line-2); }
#tipjar-card { margin-top: 14px; }
#tipjar .tip-glyph { color: var(--heart); font-size: 18px; line-height: 1; margin-right: 2px; }
#tipjar .row-k { flex: 1; }
:root { --games-gold: #c48a12; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --games-gold: #f2b93a; } }
:root[data-theme="dark"] { --games-gold: #f2b93a; }
#games-card { margin-top: 14px; }
#games-row { padding: 12px 16px; }
.games-lockup { flex: none; display: inline-flex; flex-direction: column; align-items: flex-end; line-height: 1; font-family: "SF Pro Rounded", ui-rounded, var(--font); font-weight: 700; }
.games-lockup .gl-mark { font-size: 22px; letter-spacing: -0.01em; color: var(--ink); }
.games-lockup .gl-ca { color: var(--dim); }
.games-lockup .gl-sub { font-size: 10px; letter-spacing: .02em; color: var(--games-gold); margin-top: -1px; margin-right: 1px; }
#games-row .games-more { flex: 1; text-align: right; color: var(--dim); font-weight: 400; }
#account-card { padding: 14px 16px 0; }
#account-card .row-note { margin: 0 0 12px; }
#account-card .rows { margin: 0 -16px; }
#account-card .rows > button.row-tap { padding: 14px 16px; border-bottom: 0; border-top: 1px solid var(--line-2); }
.rows > button.row-tap.danger { color: var(--bad); }
details.technical { margin-top: 14px; }
details.technical > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 16px; }
details.technical > summary::-webkit-details-marker { display: none; }
details.technical[open] > summary .chev { transform: rotate(90deg); }
details.technical > summary:active { background: var(--pill); }
details.technical .kv { margin: 0; padding: 4px 16px 12px; border-top: 1px solid var(--line-2); }
details.technical .kv > div { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line-2); }
details.technical .kv > div:last-child { border-bottom: 0; }
details.technical .kv dt { flex: 0 0 76px; font-size: 13px; color: var(--dim); }
details.technical .kv dd { margin: 0; flex: 1; min-width: 0; font-size: 12.5px; font-family: var(--font-mono); color: var(--ink-2); line-height: 1.5; overflow-wrap: anywhere; }
details.technical > .row-note { padding: 0 16px 14px; }

/* ── the menu sheet (in flow, IOS.md §15) ──────────────────────────────── */

.sheet { position: relative; z-index: 30; background: var(--bg); min-height: 100vh; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: calc(12px + var(--glass-t) + env(safe-area-inset-top, 0px)) calc(16px + env(safe-area-inset-right, 0px)) 6px calc(16px + env(safe-area-inset-left, 0px)); max-width: 560px; margin: 0 auto; box-sizing: border-box; }
.sheet-head h2 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -.4px; }
.sheet-body { padding: 4px calc(16px + env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) calc(16px + env(safe-area-inset-left, 0px)); max-width: 560px; width: 100%; margin: 0 auto; box-sizing: border-box; }
.sheet-body h2.sec:first-child { margin-top: 14px; }

/* ── the toast and the banner ──────────────────────────────────────────── */

.toast { position: absolute; left: 4px; right: 4px; bottom: 6px; z-index: 9; padding: 10px 14px; border-radius: var(--r-mid); background: var(--ink); color: var(--bg); font-size: 12.5px; line-height: 1.45; box-shadow: var(--shadow); pointer-events: none; animation: toast-in 180ms ease-out; }
.toast.warn { color: #ff8a8a; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.banner { position: fixed; left: 12px; right: 12px; bottom: calc(72px + env(safe-area-inset-bottom, 0px)); display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--ink); color: var(--bg); border-radius: var(--r-mid); font-size: 13.5px; line-height: 1.45; box-shadow: var(--shadow); z-index: 20; }
.banner .banner-retry { margin-left: auto; padding: 6px 13px; font-size: 12.5px; font-weight: 600; line-height: 1.2; border-radius: 999px; background: var(--bg); color: var(--ink); border: 0; cursor: pointer; }
.banner .banner-retry:disabled { opacity: .45; }
.banner .banner-retry + button { margin-left: 4px; }
.banner button { margin-left: auto; flex: none; font: inherit; font-size: 20px; line-height: 1; border: 0; background: transparent; color: inherit; cursor: pointer; }
.update-note { color: var(--warn); }
