:root {
  --bg: #1c1410;
  --bg-2: #2a1e17;
  --ink: #f3e9dc;
  --muted: #b9a893;
  --dark-sq: #6d4426;
  --dark-sq-2: #5a3720;
  --light-sq: #e9cfa5;
  --light-sq-2: #dcbf92;
  --red: #c8352b;
  --red-2: #8f1f19;
  --black: #2b2b2e;
  --black-2: #0f0f11;
  --gold: #f0b429;
  --hint: rgba(240, 180, 41, 0.55);
  --board: min(92vw, 60vh, 560px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(120% 90% at 50% 0%, var(--bg-2), var(--bg) 70%);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: max(0.75rem, env(safe-area-inset-top)) 0.75rem max(1rem, env(safe-area-inset-bottom));
  max-width: 720px;
  margin: 0 auto;
}
.top {
  width: var(--board);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
h1 .variant { font-weight: 400; text-transform: none; letter-spacing: 0; opacity: 0.8; margin-left: 0.4rem; white-space: nowrap; }
h1 { white-space: nowrap; }
h1 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0;
  color: var(--muted);
}
.controls { display: flex; gap: 0.4rem; }
button {
  font: inherit;
  font-size: 0.9rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  transition: background 0.15s;
}
button:hover { background: rgba(255, 255, 255, 0.12); }
button:disabled { opacity: 0.4; cursor: default; }

.player {
  width: var(--board);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.9rem;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: border-color 0.2s, background 0.2s;
}
.player.active {
  border-color: var(--gold);
  background: rgba(240, 180, 41, 0.08);
}
.player .name { font-weight: 600; }
.player .captured { margin-left: auto; color: var(--muted); font-size: 0.9rem; }
.dot { width: 18px; height: 18px; border-radius: 50%; display: inline-block; }
.dot-r { background: radial-gradient(circle at 35% 35%, #e05a4e, var(--red-2)); }
.dot-b { background: radial-gradient(circle at 35% 35%, #5a5a60, var(--black-2)); }

.board-wrap { position: relative; }
.board {
  width: var(--board);
  height: var(--board);
  display: grid;
  border: 6px solid #3a2416;
  border-radius: 6px;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.8), inset 0 0 0 1px rgba(0, 0, 0, 0.4);
  transition: transform 0.4s ease;
}
.board.rotated { transform: rotate(180deg); }
.board.rotated .sq { transform: rotate(180deg); }
.sq {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--light-sq), var(--light-sq-2));
}
.sq.dark { background: linear-gradient(135deg, var(--dark-sq), var(--dark-sq-2)); cursor: pointer; }
.sq.hint::after {
  content: "";
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: var(--hint);
  box-shadow: 0 0 0 4px rgba(240, 180, 41, 0.18);
}
.sq.capture-hint::after { width: 40%; height: 40%; background: rgba(240, 180, 41, 0.35); border: 3px solid var(--gold); }
.sq.selected { box-shadow: inset 0 0 0 4px var(--gold); }
.sq.must { box-shadow: inset 0 0 0 3px rgba(240, 180, 41, 0.6); }
.piece {
  width: 78%;
  height: 78%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.55), inset 0 -4px 6px rgba(0, 0, 0, 0.35), inset 0 3px 4px rgba(255, 255, 255, 0.18);
  transition: transform 0.12s;
  pointer-events: none;
}
.sq.selected .piece { transform: scale(1.08); }
.piece.r { background: radial-gradient(circle at 35% 30%, #ea6a5c, var(--red) 55%, var(--red-2)); }
.piece.b { background: radial-gradient(circle at 35% 30%, #63636a, var(--black) 55%, var(--black-2)); }
.piece.taken { opacity: 0.35; filter: grayscale(0.6); }
.board[data-size="10"] .piece.k::before { border-width: 2px; }
.piece.k::before {
  content: "";
  width: 46%;
  height: 46%;
  border-radius: 50%;
  border: 3px solid var(--gold);
  box-shadow: 0 0 6px rgba(240, 180, 41, 0.6);
}
.status { min-height: 1.4em; margin: 0; color: var(--ink); font-size: 1rem; text-align: center; }
.rules { margin: 0; color: var(--muted); font-size: 0.8rem; text-align: center; max-width: var(--board); }

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 12, 8, 0.72);
  border-radius: 6px;
  backdrop-filter: blur(3px);
}
.overlay[hidden] { display: none; }
.overlay-card {
  text-align: center;
  padding: 1.4rem 1.8rem;
  border-radius: 14px;
  background: var(--bg-2);
  border: 1px solid rgba(240, 180, 41, 0.35);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}
.overlay-card p { margin: 0 0 1rem; font-size: 1.3rem; font-weight: 600; }
.overlay .overlay-card button { background: var(--gold); color: #2a1e17; border-color: transparent; font-weight: 600; }

.picker {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 12, 8, 0.72);
  backdrop-filter: blur(3px);
  z-index: 10;
}
.picker[hidden] { display: none; }
.picker-options { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 0.8rem; }
.picker-options button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  border-radius: 12px;
  padding: 0.7rem 1rem;
  min-width: 260px;
  text-align: left;
}
.picker-options button small { color: var(--muted); font-size: 0.78rem; }
button.link { background: none; border: none; color: var(--muted); }
