@font-face {
  font-family: "Fredoka";
  src: url("fonts/fredoka-sub.woff") format("woff");
  font-weight: 300 700;
  font-display: swap;
}

:root, [data-swatch="classic"] {
  --night: #241a44;
  --night-2: #33265e;
  --night-3: #45357a;
  --ink: #fff8ec;
  --ink-2: #d9cff5;
  --dim: #a99cd0;
  --accent: #ffd166;
  --pink: #ff8fc7;
  --bad: #ff7a90;
  --sq-light: #ecdcbf;   /* parchment */
  --sq-dark: #8466ad;    /* heather */
  --sel: #ffd166;
  --last: rgba(255, 209, 102, .42);
  --radius: 14px;
  /* theme tokens (see Themes at the end): these are "classic" */
  --deep: #1b1436; --panel: #251b47; --raised: #3e2f72; --shade: #160f2e; --big-bot: #2b2052; --resume-top: #4a3a7e;
  --on-accent: #2c2050; --accent-shadow: #b0862e; --bar-bg: rgba(27, 20, 54, .7); --banner-bg: rgba(36, 26, 68, .94);
  --frame: #5a4592; --mvnum: #6f62a0; --sheen: rgba(255, 255, 255, .10); --sel-sq: rgba(255, 209, 102, .55);
  --coord-l: #8466ad; --coord-d: var(--sq-light);
  --dot-l: rgba(44, 32, 80, .38); --ring-l: rgba(44, 32, 80, .45); --dot-d: rgba(255, 244, 220, .45); --ring-d: rgba(255, 244, 220, .55);
  --w-fill: #fff4dc; --w-line: #2c2050; --w-mark: #e7a23a; --b-fill: #2b1d4d; --b-line: #d4c4fa; --b-mark: #ffd166;
  --sig-w: #fff4dc; --sig-b: #8f7bd0;
  --sky:
    radial-gradient(2px 2px at 12% 18%, #fff8 50%, transparent 51%),
    radial-gradient(2px 2px at 82% 9%, #fff9 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 66% 30%, #fff6 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 30% 6%, #fff5 50%, transparent 51%),
    radial-gradient(2px 2px at 92% 74%, #fff6 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 6% 88%, #fff5 50%, transparent 51%),
    radial-gradient(60% 40% at 50% 0%, #4b3a8a 0%, transparent 70%),
    radial-gradient(50% 35% at 100% 100%, #3b2a6a 0%, transparent 70%),
    linear-gradient(#2a1f50, #1d1538);
  --board: min(calc(100vw - 16px), calc(100dvh - 280px), 640px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--night);
  color: var(--ink);
  font-family: "Fredoka", "Trebuchet MS", system-ui, sans-serif;
  font-size: 17px;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overflow-x: hidden;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; touch-action: manipulation; cursor: pointer; }
input { font: inherit; -webkit-user-select: text; user-select: text; }
[hidden] { display: none !important; }

/* a still night sky */
.sky {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: var(--sky);
}

.app {
  max-width: 680px; margin: 0 auto; min-height: 100dvh;
  padding: max(8px, env(safe-area-inset-top)) 8px max(10px, env(safe-area-inset-bottom));
}
.screen { display: flex; flex-direction: column; min-height: calc(100dvh - 20px); }

/* ---------- Home ---------- */
#home { gap: 12px; padding: 8px 8px 0; }
.brand { text-align: center; margin-top: 4vh; }
.brand .logo { width: 84px; height: 84px; fill: var(--w-fill); stroke: var(--w-line); stroke-width: 2; stroke-linejoin: round; color: var(--accent);
  filter: drop-shadow(0 6px 14px rgba(0,0,0,.45)); }
.brand h1 { margin: 2px 0 0; font-size: 40px; font-weight: 700; letter-spacing: .02em; color: var(--ink);
  text-shadow: 0 3px 0 var(--shade); }
.brand .tag { margin: 0; color: var(--dim); }

.big {
  display: block; width: 100%; text-align: left; border: 2px solid var(--night-3); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--night-2), var(--big-bot)); padding: 15px 18px; min-height: 64px;
  box-shadow: 0 4px 0 var(--shade);
}
.big b { display: block; font-size: 20px; font-weight: 600; }
.big small { display: block; color: var(--dim); font-size: 15px; margin-top: 2px; }
.big:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--shade); }
.big.resume { border-color: var(--accent); background: linear-gradient(180deg, var(--resume-top), var(--night-2)); }
.big.resume b { color: var(--accent); }
.modes { display: grid; gap: 12px; }
.home-foot { margin-top: auto; display: flex; flex-wrap: wrap; gap: 10px; align-items: end; padding: 14px 0 6px; }
.sheet .namefield { margin-top: 8px; }
.namefield { flex: 1 1 100%; display: grid; gap: 4px; color: var(--dim); font-size: 14px; }
.namefield input { background: var(--deep); border: 2px solid var(--night-3); border-radius: 12px; color: var(--ink); padding: 11px 12px; font-size: 17px; }
.namefield input:focus { outline: none; border-color: var(--accent); }
.chip-btn { flex: 1; border: 2px solid var(--night-3); background: var(--deep); border-radius: 99px; padding: 10px 14px; min-height: 46px; }
.chip-btn[aria-pressed="false"] { color: var(--dim); }

/* ---------- Sheets (bottom drawers) ---------- */
.sheet-bg { position: fixed; inset: 0; background: var(--scrim, rgba(10, 6, 24, .6)); z-index: 20; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-width: 680px; margin: 0 auto;
  background: var(--night-2); border-radius: 22px 22px 0 0; border-top: 2px solid var(--night-3);
  padding: 18px 16px max(18px, env(safe-area-inset-bottom)); max-height: 92dvh; overflow-y: auto;
  animation: up .22s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet h2 { margin: 0 0 6px; font-size: 22px; font-weight: 600; }
.label { color: var(--dim); font-size: 14px; margin: 14px 0 6px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.seg.two { grid-template-columns: 1fr 1fr; }
.seg.four { grid-template-columns: repeat(4, 1fr); }
.seg button {
  background: var(--panel); border: 2px solid var(--night-3); border-radius: 12px; padding: 10px 6px; min-height: 52px; text-align: center;
}
.seg button b { display: block; font-weight: 600; }
.seg button small { display: block; color: var(--dim); font-size: 13px; line-height: 1.2; }
.seg button[aria-pressed="true"] { border-color: var(--accent); background: var(--raised); }
.go {
  display: block; width: 100%; margin-top: 18px; min-height: 56px; border: 0; border-radius: 14px;
  background: var(--accent); color: var(--on-accent); font-size: 20px; font-weight: 600; box-shadow: 0 4px 0 var(--accent-shadow);
}
.go:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--accent-shadow); }
.go.small { width: auto; margin: 0; padding: 0 22px; font-size: 18px; }
.go.ghost { background: var(--night-3); color: var(--ink); box-shadow: 0 4px 0 var(--shade); }
.joinrow { display: flex; gap: 8px; }
.joinrow input {
  flex: 1; min-width: 0; text-transform: uppercase; letter-spacing: .3em; text-align: center; font-size: 24px; font-weight: 600;
  background: var(--deep); border: 2px solid var(--night-3); border-radius: 14px; color: var(--ink); padding: 8px;
}
.joinrow input:focus { outline: none; border-color: var(--accent); }
.or { text-align: center; color: var(--dim); font-size: 14px; margin: 16px 0 0; }
.err { color: var(--bad); min-height: 1.2em; margin: 10px 0 0; text-align: center; }
.howto { color: var(--ink-2); line-height: 1.45; margin: 8px 0; }
.legend { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0; }
.legend span { display: flex; align-items: center; gap: 6px; background: var(--panel); border-radius: 10px; padding: 4px 8px; font-size: 15px; }
.legend .pc { width: 34px; height: 34px; }

/* ---------- Game ---------- */
#game { align-items: center; gap: 6px; }
.topbar { display: flex; align-items: center; gap: 8px; width: var(--board); }
.icon-btn { width: 46px; height: 46px; border-radius: 12px; border: 2px solid var(--night-3); background: var(--deep); display: grid; place-items: center; padding: 0; }
.icon-btn svg { width: 24px; height: 24px; }
.mode-label { flex: 1; text-align: center; color: var(--ink-2); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pbar { width: var(--board); display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 4px 8px;
  border-radius: 12px; background: var(--bar-bg); border: 2px solid transparent; transition: border-color .2s; }
.pbar.turn { border-color: var(--accent); }
.pbar .sigil { width: 22px; height: 22px; flex: none; }
.pbar.w .sigil { fill: var(--sig-w); } .pbar.b .sigil { fill: var(--sig-b); }
.pname { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 62%; flex: 0 1 auto; min-width: 0; }
.pname small { color: var(--dim); font-weight: 400; margin-left: 4px; }
.taken { flex: 1; display: flex; flex-wrap: wrap; align-items: center; min-height: 20px; }
.taken .pc { width: 19px; height: 19px; margin-right: -5px; }
.taken .plus { margin-left: 8px; color: var(--dim); font-size: 14px; }
.clock { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 52px; text-align: center; border-radius: 8px; padding: 2px 8px; background: var(--deep); color: var(--dim); }
.pbar.turn .clock { color: var(--ink); background: var(--raised); }
.clock.low { color: var(--on-accent) !important; background: var(--bad) !important; }
.pbar.upside { transform: rotate(180deg); }

.board-wrap { position: relative; width: var(--board); height: var(--board); }
.board {
  position: relative; width: 100%; height: 100%; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
  border-radius: 10px; overflow: hidden; touch-action: none;
  box-shadow: 0 0 0 4px var(--deep), 0 0 0 6px var(--frame), 0 14px 30px rgba(0,0,0,.5);
}
.sq { position: relative; background: var(--sq-light); }
.sq.dark { background: var(--sq-dark); }
/* hand-made feel: a soft sheen on each square */
.sq::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(135deg, var(--sheen), transparent 60%); }
.sq.last::after { content: ""; position: absolute; inset: 0; background: var(--last); pointer-events: none; }
.sq.sel::after { content: ""; position: absolute; inset: 0; background: var(--sel-sq); pointer-events: none; }
.sq.check { background: radial-gradient(circle, #ff6f8b 0%, #e2456a 40%, transparent 75%), var(--sq-light); }
.sq.dark.check { background: radial-gradient(circle, #ff6f8b 0%, #e2456a 40%, transparent 75%), var(--sq-dark); }
.sq .dot { position: absolute; left: 50%; top: 50%; width: 30%; height: 30%; margin: -15% 0 0 -15%; border-radius: 50%;
  background: var(--dot-l); pointer-events: none; z-index: 2; }
.sq .ring { position: absolute; inset: 4%; border-radius: 50%; border: 4px solid var(--ring-l); pointer-events: none; z-index: 2; }
.sq.dark .dot { background: var(--dot-d); }
.sq.dark .ring { border-color: var(--ring-d); }
.sq.hover { box-shadow: inset 0 0 0 4px var(--accent); }
.coord { position: absolute; font-size: clamp(10px, calc(var(--board) / 50), 14px); font-weight: 600; pointer-events: none; color: var(--coord-l); z-index: 1; }
.sq.dark .coord { color: var(--coord-d); }
.coord.f { right: 3px; bottom: 1px; }
.coord.r { left: 3px; top: 1px; }

.pc { display: block; width: 100%; height: 100%; overflow: visible; stroke-width: 2.1; stroke-linejoin: round; stroke-linecap: round; }
.pc.w { fill: var(--w-fill); stroke: var(--w-line); color: var(--w-mark); }
.pc.b { fill: var(--b-fill); stroke: var(--b-line); color: var(--b-mark); }
.sq .pc { position: absolute; inset: 0; z-index: 3; pointer-events: none; filter: drop-shadow(0 2px 1.5px rgba(20, 10, 40, .45)); }
.sq .pc.upside { transform: rotate(180deg); }
.pc.moving { transition: transform .18s ease-out; }
.drag-ghost { position: fixed; z-index: 30; pointer-events: none; filter: drop-shadow(0 10px 8px rgba(0,0,0,.45)); }

.banner { position: absolute; left: 8%; right: 8%; top: 40%; z-index: 6; text-align: center; padding: 12px 14px;
  background: var(--banner-bg); border: 2px solid var(--accent); border-radius: 14px; font-size: 18px; }
.banner .modal-buttons { margin-top: 10px; }

.status { min-height: 26px; color: var(--ink-2); text-align: center; font-size: 17px; }
.status b { color: var(--accent); font-weight: 600; }
.movelist { width: var(--board); display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; min-height: 30px; padding: 2px 2px; color: var(--dim); font-size: 15px; white-space: nowrap; }
.movelist::-webkit-scrollbar { display: none; }
.movelist .mv { flex: none; }
.movelist .mv i { font-style: normal; color: var(--mvnum); margin-right: 3px; }
.movelist .mv:last-child { color: var(--ink); }
.actions { width: var(--board); display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: auto; padding-top: 6px; }
.act { min-height: 52px; border-radius: 12px; border: 2px solid var(--night-3); background: var(--night-2); font-size: 16px; padding: 4px; line-height: 1.1; }
.act:disabled { opacity: .35; }
.act:active:not(:disabled) { background: var(--night-3); }

/* ---------- Modals ---------- */
.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: var(--scrim, rgba(10, 6, 24, .62)); padding: 16px; }
.modal .card { width: min(100%, 380px); background: var(--night-2); border: 2px solid var(--night-3); border-radius: 20px; padding: 20px 18px; text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,.5); animation: up .2s ease-out; }
.modal h3 { margin: 0 0 6px; font-size: 24px; font-weight: 600; }
.modal p { margin: 0 0 8px; color: var(--ink-2); }
.modal-buttons { display: grid; gap: 10px; margin-top: 14px; }
.modal-buttons .go { margin: 0; }
.promo-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.promo-row button { aspect-ratio: 1; border-radius: 14px; border: 2px solid var(--night-3); background: var(--sq-light); padding: 4px; }
.promo-row button:active { border-color: var(--accent); }
.roomcode { font-size: 52px; font-weight: 700; letter-spacing: .22em; margin: 2px 0 6px; padding-left: .22em; color: var(--accent); }

.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: var(--night); padding: 10px 16px; border-radius: 12px; font-weight: 600; pointer-events: none;
  opacity: 0; transition: opacity .2s; max-width: 90vw; text-align: center; }
.toast.on { opacity: 1; }

/* Landscape phones and desktop: board on the left, everything else beside it.
   (From 560px wide, so a small phone on its side gets the big board too, not a tiny one above the buttons.) */
@media (min-aspect-ratio: 6/5) and (min-width: 560px) {
  :root { --board: min(calc(100dvh - 40px), calc(100vw - 316px), 720px); }
  .app { max-width: 1100px; }
  #game { display: grid; grid-template-columns: var(--board) minmax(250px, 320px); grid-template-rows: auto auto auto 1fr auto auto; column-gap: 20px; row-gap: 8px; align-items: start; justify-content: center; }
  #game .board-wrap { grid-column: 1; grid-row: 1 / span 6; }
  #game .topbar, #game .pbar, #game .status, #game .movelist, #game .actions { grid-column: 2; width: 100%; }
  #game .topbar { grid-row: 1; } #bar-top { grid-row: 2; } #game .status { grid-row: 3; } #game .movelist { grid-row: 4; align-self: stretch; }
  #bar-bottom { grid-row: 5; } #game .actions { grid-row: 6; }
  #game .actions { grid-template-columns: 1fr 1fr; }
  .movelist { flex-wrap: wrap; white-space: normal; overflow: visible; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- Checkers ---------- */
.sq .pc { inset: 4%; width: 92%; height: 92%; }
:root, [data-swatch="classic"] { --w-mark: #7a5cc0; }
.pc.w { fill: var(--w-fill); stroke: var(--w-line); color: var(--w-mark); }
.pc.b { fill: var(--b-fill); stroke: var(--b-line); color: var(--b-mark); }
.sq.must::after { content: ""; position: absolute; inset: 6%; border-radius: 50%; pointer-events: none; z-index: 4;
  box-shadow: 0 0 0 3px var(--accent), 0 0 14px 4px rgba(255, 209, 102, .55); animation: glow 1.6s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 3px var(--accent), 0 0 6px 1px rgba(255, 209, 102, .3); } }
.sq.path::after { content: ""; position: absolute; inset: 0; background: rgba(255, 209, 102, .35); pointer-events: none; }
.sq .pc.jumped { opacity: .35; }
.sq .pc.fading { animation: fade .35s ease-out forwards; }
@keyframes fade { to { opacity: 0; transform: scale(.6); } }
.legend .pc { width: 38px; height: 38px; }
.brand .logo { fill: var(--w-fill); stroke: var(--w-line); color: var(--w-mark); }

/* Short landscape screens (phones on their side): tighter side column, and the home menu in two columns */
@media (orientation: landscape) and (max-height: 540px) {
  :root { --board: min(calc(100dvh - 24px), calc(100vw - 300px), 720px); }
  .app { padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: max(6px, env(safe-area-inset-bottom));
    padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
  .screen { min-height: calc(100dvh - 12px); }
  #game { row-gap: 6px; column-gap: 14px; }
  .act { min-height: 46px; }
  .movelist { min-height: 0; }
  #home { display: grid; grid-template-columns: 1fr 1.25fr; grid-template-rows: auto 1fr; column-gap: 20px; row-gap: 10px; align-content: center; }
  #home .brand { grid-column: 1; grid-row: 1; margin-top: 0; align-self: end; }
  #home .brand .logo { width: 60px; height: 60px; }
  #home .brand h1 { font-size: 32px; }
  #home .home-foot { grid-column: 1; grid-row: 2; margin-top: 0; align-self: start; padding-top: 4px; }
  #home #resume, #home .modes { grid-column: 2; }
  #home #resume { grid-row: 1; align-self: end; }
  #home .modes { grid-row: 1 / span 2; align-self: center; gap: 10px; }
  #home #resume:not([hidden]) ~ .modes { grid-row: 2; align-self: start; }
  .big { padding: 10px 16px; min-height: 56px; }
}

/* ---------- Themes ----------
   Each theme is a set of colour tokens on <html data-theme="...">. "classic" is the :root values above.
   theme.js applies the saved one before the page is drawn; the picker is the Theme sheet on the home screen. */
:root[data-theme="midnight"], [data-swatch="midnight"] {
  --night: #0e0f14; --night-2: #1a1c24; --night-3: #2c2f3b; --ink: #eef0f5; --ink-2: #c9ccd6; --dim: #9599a8;
  --accent: #8fb8ff; --on-accent: #0e1626; --accent-shadow: #4f6fa8; --bad: #ff7a85;
  --deep: #08090d; --panel: #15171e; --raised: #263147; --shade: #000; --big-bot: #14161c; --resume-top: #22283a;
  --bar-bg: rgba(20, 22, 30, .85); --banner-bg: rgba(14, 15, 20, .95); --frame: #3a4152; --mvnum: #6b7080;
  --sky: radial-gradient(60% 40% at 50% 0%, #1d2233 0%, transparent 70%), linear-gradient(#111319, #0a0b0f);
  --sq-light: #b9bfcc; --sq-dark: #5b6377; --coord-l: #4b5266; --coord-d: #e3e7ee;
  --w-fill: #f2f2ee; --w-line: #15171e; --w-mark: #5f8fe0; --b-fill: #1c1e26; --b-line: #e6e8ef; --b-mark: #8fb8ff;
  --sig-w: #f2f2ee; --sig-b: #9aa3b8; --last: rgba(143, 184, 255, .42); --sel-sq: rgba(143, 184, 255, .6);
}
:root[data-theme="wood"], [data-swatch="wood"] {
  color-scheme: light;
  --night: #f3ead8; --night-2: #fffaf0; --night-3: #d8c7a4; --ink: #2e2214; --ink-2: #4a3a26; --dim: #6b573d;
  --accent: #a84a24; --on-accent: #fffaf0; --accent-shadow: #6e2f14; --bad: #b3261e;
  --deep: #fffdf8; --panel: #f7eedd; --raised: #f0dcc0; --shade: #c9b48e; --big-bot: #f5ead6; --resume-top: #fff3df;
  --bar-bg: rgba(255, 250, 240, .85); --banner-bg: rgba(255, 250, 240, .97); --frame: #6b4423; --mvnum: #9a8464;
  --sky: radial-gradient(60% 40% at 50% 0%, #fff7e6 0%, transparent 70%), linear-gradient(#f6eedd, #eadcc0);
  --sq-light: #f0d9b5; --sq-dark: #b58863; --coord-l: #8a6445; --coord-d: #3b2616; --sheen: rgba(255, 255, 255, .14);
  --w-fill: #fffaf0; --w-line: #2e2214; --w-mark: #c4862f; --b-fill: #3b2616; --b-line: #f6e6cc; --b-mark: #e0a84a;
  --sig-w: #c4862f; --sig-b: #3b2616; --last: rgba(214, 170, 40, .45); --sel-sq: rgba(214, 170, 40, .62);
}
:root[data-theme="neon"], [data-swatch="neon"] {
  --night: #0a0618; --night-2: #160d2e; --night-3: #3a1d6e; --ink: #f4f1ff; --ink-2: #d6ccff; --dim: #a596d8;
  --accent: #2af5d2; --on-accent: #04201b; --accent-shadow: #0f8f7a; --bad: #ff4f8b;
  --deep: #07041a; --panel: #120a28; --raised: #2a1460; --shade: #000; --big-bot: #110a26; --resume-top: #26135a;
  --bar-bg: rgba(16, 8, 40, .85); --banner-bg: rgba(10, 6, 24, .95); --frame: #ff3fd4; --mvnum: #7a68b8;
  --sky: radial-gradient(50% 35% at 15% 0%, rgba(255, 63, 212, .32) 0%, transparent 70%), radial-gradient(50% 35% at 90% 100%, rgba(42, 245, 210, .22) 0%, transparent 70%), linear-gradient(#0d0722, #06030f);
  --sq-light: #cfc9ff; --sq-dark: #4b2a8c; --coord-l: #4b2a8c; --coord-d: #e9e5ff;
  --w-fill: #effffc; --w-line: #0a0618; --w-mark: #ff3fd4; --b-fill: #1a0638; --b-line: #2af5d2; --b-mark: #ff3fd4;
  --sig-w: #effffc; --sig-b: #2af5d2; --last: rgba(42, 245, 210, .36); --sel-sq: rgba(42, 245, 210, .52);
}
:root[data-theme="tournament"], [data-swatch="tournament"] {
  --night: #12241a; --night-2: #1b3426; --night-3: #2f5240; --ink: #f1f5ec; --ink-2: #d4e2cf; --dim: #a3bca6;
  --accent: #f2c14e; --on-accent: #22301f; --accent-shadow: #a8812a; --bad: #ff8a7a;
  --deep: #0c1a12; --panel: #17301f; --raised: #2c4a36; --shade: #07110b; --big-bot: #16301f; --resume-top: #2a4a35;
  --bar-bg: rgba(12, 26, 18, .8); --banner-bg: rgba(18, 36, 26, .96); --frame: #4a6b3a; --mvnum: #6f8f74;
  --sky: radial-gradient(60% 40% at 50% 0%, #2c5238 0%, transparent 70%), linear-gradient(#173023, #0d1b13);
  --sq-light: #eeeed2; --sq-dark: #769656; --coord-l: #5f7d45; --coord-d: #f4f4de;
  --w-fill: #ffffff; --w-line: #1f2a1f; --w-mark: #d9a43a; --b-fill: #2a2a2a; --b-line: #f4f4e8; --b-mark: #f2c14e;
  --sig-w: #ffffff; --sig-b: #8fb08f; --last: rgba(246, 246, 105, .5); --sel-sq: rgba(246, 246, 105, .65);
}
:root[data-theme="ocean"], [data-swatch="ocean"] {
  --night: #0b2236; --night-2: #12324d; --night-3: #24557a; --ink: #eef7ff; --ink-2: #cfe4f5; --dim: #9dbdd4;
  --accent: #ffb86b; --on-accent: #2b1a08; --accent-shadow: #b0753a; --bad: #ff8a8a;
  --deep: #081a2a; --panel: #0f2b43; --raised: #1f4a6e; --shade: #04121e; --big-bot: #0f2c45; --resume-top: #1d4668;
  --bar-bg: rgba(8, 26, 42, .8); --banner-bg: rgba(11, 34, 54, .96); --frame: #6fa3c7; --mvnum: #6a90ad;
  --sky: radial-gradient(60% 40% at 50% 0%, #1f5580 0%, transparent 70%), linear-gradient(#0f2c45, #071724);
  --sq-light: #e8eef2; --sq-dark: #7d9bb0; --coord-l: #55778f; --coord-d: #0b2236;
  --w-fill: #ffffff; --w-line: #0b2236; --w-mark: #f0963c; --b-fill: #13283b; --b-line: #e6f1fa; --b-mark: #ffb86b;
  --sig-w: #ffffff; --sig-b: #6fa3c7; --last: rgba(255, 184, 107, .45); --sel-sq: rgba(255, 184, 107, .62);
}
:root[data-theme="pastel"], [data-swatch="pastel"] {
  color-scheme: light;
  --night: #f7f1fb; --night-2: #ffffff; --night-3: #dccdf0; --ink: #3a2b52; --ink-2: #4f3f6a; --dim: #6a5a86;
  --accent: #f7b6d2; --on-accent: #3a2b52; --accent-shadow: #d98bb0; --bad: #b42848;
  --deep: #ffffff; --panel: #f3ebfa; --raised: #f8dcec; --shade: #d8c8ea; --big-bot: #f6effc; --resume-top: #fde8f2;
  --bar-bg: rgba(255, 255, 255, .85); --banner-bg: rgba(255, 255, 255, .97); --frame: #b8a2e0; --mvnum: #9f8fbb;
  --sky: radial-gradient(50% 40% at 10% 0%, #ffe3ef 0%, transparent 70%), radial-gradient(50% 40% at 90% 100%, #dff3ee 0%, transparent 70%), linear-gradient(#f9f3fd, #f1eafa);
  --sq-light: #fdf3f7; --sq-dark: #9d86d0; --coord-l: #7d69b0; --coord-d: #fdf3f7;
  --w-fill: #ffffff; --w-line: #4a3a68; --w-mark: #f28cb8; --b-fill: #4a3a68; --b-line: #ffffff; --b-mark: #ffd36e;
  --sig-w: #f28cb8; --sig-b: #4a3a68; --last: rgba(242, 140, 184, .38); --sel-sq: rgba(242, 140, 184, .55);
}
:root[data-theme="contrast"], [data-swatch="contrast"] {
  --night: #000; --night-2: #000; --night-3: #fff; --ink: #fff; --ink-2: #fff; --dim: #e6e6e6;
  --accent: #ffe500; --on-accent: #000; --accent-shadow: #8a7c00; --bad: #ff6b6b;
  --deep: #000; --panel: #000; --raised: #333; --shade: #000; --big-bot: #000; --resume-top: #1a1a1a;
  --bar-bg: #000; --banner-bg: #000; --frame: #fff; --mvnum: #c8c8c8; --sky: linear-gradient(#000, #000);
  --sq-light: #ffffff; --sq-dark: #1f5fc8; --coord-l: #000; --coord-d: #fff; --sheen: transparent;
  --dot-l: rgba(0, 0, 0, .6); --ring-l: rgba(0, 0, 0, .7); --dot-d: rgba(255, 255, 255, .8); --ring-d: rgba(255, 255, 255, .85);
  --w-fill: #ffffff; --w-line: #000; --w-mark: #000; --b-fill: #000; --b-line: #fff; --b-mark: #ffe500;
  --sig-w: #fff; --sig-b: #ffe500; --last: rgba(255, 229, 0, .55); --sel-sq: rgba(255, 229, 0, .78);
}
:root[data-theme="contrast"] .pc { stroke-width: 2.8; }
:root[data-theme="contrast"] .big, :root[data-theme="contrast"] .seg button, :root[data-theme="contrast"] .act { border-color: #fff; }

/* the picker: one swatch per theme, a little board corner and both pieces in that theme's colours */
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 10px; }
.themes button { display: flex; align-items: center; gap: 10px; min-height: 60px; padding: 8px 10px; text-align: left;
  border-radius: 14px; border: 2px solid var(--night-3); background: var(--panel); color: var(--ink); }
.themes button[aria-pressed="true"] { border-color: var(--accent); background: var(--raised); }
.themes .sw { flex: none; display: grid; grid-template-columns: 1fr 1fr; width: 40px; height: 40px; border-radius: 8px; overflow: hidden; box-shadow: 0 0 0 2px var(--deep); }
.themes .sw i { display: block; background: var(--sq-light); }
.themes .sw i.d { background: var(--sq-dark); }
.themes .sw svg { width: 100%; height: 100%; }
