/* ── Fonts ──────────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600;700&family=Source+Sans+3:wght@400;500;600;700&display=swap');

/* ── Design Tokens ──────────────────────────────────────────────────────────── */
:root {
  --bg: #f2e8d8;
  --bg-deep: #e7d8be;
  --surface: rgba(251, 245, 234, 0.92);
  --surface-strong: #fbf6ec;
  --surface-soft: rgba(255, 251, 244, 0.72);
  --text: #221b16;
  --text-muted: #6f6255;
  --text-soft: #8f7f70;
  --border: rgba(111, 85, 57, 0.22);
  --border-strong: rgba(111, 85, 57, 0.36);
  --accent: #9c382c;
  --accent-deep: #7f291f;
  --ink: #181411;
  --btn-primary: #231915;
  --btn-hover: #3a2820;
  --btn-ghost-border: rgba(111, 85, 57, 0.36);
  --ko-color: #9c382c;
  --shadow-board: 0 26px 60px rgba(59, 37, 20, 0.22);
  --shadow-card: 0 16px 36px rgba(52, 34, 22, 0.12);
  --shadow-paper: 0 6px 20px rgba(60, 40, 25, 0.08);
  --radius: 16px;
  --radius-sm: 10px;
  --transition: 0.18s ease;
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  min-height: 100%;
}

/* ── Base ───────────────────────────────────────────────────────────────────── */
body {
  font-family: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 17px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 20px 40px;
  min-height: 100vh;
  background:
    radial-gradient(circle at top, rgba(255, 251, 244, 0.72), transparent 36%),
    linear-gradient(180deg, rgba(255, 249, 240, 0.5), transparent 30%),
    linear-gradient(135deg, var(--bg), var(--bg-deep));
  position: relative;
  overflow-x: hidden;
}

body::before,
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  opacity: 0.32;
  background-image:
    linear-gradient(rgba(120, 98, 72, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 98, 72, 0.04) 1px, transparent 1px);
  background-size: 160px 160px, 160px 160px;
  mask-image: radial-gradient(circle at center, black 55%, transparent 100%);
}

body::after {
  opacity: 0.18;
  background:
    radial-gradient(circle at 20% 16%, rgba(156, 56, 44, 0.18), transparent 18%),
    radial-gradient(circle at 82% 10%, rgba(126, 96, 56, 0.14), transparent 16%),
    radial-gradient(circle at 50% 95%, rgba(255, 255, 255, 0.35), transparent 24%);
}

