@font-face { font-family: "Alfa Slab One"; src: url("./assets/fonts/alfa-slab-one.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Bitter"; src: url("./assets/fonts/bitter.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
:root {
  --blue: #002664; --blue-lit: #7fa8ff; --red: #bf0d3e; --red-deep: #9a0b33; --bone: #f3eadb; --bone-dim: #cfc3ae;
  --brass: #d9b566; --walnut: #140d08; --hide: rgba(31, 19, 11, 0.8); --hide-solid: #24170e; --hair: rgba(217, 181, 102, 0.42);
  --display: "Alfa Slab One", Rockwell, "Roboto Slab", Georgia, serif;
  --text: "Bitter", Rockwell, Georgia, serif;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px); --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--walnut); color: var(--bone); font: 500 16px/1.4 var(--text); overflow: hidden; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
body { position: fixed; inset: 0; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; }

/* ---------- loading ---------- */
#loader { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; background: radial-gradient(120% 90% at 50% 40%, #2a190d 0%, var(--walnut) 62%); transition: opacity 0.7s ease; }
#loader.done { opacity: 0; pointer-events: none; }
.load-box { display: grid; justify-items: center; gap: 18px; padding: 24px; text-align: center; }
.load-star { width: min(34vw, 150px); height: auto; overflow: visible; }
.load-star .rim { fill: none; stroke: var(--brass); stroke-width: 1.4; stroke-linejoin: round; }
.load-star .fill { fill: var(--bone); }
.load-title { font: 400 clamp(1.7rem, 6vw, 2.6rem)/1 var(--display); letter-spacing: 0.02em; color: var(--bone); margin: 0; }
.load-note { margin: 0; color: var(--bone-dim); min-height: 1.4em; }
.load-note.err { color: #ffb3b3; max-width: 34ch; }

/* ---------- shared pieces of chrome ---------- */
.tab { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border: 1px solid var(--hair); border-radius: 10px; background: var(--hide); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); color: var(--bone); font-weight: 600; white-space: nowrap; transition: background 0.15s, border-color 0.15s, transform 0.1s; }
button.tab:hover { background: rgba(58, 36, 20, 0.9); border-color: var(--brass); }
button.tab:active { transform: translateY(1px); }
button.tab:disabled { opacity: 0.42; cursor: default; }
button.tab[aria-pressed="true"] { border-color: var(--brass); color: var(--brass); }
.tab svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- in-game HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: auto; }
.bar { position: absolute; left: 0; right: 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 12px calc(14px + var(--safe-r)) 0 calc(14px + var(--safe-l)); pointer-events: none !important; }
.bar > * { pointer-events: auto; }
.bar.top { top: var(--safe-t); }
.tools { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.status { position: absolute; left: 50%; top: calc(12px + var(--safe-t)); transform: translateX(-50%); display: grid; justify-items: center; gap: 6px; pointer-events: none !important; max-width: calc(100vw - 150px); }
#turn { min-height: 44px; padding: 0 18px 0 14px; font-size: 1.05rem; pointer-events: none; }
#turn .who { width: 20px; height: 20px; flex: none; }
#turn .who path { stroke: var(--bone); stroke-width: 1.6; stroke-linejoin: round; }
#turn[data-turn="w"] .who path { fill: var(--bone); }
#turn[data-turn="b"] .who path { fill: #1b4fb8; }
#turn.check { border-color: #ff6b78; }
.dots { display: inline-flex; gap: 3px; margin-left: 2px; }
.dots i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; animation: dot 1.1s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: 0.15s; } .dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
#btnStop { pointer-events: auto; min-height: 40px; border-color: var(--brass); color: var(--brass); }
#taken { display: flex; gap: 16px; align-items: center; padding: 4px 13px; border-radius: 8px; background: rgba(20, 13, 8, 0.6); font-size: 1rem; line-height: 1.2; min-height: 28px; }
#taken:empty { display: none; }
#taken .set { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
#taken .dot { width: 15px; height: 15px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.22), inset 0 0 0 4px rgba(255, 255, 255, 0.16); }
#taken .set.w .dot { background: var(--bone); } #taken .set.b .dot { background: #1b4fb8; }
#taken .kings { font-size: 0.82rem; font-weight: 700; color: var(--brass); }

#tip { max-width: min(92vw, 420px); padding: 7px 14px; border-radius: 10px; background: rgba(20, 13, 8, 0.78); border: 1px solid var(--hair); color: var(--bone); font-size: 0.95rem; text-align: center; }
#movesPanel { position: absolute; right: calc(14px + var(--safe-r)); top: calc(70px + var(--safe-t)); width: 248px; max-height: min(52vh, 420px); display: flex; flex-direction: column; border: 1px solid var(--hair); border-radius: 12px; background: var(--hide); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); overflow: hidden; }
#movesPanel h2 { margin: 0; padding: 10px 14px 8px; font: 700 0.95rem/1.2 var(--text); color: var(--brass); border-bottom: 1px solid var(--hair); }
#moveList { margin: 0; padding: 8px 6px 10px 14px; list-style: none; overflow-y: auto; display: grid; grid-template-columns: 2.2em 1fr 1fr; gap: 2px 6px; font-variant-numeric: tabular-nums; user-select: text; -webkit-user-select: text; }
#moveList .n { color: var(--bone-dim); }
#moveList span { overflow-wrap: anywhere; }
#moveList .hd { color: var(--bone-dim); font-size: 0.8rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
#moveList .last { color: var(--brass); font-weight: 700; }
#moveList .none { grid-column: 1 / -1; color: var(--bone-dim); }

.bar.bottom { bottom: calc(12px + var(--safe-b)); justify-content: center; align-items: flex-end; display: none; }

/* ---------- menu: laid out like the Lone Star flag ---------- */
.screen { position: absolute; inset: 0; z-index: 20; display: grid; justify-items: center; padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b)); background: radial-gradient(90% 70% at 50% 50%, rgba(10, 6, 3, 0.25), rgba(10, 6, 3, 0.72)); overflow-y: auto; transition: opacity 0.35s ease; }
.screen.leaving { opacity: 0; pointer-events: none; }
.flag { width: min(740px, 100%); margin: auto 0; display: grid; grid-template-columns: minmax(96px, 1fr) 2fr; grid-template-rows: auto auto; border-radius: 6px; overflow: hidden; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(0, 0, 0, 0.5); }
.flag-blue { grid-row: 1 / 3; background: var(--blue); display: grid; place-items: center; padding: 18px; }
.flag-blue svg { width: min(74%, 190px); height: auto; }
.flag-blue path { fill: #fff; }
.flag-white { background: var(--bone); color: var(--blue); padding: clamp(18px, 4vw, 34px) clamp(18px, 4vw, 36px); display: grid; align-content: center; gap: 8px; }
.flag-white h1 { margin: 0; font: 400 clamp(2rem, 7.4vw, 3.7rem)/0.96 var(--display); letter-spacing: 0.01em; }
.flag-white p { margin: 0; font-weight: 600; color: #3b4f7d; }
.flag-white a { color: inherit; text-underline-offset: 3px; }
.flag-red { background: var(--red); color: #fff; padding: clamp(16px, 3.4vw, 28px) clamp(18px, 4vw, 36px) clamp(18px, 4vw, 30px); }
.pane { display: grid; gap: 12px; }
.pane h2 { margin: 0; font: 700 1.05rem/1.25 var(--text); }
.btn { min-height: 48px; padding: 0 20px; border-radius: 8px; border: 2px solid var(--bone); background: var(--bone); color: var(--blue); font-weight: 800; font-size: 1.05rem; text-align: left; display: flex; align-items: center; justify-content: space-between; gap: 12px; transition: transform 0.1s, background 0.15s, box-shadow 0.15s; }
.btn:hover { background: #fff; box-shadow: 0 4px 0 rgba(0, 0, 0, 0.22); transform: translateY(-1px); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn small { font-weight: 600; font-size: 0.85rem; color: #3b4f7d; }
.btn.ghost { background: transparent; color: #fff; }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.14); }
.btn.ghost small { color: #ffd9e0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row .btn { flex: 1 1 140px; justify-content: center; text-align: center; }
.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.chip span { display: grid; gap: 1px; padding: 8px 10px; min-height: 52px; align-content: center; border-radius: 8px; border: 2px solid rgba(255, 255, 255, 0.55); font-weight: 700; line-height: 1.15; transition: background 0.15s, color 0.15s; }
.chip span b { font-weight: 800; }
.chip span i { font-style: normal; font-size: 0.72rem; letter-spacing: 0.1em; color: #ffd9e0; }
.chip input:checked + span { background: var(--bone); color: var(--blue); border-color: var(--bone); }
.chip input:checked + span i { color: var(--red); }
.chip input:focus-visible + span { outline: 2px solid var(--brass); outline-offset: 2px; }
.chip:hover span { border-color: #fff; }
.blurb { margin: -4px 0 0; min-height: 1.4em; color: #ffe3e8; font-weight: 500; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--blue); }

/* ---------- small dialogs ---------- */
.veil { position: absolute; inset: 0; z-index: 25; display: grid; place-items: center; padding: 16px; background: rgba(10, 6, 3, 0.5); }
.veil.clear { background: none; pointer-events: none; align-items: end; padding-bottom: calc(14px + var(--safe-b)); }
.veil.clear > * { pointer-events: auto; }
.card { width: min(430px, 100%); max-height: 100%; overflow-y: auto; border: 1px solid var(--hair); border-radius: 14px; background: var(--hide-solid); box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65); padding: 20px; display: grid; gap: 14px; }
.card h2 { margin: 0; font: 400 1.5rem/1.1 var(--display); letter-spacing: 0.01em; }
.card p { margin: 0; color: var(--bone-dim); }
.card .btn { border-color: var(--bone); }
.card .btn.ghost { color: var(--bone); border-color: var(--hair); }
.card .btn.ghost:hover { border-color: var(--brass); background: rgba(217, 181, 102, 0.1); }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 40px; font-weight: 600; }
.opt select, .opt input[type="range"] { font: inherit; }
.opt select { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--hair); background: #1a100a; color: var(--bone); }
.opt input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--brass); }
.opt input[type="range"] { width: 150px; accent-color: var(--brass); }
.fine { font-size: 0.86rem; }
.fine a { color: var(--brass); }
.over { display: grid; grid-template-columns: 76px 1fr; padding: 0; overflow: hidden; gap: 0; }
.over .field { background: var(--blue); display: grid; place-items: center; }
.over .field svg { width: 46px; } .over .field path { fill: #fff; }
.over .body { padding: 18px 20px 20px; display: grid; gap: 12px; }
.credits { display: grid; gap: 8px; font-size: 0.92rem; color: var(--bone-dim); }
.credits b { color: var(--bone); }

/* ---------- mid widths: icon-only tools so they clear the turn indicator ---------- */
@media (max-width: 1120px) { .tools .tab .lbl { display: none; } .tools .tab { min-width: 46px; justify-content: center; padding: 0 12px; } }
/* ---------- narrow screens: tools move to the bottom edge ---------- */
@media (max-width: 760px) {
  .bar.top .tools { display: none; }
  .bar.bottom { display: flex; }
  .bar.bottom .tools { justify-content: center; }
  .tab { padding: 0 12px; }
  .tab .lbl { display: none; }
  .bar.bottom .tab { min-width: 52px; min-height: 48px; justify-content: center; }
  #movesPanel { left: 14px; right: 14px; width: auto; top: auto; bottom: calc(72px + var(--safe-b)); max-height: 34vh; }
  .status { max-width: calc(100vw - 132px); }
  #turn { font-size: 0.98rem; padding: 0 14px 0 10px; }
  .chips { grid-template-columns: repeat(2, 1fr); }
  .pane > .btn { flex-direction: column; align-items: flex-start; justify-content: center; gap: 0; padding: 8px 16px; min-height: 58px; }
  .flag { grid-template-columns: 72px 1fr; }
  .flag-blue { align-items: start; padding: 22px 10px; }
  .flag-blue svg { width: 100%; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .flag { grid-template-columns: 96px 1fr 1.5fr; grid-template-rows: auto; width: min(900px, 100%); }
  .flag-blue { grid-row: auto; align-items: center; padding: 14px; } .flag-white h1 { font-size: 1.9rem; }
  .flag-red { padding: 14px 18px; } .pane { gap: 8px; } .chip span { min-height: 44px; padding: 5px 9px; } .btn { min-height: 42px; }
  .chips { grid-template-columns: repeat(3, 1fr); } .blurb { display: none; }
  #movesPanel { max-height: 46vh; }
  /* on a short screen the first-move tip sits at the bottom edge, clear of the far row of checkers */
  #tip { position: absolute; left: 50%; transform: translateX(-50%); top: calc(100vh - 68px - var(--safe-t) - var(--safe-b)); top: calc(100dvh - 68px - var(--safe-t) - var(--safe-b)); width: max-content; max-width: 92vw; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; } }

.center { justify-content: center; text-align: center; }
.nojs { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; }
