/* ═══════════════════════════════════════════════════════════════
   KING OF CHECKERS
   Aesthetic: midnight card-room luxury. Espresso felt, lacquered
   walnut, ivory & carmine pieces, gold-leaf accents.
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* palette */
  --ink-950: #0d0b0a;
  --ink-900: #131110;
  --ink-850: #1a1715;
  --ink-800: #221e1b;
  --ink-700: #2e2925;
  --ink-600: #3d3630;
  --line: #35302a;
  --parchment: #e9ddc7;
  --parchment-dim: #b3a68c;
  --parchment-faint: #7d7361;
  --gold: #c9a35c;
  --gold-bright: #e8c987;
  --gold-deep: #8f6f35;
  --carmine: #a33327;
  --carmine-bright: #c94a38;

  /* board woods */
  --wood-frame-1: #4a3220;
  --wood-frame-2: #2c1d10;
  --sq-dark-1: #5d4023;
  --sq-dark-2: #4a3118;
  --sq-light-1: #d9c49a;
  --sq-light-2: #c8b083;

  /* pieces */
  --pc-red-1: #c74836;
  --pc-red-2: #8e2b1e;
  --pc-red-3: #5e1a10;
  --pc-white-1: #f4ead2;
  --pc-white-2: #d9c9a4;
  --pc-white-3: #a08d63;

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Spline Sans Mono", "SF Mono", Menlo, monospace;

  --ease-out: cubic-bezier(.22,1,.36,1);
  --ease-spring: cubic-bezier(.34,1.56,.64,1);

  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { height: 100%; }

