:root {
  --board-inner: 560px;
  --board-size: 32;
  --cell-size: 17.5px;
  --major-cell: 140px;
  --rail: 24px;
  --gap: 0px;
  --board-pad: 14px;
  --ink: #f6f0dd;
  --muted: #a9a28d;
  --panel: rgba(19, 22, 20, 0.78);
  --panel-line: rgba(224, 196, 126, 0.18);
  --gold: #d9bd75;
  --green: #0d3c2f;
  --green-2: #123a32;
  --line: rgba(232, 207, 139, 0.34);
  --line-strong: rgba(250, 225, 151, 0.62);
  --shadow: rgba(0, 0, 0, 0.5);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(7, 8, 8, 0.95), rgba(22, 24, 20, 0.92)),
    url("assets/board-lacquer.png") center / cover fixed;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.app {
  min-height: 100vh;
  padding: 14px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.34), rgba(0, 0, 0, 0.04), rgba(0, 0, 0, 0.34)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 5px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  max-width: min(1920px, calc(100vw - 28px));
  margin: 0 auto 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex: 0 0 auto;
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.92), rgba(244, 231, 185, 0.88) 32%, transparent 33%),
    radial-gradient(circle at 70% 70%, rgba(5, 7, 8, 0.96), rgba(22, 28, 31, 0.96) 41%, transparent 42%),
    linear-gradient(135deg, #d7be74, #5c4826);
  border: 1px solid rgba(255, 235, 176, 0.36);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.4), inset 0 0 18px rgba(255, 244, 190, 0.2);
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.35rem, 2.2vw, 2.25rem);
  line-height: 1;
  font-weight: 760;
  letter-spacing: 0;
}

.brand p {
  margin-top: 4px;
  color: var(--muted);
  min-height: 1.4em;
}

.top-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.command,
.segment,
.side-choice,
.zoom-choice,
.opening-choice {
  border: 1px solid rgba(233, 205, 134, 0.28);
  background: rgba(13, 16, 15, 0.72);
  min-height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, color 180ms ease;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 10px 22px rgba(0, 0, 0, 0.22);
}

.command:hover,
.segment:hover,
.side-choice:hover,
.zoom-choice:hover,
.opening-choice:hover {
  transform: translateY(-1px);
  border-color: rgba(233, 205, 134, 0.56);
}

.command:active,
.segment:active,
.side-choice:active,
.zoom-choice:active,
.opening-choice:active {
  transform: translateY(0);
}

.command:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.layout {
  display: grid;
  grid-template-columns: minmax(154px, 210px) minmax(0, 1fr) minmax(164px, 220px);
  align-items: start;
  justify-content: center;
  gap: 12px;
  max-width: min(1920px, calc(100vw - 28px));
  margin: 0 auto;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 20px 52px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(18px);
}

.score-panel,
.detail-panel {
  display: grid;
  gap: 10px;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 9px;
}

.score-row:last-of-type {
  border-bottom: 0;
}

.score-disc {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: inset -8px -9px 18px rgba(0, 0, 0, 0.38), inset 6px 6px 15px rgba(255, 255, 255, 0.16), 0 10px 18px rgba(0, 0, 0, 0.25);
}

.score-disc.black {
  background: url("assets/stone-dark.png") center / 180%;
}

.score-disc.white {
  background: url("assets/stone-light.png") center / 180%;
}

.score-label,
.control-label,
.metric span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.score-row strong {
  display: block;
  font-size: 1.85rem;
  line-height: 1;
}

.control-block {
  display: grid;
  gap: 7px;
}

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 6px;
}

.segmented-three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.segment,
.side-choice,
.zoom-choice,
.opening-choice {
  width: 100%;
}

.segment.active,
.side-choice.active,
.zoom-choice.active,
.opening-choice.active {
  color: #16140d;
  background: linear-gradient(180deg, #f3df9e, #c9a757);
  border-color: rgba(255, 232, 167, 0.72);
  box-shadow: 0 12px 28px rgba(174, 131, 41, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.46);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--gold);
}

