:root {
  --bg: #f4efe6;
  --panel: #ffffff;
  --wood: #d9a85f;
  --wood-dark: #b07f38;
  --line: #5a4020;
  --ink: #2b2b2b;
  --muted: #7a736a;
  --accent: #c0392b;
  --accent-soft: #fdecea;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(60, 40, 10, 0.15);
  font-size: 16px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background:
    radial-gradient(circle at 15% 10%, #fbf7ee 0%, transparent 45%),
    radial-gradient(circle at 85% 90%, #efe6d4 0%, transparent 50%),
    var(--bg);
  color: var(--ink);
  display: flex;
  justify-content: center;
  padding: 24px 16px;
}

.page {
  width: 100%;
  max-width: 1000px;
}

/* ---------- Header ---------- */
.header {
  text-align: center;
  margin-bottom: 20px;
}

.title {
  font-size: 2.2rem;
  letter-spacing: 0.35em;
  text-indent: 0.35em;
  font-weight: 700;
}

.subtitle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.95rem;
}

/* ---------- Layout ---------- */
.game {
  display: flex;
  gap: 22px;
  align-items: flex-start;
  flex-wrap: wrap;
  justify-content: center;
}

.board-wrap {
  flex: 1 1 480px;
  max-width: 640px;
}

.board-frame {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  line-height: 0;
}

#board {
  display: block;
  width: 100%;
  height: auto;
  cursor: pointer;
  touch-action: manipulation;
}

/* ---------- Overlay ---------- */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(30, 22, 10, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.5;
  animation: fadeIn 0.25s ease;
}

.overlay-card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 28px 34px;
  text-align: center;
  box-shadow: var(--shadow);
  animation: popIn 0.3s ease;
}

.overlay-emoji {
  font-size: 2.6rem;
  margin-bottom: 8px;
}

.overlay-card h2 {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.overlay-card p {
  color: var(--muted);
  margin-bottom: 18px;
}

.overlay-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes popIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ---------- Panel ---------- */
.panel {
  flex: 1 1 260px;
  max-width: 320px;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.scoreboard {
  display: flex;
  gap: 10px;
}

.score-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: #faf7f1;
  border: 1px solid #eee5d6;
  border-radius: 10px;
  padding: 10px 6px;
  font-size: 0.78rem;
  color: var(--muted);
}

.score-item strong {
  font-size: 1.25rem;
  color: var(--ink);
}

/* ---------- Stones ---------- */
.stone-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-block;
}

.stone-icon.black {
  background: radial-gradient(circle at 32% 30%, #6b6b6b, #111 55%, #000 100%);
}

.stone-icon.white {
  background: radial-gradient(circle at 32% 30%, #ffffff, #e8e8e8 55%, #c9c9c9 100%);
  box-shadow: inset 0 0 0 1px #d8d2c6;
}

.draw-icon {
  font-size: 1.2rem;
  color: var(--muted);
  line-height: 22px;
}

/* ---------- Mode box ---------- */
.mode-box {
  background: #faf7f1;
  border: 1px solid #eee5d6;
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mode-label {
  font-size: 0.75rem;
  color: var(--muted);
}

.mode-switch {
  display: flex;
  gap: 8px;
}

.mode-btn {
  flex: 1;
  padding: 9px 10px;
  font-size: 0.9rem;
}

.mode-btn.active {
  background: #3a6df0;
  color: #fff;
  box-shadow: 0 4px 10px rgba(58, 109, 240, 0.3);
}

.mode-btn.active:hover {
  background: #2f5ad0;
}

.side-switch {
  display: flex;
  align-items: center;
  gap: 8px;
}

.side-label {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.side-btn {
  flex: 1;
  padding: 8px 10px;
  font-size: 0.85rem;
}

.side-btn.active {
  background: #2e7d32;
  color: #fff;
  box-shadow: 0 4px 10px rgba(46, 125, 50, 0.3);
}

.side-btn.active:hover {
  background: #276a2b;
}

/* ---------- Turn box ---------- */
.turn-box {
  background: #faf7f1;
  border: 1px solid #eee5d6;
  border-radius: 10px;
  padding: 12px 14px;
}

.turn-label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.turn-display {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

/* ---------- Move info ---------- */
.move-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.move-info strong {
  color: var(--ink);
  font-size: 1.05rem;
}

.board-info {
  font-size: 0.78rem;
  padding: 3px 10px;
  border: 1px dashed #d9cfbc;
  border-radius: 999px;
}

/* ---------- Buttons ---------- */
.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  background: #f3ede1;
  color: var(--ink);
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:hover {
  background: #ece3d1;
}

.btn:active {
  transform: translateY(1px) scale(0.99);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 14px rgba(192, 57, 43, 0.3);
}

.btn-primary:hover {
  background: #a93226;
}

.btn-ghost {
  background: #fff;
  border-color: #ddd3c1;
}

.overlay-actions .btn {
  padding: 10px 18px;
}

/* ---------- Rules ---------- */
.rules {
  font-size: 0.88rem;
  color: var(--muted);
  border-top: 1px solid #eee5d6;
  padding-top: 12px;
}

.rules summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 8px;
}

.rules ul {
  padding-left: 18px;
  line-height: 1.8;
}

/* ---------- Footer ---------- */
.footer {
  margin-top: 22px;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .game {
    flex-direction: column;
    align-items: center;
  }

  .panel {
    width: 100%;
    max-width: 640px;
  }

  .actions {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .actions .btn {
    flex: 1 1 auto;
  }
}