a {
  color: inherit;
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
button,
input,
select {
  font: inherit;
}

button {
  font-size: 0.94rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 10px 22px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition:
    background var(--transition),
    color var(--transition),
    border-color var(--transition),
    transform var(--transition),
    box-shadow var(--transition);
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(180deg, #2c201a, var(--btn-primary));
  color: #fbf6ee;
  box-shadow: 0 12px 22px rgba(35, 25, 21, 0.18);
}

.btn-primary:hover {
  background: linear-gradient(180deg, #423027, var(--btn-hover));
}

.btn-ghost {
  background: rgba(255, 251, 244, 0.56);
  color: var(--text);
  border-color: var(--btn-ghost-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.btn-ghost:hover {
  background: rgba(255, 251, 244, 0.9);
  border-color: var(--border-strong);
}

/* ── Setup Page ─────────────────────────────────────────────────────────────── */
.setup-screen {
  width: min(100%, 760px);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 4px;
  position: relative;
  z-index: 1;
}

.setup-mark {
  position: fixed;
  top: 22px;
  left: 22px;
  width: 100px;
  height: 100px;
  border-radius: 28px;
  border: 1px solid rgba(156, 56, 44, 0.34);
  background:
    linear-gradient(180deg, rgba(183, 74, 57, 0.94), rgba(140, 39, 27, 0.96));
  color: #f8eee4;
  display: grid;
  place-items: center;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-indent: 0.14em;
  z-index: 2;
  box-shadow:
    0 12px 28px rgba(128, 38, 28, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.setup-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: clamp(3rem, 7vw, 4.5rem);
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--ink);
  line-height: 0.92;
  margin-bottom: 6px;
  text-align: center;
}

.setup-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-top: 10px;
  margin-bottom: 8px;
  text-align: center;
}

.setup-links {
  display: flex;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  justify-content: center;
}

.guide-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  box-shadow: none;
}

.guide-link:hover {
  color: var(--accent-deep);
}

.setup-mode-frame {
  width: min(100%, 660px);
  margin-bottom: 16px;
  background:
    linear-gradient(180deg, rgba(255, 252, 247, 0.75), rgba(247, 239, 226, 0.92));
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  padding: 14px;
  box-shadow: var(--shadow-card);
}

.mode-description-frame {
  width: min(100%, 660px);
  margin-bottom: 16px;
  padding: 12px 18px;
  background: rgba(255, 250, 242, 0.72);
  border: 1px solid rgba(111, 85, 57, 0.18);
  border-radius: 16px;
  box-shadow: var(--shadow-paper);
}

.mode-description-text {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
  margin: 0 auto;
}

.mode-buttons {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.mode-btn {
  min-height: 72px;
  padding: 12px 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 251, 244, 0.94), rgba(244, 235, 222, 0.92));
  box-shadow: var(--shadow-paper);
  color: var(--ink);
}

.mode-btn.active {
  background:
    linear-gradient(180deg, rgba(156, 56, 44, 0.98), rgba(126, 41, 31, 0.98));
  border-color: rgba(115, 28, 20, 0.7);
  box-shadow: 0 14px 28px rgba(126, 41, 31, 0.22);
  color: #fbf5ee;
}

.mode-btn--soon {
  position: relative;
  overflow: hidden;
  opacity: 0.65;
}

.mode-btn--soon::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top right,
    transparent calc(50% - 0.5px),
    rgba(111, 85, 57, 0.35) calc(50% - 0.5px),
    rgba(111, 85, 57, 0.35) calc(50% + 0.5px),
    transparent calc(50% + 0.5px)
  );
  pointer-events: none;
  z-index: 1;
}

.mode-btn--soon::after {
  content: 'Coming soon';
  position: absolute;
  bottom: 8px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-soft);
  pointer-events: none;
  z-index: 2;
}

.mode-btn--soon:hover {
  transform: none;
}

.mode-message {
  margin-bottom: 16px;
}

.mode-message-text {
  text-align: center;
  color: var(--text-muted);
}

.setup-frame {
  width: min(100%, 660px);
  background:
    linear-gradient(180deg, rgba(255, 252, 247, 0.75), rgba(247, 239, 226, 0.92));
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  padding: 22px;
  box-shadow: var(--shadow-card);
  position: relative;
}

.setup-frame::before {
  content: '';
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(156, 56, 44, 0.12);
  border-radius: calc(var(--radius) - 2px);
  pointer-events: none;
}

.section-kicker {
  display: block;
  margin-bottom: 10px;
  font-size: 0.74rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-soft);
  text-align: center;
}

.size-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.size-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 92px;
  padding: 16px 14px;
  background:
    linear-gradient(180deg, rgba(255, 251, 244, 0.94), rgba(244, 235, 222, 0.92));
  border: 1px solid var(--border);
  border-radius: 14px;
  text-align: center;
  box-shadow: var(--shadow-paper);
}

.size-btn:hover {
  border-color: rgba(156, 56, 44, 0.3);
  box-shadow: 0 12px 22px rgba(60, 40, 25, 0.11);
}

.size-btn.active {
  background:
    linear-gradient(180deg, rgba(156, 56, 44, 0.98), rgba(126, 41, 31, 0.98));
  border-color: rgba(115, 28, 20, 0.7);
  box-shadow: 0 14px 28px rgba(126, 41, 31, 0.22);
}

.size-btn .size-label {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.55rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.size-btn .size-desc {
  font-size: 0.76rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.size-btn.active .size-label,
.size-btn.active .size-desc {
  color: #fbf5ee;
}

.options-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-paper);
}

.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px 11px;
}

.option-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.option-heading {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.12rem;
  font-weight: 600;
  color: var(--ink);
}

.option-detail {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.option-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(111, 85, 57, 0.18), transparent);
  margin: 0 18px;
}

.option-sub {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px 14px;
  color: var(--text-muted);
}

