/* Go — a kaya board on a warm paper page. Slate and shell stones are CSS (gradients, a per-stone
   turn of the shell's stripes); the wood's grain is an SVG turbulence stretched along the board.
   Every size inside the board is a share of it (container units), so it is sharp at any size. */

:root {
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --ease: cubic-bezier(0.4, 0.1, 0.2, 1);
  --spring: cubic-bezier(0.25, 0.9, 0.3, 1.15);
  color-scheme: light;
  --bg-a: #f3ecdd;
  --bg-b: #e2d6bd;
  --ink: #2a231a;
  --muted: #6b5f4c;
  --line: rgba(60, 45, 25, 0.14);
  --surface: #fbf7ef;
  --surface-2: #f1e9da;
  --chip: rgba(255, 255, 255, 0.55);
  --chip-line: rgba(255, 255, 255, 0.75);
  --accent: #9c3f1c;
  --accent-ink: #fff8ef;
  --accent-soft: rgba(156, 63, 28, 0.13);
  --good: #2f6b3e;
  --bad: #a1321e;
  --backdrop: rgba(35, 25, 12, 0.42);
  --toast: rgba(34, 27, 18, 0.94);
  --shadow: 0 18px 40px -22px rgba(60, 40, 15, 0.55);
  --ca-accent: #9c3f1c;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg-a: #1b1712;
  --bg-b: #100d0a;
  --ink: #efe6d6;
  --muted: #b9ac95;
  --line: rgba(255, 240, 215, 0.12);
  --surface: #241f19;
  --surface-2: #2d2720;
  --chip: rgba(255, 245, 228, 0.06);
  --chip-line: rgba(255, 245, 228, 0.1);
  --accent: #e29466;
  --accent-ink: #1d130b;
  --accent-soft: rgba(226, 148, 102, 0.16);
  --good: #8fd19c;
  --bad: #f29a86;
  --backdrop: rgba(0, 0, 0, 0.55);
  --toast: rgba(250, 242, 228, 0.95);
  --shadow: 0 18px 40px -22px rgba(0, 0, 0, 0.8);
  --ca-accent: #e29466;
}

/* the boards: kaya (golden, straight grain), walnut (deep brown), night slate (dark stone) */
:root, :root[data-board="kaya"] {
  --wood: #ddb168;
  --wood-a: #e8c27c;
  --wood-b: #c99a50;
  --wood-edge: #a8793a;
  --grain-op: 0.55;
  --grid: rgba(40, 24, 8, 0.82);
  --star: rgba(40, 24, 8, 0.9);
  --coord: rgba(55, 35, 12, 0.85);
}
:root[data-board="walnut"] {
  --wood: #8e5d38;
  --wood-a: #a06a40;
  --wood-b: #74472a;
  --wood-edge: #5a361e;
  --grain-op: 0.7;
  --grid: rgba(20, 10, 3, 0.85);
  --star: rgba(20, 10, 3, 0.92);
  --coord: rgba(255, 236, 210, 0.82);
}
:root[data-board="slate"] {
  --wood: #30353a;
  --wood-a: #3a4046;
  --wood-b: #24282c;
  --wood-edge: #191c1f;
  --grain-op: 0.25;
  --grid: rgba(232, 224, 205, 0.55);
  --star: rgba(232, 224, 205, 0.75);
  --coord: rgba(232, 224, 205, 0.75);
}

