/* 弈境 · 围棋 AI 对弈 */

:root {
  --bg: #131110;
  --bg-soft: #1b1815;
  --panel: rgba(255, 255, 255, 0.035);
  --panel-2: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f2ece3;
  --muted: #9c9287;
  --gold: #d8b26a;
  --gold-soft: rgba(216, 178, 106, 0.16);
  --accent: #d9663f;
  --ok: #7fb37b;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

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

body {
  background: radial-gradient(1200px 700px at 15% -10%, #2a211a 0%, transparent 60%),
              radial-gradient(900px 600px at 110% 110%, #1d2422 0%, transparent 55%),
              var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
}

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 26px 24px 40px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

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

.logo {
  width: 46px; height: 46px;
  border-radius: 14px;
  background: linear-gradient(145deg, #2a231d, #171310);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}

.logo .stone { position: absolute; width: 17px; height: 17px; }
.logo .stone.black { transform: translate(-6px, -5px); }
.logo .stone.white { transform: translate(6px, 6px); }

.brand-text h1 {
  margin: 0;
  font-size: 21px;
  letter-spacing: 0.18em;
  font-weight: 600;
  font-family: "Songti SC", "Noto Serif SC", Georgia, serif;
}

.brand-text p {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.08em;
}

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

.ghost-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
}

.ghost-btn:hover { color: var(--text); border-color: var(--line-strong); background: var(--panel); }

/* ---------- 主区 ---------- */
.main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 26px;
  align-items: start;
  flex: 1;
}

.board-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.board-shell {
  position: relative;
  border-radius: 22px;
  padding: 14px;
  background: linear-gradient(160deg, rgba(255,255,255,0.075), rgba(255,255,255,0.02));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
}

.board-glow {
  position: absolute;
  inset: 8% 12% -6% 12%;
  background: radial-gradient(ellipse at center, rgba(216, 178, 106, 0.20), transparent 68%);
  filter: blur(28px);
  z-index: 0;
  pointer-events: none;
}

#board {
  position: relative;
  z-index: 1;
  display: block;
  border-radius: 12px;
  touch-action: manipulation;
  cursor: pointer;
}

.thinking {
  position: absolute;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(19, 17, 16, 0.86);
  border: 1px solid rgba(216, 178, 106, 0.35);
  color: var(--gold);
  font-size: 12.5px;
  letter-spacing: 0.06em;
  backdrop-filter: blur(8px);
  animation: fadeUp 0.25s ease;
}

.thinking .dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--gold);
  animation: blink 1.1s infinite ease-in-out;
}
.thinking .dot:nth-child(2) { animation-delay: 0.15s; }
.thinking .dot:nth-child(3) { animation-delay: 0.3s; }
.thinking-text { margin-left: 4px; }