.sub-label {
  font-size: 0.76rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.komi-standard-note {
  font-style: italic;
}

.sub-select {
  min-height: 34px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 252, 246, 0.9);
  color: var(--text);
}

/* ── Segmented control (colour picker) ──────────────────────────────────────── */
.seg-control {
  display: flex;
  flex-shrink: 0;
  background: rgba(123, 104, 81, 0.12);
  border: 1px solid rgba(111, 85, 57, 0.22);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.seg-btn {
  padding: 5px 11px;
  border-radius: 999px;
  border: none;
  background: transparent;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  box-shadow: none;
  letter-spacing: 0.03em;
  white-space: nowrap;
  min-height: unset;
  line-height: 1.2;
}

.seg-btn:hover {
  transform: none;
  background: rgba(156, 56, 44, 0.07);
}

.seg-btn.active {
  background: linear-gradient(180deg, rgba(156, 56, 44, 0.96), rgba(126, 41, 31, 0.96));
  color: #fbf5ee;
  box-shadow: 0 2px 5px rgba(126, 41, 31, 0.2);
}

.seg-btn.active:hover {
  background: linear-gradient(180deg, rgba(156, 56, 44, 0.96), rgba(126, 41, 31, 0.96));
  transform: none;
}

.start-btn {
  width: 100%;
  padding: 12px 16px;
  font-size: 0.88rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.start-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.toggle {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(123, 104, 81, 0.26);
  border: 1px solid rgba(111, 85, 57, 0.2);
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 4px;
  top: 3px;
  background: #fff8ef;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}

.toggle input:checked + .toggle-slider {
  background: rgba(156, 56, 44, 0.88);
  border-color: rgba(126, 41, 31, 0.72);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(19px);
}

/* ── Game Page ──────────────────────────────────────────────────────────────── */
.game-page {
  padding-top: 22px;
}

.info-bar {
  display: flex;
  align-items: center;
  gap: 18px;
  width: min(100%, 980px);
  margin-bottom: 14px;
  padding: 14px 18px;
  background: rgba(251, 245, 234, 0.82);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-paper);
  backdrop-filter: blur(4px);
  flex-wrap: wrap;
}

.brand-chip {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(156, 56, 44, 0.08);
  border: 1px solid rgba(156, 56, 44, 0.18);
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1rem;
  letter-spacing: 0.08em;
  color: var(--accent-deep);
}

.turn-block {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stone-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.stone-dot.black {
  background: radial-gradient(circle at 30% 28%, #58504d, #141110 72%);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.42);
}

.stone-dot.white {
  background: radial-gradient(circle at 30% 28%, #fffdf8, #d2c5b1 88%);
  border: 1px solid rgba(94, 78, 60, 0.22);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.16);
}

.turn-indicator {
  font-size: 1rem;
  font-weight: 600;
}

.ko-indicator {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ko-color);
  background: rgba(156, 56, 44, 0.08);
  padding: 5px 10px;
  border-radius: 999px;
  display: none;
}

.ko-indicator.visible {
  display: inline-block;
}

.captures {
  margin-left: auto;
  font-size: 0.88rem;
  color: var(--text-muted);
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.captures strong,
.move-count strong {
  color: var(--text);
  font-weight: 700;
}

.status-msg {
  min-height: 1.4em;
  font-size: 0.84rem;
  color: var(--ko-color);
  margin-bottom: 10px;
  text-align: center;
}

.game-area {
  display: flex;
  align-items: flex-start;
  gap: 22px;
}

.board-container {
  position: relative;
  line-height: 0;
  padding: 16px;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 251, 244, 0.72), rgba(237, 224, 205, 0.9));
  border: 1px solid rgba(111, 85, 57, 0.18);
  box-shadow: var(--shadow-card);
}

.board-container::before {
  content: '';
  position: absolute;
  inset: 8px;
  border-radius: 18px;
  border: 1px solid rgba(111, 85, 57, 0.1);
  pointer-events: none;
}

#board-canvas {
  display: block;
  cursor: crosshair;
  border-radius: 12px;
  box-shadow: var(--shadow-board);
}

.board-result {
  position: absolute;
  inset: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  z-index: 10;
}

.board-result-card,
.result-card,
.modal-card,
.guide-card {
  background:
    linear-gradient(180deg, rgba(255, 252, 247, 0.96), rgba(245, 236, 222, 0.96));
  border: 1px solid var(--border);
  box-shadow: 0 20px 50px rgba(45, 30, 18, 0.18);
}

.board-result-card {
  border-radius: 20px;
  padding: 30px 40px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.controls {
  display: flex;
  gap: 10px;
  margin-top: 22px;
  flex-wrap: wrap;
  justify-content: center;
}

.score-side-panel {
  width: 156px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px 16px 18px;
  box-shadow: var(--shadow-paper);
  position: sticky;
  top: 20px;
  flex-shrink: 0;
}

.side-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(111, 85, 57, 0.18);
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ink);
}