* { box-sizing: border-box; }
/* no double-tap zoom on iOS: js/touch-guard.js adds the same rule plus a JS fallback */
:where(html, body, body *) { touch-action: manipulation; }
html { -webkit-text-size-adjust: 100%; background: var(--bg-b); }
body {
  margin: 0;
  height: calc(100dvh / var(--ca-zoom, 1));
  overflow: hidden;
  font: 16px/1.4 var(--sans);
  color: var(--ink);
  background: radial-gradient(120% 80% at 20% 0%, var(--bg-a), var(--bg-b) 75%) fixed;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
input, textarea, .prose p, .prose li, .coach-text { -webkit-user-select: text; user-select: text; }
button { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------------------------ layout */
[hidden] { display: none !important; }
.app {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "top" "stage" "act";
  gap: 8px;
  padding: calc(env(safe-area-inset-top) + var(--ca-space-top, 0px) + 6px) calc(env(safe-area-inset-right) + 12px) calc(env(safe-area-inset-bottom) + 10px) calc(env(safe-area-inset-left) + 12px);
  max-width: 1500px;
  margin: 0 auto;
}
/* phone and tablet upright: the plates hug the board, the room left goes round them */
.stage {
  grid-area: stage;
  display: flex; flex-direction: column; justify-content: center; gap: 8px;
  min-height: 0; container-type: size;
}
.stage > .plate { flex: none; }
.board-wrap {
  position: relative; flex: none; width: 100%;
  height: min(100cqw, calc(100cqh - 2 * var(--plate-h, 52px) - 16px));
  container-type: size; display: grid; place-items: center;
}
.stage.coaching { justify-content: flex-start; }
.stage.coaching .plate { display: none; }
.stage.coaching .board-wrap { flex: 1 1 0; height: auto; min-height: 0; }
.coach { flex: none; }
.top { grid-area: top; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; }
/* room in the bar for the chip's 44 px target (4 px round it), or the bar measures as too narrow
   for its tools; the ends stay where they were */
.top { padding-inline: 4px; margin-inline: -4px; }
#actions, #mark-bar { grid-area: act; }

@media (min-width: 760px) and (min-aspect-ratio: 5/4) {
  .app {
    grid-template-columns: minmax(0, 1fr) minmax(290px, 360px);
    grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
    grid-template-areas: "top top" "board ptop" "board pbot" "board coach" "board ." "board act";
    column-gap: 22px;
    padding-top: calc(env(safe-area-inset-top) + var(--ca-space-top, 0px) + 10px);
    padding-bottom: calc(env(safe-area-inset-bottom) + 16px);
  }
  .stage { display: contents; }
  #plate-top { grid-area: ptop; }
  #plate-bottom { grid-area: pbot; }
  .board-wrap, .stage.coaching .board-wrap { grid-area: board; height: auto; min-height: 0; }
  .coach { grid-area: coach; }
  #actions, #mark-bar { flex-wrap: wrap; }
  #actions .btn { flex: 1 1 40%; }
}

/* ------------------------------------------------------------------ header */
/* the school and the puzzle of the day: the game's own round buttons, at the right end beside the
   bar's tools and the chip (App Standard §4.1) */
.ca-start { margin-right: auto; }
.own-tools { display: flex; align-items: center; gap: 6px; flex: none; }
.icon-btn {
  position: relative;
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; border-radius: 13px;
  border: 1px solid transparent; background: transparent; color: var(--ink); cursor: pointer;
  transition: background-color 0.15s;
}
.icon-btn:hover { background: var(--chip); border-color: var(--chip-line); }
.icon-btn.small { width: 40px; height: 40px; }
.icon-btn .dot { position: absolute; top: 3px; right: 3px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--bg-a); }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------------ plates */
.plate {
  display: flex; align-items: center; gap: 10px;
  min-height: 52px; padding: 7px 14px 7px 8px; border-radius: 16px;
  background: var(--chip); border: 1px solid var(--chip-line);
  transition: background-color 0.25s, box-shadow 0.25s;
}
.plate.active { background: var(--surface); box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow); }
.plate.won .who b::after { content: " ✦"; color: var(--accent); }
.plate.far { transform: rotate(180deg); }
.plate .who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.plate .who b { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plate .who b .kind { font-weight: 500; color: var(--muted); }
.plate .who small { color: var(--muted); font-size: 13px; min-height: 1.2em; }
.plate.active .who small { color: var(--accent); font-weight: 600; }
.plate .caps { color: var(--muted); font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }

.token { display: inline-block; flex: none; width: 30px; height: 30px; border-radius: 50%; }
.token.b, .stone.b {
  background:
    radial-gradient(circle at 36% 30%, rgba(255, 255, 255, 0.32) 0, rgba(255, 255, 255, 0.1) 13%, rgba(255, 255, 255, 0) 32%),
    radial-gradient(circle at 50% 55%, #3b3d42 0%, #1d1e21 52%, #09090a 100%);
}
.token.w, .stone.w {
  background:
    radial-gradient(circle at 38% 30%, #ffffff 0, rgba(255, 255, 255, 0) 44%),
    repeating-linear-gradient(var(--a, 20deg), rgba(130, 118, 95, 0) 0 6.5%, rgba(130, 118, 95, 0.1) 6.5% 7.6%, rgba(130, 118, 95, 0) 7.6% 11%),
    radial-gradient(circle at 50% 55%, #f8f5ee 0%, #ece7db 60%, #cdc6b5 100%);
}
.token { box-shadow: 0 2px 4px rgba(30, 20, 8, 0.35); }

/* ------------------------------------------------------------------ the board */
.board {
  --span: 10.24;
  --m: 0.62;
  position: relative;
  width: min(100cqw, 100cqh);
  aspect-ratio: 1;
  container-type: inline-size;
  border-radius: 1.4%;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='600' preserveAspectRatio='none'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.09 0.0035' numOctaves='3' seed='7'/%3E%3CfeColorMatrix values='0 0 0 0 0.32 0 0 0 0 0.18 0 0 0 0 0.06 0 0 0 1.25 -0.45'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E") 0 0 / 100% 100%,
    linear-gradient(100deg, var(--wood-a), var(--wood) 30%, var(--wood-b) 52%, var(--wood) 74%, var(--wood-a));
  box-shadow:
    0 0.9cqh 0 -0.2cqh var(--wood-edge),
    0 2.4cqh 3.6cqh -1.6cqh rgba(25, 15, 5, 0.55),
    inset 0 0 0 1px rgba(255, 240, 210, 0.18),
    inset 0 -0.4cqh 1.2cqh rgba(60, 35, 10, 0.18);
  outline: none;
  cursor: pointer;
  touch-action: none;
}
.board::before {
  /* the grain, a little stronger or weaker per wood, and a soft sheen */
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(90% 70% at 30% 15%, rgba(255, 250, 235, 0.22), rgba(255, 250, 235, 0) 60%);
  opacity: calc(var(--grain-op) + 0.3);
}
.board:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
.board.turned { transform: rotate(180deg); }
.board.turned .stone.w { transform: translate(-50%, -50%) rotate(180deg); }
.grid { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.grid line { stroke: var(--grid); stroke-width: 2.4; stroke-linecap: square; }
.grid line.edge { stroke-width: 3.6; }
.grid .stars circle { fill: var(--star); }
.grid .coords text { fill: var(--coord); font: 600 29px var(--sans); text-anchor: middle; dominant-baseline: central; }
.goban.turned .grid .coords text { display: none; }
.layer { position: absolute; inset: 0; pointer-events: none; }

.stone, .mark, .last-mark, .focus-ring {
  position: absolute;
  left: calc((var(--x) + var(--m)) * 100% / var(--span));
  top: calc((var(--y) + var(--m)) * 100% / var(--span));
  transform: translate(-50%, -50%);
}
.stone {
  width: calc(100cqw / var(--span) * 0.955);
  aspect-ratio: 1;
  border-radius: 50%;
  box-shadow:
    calc(100cqw / var(--span) * 0.05) calc(100cqw / var(--span) * 0.09) calc(100cqw / var(--span) * 0.11) rgba(35, 20, 6, 0.45),
    inset calc(100cqw / var(--span) * -0.03) calc(100cqw / var(--span) * -0.05) calc(100cqw / var(--span) * 0.08) rgba(0, 0, 0, 0.18);
  transition: opacity 0.38s var(--ease), transform 0.38s var(--ease);
}
.stone.drop { animation: drop 0.2s var(--ease) both; }
@keyframes drop {
  from { transform: translate(-50%, -50%) scale(1.13); opacity: 0.2; box-shadow: calc(100cqw / var(--span) * 0.12) calc(100cqw / var(--span) * 0.22) calc(100cqw / var(--span) * 0.26) rgba(35, 20, 6, 0.3); }
}
.stone.gone { opacity: 0; transform: translate(-50%, -85%) scale(0.9); }
.stone.ghost { opacity: 0.42; box-shadow: none; transition: none; }
.stone.ghost.armed { opacity: 0.78; outline: calc(100cqw / var(--span) * 0.05) solid var(--accent); outline-offset: calc(100cqw / var(--span) * 0.03); }
.stone.dead { opacity: 0.45; }
.stone.atari::after, .stone.target::after {
  content: ""; position: absolute; inset: -9%; border-radius: 50%;
  border: calc(100cqw / var(--span) * 0.07) solid #e2552f;
  animation: pulse 1.6s ease-in-out infinite;
}
.stone.target::after { border-style: dashed; border-color: var(--accent); animation: none; inset: -12%; }
@keyframes pulse { 50% { opacity: 0.35; } }
.last-mark {
  width: calc(100cqw / var(--span) * 0.34); aspect-ratio: 1; border-radius: 50%;
  border: calc(100cqw / var(--span) * 0.065) solid rgba(255, 255, 255, 0.92);
}
.last-mark.on-white { border-color: rgba(25, 20, 15, 0.85); }
.focus-ring {
  width: calc(100cqw / var(--span) * 1.02); aspect-ratio: 1; border-radius: 22%;
  border: calc(100cqw / var(--span) * 0.06) solid var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.6);
}
.mark { width: calc(100cqw / var(--span) * 0.36); aspect-ratio: 1; }
.mark.terr { border-radius: 14%; width: calc(100cqw / var(--span) * 0.34); }
.mark.terr.c1 { background: #17181a; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35); }
.mark.terr.c2 { background: #f5f2ea; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35); }
.mark.ko { border: calc(100cqw / var(--span) * 0.06) solid var(--grid); width: calc(100cqw / var(--span) * 0.42); border-radius: 10%; }
.mark.hint { width: calc(100cqw / var(--span) * 0.9); border-radius: 50%; border: calc(100cqw / var(--span) * 0.07) dashed var(--accent); background: var(--accent-soft); animation: pulse 1.8s ease-in-out infinite; }
.mark.lib { width: calc(100cqw / var(--span) * 0.26); border-radius: 50%; background: var(--accent); opacity: 0.85; animation: pop 0.3s var(--spring) both; }
.mark.dead { display: none; }
@keyframes pop { from { transform: translate(-50%, -50%) scale(0); } }

.banner {
  position: absolute; left: 50%; top: 50%; z-index: 3; max-width: 88%;
  transform: translate(-50%, -50%) scale(0.96); opacity: 0;
  padding: 11px 18px; border-radius: 14px; text-align: center;
  background: var(--toast); color: var(--bg-a); font-weight: 600;
  pointer-events: none; transition: opacity 0.25s, transform 0.25s var(--ease);
}
.banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* ------------------------------------------------------------------ actions */
.actions { display: flex; gap: 8px; align-items: center; }
.actions .btn { flex: 1 1 0; min-width: 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 46px; padding: 0 14px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background-color 0.15s, transform 0.12s;
}
.btn span { overflow: hidden; text-overflow: ellipsis; }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; }
.btn .short { display: none; }
@media (max-width: 360px) { .btn .long { display: none; } .btn .short { display: inline; } }
.btn svg { flex: none; }
.marking { flex-wrap: wrap; }
.mark-text { flex: 1 1 100%; margin: 0 2px 2px; color: var(--muted); font-size: 14px; }
@media (max-width: 440px) {
  .actions { gap: 6px; }
  .actions .btn { padding: 0 6px; gap: 5px; font-size: 14.5px; }
  #actions .btn svg { display: none; }
}

/* ------------------------------------------------------------------ the coach */
.coach {
  display: flex; flex-direction: column; gap: 6px;
  padding: 14px 16px 16px; border-radius: 18px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  max-height: 46cqh; overflow: auto; overscroll-behavior: contain;
}
.coach[hidden] { display: none; }
.coach-head { display: flex; align-items: center; justify-content: space-between; margin: -6px -8px -4px 0; }
.coach-kicker { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 650; }
.coach h2 { margin: 0; font: 600 21px/1.2 var(--serif); }
.coach-text { margin: 0; }
.coach-note { margin: 0; min-height: 1.4em; color: var(--muted); font-weight: 600; }
.coach-note.good { color: var(--good); }
.coach-note.bad { color: var(--bad); }
.steps { display: flex; gap: 6px; }
.steps i { width: 22px; height: 5px; border-radius: 3px; background: var(--line); }
.steps i.done { background: var(--accent); }
.steps i.now { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.coach-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; margin-top: 4px; }
.coach-actions .btn { flex: 1 1 auto; }
@media (max-height: 640px) and (max-width: 759px) {
  .coach { padding: 10px 14px 12px; gap: 4px; }
  .coach h2 { font-size: 18px; }
  .coach-text { font-size: 14.5px; }
}

/* ------------------------------------------------------------------ toast, backdrop */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 84px); z-index: 60;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  max-width: min(calc(92vw / var(--ca-zoom, 1)), 440px); padding: 11px 16px; border-radius: 13px;
  background: var(--toast); color: var(--bg-a); font-weight: 550; text-align: center;
  transition: opacity 0.22s, transform 0.22s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.backdrop { position: fixed; inset: 0; z-index: 40; background: var(--backdrop); }
.backdrop[hidden] { display: none; }

/* ------------------------------------------------------------------ sheets */
.sheet {
  position: fixed; z-index: 50; left: 0; right: 0; bottom: 0;
  max-height: calc(90dvh / var(--ca-zoom, 1)); display: flex; flex-direction: column;
  background: var(--surface); color: var(--ink);
  border-radius: 22px 22px 0 0; box-shadow: 0 -20px 50px -20px rgba(0, 0, 0, 0.45);
  padding-bottom: env(safe-area-inset-bottom);
  transform: translateY(16px); opacity: 0.98; transition: transform 0.24s var(--ease);
}
.sheet.open { transform: none; }
.sheet[hidden] { display: none; }
.sheet > header { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 6px 20px; }
.sheet h2 { margin: 0; font: 600 22px/1.2 var(--serif); }
.sheet-body { overflow: auto; overscroll-behavior: contain; padding: 4px 20px 20px; }
.sheet-foot { padding: 10px 20px 16px; border-top: 1px solid var(--line); }
@media (min-width: 640px) {
  .sheet { left: 50%; bottom: auto; top: 50%; width: min(560px, calc(94vw / var(--ca-zoom, 1))); max-height: calc(86dvh / var(--ca-zoom, 1)); border-radius: 22px; transform: translate(-50%, -48%); }
  .sheet.open { transform: translate(-50%, -50%); }
}
.field { margin: 14px 0 4px; }
.field-label { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 650; }
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.choice {
  display: grid; align-content: center; justify-items: start; gap: 2px; text-align: left;
  min-height: 48px; padding: 10px 12px; border-radius: 13px;
  border: 1px solid var(--line); background: var(--surface-2); cursor: pointer;
}
.choice small { color: var(--muted); font-size: 12.5px; line-height: 1.3; }
.choice.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.rules-fold { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 6px; }
.rules-fold summary { cursor: pointer; padding: 10px 0; font-weight: 650; min-height: 44px; display: flex; align-items: center; }
.names .name-field { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.names input { flex: 1; min-height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); font: inherit; color: var(--ink); }
.prose h3 { margin: 18px 0 4px; font: 600 17px var(--serif); }
.prose p { margin: 0 0 6px; color: var(--ink); }
.prose .btn { margin-top: 14px; }
.version, .note { color: var(--muted); font-size: 13.5px; }
.lead { color: var(--muted); margin: 4px 0 12px; }
.section { margin: 20px 0 8px; font: 600 17px var(--serif); }
.lessons { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.lesson-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  min-height: 56px; padding: 8px 12px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--surface-2); cursor: pointer;
}
.lesson-row .num { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line); font-weight: 700; color: var(--muted); }
.lesson-row.done .num { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.lesson-row .words { display: flex; flex-direction: column; min-width: 0; }
.lesson-row small { color: var(--muted); font-size: 13px; }
.puzzle-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 8px; margin-top: 10px; }
.puzzle-chip {
  position: relative; min-height: 48px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); font-weight: 650; cursor: pointer; font-variant-numeric: tabular-nums;
}
.puzzle-chip::after { content: ""; position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%); width: 18px; height: 4px; border-radius: 2px; background: var(--line); }
.puzzle-chip.d1::after { width: 6px; }
.puzzle-chip.d2::after { width: 12px; }
.puzzle-chip.done { background: var(--accent-soft); border-color: var(--accent); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.tab { min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; font-weight: 600; }
.tab.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.stats { display: grid; gap: 2px; }
.stat { display: flex; justify-content: space-between; gap: 12px; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.stat span { color: var(--muted); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.row .words { display: flex; flex-direction: column; }
.row small { color: var(--muted); font-size: 13px; }
.row select { min-height: 40px; max-width: 55%; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); font: inherit; padding: 0 8px; }
.row input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
#settings-rows .btn { margin-top: 12px; }
#settings-body > :not(#settings-rows) { margin-top: 14px; }

/* ------------------------------------------------------------------ dialogs */
.dialog {
  position: fixed; z-index: 55; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(calc(92vw / var(--ca-zoom, 1)), 420px); padding: 22px; border-radius: 22px;
  background: var(--surface); box-shadow: 0 30px 70px -25px rgba(0, 0, 0, 0.6); text-align: center;
}
.dialog[hidden] { display: none; }
.dialog .row { border: 0; justify-content: center; flex-wrap: wrap; gap: 8px; min-height: 0; }
.dialog .row .btn { flex: 1 1 140px; }
.result h2 { margin: 4px 0 10px; font: 600 28px/1.15 var(--serif); }
.result .glow { position: absolute; inset: 0; border-radius: inherit; background: radial-gradient(70% 50% at 50% 0%, var(--accent-soft), transparent 70%); pointer-events: none; }
.final { display: flex; align-items: center; justify-content: center; gap: 14px; font: 600 30px var(--serif); font-variant-numeric: tabular-nums; }
.final[hidden] { display: none; }
.final .side { display: inline-flex; align-items: center; gap: 8px; }
.final .token { width: 26px; height: 26px; }
.final .dash { color: var(--muted); }
#result-text { color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
/* short screens: the header gives way, the board keeps its room */
@media (max-height: 600px) {
  :root { --plate-h: 44px; }
  .plate { min-height: 44px; padding-top: 4px; padding-bottom: 4px; }
  .token { width: 26px; height: 26px; }
  .btn { min-height: 44px; }
  .app { gap: 6px; }
}
.version { color: var(--muted); font-size: 13px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* cloud-apps bar 1.30.0 */
:root { --ca-brand-icon-w: 89px; } /* the brand's width with the icon alone (the mark, the divider, the app's icon) */
.ca-start { display: flex; align-items: center; flex: 0 100 auto; min-width: min(var(--ca-brand-icon-w), 100%); }
.ca-brand { display: flex; align-items: center; min-width: 0; height: 40px; color: inherit; font-family: inherit; }
.ca-brand a { display: flex !important; align-items: center !important; box-sizing: border-box !important; color: inherit !important; text-decoration: none !important; border-radius: 12px !important; -webkit-tap-highlight-color: transparent; transition: background-color .15s ease; }
.ca-brand-home { flex: none !important; justify-content: center !important; width: 40px !important; height: 40px !important; padding: 0 !important; margin: 0 0 0 -5px !important; }
.ca-brand-home img { display: block !important; width: 30px !important; height: 30px !important; margin: 0 !important; transition: transform .38s cubic-bezier(.34, 1.56, .64, 1); }
.ca-brand-sep { flex: none; display: block; width: 1.5px; height: 18px; margin: 0 4px; border-radius: 1px; background: currentColor; opacity: .22; transform: rotate(18deg); }
.ca-brand-app { flex: 0 1 auto !important; min-width: 44px !important; height: 40px !important; padding: 0 9px 0 5px !important; margin: 0 !important; }
.ca-brand-in { display: flex; flex-wrap: wrap; align-items: center; align-content: flex-start; column-gap: 9px; min-width: 0; height: 40px; overflow: hidden; }
.ca-brand-in img { flex: none; display: block !important; width: 30px !important; height: 30px !important; margin: 5px 0 !important; border-radius: 8px; }
.ca-brand[data-ca-icon] .ca-brand-name { display: none !important; }
.ca-brand[data-ca-icon] .ca-brand-app { padding-right: 5px !important; }
.ca-brand-name { display: block; height: 40px; margin: 0 !important; padding: 0 !important; line-height: 40px !important; white-space: nowrap; font-family: var(--ca-brand-font, inherit); font-size: 17px !important; font-weight: 700; letter-spacing: -.015em; color: inherit; text-shadow: var(--ca-brand-shadow, none); }
@media (hover: hover) { .ca-brand a:hover { background-color: color-mix(in srgb, currentColor 7%, transparent); } .ca-brand-home:hover img { transform: rotate(-6deg) scale(1.06); } }
.ca-brand a:focus-visible { outline: 3px solid var(--ca-accent, #4f6bff); outline-offset: -3px; }
.ca-end { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex: none; min-width: 0; }
.ca-tools { display: flex; align-items: center; gap: 6px; }
.ca-tools[hidden] { display: none !important; }
.ca-tool { position: relative; flex: none; display: inline-grid; place-items: center !important; box-sizing: border-box !important; width: 36px !important; height: 36px !important; min-width: 0 !important; min-height: 0 !important; max-width: none !important; padding: 0 !important; margin: 0; border-radius: 50% !important;
  border: 1px solid var(--ca-tool-line, color-mix(in srgb, currentColor 16%, transparent)) !important; background: var(--ca-tool-bg, color-mix(in srgb, currentColor 6%, transparent)) !important; color: var(--ca-tool-ink, inherit) !important;
  font: inherit; line-height: 0 !important; letter-spacing: 0; text-decoration: none !important; box-shadow: none; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background-color .15s ease, transform .12s ease; }
.ca-tool[hidden] { display: none !important; }
.ca-tool::before { content: ""; position: absolute; inset: -4px; }
.ca-tool svg { display: block; width: 20px !important; height: 20px !important; margin: 0 !important; pointer-events: none; }
.ca-tool svg[hidden] { display: none !important; }
@media (hover: hover) { .ca-tool:hover { background: var(--ca-tool-hover, color-mix(in srgb, currentColor 13%, transparent)) !important; } }
.ca-tool:active { transform: scale(.94); }
.ca-tool:focus-visible { outline: 3px solid var(--ca-accent, #4f6bff); outline-offset: 2px; }
.ca-tool-talk { color: var(--ca-accent, #4f6bff) !important; border-color: color-mix(in srgb, var(--ca-accent, #4f6bff) 50%, transparent) !important; background: color-mix(in srgb, var(--ca-accent, #4f6bff) 13%, transparent) !important; }
.ca-tool .ca-tlive { position: absolute; top: 1px; right: 1px; width: 9px; height: 9px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 2px color-mix(in srgb, #22c55e 30%, transparent); }
.ca-tool-talk.ca-new::after { content: ""; position: absolute; inset: -1px; border-radius: 50%; pointer-events: none; animation: ca-bar-ring 1.2s ease-out 2; }
@keyframes ca-bar-ring { from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ca-accent, #4f6bff) 55%, transparent); } to { box-shadow: 0 0 0 11px transparent; } }
.ca-tool .ca-tcount, .ca-tool .ca-tunread { position: absolute; right: -5px; display: grid; place-items: center; box-sizing: border-box; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; color: #fff; font: 700 10.5px/1 -apple-system, BlinkMacSystemFont, Inter, "Segoe UI", Roboto, sans-serif; font-variant-numeric: tabular-nums; letter-spacing: 0; pointer-events: none; }
.ca-tool .ca-tcount { bottom: -5px; background: #1f9d55; }
.ca-tool .ca-tunread { top: -5px; background: #e5484d; }
@media (max-width: 599.98px), (max-height: 499.98px) { .ca-tools-app { display: none !important; } }
.ca-end[data-ca-cramped] .ca-tools-app { display: none !important; }
.ca-end[data-ca-tight] .ca-tool-friends { display: none !important; }
@media (prefers-reduced-motion: reduce) { .ca-tool, .ca-brand a, .ca-brand-home img { transition: none; } .ca-tool-talk.ca-new::after { animation: none; } }
/* end of the cloud-apps bar */
/* ---- cloud-apps: big screens (App Standard §6.5) — written by `cloud-apps vendor-sdk`; do not edit ---- */
/* Past 1584 × 990 the page is laid out at about 1440 × 900 and zoomed to fill the screen; viewport
   units in this file are divided by --ca-zoom. cloud-kit.js turns it off where the engine has no
   standard zoom (html[data-ca-zoom="off"]). */
@media (min-width: 1585px) and (min-height: 991px) { :root { --ca-zoom: 1.1; } }
@media (min-width: 1656px) and (min-height: 1035px) { :root { --ca-zoom: 1.15; } }
@media (min-width: 1728px) and (min-height: 1080px) { :root { --ca-zoom: 1.2; } }
@media (min-width: 1800px) and (min-height: 1125px) { :root { --ca-zoom: 1.25; } }
@media (min-width: 1872px) and (min-height: 1170px) { :root { --ca-zoom: 1.3; } }
@media (min-width: 1945px) and (min-height: 1215px) { :root { --ca-zoom: 1.35; } }
@media (min-width: 2016px) and (min-height: 1260px) { :root { --ca-zoom: 1.4; } }
@media (min-width: 2088px) and (min-height: 1305px) { :root { --ca-zoom: 1.45; } }
@media (min-width: 2160px) and (min-height: 1350px) { :root { --ca-zoom: 1.5; } }
@media (min-width: 2232px) and (min-height: 1395px) { :root { --ca-zoom: 1.55; } }
@media (min-width: 2304px) and (min-height: 1440px) { :root { --ca-zoom: 1.6; } }
@media (min-width: 2376px) and (min-height: 1485px) { :root { --ca-zoom: 1.65; } }
@media (min-width: 2448px) and (min-height: 1530px) { :root { --ca-zoom: 1.7; } }
@media (min-width: 2520px) and (min-height: 1575px) { :root { --ca-zoom: 1.75; } }
@media (min-width: 2592px) and (min-height: 1620px) { :root { --ca-zoom: 1.8; } }
@media (min-width: 2664px) and (min-height: 1665px) { :root { --ca-zoom: 1.85; } }
@media (min-width: 2736px) and (min-height: 1710px) { :root { --ca-zoom: 1.9; } }
@media (min-width: 2808px) and (min-height: 1755px) { :root { --ca-zoom: 1.95; } }
@media (min-width: 2880px) and (min-height: 1800px) { :root { --ca-zoom: 2; } }
@media (min-width: 2952px) and (min-height: 1845px) { :root { --ca-zoom: 2.05; } }
@media (min-width: 3024px) and (min-height: 1890px) { :root { --ca-zoom: 2.1; } }
@media (min-width: 3096px) and (min-height: 1935px) { :root { --ca-zoom: 2.15; } }
@media (min-width: 3169px) and (min-height: 1981px) { :root { --ca-zoom: 2.2; } }
@media (min-width: 3240px) and (min-height: 2025px) { :root { --ca-zoom: 2.25; } }
@media (min-width: 3312px) and (min-height: 2070px) { :root { --ca-zoom: 2.3; } }
@media (min-width: 3384px) and (min-height: 2115px) { :root { --ca-zoom: 2.35; } }
@media (min-width: 3456px) and (min-height: 2160px) { :root { --ca-zoom: 2.4; } }
@media (min-width: 3529px) and (min-height: 2205px) { :root { --ca-zoom: 2.45; } }
@media (min-width: 3600px) and (min-height: 2250px) { :root { --ca-zoom: 2.5; } }
@media (min-width: 3672px) and (min-height: 2295px) { :root { --ca-zoom: 2.55; } }
@media (min-width: 3744px) and (min-height: 2340px) { :root { --ca-zoom: 2.6; } }
@media (min-width: 3816px) and (min-height: 2385px) { :root { --ca-zoom: 2.65; } }
@media (min-width: 3889px) and (min-height: 2430px) { :root { --ca-zoom: 2.7; } }
@media (min-width: 3960px) and (min-height: 2475px) { :root { --ca-zoom: 2.75; } }
@media (min-width: 4032px) and (min-height: 2520px) { :root { --ca-zoom: 2.8; } }
@media (min-width: 4104px) and (min-height: 2565px) { :root { --ca-zoom: 2.85; } }
@media (min-width: 4176px) and (min-height: 2610px) { :root { --ca-zoom: 2.9; } }
@media (min-width: 4248px) and (min-height: 2655px) { :root { --ca-zoom: 2.95; } }
@media (min-width: 4320px) and (min-height: 2700px) { :root { --ca-zoom: 3; } }
@media (min-width: 4392px) and (min-height: 2745px) { :root { --ca-zoom: 3.05; } }
@media (min-width: 4464px) and (min-height: 2790px) { :root { --ca-zoom: 3.1; } }
@media (min-width: 4536px) and (min-height: 2835px) { :root { --ca-zoom: 3.15; } }
@media (min-width: 4608px) and (min-height: 2880px) { :root { --ca-zoom: 3.2; } }
@media (min-width: 4680px) and (min-height: 2925px) { :root { --ca-zoom: 3.25; } }
@media (min-width: 4752px) and (min-height: 2970px) { :root { --ca-zoom: 3.3; } }
@media (min-width: 4824px) and (min-height: 3015px) { :root { --ca-zoom: 3.35; } }
@media (min-width: 4896px) and (min-height: 3060px) { :root { --ca-zoom: 3.4; } }
@media (min-width: 4968px) and (min-height: 3105px) { :root { --ca-zoom: 3.45; } }
@media (min-width: 5040px) and (min-height: 3150px) { :root { --ca-zoom: 3.5; } }
@media (min-width: 5112px) and (min-height: 3195px) { :root { --ca-zoom: 3.55; } }
@media (min-width: 5184px) and (min-height: 3240px) { :root { --ca-zoom: 3.6; } }
@media (min-width: 5256px) and (min-height: 3285px) { :root { --ca-zoom: 3.65; } }
@media (min-width: 5328px) and (min-height: 3330px) { :root { --ca-zoom: 3.7; } }
@media (min-width: 5400px) and (min-height: 3375px) { :root { --ca-zoom: 3.75; } }
@media (min-width: 5472px) and (min-height: 3420px) { :root { --ca-zoom: 3.8; } }
@media (min-width: 5544px) and (min-height: 3465px) { :root { --ca-zoom: 3.85; } }
@media (min-width: 5616px) and (min-height: 3510px) { :root { --ca-zoom: 3.9; } }
@media (min-width: 5688px) and (min-height: 3555px) { :root { --ca-zoom: 3.95; } }
@media (min-width: 5760px) and (min-height: 3600px) { :root { --ca-zoom: 4; } }
@media (min-width: 5832px) and (min-height: 3645px) { :root { --ca-zoom: 4.05; } }
@media (min-width: 5904px) and (min-height: 3690px) { :root { --ca-zoom: 4.1; } }
@media (min-width: 5977px) and (min-height: 3736px) { :root { --ca-zoom: 4.15; } }
@media (min-width: 6048px) and (min-height: 3780px) { :root { --ca-zoom: 4.2; } }
@media (min-width: 6120px) and (min-height: 3825px) { :root { --ca-zoom: 4.25; } }
@media (min-width: 6192px) and (min-height: 3870px) { :root { --ca-zoom: 4.3; } }
@media (min-width: 6264px) and (min-height: 3915px) { :root { --ca-zoom: 4.35; } }
@media (min-width: 6337px) and (min-height: 3961px) { :root { --ca-zoom: 4.4; } }
@media (min-width: 6408px) and (min-height: 4005px) { :root { --ca-zoom: 4.45; } }
@media (min-width: 6480px) and (min-height: 4050px) { :root { --ca-zoom: 4.5; } }
@media (min-width: 6552px) and (min-height: 4095px) { :root { --ca-zoom: 4.55; } }
@media (min-width: 6624px) and (min-height: 4140px) { :root { --ca-zoom: 4.6; } }
@media (min-width: 6697px) and (min-height: 4185px) { :root { --ca-zoom: 4.65; } }
@media (min-width: 6768px) and (min-height: 4230px) { :root { --ca-zoom: 4.7; } }
@media (min-width: 6840px) and (min-height: 4275px) { :root { --ca-zoom: 4.75; } }
@media (min-width: 6912px) and (min-height: 4320px) { :root { --ca-zoom: 4.8; } }
@media (min-width: 6984px) and (min-height: 4365px) { :root { --ca-zoom: 4.85; } }
@media (min-width: 7057px) and (min-height: 4410px) { :root { --ca-zoom: 4.9; } }
@media (min-width: 7128px) and (min-height: 4455px) { :root { --ca-zoom: 4.95; } }
@media (min-width: 7200px) and (min-height: 4500px) { :root { --ca-zoom: 5; } }
@media (min-width: 1585px) and (min-height: 991px) {
  html { zoom: var(--ca-zoom, 1); }
  html[data-ca-zoom='off'] { --ca-zoom: 1 !important; }
}
/* ---- end of big screens ---- */