.difficulty-readout {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.difficulty-readout strong {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  color: #17140b;
  background: linear-gradient(180deg, #f2dda0, #b99142);
}

.difficulty-readout span {
  color: var(--ink);
  font-weight: 680;
}

.board-stage {
  display: grid;
  place-items: center;
  width: 100%;
  min-width: 0;
}

.board-viewport {
  width: 100%;
  max-height: none;
  overflow: visible;
  padding: 0;
  scrollbar-color: rgba(220, 184, 91, 0.75) rgba(5, 10, 8, 0.6);
  scrollbar-width: thin;
}

.board-viewport::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.board-viewport::-webkit-scrollbar-track {
  background: rgba(5, 10, 8, 0.62);
}

.board-viewport::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #e4ca7a, #8d6d2d);
  border-radius: 10px;
}

.board-shell {
  position: relative;
  padding: var(--board-pad);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 238, 183, 0.18), rgba(18, 16, 10, 0.58)),
    url("assets/board-lacquer.png") center / cover;
  border: 1px solid rgba(246, 220, 150, 0.24);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.54),
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -16px 34px rgba(0, 0, 0, 0.34);
  transform-style: preserve-3d;
  transition: transform 260ms ease, box-shadow 260ms ease;
  width: max-content;
  margin: 0 auto;
}

.board-shell.ai-thinking {
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.54),
    0 0 42px rgba(217, 189, 117, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -16px 34px rgba(0, 0, 0, 0.34);
}

.board-aura {
  position: absolute;
  inset: 10px;
  border-radius: 8px;
  border: 1px solid rgba(249, 224, 151, 0.2);
  pointer-events: none;
}

.board-frame {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--rail) var(--board-inner) var(--rail);
  grid-template-rows: var(--rail) var(--board-inner) var(--rail);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(254, 231, 159, 0.24), rgba(16, 11, 5, 0.74)),
    repeating-linear-gradient(90deg, rgba(255, 235, 170, 0.05) 0 1px, transparent 1px 4px),
    #21170c;
  border: 1px solid rgba(255, 232, 166, 0.26);
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.55),
    inset 0 12px 24px rgba(255, 240, 181, 0.08),
    0 18px 40px rgba(0, 0, 0, 0.34);
  overflow: hidden;
}

.rail-corner {
  background:
    radial-gradient(circle at 50% 50%, rgba(241, 211, 130, 0.25), transparent 46%),
    linear-gradient(145deg, rgba(0, 0, 0, 0.18), rgba(255, 239, 170, 0.08));
}

.coord-row,
.coord-col {
  display: grid;
  color: rgba(245, 221, 155, 0.72);
  font-size: 0.62rem;
  font-weight: 760;
  letter-spacing: 0;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.88);
  user-select: none;
}

.coord-row {
  grid-template-columns: repeat(var(--board-size), 1fr);
  align-items: center;
}

.coord-col {
  grid-template-rows: repeat(var(--board-size), 1fr);
  justify-items: center;
}

.coord-col-left {
  align-items: center;
}

.coord-col-right {
  align-items: center;
}

.coord {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  opacity: 0.18;
}

.coord.major {
  opacity: 0.92;
}

.coord.edge-active {
  color: #fff1b4;
  opacity: 1;
  text-shadow: 0 0 12px rgba(232, 190, 86, 0.9), 0 1px 2px #000;
}

.board-space {
  position: relative;
  width: var(--board-inner);
  height: var(--board-inner);
  overflow: hidden;
  background: #08291f;
  box-shadow:
    inset 0 0 0 2px rgba(0, 0, 0, 0.5),
    inset 0 0 42px rgba(0, 0, 0, 0.38);
}

.board-glass {
  position: absolute;
  z-index: 3;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 28% 18%, rgba(255, 255, 255, 0.11), transparent 18%),
    linear-gradient(120deg, transparent 10%, rgba(255, 255, 255, 0.08) 28%, transparent 48%);
  mix-blend-mode: screen;
  opacity: 0.42;
}