.side-score-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.side-score-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.side-score-label {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.side-score-val {
  font-size: 1rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.side-panel-total {
  padding-top: 12px;
  border-top: 1px solid rgba(111, 85, 57, 0.18);
  font-size: 0.84rem;
  color: var(--text-muted);
}

.side-panel-total strong {
  color: var(--ink);
  font-size: 1.12rem;
  font-weight: 700;
}

.scoring-panel {
  margin-top: 14px;
  padding: 18px 20px;
  background: rgba(251, 245, 234, 0.84);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-paper);
}

.scoring-instructions {
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.scoring-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.move-count {
  font-size: 0.84rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ── Bot countdown ring ─────────────────────────────────────────────────────── */
.bot-timer {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.bot-timer-svg {
  width: 26px;
  height: 26px;
  transform: rotate(-90deg); /* start arc at 12 o'clock */
  overflow: visible;
}

.bot-timer-track {
  fill: none;
  stroke: rgba(111, 85, 57, 0.18);
  stroke-width: 3.5;
}

/* circumference of r=14 circle ≈ 87.96 */
.bot-timer-arc {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-dasharray: 87.96 0;
}

.bot-timer-arc.running {
  animation: bot-timer-drain linear forwards;
}

@keyframes bot-timer-drain {
  from { stroke-dasharray: 87.96 0; }
  to   { stroke-dasharray: 0 87.96; }
}

.bot-thinking {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 22px;
  padding: 12px 22px;
  background: rgba(251, 245, 234, 0.84);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-paper);
}

.bot-thinking-text {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

.bot-thinking-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  animation: bot-pulse 1.1s ease-in-out infinite;
}

@keyframes bot-pulse {
  0%, 100% { opacity: 1;    transform: scale(1);   }
  50%       { opacity: 0.3; transform: scale(0.65); }
}

/* ── Difficulty slider ──────────────────────────────────────────────────── */
.diff-slider-wrap {
  width: 100%;
  padding: 4px 2px 0;
  box-sizing: border-box;
}

/* Fixed-height container — tick marks and input both fill this area */
.diff-track-area {
  position: relative;
  height: 24px;
}

/* Visible track line drawn here so ticks sit in front of it */
.diff-track-area::before {
  content: '';
  position: absolute;
  left: 0; right: 0;
  top: 50%;
  height: 5px;
  transform: translateY(-50%);
  background: var(--border-strong);
  border-radius: 3px;
  pointer-events: none;
}

/* Tick marks — in DOM before the input so they paint behind the thumb */
.diff-ticks {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.diff-ticks span {
  width: 14px;
  height: 14px;
  background:
    linear-gradient(var(--border-strong), var(--border-strong)),
    var(--bg);
  border-radius: 50%;
  flex-shrink: 0;
}

/* Input fills the track area; native track transparent since we draw our own */
.diff-slider {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  outline: none;
  cursor: pointer;
}

.diff-slider::-webkit-slider-runnable-track {
  height: 5px;
  background: transparent;
  border-radius: 3px;
}

.diff-slider::-moz-range-track {
  height: 5px;
  background: transparent;
  border-radius: 3px;
  border: none;
}

.diff-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--btn-primary);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(52, 34, 22, 0.28);
  border: 2px solid rgba(251, 245, 234, 0.9);
  margin-top: -7.5px; /* centres 20px thumb on 5px track */
}

.diff-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--btn-primary);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(52, 34, 22, 0.28);
  border: 2px solid rgba(251, 245, 234, 0.9);
}