body {
  min-height: 100%;
  background: var(--ink-900);
  color: var(--parchment);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  /* felt texture: layered radial glows + fine noise via gradients */
  background-image:
    radial-gradient(120% 90% at 50% -10%, #241e19 0%, transparent 60%),
    radial-gradient(90% 70% at 50% 110%, #1c1613 0%, transparent 55%),
    repeating-linear-gradient(45deg, rgba(255,255,255,.006) 0 2px, transparent 2px 4px),
    repeating-linear-gradient(-45deg, rgba(0,0,0,.02) 0 2px, transparent 2px 4px);
  background-attachment: fixed;
}

/* no double-tap zoom anywhere; the board rejects all browser gestures */
html { touch-action: manipulation; }

/* no visible scrollbars anywhere; everything still scrolls */
* { scrollbar-width: none; -ms-overflow-style: none; }
*::-webkit-scrollbar { width: 0; height: 0; display: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; touch-action: manipulation; }
.board-frame, .board-frame * { touch-action: none; user-select: none; -webkit-user-select: none; }
button:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 4px; }

.screen { min-height: 100dvh; display: flex; flex-direction: column; }
[hidden] { display: none !important; }

/* ═══════════════ MENU ═══════════════ */

.screen--menu { align-items: center; padding: calc(var(--sat) + 28px) 20px calc(var(--sab) + 28px); }
.menu-inner { width: 100%; max-width: 430px; display: flex; flex-direction: column; }

/* staggered entrance */
.masthead, .ledger, .setup__block, .btn-play, .menu-foot, .btn-ghost {
  animation: rise .7s var(--ease-out) both;
}
.ledger { animation-delay: .08s; }
.setup__block:nth-child(1) { animation-delay: .14s; }
.setup__block:nth-child(2) { animation-delay: .20s; }
.setup__block:nth-child(3) { animation-delay: .26s; }
.btn-play { animation-delay: .34s; }
.btn-ghost { animation-delay: .38s; }
.menu-foot { animation-delay: .42s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.masthead { text-align: center; margin-bottom: 26px; }

.masthead__crest { width: 84px; margin: 0 auto 14px; filter: drop-shadow(0 6px 18px rgba(201,163,92,.25)); }
.crest-svg { display: block; width: 100%; }
.crest-ring { fill: none; stroke: var(--gold-deep); stroke-width: 1.5; }
.crest-disc { fill: var(--carmine); }
.crest-groove { fill: none; stroke: rgba(0,0,0,.28); stroke-width: 1.4; }
.crest-crown { fill: var(--gold-bright); }

.masthead__over {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .32em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 6px;
}
.masthead__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(38px, 10.5vw, 52px);
  line-height: 1.04;              /* roomy enough that descenders stay inside */
  letter-spacing: -.01em;
  padding-bottom: .08em;          /* gradient text only paints inside the box */
  background: linear-gradient(175deg, #f6ecd6 30%, #cbb98f 75%, #a8925f);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.masthead__title em {
  font-style: italic;
  font-weight: 400;
  font-size: .62em;
}
.masthead__tag {
  margin-top: 10px;
  font-size: 15px;
  color: var(--parchment-dim);
}
.masthead__tag em { font-family: var(--font-display); font-style: italic; color: var(--gold-bright); }

/* who's playing */
.ledger__who {
  text-align: center;
  font-size: 13px;
  color: var(--parchment-faint);
  margin-bottom: 8px;
  animation: rise .7s var(--ease-out) both;
  animation-delay: .06s;
}
.who-btn {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 15px;
  color: var(--gold-bright);
  border-bottom: 1px dotted var(--gold-deep);
  padding-bottom: 1px;
}

/* leaderboard button */
.btn-lb {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%;
  padding: 12px;
  margin: -14px 0 26px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(160deg, var(--ink-850), var(--ink-900));
  color: var(--gold);
  font-family: var(--font-mono);
  font-size: 11px; letter-spacing: .22em; text-transform: uppercase;
  transition: border-color .2s, color .2s;
  animation: rise .7s var(--ease-out) both;
  animation-delay: .1s;
}
.btn-lb svg { width: 18px; height: 18px; }
.btn-lb:hover { border-color: var(--gold-deep); color: var(--gold-bright); }

/* record ledger */
.ledger {
  display: flex; align-items: center; justify-content: center; gap: 22px;
  padding: 14px 10px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 28px;
}
.ledger__cell { display: flex; flex-direction: column; align-items: center; min-width: 58px; }
.ledger__num { font-family: var(--font-display); font-size: 30px; font-weight: 500; line-height: 1.05; color: var(--parchment); font-variant-numeric: tabular-nums; }
.ledger__lbl { font-family: var(--font-mono); font-size: 10px; letter-spacing: .22em; text-transform: uppercase; color: var(--parchment-faint); margin-top: 2px; }
.ledger__rule { width: 1px; height: 34px; background: var(--line); }

/* setup blocks */
.setup { display: flex; flex-direction: column; gap: 26px; margin-bottom: 30px; }
.setup__label {
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 500;
  letter-spacing: .28em; text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 12px;
}

/* variant cards: horizontal scroll */
.variant-scroll {
  display: flex; gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 2px 2px 10px;
  margin: 0 -20px; padding-left: 20px; padding-right: 20px;
  scrollbar-width: none;
}
.variant-scroll::-webkit-scrollbar { display: none; }

.vcard {
  position: relative;
  flex: 0 0 148px;
  scroll-snap-align: start;
  text-align: left;
  padding: 14px 14px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(160deg, var(--ink-850), var(--ink-900));
  transition: border-color .25s, background .25s, transform .25s var(--ease-out);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.vcard__info {
  position: absolute;
  top: 8px; right: 8px;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  color: var(--parchment-faint);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 14px;
  line-height: 1;
  transition: color .2s, border-color .2s;
  z-index: 2;
}
.vcard__info:hover { color: var(--gold-bright); border-color: var(--gold-deep); }
.vcard[aria-checked="true"] .vcard__info { color: var(--gold); border-color: var(--gold-deep); }
.vcard:active { transform: scale(.97); }
.vcard[aria-checked="true"] {
  border-color: var(--gold-deep);
  background: linear-gradient(160deg, #262019, #1a1512);
  box-shadow: 0 0 0 1px var(--gold-deep), 0 8px 24px -12px rgba(201,163,92,.35);
}
.vcard__flag {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .18em;
  line-height: 1;
  color: var(--gold);
  margin-bottom: 10px;
}
.vcard__name { display: block; font-family: var(--font-display); font-size: 16.5px; font-weight: 600; line-height: 1.15; color: var(--parchment); }
.vcard__meta { display: block; margin-top: 5px; font-family: var(--font-mono); font-size: 10px; letter-spacing: .06em; color: var(--parchment-faint); }
.vcard[aria-checked="true"] .vcard__meta { color: var(--gold); }

/* saved-ruleset cards ride the rail with a scripted look */
.vcard--preset { border-style: dashed; border-color: var(--gold-deep); }
.vcard--preset .vcard__name { font-style: italic; }
.vcard--preset[aria-checked="true"] { border-style: solid; }

/* save-a-ruleset row inside the house sheet */
.house-save {
  display: flex; gap: 8px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--line);
}
.house-save input {
  flex: 1; min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--ink-800);
  color: var(--parchment);
  font: inherit; font-size: 14px;
  outline: none;
}
.house-save input:focus { border-color: var(--gold-deep); }
.house-save button {
  flex: none;
  padding: 10px 18px;
  border-radius: 10px;
  background: linear-gradient(178deg, #d8b26b, #b78d47 55%, #96702f);
  color: #241a08;
  font-weight: 700;
  font-size: 14px;
}

/* house rules button under the cards */
.house-btn {
  display: flex; align-items: center; gap: 8px;
  margin-top: 2px;
  padding: 8px 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  font-size: 13px;
  color: var(--parchment-dim);
  transition: color .2s, border-color .2s;
}
.house-btn svg { width: 16px; height: 16px; flex: none; }
.house-btn:hover { color: var(--gold-bright); border-color: var(--gold-deep); }
.house-btn.tweaked { color: var(--gold-bright); border-color: var(--gold-deep); border-style: solid; }

/* segmented control */
.seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--ink-850);
}
.seg__opt {
  padding: 12px 6px 10px;
  text-align: center;
  border-right: 1px solid var(--line);
  transition: background .25s, color .25s;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--parchment-dim);
}
.seg__opt:last-child { border-right: 0; }
/* end options carry the parent's curve so the selected outline isn't clipped */
.seg__opt:first-child { border-radius: 11px 0 0 11px; }
.seg__opt:last-child { border-radius: 0 11px 11px 0; }
.seg__opt:only-child { border-radius: 11px; }
.seg__opt[aria-checked="true"] {
  background: linear-gradient(180deg, #2b2118, #221a13);
  color: var(--gold-bright);
  box-shadow: inset 0 0 0 1px var(--gold-deep);
}
.seg__opt-name { font-family: var(--font-display); font-size: 14.5px; font-weight: 600; line-height: 1.1; }
.seg__opt-sub { font-family: var(--font-mono); font-size: 9px; letter-spacing: .14em; text-transform: uppercase; opacity: .75; }
.seg__hint { margin-top: 9px; font-size: 12.5px; color: var(--parchment-faint); min-height: 1.4em; font-style: italic; font-family: var(--font-display); }

/* color choice swatches */
.seg--colors .seg__opt { flex-direction: row; justify-content: center; gap: 9px; padding: 13px 6px; }
.swatch { width: 22px; height: 22px; border-radius: 50%; flex: none; box-shadow: inset 0 -3px 5px rgba(0,0,0,.35), inset 0 2px 3px rgba(255,255,255,.25), 0 2px 4px rgba(0,0,0,.5); }
.swatch--red { background: radial-gradient(circle at 35% 30%, var(--pc-red-1), var(--pc-red-2) 60%, var(--pc-red-3)); }
.swatch--white { background: radial-gradient(circle at 35% 30%, var(--pc-white-1), var(--pc-white-2) 65%, var(--pc-white-3)); }

/* play button */
.btn-play {
  position: relative;
  display: block; width: 100%;
  padding: 17px 20px;
  border-radius: 14px;
  background: linear-gradient(178deg, #d8b26b, #b78d47 55%, #96702f);
  color: #241a08;
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(255,235,190,.6) inset, 0 -2px 0 rgba(80,55,10,.45) inset, 0 12px 30px -10px rgba(201,163,92,.45);
  transition: transform .2s var(--ease-out), box-shadow .3s;
}
.btn-play:active { transform: scale(.98); }
.btn-play::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,.35) 48%, transparent 62%);
  transform: translateX(-120%);
  animation: sheen 4.5s ease-in-out infinite;
}
@keyframes sheen { 0%, 55% { transform: translateX(-120%); } 75%, 100% { transform: translateX(120%); } }
.btn-play__word {
  position: relative;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: .02em;
}
.btn-play--sm { padding: 13px 26px; width: auto; }
.btn-play--sm .btn-play__word { font-size: 16px; }