.board {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(var(--board-size), 1fr);
  grid-template-rows: repeat(var(--board-size), 1fr);
  gap: 0;
  padding: 0;
  border-radius: 6px;
  background:
    linear-gradient(to right, var(--line-strong) 0 1px, transparent 1px) 0 0 / var(--major-cell) var(--major-cell),
    linear-gradient(to bottom, var(--line-strong) 0 1px, transparent 1px) 0 0 / var(--major-cell) var(--major-cell),
    repeating-linear-gradient(to right, var(--line) 0 1px, transparent 1px var(--cell-size)),
    repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px var(--cell-size)),
    radial-gradient(circle at 50% 50%, rgba(27, 100, 74, 0.5), rgba(7, 38, 29, 0.58) 54%, rgba(1, 18, 14, 0.84)),
    url("assets/board-lacquer.png") center / cover;
  box-shadow:
    inset 0 0 0 2px rgba(247, 218, 141, 0.32),
    inset 0 0 40px rgba(0, 0, 0, 0.52);
  overflow: hidden;
}

.board::before,
.board::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.board::before {
  z-index: 1;
  background:
    radial-gradient(circle at 50% 50%, transparent 0 5px, rgba(239, 206, 117, 0.28) 6px 7px, transparent 8px),
    radial-gradient(circle at 25% 25%, rgba(239, 206, 117, 0.45) 0 3px, transparent 4px),
    radial-gradient(circle at 75% 25%, rgba(239, 206, 117, 0.45) 0 3px, transparent 4px),
    radial-gradient(circle at 25% 75%, rgba(239, 206, 117, 0.45) 0 3px, transparent 4px),
    radial-gradient(circle at 75% 75%, rgba(239, 206, 117, 0.45) 0 3px, transparent 4px);
  opacity: 0.55;
}

.board::after {
  z-index: 2;
  background: linear-gradient(105deg, transparent 15%, rgba(255, 242, 184, 0.16) 45%, transparent 68%);
  transform: translateX(-125%);
  opacity: 0;
}

.board-shell.ai-thinking .board::after {
  opacity: 1;
  animation: scanLight 1.35s ease-in-out infinite;
}

.cell {
  position: relative;
  z-index: 4;
  min-width: 0;
  min-height: 0;
  border: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  cursor: default;
  overflow: visible;
  contain: layout;
}

.cell::before {
  content: "";
  position: absolute;
  inset: 7%;
  border: 1px solid rgba(255, 231, 151, 0.34);
  background:
    linear-gradient(135deg, rgba(255, 238, 166, 0.2), rgba(16, 86, 61, 0.04)),
    radial-gradient(circle, rgba(255, 232, 154, 0.18), transparent 64%);
  box-shadow: inset 0 0 10px rgba(255, 228, 143, 0.1), 0 0 10px rgba(214, 176, 82, 0.12);
  transform: scale(0.72);
  opacity: 0;
  transition: opacity 160ms ease, transform 180ms ease, border-color 180ms ease;
}

.cell.legal {
  cursor: pointer;
}

.cell.legal::after {
  content: "";
  position: absolute;
  display: grid;
  place-items: center;
  width: calc(38% + var(--move-power, 0.4) * 18%);
  height: calc(38% + var(--move-power, 0.4) * 18%);
  left: 50%;
  top: 50%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  color: rgba(255, 246, 207, 0.9);
  font-size: clamp(0.46rem, calc(var(--cell-size) * 0.34), 0.82rem);
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 1px 2px #000;
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.44), transparent 18%),
    radial-gradient(circle, rgba(255, 243, 183, 0.42), rgba(231, 201, 123, 0.14) 54%, transparent 70%);
  border: 1px solid rgba(255, 238, 171, 0.58);
  box-shadow: 0 0 12px rgba(214, 176, 82, 0.5), inset 0 0 10px rgba(255, 243, 183, 0.16);
  animation: legalPulse 1.6s ease-in-out infinite;
  transition: transform 130ms ease, opacity 130ms ease, box-shadow 130ms ease;
}

.turn-black .cell.legal::after {
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.2), transparent 18%),
    radial-gradient(circle, rgba(54, 61, 62, 0.72), rgba(8, 10, 11, 0.32) 58%, transparent 72%);
}

.turn-white .cell.legal::after {
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.88), transparent 18%),
    radial-gradient(circle, rgba(255, 247, 218, 0.78), rgba(226, 205, 158, 0.32) 58%, transparent 72%);
}

.board-32 .cell.legal::after {
  content: attr(data-flips);
}

.board-64 .cell.legal::after {
  width: calc(46% + var(--move-power, 0.4) * 16%);
  height: calc(46% + var(--move-power, 0.4) * 16%);
}

.cell.legal:hover::before {
  transform: scale(1);
  opacity: 0.82;
}

