:root {
  color-scheme: dark;
  --bg: #071011;
  --surface: #0d1819;
  --surface2: #122123;
  --text: #edf7f4;
  --muted: #8da3a0;
  --line: #203335;
  --accent: #7fe4c4;
  --light-square: #b7c9bd;
  --dark-square: #47645c;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: var(--accent); }
button, textarea { font: inherit; }
.topbar { height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; border-bottom: 1px solid var(--line); background: rgba(7,16,17,.92); position: sticky; top: 0; z-index: 10; backdrop-filter: blur(12px); }
.brand { text-decoration: none; color: var(--text); font-weight: 800; letter-spacing: -.02em; display: flex; align-items: center; gap: 9px; }
.fish { font-size: 24px; }
.badge { color: var(--muted); font-size: 13px; border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; }
.shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 46px 0 60px; }
.hero { margin-bottom: 28px; }
.eyebrow { color: var(--accent); font-size: 12px; letter-spacing: .16em; font-weight: 800; }
h1 { font-size: clamp(36px, 7vw, 72px); margin: 6px 0 10px; letter-spacing: -.055em; line-height: .98; }
.sub { color: var(--muted); font-size: 17px; max-width: 720px; }
.workspace { display: grid; grid-template-columns: minmax(0, 720px) minmax(300px, 1fr); gap: 28px; align-items: start; }
.board-area { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; }
.board { width: 100%; aspect-ratio: 1; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: repeat(8, minmax(0, 1fr)); min-width: 0; min-height: 0; align-self: start; container-type: inline-size; border-radius: 10px; overflow: hidden; box-shadow: 0 20px 70px rgba(0,0,0,.28); }
.square { border: 0; border-radius: 0; display: grid; place-items: center; position: relative; cursor: pointer; padding: 0; min-width: 0; min-height: 0; overflow: hidden; font-size: 0; line-height: 1; font-family: "Arial Unicode MS", "Noto Sans Symbols 2", serif; }
.square.light { background: var(--light-square); }
.square.dark { background: var(--dark-square); }
.square.selected { outline: 5px solid rgba(127,228,196,.8); outline-offset: -5px; }
.square.target::after { content: ""; width: 18%; aspect-ratio: 1; border-radius: 50%; background: rgba(3,16,14,.35); position: absolute; }
.square.capture::after { content: ""; position: absolute; inset: 8%; border: 5px solid rgba(3,16,14,.30); border-radius: 50%; }
.eval-wrap { height: 100%; min-height: 0; background: #eee; border-radius: 7px; overflow: hidden; position: relative; }
.eval-black { position: absolute; top: 0; left: 0; width: 100%; height: 50%; background: #1a1d1d; transition: height .18s ease; }
.eval-text { position: absolute; left: 50%; bottom: 7px; transform: translateX(-50%); z-index: 2; color: #111; font-size: 11px; font-weight: 800; writing-mode: vertical-rl; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
.status-row { display: flex; align-items: center; gap: 9px; margin-bottom: 18px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #d3a74b; box-shadow: 0 0 0 4px rgba(211,167,75,.12); }
.dot.ready { background: #65d6a8; box-shadow: 0 0 0 4px rgba(101,214,168,.12); }
.dot.error { background: #ef7777; box-shadow: 0 0 0 4px rgba(239,119,119,.12); }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.metric-grid > div, .line-card { background: var(--surface2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.metric-grid span, .line-card span, .label { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; }
.metric-grid strong { font-size: 18px; }
.line-card { min-height: 96px; margin-bottom: 16px; }
.pv { line-height: 1.55; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; overflow-wrap: anywhere; }
textarea { width: 100%; resize: vertical; background: #081213; color: var(--text); border: 1px solid var(--line); border-radius: 9px; padding: 11px; margin-bottom: 9px; }
button { border: 1px solid transparent; background: var(--accent); color: #062019; border-radius: 9px; padding: 10px 13px; cursor: pointer; font-weight: 750; }
button.secondary { background: #152527; color: var(--text); border-color: var(--line); }
button:hover { filter: brightness(1.06); }
.actions { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 9px; }
.actions.three { grid-template-columns: repeat(3, 1fr); }
.message { color: var(--muted); font-size: 13px; min-height: 20px; margin-bottom: 0; }
.about { margin-top: 42px; border-top: 1px solid var(--line); padding-top: 26px; max-width: 820px; }
.about h2 { margin-bottom: 8px; }
.about p { color: var(--muted); line-height: 1.65; }
.tiny { font-size: 13px; }
@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .shell { width: min(760px, calc(100% - 22px)); padding-top: 30px; }
}
@media (max-width: 520px) {
  .topbar { padding: 0 14px; }
  .board-area { grid-template-columns: 22px minmax(0, 1fr); gap: 6px; }
  .panel { padding: 14px; }
  .metric-grid strong { font-size: 15px; }
}

/* Piece content never participates in grid track sizing. */
.piece { position: absolute; inset: 0; display: grid; place-items: center; font-size: 10cqw; line-height: 1; pointer-events: none; font-family: "DejaVu Sans", "Arial Unicode MS", serif; }
.piece.white { color: #fff8e6; -webkit-text-stroke: 1px #18342c; filter: drop-shadow(0 1px 1px #16382b); }
.piece.black { color: #102820; -webkit-text-stroke: .5px #c0d3c5; }
.square.last { box-shadow: inset 0 0 0 100px #e7d97740; }
.square.check { background: #b55a53; }
.square:focus-visible { outline: 3px solid #fff; outline-offset: -3px; z-index: 2; }
.coord { position: absolute; font: 700 clamp(8px, 1.5cqw, 12px)/1 system-ui; color: #16352b; pointer-events: none; }
.coord.file { bottom: 3px; right: 4px; }
.coord.rank { top: 3px; left: 4px; }
.square.dark .coord { color: #edf7e9; }
.board-area, .panel, .metric-grid > div { min-width: 0; }
.panel { overflow-wrap: anywhere; }
button:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button:disabled { opacity: .45; cursor: not-allowed; }
.game-state { font-size: 14px; color: var(--text); margin: 14px 0 8px; }
.help { font-size: 12px; color: var(--muted); line-height: 1.6; }
.eval-wrap.flipped .eval-black { top: auto; bottom: 0; }
.eval-text { background: #fff9; border-radius: 4px; padding: 4px 2px; }
dialog { background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 14px; max-width: calc(100% - 24px); }
dialog::backdrop { background: #000a; }
.promotion-options { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media (max-width: 380px) { h1 { font-size: 34px; } .metric-grid > div { padding: 8px; } }