.btn-ghost {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--parchment-dim);
  font-size: 14px;
  transition: border-color .2s, color .2s;
}
.btn-ghost:hover { border-color: var(--gold-deep); color: var(--gold-bright); }

.menu-foot { margin-top: 28px; display: flex; justify-content: center; align-items: center; gap: 12px; }
.foot-link { font-size: 13px; color: var(--parchment-faint); transition: color .2s; }
.foot-link:hover { color: var(--gold-bright); }
.foot-dot { color: var(--ink-600); }

/* ═══════════════ GAME ═══════════════ */

.screen--game {
  padding: calc(var(--sat) + 10px) 12px calc(var(--sab) + 10px);
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
  gap: 8px;
  /* the game page never scrolls */
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.game-top { display: flex; align-items: center; gap: 10px; }
.game-top__mid { flex: 1; text-align: center; min-width: 0; }
.game-top__variant { display: block; font-family: var(--font-display); font-weight: 600; font-size: 16px; color: var(--parchment); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game-top__opp { display: block; font-family: var(--font-mono); font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); }

.icon-btn {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--parchment-dim);
  background: var(--ink-850);
  transition: color .2s, border-color .2s;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { color: var(--gold-bright); border-color: var(--gold-deep); }

/* player plates */
.plate {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: linear-gradient(165deg, var(--ink-850), var(--ink-900));
  min-height: 56px;
}
.plate__id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.plate__avatar {
  width: 38px; height: 38px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 11px; font-weight: 600; letter-spacing: .05em;
}
.plate__avatar--ai { background: radial-gradient(circle at 35% 30%, #3a322b, #201b16); color: var(--gold); border: 1px solid var(--gold-deep); }
.plate__avatar--ai svg { width: 26px; height: 26px; }
.plate__avatar--you { background: radial-gradient(circle at 35% 30%, #4c2e26, #2a1712); color: var(--parchment); border: 1px solid #5e3a2c; }
.plate__names { display: flex; flex-direction: column; min-width: 0; }
.plate__name { font-family: var(--font-display); font-weight: 600; font-size: 15px; line-height: 1.15; white-space: nowrap; }
.plate__status { font-family: var(--font-mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--parchment-faint); margin-top: 1px; transition: color .3s; }
.plate--active { border-color: var(--gold-deep); box-shadow: 0 0 0 1px var(--gold-deep), 0 6px 20px -10px rgba(201,163,92,.4); }
.plate--active .plate__status { color: var(--gold-bright); }

/* thinking animation */
.plate__status.thinking::after {
  content: "";
  display: inline-block;
  animation: dots 1.2s steps(4) infinite;
}
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

/* captured pieces pot */
.plate__pot { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 0; max-width: 46%; }
.pot-pc {
  width: 16px; height: 16px; border-radius: 50%;
  margin-left: -5px;
  box-shadow: inset 0 -2px 3px rgba(0,0,0,.4), inset 0 1px 2px rgba(255,255,255,.25), 0 1px 2px rgba(0,0,0,.5);
  animation: potIn .4s var(--ease-spring) both;
}
@keyframes potIn { from { transform: scale(0); } to { transform: scale(1); } }
.pot-pc--red { background: radial-gradient(circle at 35% 30%, var(--pc-red-1), var(--pc-red-2) 60%, var(--pc-red-3)); }
.pot-pc--white { background: radial-gradient(circle at 35% 30%, var(--pc-white-1), var(--pc-white-2) 65%, var(--pc-white-3)); }
.pot-pc--king { outline: 1.5px solid var(--gold); outline-offset: -1.5px; }

/* board */
.board-arena { display: grid; place-items: center; }
.board-frame {
  position: relative;
  width: min(100%, calc(100dvh - 320px));
  aspect-ratio: 1;
  padding: 2.8%; /* square frame: % padding resolves against width on all sides */
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.06), transparent 40%),
    repeating-linear-gradient(80deg, rgba(0,0,0,.09) 0 3px, transparent 3px 9px),
    linear-gradient(160deg, var(--wood-frame-1), var(--wood-frame-2));
  box-shadow:
    0 1px 0 rgba(255,220,170,.12) inset,
    0 24px 60px -20px rgba(0,0,0,.8),
    0 6px 18px rgba(0,0,0,.45);
}
.board {
  position: relative;
  width: 100%; height: 100%;
  display: grid;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 0 0 2px rgba(0,0,0,.5), inset 0 2px 10px rgba(0,0,0,.4);
}
.sq { position: relative; }
.sq--light {
  background:
    repeating-linear-gradient(75deg, rgba(0,0,0,.035) 0 2px, transparent 2px 7px),
    linear-gradient(150deg, var(--sq-light-1), var(--sq-light-2));
}
.sq--dark {
  background:
    repeating-linear-gradient(75deg, rgba(0,0,0,.06) 0 2px, transparent 2px 7px),
    linear-gradient(150deg, var(--sq-dark-1), var(--sq-dark-2));
}
.sq__num {
  position: absolute; top: 3%; left: 6%;
  font-family: var(--font-mono); font-size: clamp(7px, 1.7vw, 10px);
  color: rgba(233,221,199,.4);
  pointer-events: none;
}

/* square highlights */
.sq--sel { box-shadow: inset 0 0 0 3px var(--gold-bright); }
.sq--target::after {
  content: "";
  position: absolute; inset: 0;
  margin: auto;
  width: 30%; height: 30%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(232,201,135,.85), rgba(232,201,135,.25) 70%);
  animation: targetPulse 1.4s ease-in-out infinite;
}
.sq--target-cap::after {
  width: 68%; height: 68%;
  background: none;
  border: 3px solid var(--carmine-bright);
  border-radius: 50%;
  box-sizing: border-box;
  animation: targetPulse 1.1s ease-in-out infinite;
}
@keyframes targetPulse { 0%,100% { opacity: .65; transform: scale(.92);} 50% { opacity: 1; transform: scale(1);} }
.sq--last { box-shadow: inset 0 0 0 200px rgba(232,201,135,.13); }
.sq--hint { box-shadow: inset 0 0 0 3px var(--carmine-bright); animation: targetPulse 1s ease-in-out infinite; }

/* pieces layer */
.board__pieces, .board__fx {
  position: absolute;
  inset: 2.8%;
  pointer-events: none;
}

/* desktop-only side move sheet */
.side-moves { display: none; }
.piece {
  position: absolute;
  width: calc(100% / var(--n));
  height: calc(100% / var(--n));
  transform: translate(calc(var(--px) * 100%), calc(var(--py) * 100%));
  transition: transform .32s var(--ease-out);
  pointer-events: auto;
  z-index: 2;
}
.piece.moving { z-index: 6; transition-duration: .38s; }
.piece__disc {
  position: absolute; inset: 9%;
  border-radius: 50%;
  transition: transform .2s var(--ease-out), box-shadow .2s;
}
.piece--red .piece__disc {
  background:
    radial-gradient(circle at 50% 50%, transparent 54%, rgba(0,0,0,.22) 56% 60%, transparent 62%),
    radial-gradient(circle at 50% 50%, transparent 40%, rgba(0,0,0,.14) 42% 45%, transparent 47%),
    radial-gradient(circle at 36% 30%, var(--pc-red-1), var(--pc-red-2) 62%, var(--pc-red-3) 95%);
  box-shadow:
    inset 0 3px 4px rgba(255,160,130,.35),
    inset 0 -5px 8px rgba(40,5,0,.55),
    0 4px 7px rgba(0,0,0,.55),
    0 1px 2px rgba(0,0,0,.6);
}
.piece--white .piece__disc {
  background:
    radial-gradient(circle at 50% 50%, transparent 54%, rgba(90,70,35,.25) 56% 60%, transparent 62%),
    radial-gradient(circle at 50% 50%, transparent 40%, rgba(90,70,35,.16) 42% 45%, transparent 47%),
    radial-gradient(circle at 36% 30%, var(--pc-white-1), var(--pc-white-2) 62%, var(--pc-white-3) 95%);
  box-shadow:
    inset 0 3px 4px rgba(255,255,240,.7),
    inset 0 -5px 8px rgba(90,70,30,.45),
    0 4px 7px rgba(0,0,0,.5),
    0 1px 2px rgba(0,0,0,.55);
}
.piece.selected .piece__disc { transform: scale(1.08); box-shadow: 0 8px 16px rgba(0,0,0,.6), 0 0 0 3px var(--gold-bright); }

/* crown for kings */
.piece__crown {
  position: absolute; inset: 0;
  display: none;
  place-items: center;
  z-index: 2;
}
.piece--king .piece__crown { display: grid; animation: crownIn .5s var(--ease-spring) both; }
@keyframes crownIn { from { transform: scale(0) rotate(-30deg); } to { transform: scale(1) rotate(0); } }
.piece__crown svg { width: 46%; height: 46%; }
.piece--red .piece__crown svg path, .piece--red .piece__crown svg rect { fill: var(--gold-bright); }
.piece--white .piece__crown svg path, .piece--white .piece__crown svg rect { fill: var(--gold-deep); }

/* capture vanish */
.piece.captured { z-index: 1; }
.piece.captured .piece__disc { animation: capturePop .38s var(--ease-out) forwards; }
@keyframes capturePop {
  0% { transform: scale(1); opacity: 1; }
  35% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(.2); opacity: 0; }
}

/* forced-capture callout: wiggle + escaping glow */
.piece.must-jump .piece__disc { animation: wiggle .55s ease; }
@keyframes wiggle {
  0%, 100% { transform: none; }
  20% { transform: translateX(-7%) rotate(-5deg); }
  40% { transform: translateX(6%) rotate(4deg); }
  60% { transform: translateX(-4%) rotate(-3deg); }
  80% { transform: translateX(3%) rotate(1.5deg); }
}
.fx-glow {
  position: absolute;
  width: calc(100% / var(--n)); height: calc(100% / var(--n));
  transform: translate(calc(var(--px) * 100%), calc(var(--py) * 100%));
  display: grid; place-items: center;
  pointer-events: none;
}
.fx-glow::before {
  content: "";
  width: 100%; height: 100%;
  border-radius: 50%;
  background: radial-gradient(circle, transparent 38%, rgba(232,201,135,.55) 58%, transparent 74%);
  filter: blur(1px);
  animation: glowOut .9s ease-out forwards;
}
@keyframes glowOut {
  from { transform: scale(.55); opacity: 1; }
  to { transform: scale(2.1); opacity: 0; }
}

/* promotion flash */
.fx-promote {
  position: absolute;
  width: calc(100% / var(--n)); height: calc(100% / var(--n));
  transform: translate(calc(var(--px) * 100%), calc(var(--py) * 100%));
  display: grid; place-items: center;
}
.fx-promote::before {
  content: "";
  width: 90%; height: 90%;
  border-radius: 50%;
  border: 3px solid var(--gold-bright);
  animation: ringOut .7s var(--ease-out) forwards;
}
@keyframes ringOut { from { transform: scale(.5); opacity: 1; } to { transform: scale(1.7); opacity: 0; } }

/* tools */
.game-tools {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
}
.tool {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 9px 4px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--ink-850);
  color: var(--parchment-dim);
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  transition: color .2s, border-color .2s, opacity .2s;
}
.tool svg { width: 19px; height: 19px; }
.tool:hover { color: var(--gold-bright); border-color: var(--gold-deep); }
.tool:disabled { opacity: .35; pointer-events: none; }