.cell.legal:hover::after,
.cell.legal.targeted::after {
  transform: translate(-50%, -50%) scale(1.28);
  opacity: 1;
  box-shadow:
    0 0 18px rgba(242, 205, 104, 0.72),
    0 0 34px rgba(108, 202, 143, 0.22),
    inset 0 0 12px rgba(255, 248, 204, 0.28);
}

.cell.legal:active::after {
  transform: translate(-50%, -50%) scale(0.92);
}

.cell.preview-move::before {
  transform: scale(1);
  opacity: 1;
  border-color: rgba(255, 241, 173, 0.86);
  box-shadow:
    inset 0 0 14px rgba(255, 230, 139, 0.18),
    0 0 18px rgba(241, 202, 97, 0.54);
}

.cell.preview-captured::before {
  transform: scale(1);
  opacity: 0.9;
  border-color: rgba(255, 213, 115, 0.72);
  background:
    linear-gradient(135deg, rgba(255, 221, 126, 0.28), rgba(26, 111, 75, 0.08)),
    radial-gradient(circle, rgba(255, 232, 154, 0.28), transparent 64%);
  animation: previewTaken 900ms ease-in-out infinite;
}

.cell.preview-captured::after {
  content: attr(data-capture-step);
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 10;
  width: 60%;
  height: 60%;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff5cf;
  font-size: clamp(0.46rem, calc(var(--cell-size) * 0.34), 0.78rem);
  font-weight: 850;
  line-height: 1;
  text-shadow: 0 1px 2px #000, 0 0 8px rgba(255, 218, 114, 0.82);
  background: radial-gradient(circle, rgba(255, 214, 105, 0.42), rgba(255, 214, 105, 0.08) 62%, transparent 72%);
  border: 1px solid rgba(255, 235, 166, 0.5);
  transform: translate(-50%, -50%);
  animation: previewStep 900ms ease-in-out infinite;
  animation-delay: var(--preview-delay, 0ms);
}

.board-64 .cell.preview-captured::after {
  width: 42%;
  height: 42%;
  font-size: clamp(0.38rem, calc(var(--cell-size) * 0.28), 0.62rem);
}

.cell.preview-captured .piece {
  filter: brightness(1.22) saturate(1.18);
}

.cell.last {
  z-index: 8;
}

.cell.captured {
  animation: squareFlash 720ms ease var(--anim-delay, 0ms);
}

.cell.targeted {
  z-index: 9;
}

.cell.targeted::before {
  transform: scale(1);
  opacity: 0.64;
}

.cell.last::before {
  transform: scale(1);
  opacity: 0.72;
  animation: selectedGlow 1.2s ease-out both;
}

.move-ripple {
  position: absolute;
  inset: -95%;
  border-radius: 50%;
  border: 2px solid rgba(255, 229, 150, 0.72);
  opacity: 0;
  pointer-events: none;
  animation: moveRipple 980ms ease-out;
  mix-blend-mode: screen;
}

.move-ripple::before,
.move-ripple::after {
  content: "";
  position: absolute;
  inset: 14%;
  border-radius: inherit;
  border: 1px solid rgba(145, 231, 173, 0.42);
}

.move-ripple::after {
  inset: 28%;
  border-color: rgba(255, 248, 197, 0.55);
}

.move-burst {
  position: absolute;
  inset: -75%;
  border-radius: 50%;
  pointer-events: none;
  background:
    conic-gradient(from 0deg, transparent 0 12deg, rgba(255, 236, 155, 0.7) 13deg 18deg, transparent 19deg 42deg);
  opacity: 0;
  mix-blend-mode: screen;
  animation: moveBurst 680ms ease-out;
}

.capture-ray {
  position: absolute;
  z-index: 7;
  height: max(3px, calc(var(--cell-size) * 0.22));
  border-radius: 999px;
  pointer-events: none;
  transform-origin: left center;
  opacity: 0;
  background:
    linear-gradient(90deg, rgba(255, 243, 184, 0), rgba(255, 232, 143, 0.92) 34%, rgba(95, 218, 148, 0.22) 72%, rgba(255, 243, 184, 0));
  box-shadow:
    0 0 12px rgba(247, 212, 118, 0.62),
    0 0 24px rgba(93, 216, 144, 0.18);
  animation: captureRay 760ms ease-out var(--ray-delay, 0ms);
}