.diff-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
}

.diff-labels span {
  flex: 1;
  font-size: 0.76rem;
  color: var(--text-muted);
  font-weight: 500;
  text-align: center;
}

.diff-labels span:first-child { text-align: left; }
.diff-labels span:last-child  { text-align: right; }

.diff-think-note {
  margin: 12px 0 0;
  font-size: 0.78rem;
  color: var(--text-soft);
  text-align: center;
}

.btn-danger {
  color: var(--ko-color);
  border-color: rgba(156, 56, 44, 0.28);
}

.btn-danger:hover {
  background: rgba(156, 56, 44, 0.07);
  border-color: rgba(156, 56, 44, 0.55);
}

/* ── Guide Modal ────────────────────────────────────────────────────────────── */
.guide-card {
  position: relative;
  max-width: 640px;
  width: min(92%, 640px);
  border-radius: 24px;
  padding: 28px 28px 26px;
}

.guide-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 999px;
  box-shadow: none;
}

.guide-close:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.04);
}

.guide-title {
  padding-right: 28px;
  margin-bottom: 10px;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 2rem;
  font-weight: 600;
  color: var(--ink);
}

.guide-intro {
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.guide-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.guide-list dt {
  margin-bottom: 3px;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ink);
}

.guide-list dd {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.58;
  color: var(--text-muted);
}

.guide-komi-note {
  font-size: 0.8rem;
  color: var(--text-soft);
}

/* ── Confirm / Result Modals ───────────────────────────────────────────────── */
.modal-overlay,
.result-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal-overlay {
  background: rgba(31, 22, 17, 0.3);
  z-index: 200;
}

.result-overlay {
  background: rgba(31, 22, 17, 0.36);
  z-index: 300;
}

.modal-card {
  width: min(92%, 380px);
  border-radius: 22px;
  padding: 26px 26px 20px;
}

.modal-message {
  font-size: 0.97rem;
  line-height: 1.56;
  color: var(--text);
  margin-bottom: 18px;
}

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

.result-card {
  border-radius: 24px;
  padding: 34px 42px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.result-message {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  font-weight: 600;
  color: var(--ink);
  line-height: 1.08;
}

/* ── Pass Toast ─────────────────────────────────────────────────────────────── */
.pass-toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  background: rgba(34, 25, 21, 0.92);
  color: #fbf6ee;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 8px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  z-index: 150;
  transition: opacity 0.18s ease, transform 0.18s ease;
  box-shadow: 0 10px 26px rgba(32, 22, 18, 0.24);
}

.pass-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .game-area {
    flex-direction: column;
    align-items: center;
  }

  .score-side-panel {
    position: static;
    width: min(100%, 660px);
  }

  .score-side-panel + .board-container,
  .board-container + .score-side-panel {
    order: 0;
  }
}

@media (max-width: 720px) {
  body {
    padding: 22px 14px 28px;
  }

  .setup-mark {
    top: 16px;
    left: 16px;
    width: 92px;
    height: 92px;
    font-size: 2.2rem;
  }

  .setup-frame {
    padding: 18px;
  }

  .size-buttons {
    grid-template-columns: 1fr;
  }

  .mode-buttons {
    grid-template-columns: 1fr 1fr;
  }

  .setup-links {
    gap: 12px;
    margin-bottom: 14px;
  }

  .mode-description-frame {
    padding: 12px 14px;
  }

  .info-bar {
    width: 100%;
    padding: 14px;
  }

  .captures {
    margin-left: 0;
  }

  .board-container {
    padding: 10px;
  }

  .controls,
  .scoring-actions {
    width: 100%;
  }

  .controls button,
  .scoring-actions button {
    flex: 1 1 160px;
  }
}

@media (max-width: 520px) {
  .setup-title {
    font-size: 2.6rem;
  }

  .setup-subtitle {
    margin-top: 10px;
    margin-bottom: 8px;
  }

  .option-row {
    align-items: flex-start;
  }

  .option-sub {
    flex-wrap: wrap;
  }

  .mode-buttons {
    grid-template-columns: 1fr;
  }
}

  .guide-card,
  .result-card,
  .board-result-card {
    padding-left: 22px;
    padding-right: 22px;
  }
}
