/* Next Move: phone-first styles, light and dark. theme.js sets data-theme="light" or "dark" on <html>
   before anything is drawn: the member's choice, or the device's setting when they chose Automatic. */

:root {
  color-scheme: light;
  --bg: #f4f3ef;
  --surface: #fcfcfb;
  --surface-2: #efeee9;
  --input-bg: #ffffff;
  --text: #1b1a18;
  --text-2: #52514e;
  --muted: #6b6a64;
  --line: #e1e0d9;
  --line-strong: #cfcdc4;
  --hover: rgba(0, 0, 0, .05);
  --accent: #1d6f63;
  --accent-strong: #155a50;
  --accent-ink: #ffffff;
  --accent-soft: #dcefeb;
  --danger: #c4362f;
  --ok-bg: #e2f2e7;
  --ok-text: #1d5e35;
  --bad-bg: #fbe8e6;
  --bad-text: #9b2c22;
  --warn-bg: #fdf2d8;
  --warn-text: #6b4a00;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 14px rgba(0, 0, 0, .05);
  --toast-bg: #23221f;

  /* the board: the icon's teal for the dark squares, a pale tint of it for the light ones; the highlights
     are warm (yellow, amber) so they show on teal */
  --board-light: #d0e7e3;
  --board-dark: #1d6f63;
  --sq-last: rgba(255, 208, 0, .5);
  --sq-sel: rgba(255, 208, 0, .5);
  --sq-mark: rgba(56, 128, 240, .32);
  --sq-dot: rgba(25, 30, 25, .28);
  --arrow: rgba(245, 150, 20, .9);

  /* the outline around the winning-chances bar */
  --ev-edge: rgba(0, 0, 0, .28);

  /* charts: a diverging pair (won blue, lost red) with a neutral grey for draws */
  --c-win: #2a78d6;
  --c-loss: #e34948;
  --c-draw: #b5b3ab;
  --c-grid: #e1e0d9;
  --c-axis: #c3c2b7;
  --c-tick: #898781;
  --tip-bg: #ffffff;

  /* result pills */
  --win-bg: #e1ecfa;
  --win-text: #174f95;
  --loss-bg: #fbe4e3;
  --loss-text: #9b2423;
  --draw-bg: #ecebe6;
  --draw-text: #52514e;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #252523;
    --input-bg: #141413;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #9b9a92;
    --line: #2c2c2a;
    --line-strong: #3e3d3a;
    --hover: rgba(255, 255, 255, .06);
    --accent: #47b9a5;
    --accent-strong: #6fd0be;
    --accent-ink: #06231f;
    --accent-soft: #163a34;
    --danger: #e0574f;
    --ok-bg: #173523;
    --ok-text: #8fdcaa;
    --bad-bg: #3d1c19;
    --bad-text: #f3a69e;
    --warn-bg: #3a2f17;
    --warn-text: #f3d9a0;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .3);
    --toast-bg: #3a3936;
    --board-light: #bbd3d0;
    --board-dark: #1d6f63;
    --arrow: rgba(250, 165, 40, .9);
    --ev-edge: rgba(255, 255, 255, .28);
    --c-win: #3987e5;
    --c-loss: #e66767;
    --c-draw: #62615c;
    --c-grid: #2c2c2a;
    --c-axis: #383835;
    --c-tick: #898781;
    --tip-bg: #252523;
    --win-bg: #17304f;
    --win-text: #a9cbf5;
    --loss-bg: #3f1d1c;
    --loss-text: #f3a9a7;
    --draw-bg: #2c2c2a;
    --draw-text: #c3c2b7;
}

/* ---------- basics ---------- */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; line-height: 1.2; letter-spacing: -.01em; }
h2 { font-size: 17px; line-height: 1.3; }
a { color: var(--accent); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#view { min-height: 100vh; min-height: 100dvh; }
.page {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) 16px calc(96px + env(safe-area-inset-bottom));
}
.page.wide { max-width: 1120px; padding-left: 10px; padding-right: 10px; }
.loading { padding: 48px 0; }
.page > .loading:not(:only-child) { display: none; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0 16px; }
.top p.muted { font-size: 14px; margin-top: 2px; }
.game-top { padding: 0 0 8px; }
.game-top h1 { font-size: 19px; }