.capture-ray.black {
  background:
    linear-gradient(90deg, rgba(255, 243, 184, 0), rgba(168, 204, 218, 0.88) 34%, rgba(56, 75, 82, 0.2) 72%, rgba(255, 243, 184, 0));
}

.preview-ray {
  position: absolute;
  z-index: 8;
  height: max(3px, calc(var(--cell-size) * 0.2));
  border-radius: 999px;
  pointer-events: none;
  transform-origin: left center;
  opacity: 0.95;
  background:
    linear-gradient(90deg, rgba(255, 246, 200, 0.98), rgba(255, 216, 103, 0.82) 38%, rgba(90, 225, 154, 0.34));
  box-shadow:
    0 0 0 1px rgba(8, 11, 8, 0.42),
    0 0 12px rgba(250, 214, 109, 0.72),
    0 0 28px rgba(101, 221, 151, 0.26);
  animation: previewRayPulse 1.05s ease-in-out infinite;
}

.preview-ray::before {
  content: "";
  position: absolute;
  inset: -120% 0;
  border-radius: inherit;
  background:
    linear-gradient(90deg, transparent 0 18%, rgba(255, 255, 238, 0.78) 24%, transparent 34% 100%);
  animation: previewRayScan 900ms ease-in-out infinite;
  animation-delay: var(--preview-delay, 0ms);
}

.preview-ray::after {
  content: "";
  position: absolute;
  right: -1px;
  top: 50%;
  width: max(7px, calc(var(--cell-size) * 0.42));
  height: max(7px, calc(var(--cell-size) * 0.42));
  border-radius: 2px;
  border-top: 2px solid rgba(255, 244, 189, 0.98);
  border-right: 2px solid rgba(255, 244, 189, 0.98);
  transform: translateY(-50%) rotate(45deg);
  filter: drop-shadow(0 0 6px rgba(245, 210, 106, 0.82));
}

.piece {
  position: absolute;
  inset: 9%;
  border-radius: 50%;
  min-width: 5px;
  min-height: 5px;
  transform-style: preserve-3d;
  box-shadow:
    0 calc(var(--cell-size) * 0.14) calc(var(--cell-size) * 0.22) rgba(0, 0, 0, 0.52),
    inset calc(var(--cell-size) * -0.08) calc(var(--cell-size) * -0.1) calc(var(--cell-size) * 0.18) rgba(0, 0, 0, 0.38),
    inset calc(var(--cell-size) * 0.08) calc(var(--cell-size) * 0.08) calc(var(--cell-size) * 0.16) rgba(255, 255, 255, 0.2);
  animation-fill-mode: both;
}

.piece::before,
.piece::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}

.piece::before {
  background:
    radial-gradient(circle at 31% 25%, rgba(255, 255, 255, 0.38), transparent 19%),
    radial-gradient(circle at 70% 82%, rgba(0, 0, 0, 0.38), transparent 35%);
  mix-blend-mode: screen;
  opacity: 0.85;
}

.piece::after {
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.32);
}

.piece.black {
  background: url("assets/stone-dark.png") center / 190%;
}

.piece.white {
  background: url("assets/stone-light.png") center / 190%;
}

.piece.place {
  animation: pieceDrop 620ms cubic-bezier(0.16, 1, 0.3, 1) var(--anim-delay, 0ms) both;
}

.piece.flip {
  background: transparent;
  box-shadow: none;
  animation: pieceFlip 760ms cubic-bezier(0.2, 0.8, 0.2, 1) var(--anim-delay, 0ms) both;
}

.piece.flip::before,
.piece.flip::after {
  display: none;
}

.piece-face {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  backface-visibility: hidden;
  box-shadow:
    0 calc(var(--cell-size) * 0.14) calc(var(--cell-size) * 0.22) rgba(0, 0, 0, 0.52),
    inset calc(var(--cell-size) * -0.08) calc(var(--cell-size) * -0.1) calc(var(--cell-size) * 0.18) rgba(0, 0, 0, 0.38),
    inset calc(var(--cell-size) * 0.08) calc(var(--cell-size) * 0.08) calc(var(--cell-size) * 0.16) rgba(255, 255, 255, 0.2);
}

