:root {
  --bg-1: #1a1410;
  --bg-2: #251c15;
  --board-1: #e6b97a;
  --board-2: #c98c4b;
  --board-edge: #6b3a17;
  --line: #3b2310;
  --text: #f3e7d3;
  --text-dim: #b8a98e;
  --accent: #d4a256;
  --accent-2: #f0c97a;
  --danger: #c84e3b;
  --warn: #b87d2c;
  --black-stone-1: #4a4a4a;
  --black-stone-2: #050505;
  --white-stone-1: #ffffff;
  --white-stone-2: #c8c0b4;
  --panel: rgba(30, 22, 16, 0.78);
  --panel-border: rgba(212, 162, 86, 0.25);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(212, 162, 86, 0.12), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(200, 78, 59, 0.08), transparent 60%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
  background-attachment: fixed;
}

.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 32px 40px;
}

.topbar {
  text-align: center;
  margin-bottom: 22px;
}

.topbar h1 {
  margin: 0;
  font-size: 32px;
  letter-spacing: 6px;
  font-weight: 600;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.topbar .subtitle {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: 2px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 28px;
  align-items: start;
}

@media (max-width: 1024px) {
  .layout { grid-template-columns: 1fr; }
}

/* ---------- Board panel ---------- */

.board-panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding: 0 4px;
  font-size: 14px;
  color: var(--text-dim);
}

.turn-indicator {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  color: var(--text);
}

.stone-mini {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #6a6a6a, #050505 70%);
  box-shadow: inset 0 -2px 4px rgba(0,0,0,0.5), 0 1px 2px rgba(0,0,0,0.6);
  transition: background 0.25s ease;
}
.stone-mini.white {
  background: radial-gradient(circle at 30% 30%, #ffffff, #c8c0b4 70%);
  box-shadow: inset 0 -2px 4px rgba(0,0,0,0.15), 0 1px 2px rgba(0,0,0,0.4);
}

.move-count { font-variant-numeric: tabular-nums; }

.board-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  box-shadow:
    inset 0 0 0 1px rgba(0,0,0,0.25),
    0 12px 30px rgba(0,0,0,0.55);
}

#board {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

[hidden] { display: none !important; }

.winner-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.25s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.winner-card {
  background: linear-gradient(180deg, #2a1f17, #1a1410);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 28px 36px;
  text-align: center;
  box-shadow: var(--shadow);
  animation: pop 0.3s cubic-bezier(.2,.8,.3,1.2);
}
@keyframes pop { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.winner-title {
  font-size: 28px;
  letter-spacing: 4px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 6px;
}
.winner-sub { color: var(--text-dim); font-size: 13px; margin-bottom: 18px; }
.winner-actions { display: flex; gap: 10px; justify-content: center; }

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
  padding: 4px;
}

/* ---------- Buttons ---------- */

.btn {
  appearance: none;
  border: 1px solid var(--panel-border);
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(0,0,0,0.18));
  color: var(--text);
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 14px;
  letter-spacing: 1px;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { border-color: var(--accent); background: linear-gradient(180deg, rgba(212,162,86,0.12), rgba(0,0,0,0.18)); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, #d4a256, #a87a35); border-color: #d4a256; color: #1a1410; font-weight: 600; }
.btn.primary:hover { background: linear-gradient(180deg, #f0c97a, #c89548); }
.btn.warn { color: #f3c98a; }
.btn.danger { color: #ff9c8c; border-color: rgba(200, 78, 59, 0.4); }
.btn.danger:hover { background: rgba(200, 78, 59, 0.15); border-color: var(--danger); }
.btn.small { padding: 6px 10px; font-size: 12px; }

/* ---------- Side panel ---------- */

.side-panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  max-height: 760px;
  display: flex;
  flex-direction: column;
}

.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--panel-border);
  margin-bottom: 12px;
  padding-bottom: 8px;
}
.tab {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 14px;
  letter-spacing: 1px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: #1a1410;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  font-weight: 600;
}

.tab-pane {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}
.tab-pane::-webkit-scrollbar { width: 6px; }
.tab-pane::-webkit-scrollbar-thumb { background: rgba(212, 162, 86, 0.3); border-radius: 3px; }

.moves-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
}
.moves-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: background 0.12s;
}
.moves-list li:hover { background: rgba(212, 162, 86, 0.1); }
.moves-list li.last { background: rgba(212, 162, 86, 0.18); }
.moves-list .idx { color: var(--text-dim); width: 28px; }
.moves-list .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #6a6a6a, #050505 70%);
  box-shadow: inset 0 -1px 2px rgba(0,0,0,0.5);
}
.moves-list .dot.white {
  background: radial-gradient(circle at 30% 30%, #ffffff, #c8c0b4 70%);
  box-shadow: inset 0 -1px 2px rgba(0,0,0,0.2);
}

.empty-hint {
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
  padding: 30px 0;
  opacity: 0.7;
}

.history-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding: 0 4px;
  font-size: 13px;
  color: var(--text-dim);
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.history-list li {
  background: rgba(255,255,255,0.025);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.history-list li:hover { background: rgba(212, 162, 86, 0.1); border-color: var(--panel-border); }
.history-row1 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}
.history-winner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}
.history-row2 {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.history-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

/* ---------- Replay bar ---------- */

.replay-bar {
  margin-top: 18px;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  box-shadow: var(--shadow);
}
.replay-info { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--text-dim); }
.replay-info strong { color: var(--accent-2); font-size: 14px; letter-spacing: 2px; }
.replay-controls { display: flex; align-items: center; gap: 6px; }
.replay-progress {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  padding: 0 8px;
  color: var(--text-dim);
}