@keyframes blink {
  0%, 100% { opacity: 0.25; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-2px); }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translate(-50%, 6px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.board-badge {
  position: absolute;
  top: 22px;
  left: 24px;
  z-index: 2;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: rgba(48, 30, 12, 0.72);
  background: rgba(60, 38, 16, 0.12);
  border: 1px solid rgba(60, 38, 16, 0.16);
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 600;
  pointer-events: none;
}

.board-meta {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.board-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 6px 0;
  flex-wrap: wrap;
}

.turn-line {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  color: var(--text);
}

.turn-stone {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: linear-gradient(145deg, #3a342e, #0e0c0a);
  box-shadow: 0 1px 3px rgba(0,0,0,0.6), inset 0 1px 1px rgba(255,255,255,0.18);
}

.turn-stone.white {
  background: linear-gradient(145deg, #ffffff, #cfc8bd);
  box-shadow: 0 1px 3px rgba(0,0,0,0.45), inset 0 -1px 2px rgba(0,0,0,0.12);
}

.sep { color: var(--muted); }
#move-count { color: var(--muted); font-size: 13px; }

.hint {
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* ---------- 面板 ---------- */
.panel { display: flex; flex-direction: column; gap: 14px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  backdrop-filter: blur(10px);
}

.card-title {
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--muted);
  margin-bottom: 13px;
  text-transform: uppercase;
}

.match-card { padding: 14px 16px; }

.side-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0;
  border-radius: 10px;
  transition: background 0.2s ease;
}

.side-row.active { background: var(--gold-soft); box-shadow: 0 0 0 1px rgba(216,178,106,0.22); }

.side-row .stone { width: 26px; height: 26px; flex: none; }

.side-name { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.side-name strong { font-size: 14px; font-weight: 600; letter-spacing: 0.02em; }
.side-name small { font-size: 11.5px; color: var(--muted); }

.side-stats { display: flex; flex-direction: column; align-items: flex-end; }
.side-stats span { font-size: 16px; font-variant-numeric: tabular-nums; }
.side-stats small { font-size: 10px; color: var(--muted); letter-spacing: 0.08em; }

.vs-line { height: 1px; background: var(--line); margin: 9px 2px; }

.btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.btn {
  font-family: inherit;
  font-size: 13.5px;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  transition: all 0.16s ease;
  letter-spacing: 0.02em;
}

.btn:hover:not(:disabled) { background: rgba(255,255,255,0.1); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn.wide { width: 100%; margin-top: 10px; }
.btn.danger { color: #e08a75; border-color: rgba(217, 102, 63, 0.35); }
.btn.danger:hover:not(:disabled) { background: rgba(217, 102, 63, 0.14); }

.field { margin-bottom: 13px; }
.field label {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 7px;
  letter-spacing: 0.08em;
}

.segmented {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: rgba(0,0,0,0.22);
  border-radius: 11px;
  border: 1px solid var(--line);
}

.segmented button {
  flex: 1;
  font-family: inherit;
  font-size: 12.5px;
  padding: 7px 4px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.16s ease;
  white-space: nowrap;
}

.segmented button:hover { color: var(--text); }
.segmented button.on {
  background: linear-gradient(160deg, rgba(216,178,106,0.22), rgba(216,178,106,0.1));
  color: var(--gold);
  box-shadow: inset 0 0 0 1px rgba(216,178,106,0.28);
}

.tip { font-size: 11.5px; color: var(--muted); margin: 4px 0 0; }

.result-box {
  margin-top: 13px;
  padding: 13px 14px;
  border-radius: 11px;
  background: rgba(216, 178, 106, 0.09);
  border: 1px solid rgba(216, 178, 106, 0.25);
  font-size: 13px;
  line-height: 1.7;
  animation: fadeUpSmall 0.3s ease;
}

.result-box strong { color: var(--gold); }
.result-box .score-line { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }

@keyframes fadeUpSmall {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.muted-card { background: rgba(255,255,255,0.02); }

.fine { font-size: 12px; line-height: 1.75; color: var(--muted); margin: 0; }

/* ---------- 棋子外观（DOM 用） ---------- */
.stone {
  display: inline-block;
  border-radius: 50%;
  flex: none;
}

.stone.black {
  background: radial-gradient(circle at 33% 28%, #5a5148 0%, #211d19 42%, #0a0908 100%);
  box-shadow: 0 2px 6px rgba(0,0,0,0.55), inset 0 1px 1px rgba(255,255,255,0.22);
}

.stone.white {
  background: radial-gradient(circle at 33% 28%, #ffffff 0%, #f1ece2 45%, #c9c1b4 100%);
  box-shadow: 0 2px 6px rgba(0,0,0,0.4), inset 0 -1px 2px rgba(0,0,0,0.12);
}

/* ---------- 模态框 ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal[hidden] { display: none; }

.modal-mask {
  position: absolute; inset: 0;
  background: rgba(8, 7, 6, 0.72);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.2s ease;
}

.modal-body {
  position: relative;
  width: min(520px, 100%);
  max-height: 82vh;
  overflow-y: auto;
  background: linear-gradient(165deg, #211d19, #171412);
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  padding: 26px 26px 22px;
  box-shadow: var(--shadow);
  animation: pop 0.24s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}

.modal-body h2 {
  margin: 0 0 16px;
  font-size: 18px;
  letter-spacing: 0.08em;
  font-family: "Songti SC", "Noto Serif SC", Georgia, serif;
}

.modal-body h3 { margin: 20px 0 8px; font-size: 14px; color: var(--gold); }

.modal-body ul { margin: 0; padding-left: 18px; }
.modal-body li { font-size: 13.5px; line-height: 1.85; color: #cfc6ba; margin-bottom: 6px; }
.modal-body li strong { color: var(--text); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(0.96) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  z-index: 80;
  background: rgba(28, 24, 20, 0.95);
  border: 1px solid var(--line-strong);
  color: var(--text);
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.5);
  animation: fadeUp 0.22s ease;
}

.toast[hidden] { display: none; }

/* ---------- 响应式 ---------- */
@media (max-width: 960px) {
  .app { padding: 18px 14px 32px; }
  .main { grid-template-columns: 1fr; gap: 18px; }
  .panel { order: 2; }
  .board-shell { padding: 9px; border-radius: 18px; }
  .brand-text p { display: none; }
  .topbar { margin-bottom: 16px; }
}

@media (max-width: 480px) {
  .brand-text h1 { font-size: 18px; }
  .ghost-btn { padding: 7px 12px; font-size: 12px; }
  .card { padding: 14px; }
  .board-meta {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.board-foot { padding-top: 10px; }
  .hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

.thinking[hidden] { display: none !important; }
.result-box[hidden] { display: none !important; }