.piece-face::before,
.piece-face::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}

.piece-face::before {
  background:
    radial-gradient(circle at 31% 25%, rgba(255, 255, 255, 0.38), transparent 19%),
    radial-gradient(circle at 70% 82%, rgba(0, 0, 0, 0.38), transparent 35%);
  mix-blend-mode: screen;
  opacity: 0.85;
}

.piece-face::after {
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.32);
}

.piece-face.black {
  background: url("assets/stone-dark.png") center / 190%;
}

.piece-face.white {
  background: url("assets/stone-light.png") center / 190%;
}

.face-back {
  transform: rotateY(180deg);
}

#sparkCanvas {
  position: absolute;
  z-index: 7;
  inset: 0;
  width: var(--board-inner);
  height: var(--board-inner);
  pointer-events: none;
}

.board-64 .cell {
  border-radius: 2px;
  box-shadow: none;
}

.board-64 .piece {
  inset: 8%;
}

.board-64 .piece::before,
.board-64 .piece::after {
  opacity: 0.72;
}

.focus-lens {
  position: absolute;
  z-index: 9;
  left: 0;
  top: 0;
  width: clamp(74px, calc(var(--cell-size) * 7.2), 136px);
  height: clamp(74px, calc(var(--cell-size) * 7.2), 136px);
  border-radius: 50%;
  display: grid;
  place-items: end center;
  padding-bottom: 9px;
  color: #fff4c8;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.84);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

.focus-lens canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

.focus-lens span {
  position: relative;
  z-index: 2;
  text-shadow: 0 1px 3px #000, 0 0 10px rgba(255, 226, 137, 0.72);
}

.board-64 .focus-lens {
  border: 2px solid rgba(255, 239, 181, 0.74);
  background:
    radial-gradient(circle at 31% 24%, rgba(255, 255, 255, 0.34), transparent 17%),
    radial-gradient(circle at 50% 50%, rgba(255, 226, 137, 0.18), rgba(5, 38, 29, 0.24) 42%, rgba(1, 10, 8, 0.08) 72%);
  box-shadow:
    0 0 0 2px rgba(0, 0, 0, 0.62),
    0 10px 26px rgba(0, 0, 0, 0.42),
    0 0 30px rgba(230, 190, 84, 0.32),
    inset 0 0 24px rgba(255, 244, 192, 0.18),
    inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  backdrop-filter: brightness(1.24) contrast(1.28) saturate(1.25);
}

.board-64 .focus-lens::before,
.board-64 .focus-lens::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.board-64 .focus-lens::before {
  left: 21%;
  top: 15%;
  width: 34%;
  height: 17%;
  border-radius: 50%;
  border-top: 2px solid rgba(255, 255, 255, 0.54);
  transform: rotate(-22deg);
}

.board-64 .focus-lens::after {
  right: -25%;
  bottom: 3%;
  width: 42%;
  height: 9px;
  border-radius: 999px;
  background: linear-gradient(90deg, #f1d887, #6c5027 72%, #20150b);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.48), inset 0 1px 0 rgba(255, 255, 255, 0.28);
  transform: rotate(43deg);
  transform-origin: left center;
}

.board-64 .focus-lens.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.board-64.zoom-focus .focus-lens {
  width: clamp(96px, calc(var(--cell-size) * 8.6), 160px);
  height: clamp(96px, calc(var(--cell-size) * 8.6), 160px);
  background:
    radial-gradient(circle at 31% 24%, rgba(255, 255, 255, 0.38), transparent 17%),
    radial-gradient(circle at 50% 50%, rgba(255, 226, 137, 0.24), rgba(5, 38, 29, 0.26) 44%, rgba(1, 10, 8, 0.08) 74%);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.62),
    0 0 40px rgba(230, 190, 84, 0.38),
    inset 0 0 38px rgba(255, 234, 168, 0.16);
}

.metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.metric strong {
  text-align: right;
  font-size: 1rem;
}

.move-log-wrap {
  display: grid;
  gap: 10px;
}

.move-log {
  display: grid;
  gap: 6px;
  max-height: clamp(120px, calc(100vh - 470px), 220px);
  overflow: auto;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
}

.move-log li {
  padding: 4px 0;
}

.move-log b {
  color: var(--ink);
}

.thinking-dot::after {
  content: "";
  display: inline-block;
  width: 1.2em;
  text-align: left;
  animation: dots 1s steps(4, end) infinite;
}

@keyframes dots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
}