/* ═══════════════ OVERLAYS ═══════════════ */

.veil {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column;
  justify-content: flex-end; align-items: center;
  background: rgba(10,8,7,.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: veilIn .25s ease backwards;
  transition: opacity .22s ease;
}
.veil--center { justify-content: center; padding: 24px; }
.veil.closing { opacity: 0; }
@keyframes veilIn { from { opacity: 0; } to { opacity: 1; } }

/* background is frozen while any sheet is up */
body.veil-open { position: fixed; left: 0; right: 0; width: 100%; overflow: hidden; }

.verdict {
  width: 100%; max-width: 360px;
  text-align: center;
  padding: 34px 26px 28px;
  border: 1px solid var(--gold-deep);
  border-radius: 20px;
  background:
    radial-gradient(120% 100% at 50% 0%, #2b2319, var(--ink-900) 70%);
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.9), 0 0 0 1px rgba(0,0,0,.6);
  animation: verdictIn .55s var(--ease-spring) both;
}
@keyframes verdictIn { from { transform: scale(.85) translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.verdict__crest { display: flex; justify-content: center; margin-bottom: 10px; }
.verdict__crest svg { width: 54px; height: 54px; }
.verdict__over { font-family: var(--font-mono); font-size: 10px; letter-spacing: .3em; text-transform: uppercase; color: var(--gold); margin-bottom: 6px; }
.verdict__title { font-family: var(--font-display); font-weight: 650; font-size: 40px; line-height: 1; margin-bottom: 10px; }
.verdict--win .verdict__title { background: linear-gradient(175deg, #f6ecd6, #caa75f); -webkit-background-clip: text; background-clip: text; color: transparent; }
.verdict--loss .verdict__title { color: var(--carmine-bright); }
.verdict__line { font-size: 14.5px; color: var(--parchment-dim); font-style: italic; font-family: var(--font-display); margin-bottom: 22px; }
.verdict__actions { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.verdict__actions .btn-ghost { margin-top: 0; width: 100%; }

/* bottom sheets, house style: rise from the bottom, gold grabber,
   tap or drag the bar to dismiss */
.sheet {
  width: 100%; max-width: 560px;
  max-height: calc(100dvh - 52px - var(--sat));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 20px calc(18px + var(--sab));
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  background: linear-gradient(170deg, var(--ink-850), var(--ink-900));
  box-shadow: 0 -18px 60px -18px rgba(0,0,0,.9);
  animation: sheetUp .3s var(--ease-out) backwards;
  transition: transform .28s var(--ease-out);
  display: flex; flex-direction: column; gap: 8px;
  will-change: transform;
}
.sheet.dragging { transition: none; }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
.sheet--tall { max-width: 560px; }

/* grabber bar (injected on every dismissible sheet) */
.sheet__grab {
  position: sticky; top: 0; z-index: 3;
  flex: none;
  display: flex; flex-direction: column; align-items: center;
  width: calc(100% + 40px);
  margin: 0 -20px 2px;
  padding: 12px 0 7px;
  background: linear-gradient(180deg, var(--ink-850) 60%, transparent);
  border-radius: 22px 22px 0 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}
.sheet__grab:active { cursor: grabbing; }
.sheet__grab-pill {
  width: 44px; height: 5px;
  border-radius: 3px;
  background: var(--gold);
}
.sheet__grab-hint {
  margin-top: 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .08em;
  color: var(--parchment-faint);
}

/* verdict keeps its centered celebration card */
.veil--center .verdict { margin: 0; }
.sheet__title { font-family: var(--font-display); font-weight: 650; font-size: 22px; margin-bottom: 8px; text-align: center; }
.sheet__item {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--ink-800);
  font-size: 15px;
  transition: border-color .2s, color .2s;
}
.sheet__item:hover { border-color: var(--gold-deep); color: var(--gold-bright); }
.sheet__item--quiet { background: none; border-color: transparent; color: var(--parchment-faint); }
.sheet__item--danger { color: var(--carmine-bright); }

/* rules body */
.rules-body { font-size: 14.5px; color: var(--parchment-dim); display: flex; flex-direction: column; gap: 10px; padding: 4px 2px 8px; }
.rules-body h4 { font-family: var(--font-mono); font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--gold); margin-top: 8px; }
.rules-body p { line-height: 1.55; }
.rules-body strong { color: var(--parchment); }
.about-fine { font-size: 12.5px; color: var(--parchment-faint); }

/* move list */
.movelist {
  list-style: none;
  font-family: var(--font-mono); font-size: 13px;
  display: flex; flex-direction: column; gap: 2px;
  max-height: 50dvh; overflow-y: auto;
  padding: 4px 2px;
}
.movelist li { display: flex; gap: 12px; padding: 5px 8px; border-radius: 7px; }
.movelist li:nth-child(odd) { background: rgba(255,255,255,.03); }
.movelist .mv-no { color: var(--parchment-faint); min-width: 2.4em; }
.movelist .mv { color: var(--parchment); min-width: 6em; }
.movelist .mv--cap { color: var(--carmine-bright); }

/* house rules sheet */
.house-sub {
  font-size: 13px;
  color: var(--parchment-faint);
  text-align: center;
  margin: -4px 0 8px;
  font-style: italic;
  font-family: var(--font-display);
}
.house-row { border-bottom: 1px solid var(--line); padding: 12px 4px; }
.house-row__name { font-size: 14.5px; margin-bottom: 8px; }
.house-row--toggle { display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.house-row--toggle .house-row__name { margin-bottom: 0; }
.house-row .seg { font-size: 12px; }
.house-row__hint {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--parchment-faint);
}
.house-row .seg__opt { padding: 9px 4px; }
.house-row .seg__opt-name { font-family: var(--font-body); font-weight: 600; font-size: 12px; }
.house-row.disabled { opacity: .4; pointer-events: none; }

/* leaderboard */
.lb-list { list-style: none; display: flex; flex-direction: column; gap: 4px; padding: 2px; }
.lb-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 11px;
}
.lb-row:nth-child(odd) { background: rgba(255,255,255,.025); }
.lb-row.me { border-color: var(--gold-deep); background: linear-gradient(160deg, #262019, #1a1512); }
.lb-row__rank {
  font-family: var(--font-display); font-style: italic;
  font-size: 17px; color: var(--parchment-faint);
  text-align: center;
}
.lb-row:nth-child(1) .lb-row__rank { color: var(--gold-bright); }
.lb-row:nth-child(2) .lb-row__rank, .lb-row:nth-child(3) .lb-row__rank { color: var(--gold); }
.lb-row__who { min-width: 0; }
.lb-row__name { display: block; font-family: var(--font-display); font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-row__sub { display: block; font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em; color: var(--parchment-faint); }
.lb-row__pts { text-align: right; }
.lb-row__pts strong { display: block; font-family: var(--font-display); font-size: 18px; color: var(--gold-bright); line-height: 1.1; }
.lb-row__pts span { font-family: var(--font-mono); font-size: 9px; letter-spacing: .18em; text-transform: uppercase; color: var(--parchment-faint); }
.lb-empty { text-align: center; color: var(--parchment-faint); font-style: italic; font-family: var(--font-display); padding: 18px 0; }
.lb-crown { width: 13px; height: 13px; color: var(--gold-bright); vertical-align: -1px; }

/* claim sheet */
.claim-existing { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.claim-existing:empty { display: none; }
.claim-chip {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  font-size: 14px;
  font-family: var(--font-display);
  transition: border-color .2s, color .2s;
}
.claim-chip:hover, .claim-chip.on { border-color: var(--gold-deep); color: var(--gold-bright); }
.claim-input {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--ink-800);
  color: var(--parchment);
  font: inherit;
  font-size: 16px;
  text-align: center;
  outline: none;
}
.claim-input:focus { border-color: var(--gold-deep); }
.claim-err { color: var(--carmine-bright); font-size: 13px; text-align: center; }
#claim-go { width: 100%; }

/* verdict rank */
.verdict__rank {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--gold);
  margin: -14px 0 20px;
}

/* theme picker */
.theme-row { padding: 13px 4px; border-bottom: 1px solid var(--line); }
.theme-row__label { display: block; font-size: 15px; margin-bottom: 10px; }
.theme-row .seg__opt { padding: 10px 4px; }

/* settings toggles */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
  cursor: pointer;
}
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.toggle {
  width: 46px; height: 27px; flex: none;
  border-radius: 20px;
  background: var(--ink-600);
  position: relative;
  transition: background .25s;
}
.toggle::after {
  content: "";
  position: absolute; top: 3px; left: 3px;
  width: 21px; height: 21px;
  border-radius: 50%;
  background: var(--parchment);
  transition: transform .25s var(--ease-out), background .25s;
}
.toggle-row input:checked + .toggle { background: var(--gold-deep); }
.toggle-row input:checked + .toggle::after { transform: translateX(19px); background: var(--gold-bright); }

/* toast */
.toast {
  position: fixed;
  left: 50%; bottom: calc(var(--sab) + 24px);
  transform: translateX(-50%) translateY(8px);
  z-index: 80;
  background: var(--ink-800);
  border: 1px solid var(--gold-deep);
  color: var(--parchment);
  padding: 11px 20px;
  border-radius: 12px;
  font-size: 14px;
  box-shadow: 0 12px 32px rgba(0,0,0,.6);
  opacity: 0;
  transition: opacity .3s, transform .3s var(--ease-out);
  pointer-events: none;
  max-width: min(90vw, 400px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 700px) {
  .screen--game { gap: 12px; }
  .board-frame { width: min(100%, calc(100dvh - 340px)); }
}

/* ═══════════════ DESKTOP ═══════════════ */

@media (min-width: 960px) {
  .menu-inner { max-width: 520px; }
  .masthead__title { font-size: 76px; }

  .screen--game {
    max-width: 1160px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    grid-template-rows: auto auto auto minmax(120px, 1fr) auto;
    grid-template-areas:
      "top    top"
      "board  plateTop"
      "board  plateBottom"
      "board  sideMoves"
      "board  tools";
    column-gap: 30px;
    align-content: start;
    padding-top: calc(var(--sat) + 22px);
  }
  .game-top { grid-area: top; margin-bottom: 8px; }
  .board-arena { grid-area: board; align-self: start; }
  .plate--top { grid-area: plateTop; }
  .plate--bottom { grid-area: plateBottom; }
  .game-tools { grid-area: tools; }
  .board-frame { width: min(100%, calc(100dvh - 150px)); }

  .side-moves {
    grid-area: sideMoves;
    display: flex;
    flex-direction: column;
    min-height: 0;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: linear-gradient(165deg, var(--ink-850), var(--ink-900));
    padding: 12px 14px;
  }
  .side-moves__label {
    font-family: var(--font-mono);
    font-size: 10px; letter-spacing: .24em; text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 8px;
  }
  .side-moves .movelist {
    max-height: none;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }
  /* the sheet-based Moves button is redundant on desktop */
  #btn-moves { display: none; }
  .game-tools { grid-template-columns: repeat(3, 1fr); }
}

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

/* ═══════════════════════════════════════════════════════════════
   DAYLIGHT THEME: warm cream paper, espresso ink, the same gold
   leaf and carmine. The wood board is untouched; it reads
   beautifully on linen. Applied via <html data-theme="light">.
   ═══════════════════════════════════════════════════════════════ */

[data-theme="light"] {
  --ink-950: #eadfc8;
  --ink-900: #f3ecdd;
  --ink-850: #faf5ea;
  --ink-800: #efe7d4;
  --ink-700: #e3d8c0;
  --ink-600: #cfc2a4;
  --line: #dbcfb4;
  --parchment: #2b241b;
  --parchment-dim: #5d5342;
  --parchment-faint: #8a7d64;
  --gold: #8f6f35;
  --gold-bright: #7a5a22;
  --gold-deep: #b08d4c;
}

[data-theme="light"] body {
  background-image:
    radial-gradient(120% 90% at 50% -10%, #faf4e6 0%, transparent 60%),
    radial-gradient(90% 70% at 50% 110%, #e8dcc2 0%, transparent 55%),
    repeating-linear-gradient(45deg, rgba(120,90,40,.014) 0 2px, transparent 2px 4px),
    repeating-linear-gradient(-45deg, rgba(80,60,20,.02) 0 2px, transparent 2px 4px);
}

[data-theme="light"] .masthead__title {
  background: linear-gradient(175deg, #3d321f 30%, #6b5426 75%, #8f6f35);
  -webkit-background-clip: text;
  background-clip: text;
}
[data-theme="light"] .masthead__crest { filter: drop-shadow(0 6px 18px rgba(143,111,53,.35)); }

[data-theme="light"] .seg__opt[aria-checked="true"] {
  background: linear-gradient(180deg, #f4e6c2, #edd9a9);
}
[data-theme="light"] .vcard[aria-checked="true"] {
  background: linear-gradient(160deg, #f8efd9, #f2e6c9);
  box-shadow: 0 0 0 1px var(--gold-deep), 0 8px 24px -12px rgba(143,111,53,.35);
}

[data-theme="light"] .plate__avatar--ai { background: radial-gradient(circle at 35% 30%, #f2e8d2, #e2d3b2); }
[data-theme="light"] .plate__avatar--you { background: radial-gradient(circle at 35% 30%, #ecd2c4, #dcb9a4); color: #4b2318; }

[data-theme="light"] .veil {
  background: rgba(70, 58, 38, .38);
}
[data-theme="light"] .verdict {
  background: radial-gradient(120% 100% at 50% 0%, #fbf6ea, var(--ink-900) 70%);
  box-shadow: 0 30px 80px -20px rgba(90,70,30,.45), 0 0 0 1px rgba(120,95,45,.2);
}
[data-theme="light"] .sheet { box-shadow: 0 -18px 60px -18px rgba(90,70,30,.4); }

[data-theme="light"] .movelist li:nth-child(odd) { background: rgba(90,70,30,.05); }
[data-theme="light"] .lb-row:nth-child(odd) { background: rgba(90,70,30,.05); }
[data-theme="light"] .lb-row.me { background: linear-gradient(160deg, #f6ecd3, #f0e2bf); }

[data-theme="light"] .board-frame {
  box-shadow:
    0 1px 0 rgba(255,235,190,.3) inset,
    0 24px 60px -20px rgba(90,60,20,.5),
    0 6px 18px rgba(120,85,35,.25);
}

[data-theme="light"] .toast { background: var(--ink-850); box-shadow: 0 12px 32px rgba(90,70,30,.35); }