/* ---------- small pieces of layout ---------- */

.row { display: flex; align-items: center; min-width: 0; }
.row.gap { gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.center { justify-content: center; }
.row.between { justify-content: space-between; gap: 8px; }
.row.end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack.small-gap { gap: 6px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.warn { padding: 8px 10px; border-radius: 8px; background: var(--warn-bg); color: var(--warn-text); }
.lead { margin-bottom: 12px; font-size: 16px; color: var(--text-2); }
.label { display: block; margin-bottom: 6px; font-weight: 600; }

.card {
  margin-bottom: 12px;
  padding: 16px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.card > * + *, .sheet-body > * + *, .result > * + *, .done-card > * + * { margin-top: 12px; }
.card > h2 + p, .card > h2 + .muted { margin-top: 6px; }
.card > .label + .input { margin-top: 0; }
.card.empty { padding: 28px 18px; text-align: center; }
.card.empty .row { justify-content: center; }
.card.error { border-color: var(--bad-text); }
.card.error p { color: var(--bad-text); }
.stack + .card { margin-top: 12px; }

.ic { display: inline-grid; place-items: center; width: 22px; height: 22px; flex: none; }
.ic svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #d93a32;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

/* ---------- buttons and inputs ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .2s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn .ic { width: 18px; height: 18px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small { min-height: 34px; padding: 0 12px; border-radius: 9px; font-size: 14px; }
.btn.big { min-height: 52px; border-radius: 12px; font-size: 17px; }
.btn.wide { width: 100%; }
.btn.icon-only { width: 44px; padding: 0; flex: none; }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.primary:disabled:hover { background: var(--accent); border-color: var(--accent); }
.btn.glow { box-shadow: 0 0 0 4px var(--accent-soft); }
.input + .btn.wide { margin-top: 12px; }

.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}
.icon-btn:hover { background: var(--hover); }
.icon-btn:disabled { opacity: .35; cursor: default; background: transparent; }
.icon-btn.ring { border: 1px solid var(--line-strong); border-radius: 50%; }
.icon-btn.on { background: var(--accent-soft); color: var(--accent-strong); }
.icon-btn .badge { position: absolute; top: -3px; right: -3px; }

.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}
.input::placeholder { color: var(--muted); opacity: .8; }
.input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.input.code { text-transform: uppercase; letter-spacing: .08em; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.row > .input { flex: 1; min-width: 0; }
select.input { width: auto; max-width: 100%; }
.age-input { max-width: 110px; font-size: 20px; text-align: center; }

.seg { display: flex; gap: 3px; padding: 3px; border-radius: 12px; background: var(--surface-2); }
.seg button {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 40px;
  padding: 0 6px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .14); }
.seg-piece { display: inline-flex; align-items: center; gap: 2px; }
.seg-piece .pc { width: 24px; height: 24px; }

/* ---------- tabs, toast, sheets ---------- */

#tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
#tabs a {
  position: relative;
  flex: 1;
  max-width: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
}
#tabs a .ic { width: 24px; height: 24px; }
#tabs a.on { color: var(--accent); }
#tabs .badge { position: absolute; top: 3px; left: calc(50% + 6px); }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 70;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--toast-bg);
  color: #fff;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(15, 14, 12, 0);
  transition: background .2s;
}
.backdrop.open { background: rgba(15, 14, 12, .45); }
.sheet {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  max-height: 90dvh;
  padding-bottom: env(safe-area-inset-bottom);
  border-radius: 18px 18px 0 0;
  background: var(--surface);
  box-shadow: 0 -8px 30px rgba(0, 0, 0, .2);
  transform: translateY(100%);
  transition: transform .22s ease;
}
.backdrop.open .sheet { transform: none; }
.sheet.wide { max-width: 680px; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 2px 18px; }
.sheet-head h2 { flex: 1; font-size: 18px; }
.sheet-body { padding: 8px 18px 20px; overflow-y: auto; overscroll-behavior: contain; }
@media (min-width: 700px) {
  .backdrop { align-items: center; padding: 24px; }
  .sheet { border-radius: 18px; opacity: 0; transform: translateY(24px); transition: transform .2s ease, opacity .2s; }
  .backdrop.open .sheet { opacity: 1; }
}
.ask-text { color: var(--text-2); }
.menu { display: flex; flex-direction: column; }
.menu-item {
  padding: 14px 4px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  color: var(--text);
  font-size: 16px;
  text-align: left;
  cursor: pointer;
}
.menu-item:last-child { border-bottom: 0; }
.menu-item.danger { color: var(--danger); }

/* ---------- welcome ---------- */

.hero { padding: 28px 8px 18px; text-align: center; }
.hero h1 { margin-top: 10px; }
.hero p { max-width: 420px; margin: 6px auto 0; }
.hero-pieces { display: flex; justify-content: center; gap: 2px; }
.hero-pieces .pc { width: 64px; height: 64px; }

/* ---------- pieces ---------- */

.pc { display: inline-block; width: 28px; height: 28px; flex: none; }
.pc svg { display: block; width: 100%; height: 100%; overflow: visible; }
.pc .f, .pc .d { stroke-linejoin: round; stroke-linecap: round; }
.pc .f { stroke-width: 1.5; }
.pc .d { fill: none; stroke-width: 1.3; }
.pc.w .f { fill: #fbfaf6; stroke: #262420; }
.pc.w .d { stroke: #262420; }
.pc.w .e { fill: #262420; }
.pc.b .f { fill: #2d2b28; stroke: #111010; }
.pc.b .d { stroke: #d8d4cc; }
.pc.b .e { fill: #f1eee8; }
:where(:root[data-theme="dark"]) .pc.b .f { stroke: #77726a; }
.sq .pc.b .f { stroke: #111010; }

/* ---------- the board ---------- */

.board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  container-type: inline-size;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .12);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.board .sq { position: relative; aspect-ratio: 1 / 1; cursor: pointer; }
.sq.light { background-color: var(--board-light); }
.sq.dark { background-color: var(--board-dark); }
.sq .pc { position: absolute; inset: 0; z-index: 3; width: auto; height: auto; }
.board:not(.mini) .pc svg { filter: drop-shadow(0 1.5px 1px rgba(0, 0, 0, .28)); }
/* The coordinates sit outside the board, where they can be bigger than inside a square: the ranks on the
   left, the files underneath. */
.board-frame { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 5px; }
.board-frame > .board { grid-column: 2; grid-row: 1; }
.coord-ranks { grid-column: 1; grid-row: 1; display: grid; grid-template-rows: repeat(8, 1fr); min-width: 10px; }
.coord-files { grid-column: 2; grid-row: 2; display: grid; grid-template-columns: repeat(8, 1fr); padding-top: 4px; }
.coord-ranks span, .coord-files span {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  color: var(--muted);
}
.sq.last { box-shadow: inset 0 0 0 100cqw var(--sq-last); }
.sq.mark { box-shadow: inset 0 0 0 100cqw var(--sq-mark); }
.sq.sel { box-shadow: inset 0 0 0 100cqw var(--sq-sel); }
.sq.chk { background-image: radial-gradient(circle, rgba(232, 38, 30, .95) 0%, rgba(232, 38, 30, .6) 32%, rgba(232, 38, 30, 0) 72%); }
.sq.tgt::before {
  content: "";
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: var(--sq-dot);
  transform: translate(-50%, -50%);
}
.sq.cap::before {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 3%;
  border-radius: 50%;
  border: 1.1cqw solid var(--sq-dot);
}
.sq.star::after {
  content: "★";
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  place-items: center;
  color: #f2b705;
  font-size: 8.5cqw;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
  animation: twinkle 1.6s ease-in-out infinite;
}
.sq.pulse { animation: pulse 1.1s ease-in-out infinite; }
.sq.miss { animation: miss .65s ease; }
@keyframes pulse {
  0%, 100% { box-shadow: inset 0 0 0 0 rgba(242, 183, 5, 0); }
  50% { box-shadow: inset 0 0 0 1.5cqw rgba(242, 183, 5, .95); }
}
@keyframes miss {
  0%, 100% { box-shadow: inset 0 0 0 100cqw rgba(220, 40, 30, 0); }
  30% { box-shadow: inset 0 0 0 100cqw rgba(220, 40, 30, .55); }
}
@keyframes twinkle {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}
.board .arrows { position: absolute; inset: 0; z-index: 4; width: 100%; height: 100%; pointer-events: none; }
.arrow-line { stroke: var(--arrow); stroke-width: .17; stroke-linecap: round; }
.arrow-head { fill: var(--arrow); }
.board.replaying { box-shadow: 0 0 0 3px #e0a526, 0 2px 10px rgba(0, 0, 0, .12); }
.board.trying { box-shadow: 0 0 0 3px var(--accent), 0 2px 10px rgba(0, 0, 0, .12); }
.board.dim { opacity: .6; }
.board.mini { width: 64px; flex: none; border-radius: 6px; box-shadow: none; pointer-events: none; }

/* ---------- the game screen ---------- */

.game { display: grid; gap: 14px; }
.game-board {
  width: 100%;
  max-width: min(100%, max(280px, calc(100vh - 346px)));
  margin: 0 auto;
  min-width: 0;
}
@supports (height: 100dvh) {
  .game-board { max-width: min(100%, max(280px, calc(100dvh - 346px))); }
}
.board-wrap { width: 100%; }
.game-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
@media (min-width: 900px) {
  .game { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
  .game-side { position: sticky; top: 12px; }
}

.evalbar { margin-bottom: 2px; }
.ev-track {
  position: relative;
  height: 22px;
  border-radius: 7px;
  overflow: hidden;
  background: #2b2a27;
}
/* A thin outline drawn over both colours, so the white share doesn't melt into a light page
   (or the black share into a dark one). */
.ev-track::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px var(--ev-edge);
  pointer-events: none;
}
.ev-fill { width: 50%; height: 100%; background: #f6f5f1; transition: width .6s ease; }
.evalbar.left-black .ev-track { background: #f6f5f1; }
.evalbar.left-black .ev-fill { background: #2b2a27; }
.ev-labels {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  color: #fff;
  mix-blend-mode: difference;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.evalbar.stale .ev-labels { opacity: .55; }
/* Each label: the player's name and their chances ("Daniel 25%" … "75% Kbcao"); a long name is cut short. */
.ev-num { display: flex; align-items: baseline; gap: 5px; min-width: 0; max-width: 49%; white-space: nowrap; }
.ev-num b { flex: none; }
.ev-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
/* The verdict ("Kbcao is better") is for screen readers only: on screen, the names and numbers say it. */
.ev-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* The chances over the game, under the bar: the bar, move by move. One line, with the bottom player's colour
   below it and the other colour above. The teal marker is the position on the board; orange dots are key
   moves (a swing of 20 points or more). Tap or drag on it to go to a move. */
.ev-chart {
  position: relative;
  height: 64px;
  margin-top: 6px;
  border-radius: 7px;
  cursor: pointer;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.ev-plot { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; background: var(--surface-2); }
.ev-plot::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px var(--ev-edge); }
.ev-plot svg { display: block; width: 100%; height: 100%; }
.ev-w { fill: #f6f5f1; }
.ev-b { fill: #2b2a27; }
.ev-mid { stroke: rgba(128, 128, 128, .75); stroke-width: 1; stroke-dasharray: 3 3; }
.ev-now { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--accent); box-shadow: 0 0 0 1px var(--surface); pointer-events: none; }
.ev-key, .ev-cur { position: absolute; border-radius: 50%; transform: translate(-50%, -50%); }
.ev-key { width: 8px; height: 8px; background: rgb(245, 150, 20); box-shadow: 0 0 0 1.5px var(--surface); }
.ev-cur { width: 10px; height: 10px; background: var(--accent); box-shadow: 0 0 0 2px var(--surface); pointer-events: none; }

/* The coach's note on the move on the board: a coloured badge and the label (Brilliant … Blunder, Missed win),
   the move, then why. Just under the chart on a phone; at the top of the side column on a computer. The
   minimum height keeps the board from jumping as the notes get longer or shorter. */
.cls-brilliant { --mv: #128a8a; }
.cls-great { --mv: #2f6fc0; }
.cls-best { --mv: #2f8a2a; }
.cls-good { --mv: #5f8a3c; }
.cls-inaccuracy { --mv: #e2ae1c; --mv-ink: #2a2410; }
.cls-mistake { --mv: #c05f08; }
.cls-blunder { --mv: #c8321f; }
.cls-miss { --mv: #7d4fc0; }
.move-note {
  margin-top: 8px;
  min-height: 76px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: 14px;
  line-height: 1.45;
}
.move-note.quiet { color: var(--text-2); }
.note-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  margin-right: 6px;
  border-radius: 11px;
  background: var(--mv);
  color: var(--mv-ink, #fff);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: -.5px;
  vertical-align: -5px;
}
.note-label { margin-right: 6px; }
.note-move { margin-right: 6px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (min-width: 900px) {
  .move-note { margin-top: 0; min-height: 0; }
}
/* The game report (a sheet over the finished game). */
.report { display: grid; gap: 14px; }
.rp-headline { margin: 0; font-size: 17px; font-weight: 700; }
.rp-turning { margin: -8px 0 0; color: var(--text-2); }
.rp-player { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.rp-head { display: flex; align-items: center; gap: 8px; }
.rp-head h3 { margin: 0; font-size: 17px; }
.rp-acc { display: grid; justify-items: end; line-height: 1.1; }
.rp-acc b { font-size: 22px; font-variant-numeric: tabular-nums; }
.rp-acc small { color: var(--text-2); font-size: 12px; }
.rp-summary { margin: 0; color: var(--text-2); }
.rp-counts { display: flex; flex-wrap: wrap; gap: 6px; }
.rp-count { display: inline-flex; align-items: center; padding: 2px 9px 2px 2px; border-radius: 14px; background: var(--surface-2); font-size: 13px; }
.rp-count .note-badge { vertical-align: 0; }
.rp-list h4, .rp-moments h4 { margin: 2px 0 4px; font-size: 14px; }
.rp-list ul { display: grid; gap: 4px; margin: 0; padding-left: 20px; }
.rp-list.good h4 { color: var(--ok-text); }
.rp-list.work h4 { color: var(--warn-text); }
.rp-moments { display: grid; gap: 6px; }
.rp-moment {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: inherit;
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
}
.rp-moment:hover { background: var(--hover); }
.rp-tip { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border-radius: 10px; background: var(--warn-bg); color: var(--warn-text); }
.mv-sym {
  padding: 0 4px;
  border-radius: 6px;
  background: var(--mv);
  color: var(--mv-ink, #fff);
  font-size: 11px;
  font-weight: 800;
  line-height: 16px;
  letter-spacing: -.5px;
}

/* A player's row above or below the board: colour, name and whose move on the first line, the pieces they
   have captured under the name. */
.seat {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "chip who status" ". taken taken";
  align-items: center;
  column-gap: 8px;
  min-height: 34px;
  padding: 4px 2px;
  font-size: 15px;
}
/* The row above the board is the mirror image: captured pieces on top, so the name sits next to the board. */
.seat-top { grid-template-areas: ". taken taken" "chip who status"; }
.seat > .chip { grid-area: chip; }
.seat-who { grid-area: who; display: flex; align-items: center; gap: 8px; min-width: 0; }
.seat-who .seat-name { min-width: 0; }
.seat > .to-move, .seat > .thinking { grid-area: status; }
.seat > .to-move { max-width: 13em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat.active .seat-name { font-weight: 700; }
/* Captured pieces, parked cheapest first; alike ones overlap. The line keeps its height when empty, so the
   board doesn't move at the first capture. */
.taken { grid-area: taken; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 5px; min-height: 24px; }
.taken-group { display: inline-flex; }
.taken .pc { width: 24px; height: 24px; }
.taken .pc .f { stroke-width: 1.9; } /* a firmer outline at this small size, so white pieces don't fade */
.taken-group .pc + .pc { margin-left: -12px; }
.adv { color: var(--muted); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.chip { width: 14px; height: 14px; flex: none; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .35); }
.chip.w { background: #f6f5f1; }
.chip.b { background: #2b2a27; }
.dot { display: inline-block; width: 9px; height: 9px; flex: none; border-radius: 50%; background: var(--line-strong); }
.dot.online { background: #2fa36b; }
.to-move { padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); font-size: 12px; font-weight: 700; }
.thinking { display: inline-flex; align-items: center; gap: 3px; color: var(--muted); font-size: 12px; }
.thinking i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; animation: blink 1.2s infinite both; }
.thinking i:nth-child(2) { animation-delay: .2s; }
.thinking i:nth-child(3) { animation-delay: .4s; }
@keyframes blink {
  0%, 80%, 100% { opacity: .2; }
  40% { opacity: 1; }
}

.banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 12px;
  border-radius: 12px;
  background: var(--warn-bg);
  color: var(--warn-text);
  font-size: 14px;
  font-weight: 600;
}
.banner.trying { background: var(--accent-soft); color: var(--text); }
.actions:empty, .extra:empty { display: none; }
.confirm {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-radius: 14px;
  background: var(--surface);
  border: 2px solid var(--accent);
  box-shadow: var(--shadow);
}
.confirm-text { flex: 1; padding-left: 4px; font-size: 17px; }
.status-row { display: flex; align-items: center; gap: 8px; }
.status { flex: 1; color: var(--text-2); font-size: 15px; }
.status.alert { color: var(--danger); font-weight: 700; }
.btn.hint, .btn.try { flex: none; }
.try-line { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.hint-left { padding: 2px 7px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-size: 12px; font-weight: 700; }
.hint-box {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 15px;
}
.hint-box .ic { color: var(--accent-strong); }
.offer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 15px;
}
.result { padding: 18px 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); text-align: center; }
.result h2 { font-size: 22px; }
.result.win { box-shadow: inset 0 4px 0 var(--c-win); }
.result.loss { box-shadow: inset 0 4px 0 var(--c-loss); }
.result.draw { box-shadow: inset 0 4px 0 var(--c-draw); }
.try-tip { margin: 12px 0 0; }
.try-row .btn { flex: none; }
.replay { display: flex; align-items: center; justify-content: center; gap: 4px; }
.game-board > .replay { margin-top: 6px; } /* on a phone, under the coach's note */
.replay-btn { min-width: 168px; }
.moves {
  display: grid;
  grid-template-columns: 34px 1fr 1fr;
  gap: 2px 4px;
  max-height: 240px;
  overflow-y: auto;
  padding: 8px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.moves > p { grid-column: 1 / -1; padding: 4px; }
.mn { align-self: center; padding-right: 2px; color: var(--muted); font-size: 13px; text-align: right; }
.mv {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border: 0;
  border-radius: 7px;
  background: none;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
}
.mv:hover { background: var(--hover); }
.mv.on { background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; }
.hint-mark { font-size: 12px; }
@media (min-width: 900px) {
  .moves { max-height: 46vh; }
}

.code-big {
  padding: 6px 0;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: .1em;
  text-align: center;
}
.link-box {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
  word-break: break-all;
  user-select: all;
  -webkit-user-select: all;
}

.promo { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.promo-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--board-light);
  color: #2a2723;
  font-size: 14px;
  font-weight: 600;
  text-transform: capitalize;
  cursor: pointer;
}
.promo-btn .pc { width: 54px; height: 54px; }
.promo-btn .pc.b .f { stroke: #111010; }

/* ---------- the Play tab ---------- */

.sec { margin-bottom: 10px; }
.sec-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 2px 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.sec:first-child .sec-title { margin-top: 0; }
.count { padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-size: 12px; letter-spacing: 0; }
.game-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  padding: 10px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
  transition: border-color .15s;
}
.game-card:hover { border-color: var(--line-strong); }
.game-card.turn { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.gc-text { flex: 1; min-width: 0; }
.gc-title { overflow: hidden; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.gc-sub { color: var(--text-2); font-size: 14px; }
.gc-time { color: var(--muted); font-size: 12px; }
.pill { flex: none; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill.win { background: var(--win-bg); color: var(--win-text); }
.pill.loss { background: var(--loss-bg); color: var(--loss-text); }
.pill.draw { background: var(--draw-bg); color: var(--draw-text); }
.pill.turn { background: var(--accent); color: var(--accent-ink); }

/* ---------- new game ---------- */

.level-name { font-size: 17px; font-weight: 700; }
.slider { width: 100%; margin: 10px 0 2px; accent-color: var(--accent); }
.choice-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.choice {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}
.choice.on { border-color: var(--accent); background: var(--accent-soft); }
.stepper-val { min-width: 2.2ch; font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; text-align: center; }

/* ---------- people and chat ---------- */

.big-name { font-size: 20px; font-weight: 700; }
.person {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 18px;
  font-weight: 700;
}
.avatar .dot { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border: 2px solid var(--surface); }
.person-name { font-weight: 700; }
.invite-row { padding-top: 8px; border-top: 1px solid var(--line); }

.chat-sheet { height: 82vh; height: 82dvh; }
.chat-sheet .sheet-body { display: flex; flex: 1; flex-direction: column; min-height: 0; padding-bottom: 12px; }
.chat-sheet .sheet-body > * + * { margin-top: 0; }
.chat-list { display: flex; flex: 1; flex-direction: column; gap: 4px; min-height: 0; padding: 6px 2px 10px; overflow-y: auto; }
.chat-day { align-self: center; margin: 10px 0 4px; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 12px; }
.chat-empty { margin: auto 0; padding: 20px; }
.bubble { max-width: 80%; padding: 7px 11px 5px; border-radius: 16px; }
.bubble.me { align-self: flex-end; border-bottom-right-radius: 5px; background: var(--accent); color: var(--accent-ink); }
.bubble.them { align-self: flex-start; border-bottom-left-radius: 5px; background: var(--surface-2); }
.bt { white-space: pre-wrap; overflow-wrap: anywhere; }
.bm { margin-top: 1px; font-size: 11px; opacity: .7; text-align: right; }
.chat-form { display: flex; align-items: flex-end; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.chat-input { min-height: 44px; max-height: 120px; line-height: 1.35; resize: none; }

/* ---------- stats ---------- */

.filter-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.tip-host { position: relative; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 8px; margin-bottom: 12px; }
.tile { padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.tile-label { color: var(--text-2); font-size: 13px; }
.tile-value { margin-top: 2px; font-size: 28px; font-weight: 700; line-height: 1.15; }
.tile-sub { color: var(--muted); font-size: 12px; }
.chart-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 12px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--text-2); font-size: 13px; }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.sw.win, .seg-bar .win, .cell.win, .tip-key.win { background: var(--c-win); }
.sw.draw, .seg-bar .draw, .cell.draw, .tip-key.draw { background: var(--c-draw); }
.sw.loss, .seg-bar .loss, .cell.loss, .tip-key.loss { background: var(--c-loss); }
.chart { width: 100%; }
.chart svg { display: block; overflow: visible; }
.chart .bar.win { fill: var(--c-win); }
.chart .bar.draw { fill: var(--c-draw); }
.chart .bar.loss { fill: var(--c-loss); }
.chart .grid { stroke: var(--c-grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis { stroke: var(--c-axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .tick { fill: var(--c-tick); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .hit { fill: transparent; outline: none; }
.chart .hit:hover, .chart .hit:focus { fill: var(--hover); }
.split-row + .split-row { margin-top: 14px; }
.split-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 2px 10px; }
.split-name { font-weight: 700; }
.seg-bar { display: flex; gap: 2px; height: 10px; margin-top: 6px; border-radius: 5px; overflow: hidden; }
.seg-bar i { display: block; min-width: 3px; }
.seg-bar.empty { background: var(--surface-2); }
.strip { display: flex; flex-wrap: wrap; gap: 2px; }
.cell { display: block; width: 14px; height: 26px; border-radius: 3px; }
.cell:hover, .cell:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }
.tip {
  position: absolute;
  z-index: 15;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--tip-bg);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .16);
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
}
.tip-row { display: flex; align-items: center; gap: 6px; }
.tip-row b { font-variant-numeric: tabular-nums; }
.tip-row span { color: var(--text-2); }
.tip-key { display: inline-block; width: 8px; height: 8px; border-radius: 2px; }
.table-wrap { margin: 0 -4px; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
}
.table th:nth-last-child(-n+2) { text-align: right; }
.table td { padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- the Academy ---------- */

.meter { height: 10px; border-radius: 5px; background: var(--accent-soft); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 5px; background: var(--accent); transition: width .5s; }
.card > .meter + .muted { margin-top: 6px; }
.lesson-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}
.lesson-row:hover { border-color: var(--line-strong); }
.lesson-row.next { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.lesson-row .pc { width: 40px; height: 40px; }
.lesson-num {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 700;
}
.lesson-num .ic { width: 16px; height: 16px; }
.lesson-row.done .lesson-num { background: var(--accent); color: var(--accent-ink); }
.lr-title { display: block; font-weight: 700; }
.lr-sub { display: block; color: var(--muted); font-size: 13px; }
.again { margin-top: 16px; }

.step-dots { display: flex; align-items: center; gap: 5px; flex: none; }
.step-dots i { width: 8px; height: 8px; border-radius: 4px; background: var(--line-strong); transition: width .2s, background .2s; }
.step-dots i.done { background: var(--accent); opacity: .45; }
.step-dots i.on { width: 20px; background: var(--accent); }

.lesson { display: grid; gap: 12px; grid-template-areas: "coach" "board" "side"; }
.lesson > .done-card { grid-column: 1 / -1; }
.coach { grid-area: coach; display: flex; align-items: flex-start; gap: 10px; }
.coach-avatar { display: grid; place-items: center; width: 46px; height: 46px; flex: none; border-radius: 50%; background: var(--board-light); }
.coach-avatar .pc { width: 38px; height: 38px; }
.coach-bubble {
  position: relative;
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 4px 16px 16px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 16px;
  line-height: 1.5;
}
.lesson.g-y .coach-bubble { font-size: 19px; line-height: 1.45; }
.lesson.g-m .coach-bubble { font-size: 17px; }
.speak { float: right; width: 36px; height: 36px; margin: -6px -6px 2px 8px; }
.lesson-board { grid-area: board; min-width: 0; }
.lesson-board .board-wrap { max-width: min(100%, max(280px, calc(100vh - 300px))); margin: 0 auto; }
@supports (height: 100dvh) {
  .lesson-board .board-wrap { max-width: min(100%, max(280px, calc(100dvh - 300px))); }
}
.lesson-side { grid-area: side; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.task:empty { display: none; }
.feedback {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
}
.lesson.g-y .feedback { font-size: 18px; }
.feedback.ok { background: var(--ok-bg); color: var(--ok-text); }
.feedback.bad { background: var(--bad-bg); color: var(--bad-text); }
.feedback.info { background: var(--surface-2); color: var(--text-2); }
.feedback.shake { animation: shake .35s; }
.lesson-nav { display: flex; align-items: center; gap: 8px; }
.quiz { display: flex; flex-direction: column; gap: 10px; }
.quiz-q { font-size: 17px; font-weight: 700; }
.lesson.g-y .quiz-q { font-size: 20px; }
.quiz-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.quiz-opt { flex: 1 1 auto; min-width: 72px; min-height: 48px; font-size: 16px; text-align: center; white-space: normal; }
.quiz-opt.right { background: #2f8f57; border-color: #2f8f57; color: #fff; }
.quiz-opt.wrong { background: var(--bad-bg); border-color: transparent; color: var(--bad-text); animation: shake .35s; }
.done-card { max-width: 520px; margin: 20px auto; padding: 30px 18px; text-align: center; }
.done-icon { font-size: 60px; line-height: 1; animation: pop .5s cubic-bezier(.2, 1.6, .4, 1); }
.done-icon .ic { width: 64px; height: 64px; color: var(--accent); }
@keyframes shake {
  0%, 100% { transform: none; }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}
@keyframes pop {
  0% { transform: scale(.3); opacity: 0; }
  100% { transform: none; opacity: 1; }
}
@media (min-width: 900px) {
  .lesson {
    grid-template-columns: minmax(0, 1fr) 380px;
    grid-template-rows: auto 1fr;
    grid-template-areas: "board coach" "board side";
    align-items: start;
  }
  .lesson-board .board-wrap { max-width: min(100%, max(300px, calc(100vh - 170px))); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