@keyframes scanLight {
  0% {
    transform: translateX(-125%);
  }
  100% {
    transform: translateX(125%);
  }
}

@keyframes legalPulse {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(0.92);
    opacity: 0.7;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.1);
    opacity: 1;
  }
}

@keyframes pieceDrop {
  0% {
    transform: translateY(-95%) scale(1.5) rotateX(62deg);
    opacity: 0;
    filter: brightness(1.5) saturate(1.15);
  }
  54% {
    transform: translateY(8%) scale(1.16) rotateX(0deg);
    opacity: 1;
    filter: brightness(1.38) saturate(1.12);
  }
  76% {
    transform: translateY(-2%) scale(0.96) rotateX(0deg);
    filter: brightness(1.12);
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
    filter: brightness(1);
  }
}

@keyframes pieceFlip {
  0% {
    transform: rotateY(0deg) scale(1);
  }
  48% {
    transform: rotateY(92deg) scale(1.24);
    filter: brightness(1.55) saturate(1.2);
  }
  100% {
    transform: rotateY(180deg) scale(1);
  }
}

@keyframes moveRipple {
  0% {
    opacity: 0.95;
    transform: scale(0.1) rotate(0deg);
  }
  58% {
    opacity: 0.62;
  }
  100% {
    opacity: 0;
    transform: scale(1.82) rotate(16deg);
  }
}

@keyframes moveBurst {
  0% {
    opacity: 0.95;
    transform: scale(0.16) rotate(-18deg);
  }
  70% {
    opacity: 0.56;
  }
  100% {
    opacity: 0;
    transform: scale(1.18) rotate(36deg);
  }
}

@keyframes captureRay {
  0% {
    opacity: 0;
    clip-path: inset(0 100% 0 0);
  }
  24% {
    opacity: 1;
  }
  76% {
    opacity: 0.7;
    clip-path: inset(0 0 0 0);
  }
  100% {
    opacity: 0;
    clip-path: inset(0 0 0 100%);
  }
}

@keyframes previewRayPulse {
  0%,
  100% {
    opacity: 0.72;
    filter: brightness(1);
  }
  50% {
    opacity: 1;
    filter: brightness(1.28);
  }
}

@keyframes previewRayScan {
  0% {
    transform: translateX(-62%);
    opacity: 0;
  }
  24% {
    opacity: 1;
  }
  100% {
    transform: translateX(92%);
    opacity: 0;
  }
}

@keyframes previewTaken {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.35) saturate(1.2);
  }
}

@keyframes previewStep {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(0.9);
    opacity: 0.62;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.08);
    opacity: 1;
  }
}

@keyframes selectedGlow {
  0% {
    opacity: 1;
    box-shadow:
      inset 0 0 16px rgba(255, 241, 181, 0.22),
      0 0 22px rgba(235, 195, 90, 0.72);
  }
  100% {
    opacity: 0.18;
    box-shadow:
      inset 0 0 10px rgba(255, 228, 143, 0.1),
      0 0 10px rgba(214, 176, 82, 0.12);
  }
}

@keyframes squareFlash {
  0% {
    filter: brightness(1);
  }
  42% {
    filter: brightness(1.55) saturate(1.3);
  }
  100% {
    filter: brightness(1);
  }
}

@media (max-width: 1060px) {
  .layout {
    grid-template-columns: minmax(220px, 1fr) minmax(320px, auto);
  }

  .detail-panel {
    grid-column: 1 / -1;
    grid-template-columns: repeat(4, minmax(120px, 1fr));
  }

  .move-log-wrap {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .app {
    padding: 14px;
  }

  .topbar,
  .layout {
    display: grid;
    grid-template-columns: 1fr;
  }

  .top-actions {
    justify-content: stretch;
  }

  .command {
    flex: 1 1 auto;
  }

  .score-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .score-row {
    min-height: 62px;
    padding-bottom: 0;
    border-bottom: 0;
  }

  .control-block {
    grid-column: 1 / -1;
  }

  .detail-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  :root {
    --board-pad: 10px;
    --rail: 22px;
  }

}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
