/* ============ 设计基调：墨色书斋 · 榧木棋盘 · 宣纸 · 朱砂印 ============ */
:root {
  --ink: #15120f;
  --ink-2: #1f1a16;
  --ink-3: #2b241e;
  --line: rgba(239, 230, 210, 0.12);
  --paper: #efe6d2;
  --paper-2: #e3d5b8;
  --paper-edge: #cbb894;
  --text: #ede3cf;
  --text-dim: #a89984;
  --text-paper: #2a211a;
  --text-paper-dim: #7b6a58;
  --vermilion: #c23a22;
  --vermilion-2: #e0573a;
  --gold: #c9a46a;
  --wood-1: #e6bb73;
  --wood-2: #c99350;
  --font-brush: "Ma Shan Zheng", "STXingkai", "KaiTi", "楷体", serif;
  --font-serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "SimSun", serif;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 700px at 78% -10%, rgba(201, 164, 106, 0.10), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(194, 58, 34, 0.08), transparent 60%),
    var(--ink);
  color: var(--text);
  font-family: var(--font-serif);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
/* 纸纹颗粒 */
body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .5;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 .95  0 0 0 0 .85  0 0 0 .05 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

.wrap { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 28px 24px 60px; }

/* ---------- 顶栏 ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.brand { display: flex; align-items: center; gap: 12px; }
.seal {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; border-radius: 8px;
  background: var(--vermilion); color: #fbeee4;
  font-family: var(--font-brush); font-size: 30px; line-height: 1;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.18), 0 6px 18px rgba(194,58,34,.35);
  transform: rotate(-4deg);
}
.brand-name { font-size: 20px; letter-spacing: .3em; }
.brand-sub { font-size: 12px; color: var(--text-dim); letter-spacing: .2em; margin-top: 2px; }
.back { color: var(--text-dim); font-size: 14px; letter-spacing: .1em; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; transition: .2s; }
.back:hover { color: var(--text); border-color: var(--gold); }

/* ---------- 首页 ---------- */
.hero { position: relative; padding: 40px 0 36px; }
.hero h1 { font-family: var(--font-brush); font-weight: 400; font-size: clamp(56px, 10vw, 112px); margin: 0; line-height: 1; letter-spacing: .08em; }
.hero h1 em { font-style: normal; color: var(--vermilion-2); }
.hero p { color: var(--text-dim); font-size: 16px; letter-spacing: .25em; margin: 18px 0 0; }
.hero .watermark {
  position: absolute; right: -10px; top: -40px; font-family: var(--font-brush); font-size: clamp(160px, 26vw, 320px);
  color: rgba(239, 230, 210, 0.035); pointer-events: none; line-height: 1; user-select: none;
}

.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 18px; margin-top: 30px; }
.game-card {
  position: relative; overflow: hidden; min-height: 230px; border-radius: var(--radius);
  padding: 22px; display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(160deg, var(--ink-3), var(--ink-2));
  border: 1px solid var(--line);
  transition: transform .35s cubic-bezier(.2,.8,.2,1), border-color .3s, box-shadow .35s;
  animation: rise .7s both;
}
.game-card:nth-child(2) { animation-delay: .08s; } .game-card:nth-child(3) { animation-delay: .16s; }
.game-card:nth-child(4) { animation-delay: .24s; } .game-card:nth-child(5) { animation-delay: .32s; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.game-card .glyph { font-family: var(--font-brush); font-size: 92px; line-height: 1; color: rgba(239,230,210,.85); }
.game-card .name { font-size: 20px; letter-spacing: .25em; }
.game-card .desc { font-size: 13px; color: var(--text-dim); margin-top: 6px; letter-spacing: .05em; }
.game-card.active { background: linear-gradient(160deg, #f1e7d1, #dfcfae); color: var(--text-paper); border-color: transparent; }
.game-card.active .glyph { color: var(--text-paper); }
.game-card.active .desc { color: var(--text-paper-dim); }
.game-card.active:hover { transform: translateY(-6px) rotate(-.4deg); box-shadow: 0 22px 50px rgba(0,0,0,.45); }
.game-card.active::after {
  content: "开局"; position: absolute; right: 18px; top: 18px; padding: 4px 10px; border-radius: 6px;
  background: var(--vermilion); color: #fff3ea; font-size: 13px; letter-spacing: .2em;
}
.game-card.soon { opacity: .55; cursor: not-allowed; }
.game-card.soon::after { content: "筹备中"; position: absolute; right: 18px; top: 18px; font-size: 12px; color: var(--text-dim); letter-spacing: .2em; border: 1px solid var(--line); padding: 3px 9px; border-radius: 6px; }
.stones-deco { position: absolute; right: -24px; bottom: -24px; width: 130px; height: 130px; opacity: .9; }

.footer-note { margin-top: 48px; color: var(--text-dim); font-size: 12px; letter-spacing: .15em; }

/* ---------- 对局页 ---------- */
.play { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; }
.board-shell {
  position: relative; border-radius: 10px; padding: 0;
  width: min(100%, max(340px, calc(100vh - 120px))); justify-self: center;
  box-shadow: 0 2px 0 #9b6a33, 0 30px 70px rgba(0,0,0,.6), 0 0 0 1px rgba(0,0,0,.4);
  animation: rise .6s both;
}
.board-shell canvas { display: block; width: 100%; height: auto; border-radius: 10px; cursor: pointer; touch-action: manipulation; }
.board-shell.busy canvas { cursor: progress; }

.panel {
  background: linear-gradient(170deg, var(--paper), var(--paper-2));
  color: var(--text-paper); border-radius: var(--radius); padding: 22px 20px;
  box-shadow: 0 20px 50px rgba(0,0,0,.45), inset 0 0 0 1px rgba(255,255,255,.4);
  animation: rise .6s .1s both;
}
.panel h2 { font-family: var(--font-brush); font-weight: 400; font-size: 40px; margin: 0 0 4px; letter-spacing: .1em; }
.panel .rule-note { font-size: 12px; color: var(--text-paper-dim); letter-spacing: .1em; margin-bottom: 16px; }
.field { margin: 14px 0; }
.field-label { font-size: 12px; color: var(--text-paper-dim); letter-spacing: .25em; margin-bottom: 7px; }
.seg { display: flex; background: rgba(42,33,26,.08); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button {
  flex: 1; border: 0; background: transparent; padding: 8px 4px; border-radius: 8px; cursor: pointer;
  font-size: 14px; color: var(--text-paper); letter-spacing: .08em; transition: background .2s, color .2s;
}
.seg button:hover { background: rgba(42,33,26,.07); }
.seg button.on { background: var(--text-paper); color: var(--paper); }
.seg button .tag { display: block; font-size: 10px; opacity: .6; letter-spacing: 0; margin-top: 1px; }

.status {
  display: flex; align-items: center; gap: 12px; margin: 18px 0 14px; padding: 12px 14px;
  border-radius: 10px; background: rgba(42,33,26,.06); border: 1px solid rgba(42,33,26,.1);
}
.status .stone { width: 26px; height: 26px; border-radius: 50%; flex: none; }
.stone.black { background: radial-gradient(circle at 35% 30%, #5a5a5a, #111 60%, #000); box-shadow: 0 2px 4px rgba(0,0,0,.4); }
.stone.white { background: radial-gradient(circle at 35% 30%, #fff, #e8e4dc 55%, #b9b2a5); box-shadow: 0 2px 4px rgba(0,0,0,.25); }
.status-text { font-size: 15px; letter-spacing: .08em; }
.status-sub { font-size: 12px; color: var(--text-paper-dim); margin-top: 2px; }
.dots span { display: inline-block; width: 4px; height: 4px; border-radius: 50%; background: currentColor; margin-left: 3px; animation: blink 1s infinite; }
.dots span:nth-child(2) { animation-delay: .15s; } .dots span:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 100% { opacity: .2; } 50% { opacity: 1; } }

.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.btn {
  border: 1px solid rgba(42,33,26,.25); background: transparent; color: var(--text-paper);
  padding: 10px 6px; border-radius: 9px; cursor: pointer; font-size: 14px; letter-spacing: .15em; transition: .2s;
}
.btn:hover:not(:disabled) { background: rgba(42,33,26,.08); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--vermilion); border-color: var(--vermilion); color: #fff4ec; }
.btn.primary:hover { background: var(--vermilion-2); }

.ai-info { margin-top: 16px; font-size: 12px; color: var(--text-paper-dim); border-top: 1px dashed rgba(42,33,26,.2); padding-top: 12px; }
.ai-info .grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.ai-info .k { font-size: 11px; letter-spacing: .15em; }
.ai-info .v { font-size: 15px; color: var(--text-paper); font-variant-numeric: tabular-nums; margin-top: 2px; }
.ai-info .reason { margin-top: 10px; letter-spacing: .08em; }
.evalbar { height: 6px; border-radius: 3px; background: #ece6da; overflow: hidden; margin-top: 10px; box-shadow: inset 0 0 0 1px rgba(42,33,26,.2); }
.evalbar > i { display: block; height: 100%; width: 50%; background: #1b1714; transition: width .5s cubic-bezier(.2,.8,.2,1); }

.record { margin-top: 14px; max-height: 120px; overflow: auto; font-size: 12px; color: var(--text-paper-dim); line-height: 1.9; font-variant-numeric: tabular-nums; }
.record b { color: var(--text-paper); font-weight: 600; }
.toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-top: 12px; color: var(--text-paper-dim); cursor: pointer; user-select: none; }
.toggle input { accent-color: var(--vermilion); }

/* 胜负印章 */
.verdict {
  position: absolute; inset: 0; display: grid; place-items: end; padding: 9%; pointer-events: none;
}
.verdict .stamp {
  pointer-events: auto;
  padding: 18px 30px; border: 4px solid var(--vermilion); border-radius: 10px; color: var(--vermilion);
  background: rgba(239,230,210,.86); font-family: var(--font-brush); font-size: clamp(36px, 7vw, 64px); letter-spacing: .15em;
  transform: rotate(-8deg) scale(1); box-shadow: 0 20px 50px rgba(0,0,0,.35);
  animation: stamp .45s cubic-bezier(.2,1.6,.4,1) both;
  text-align: center; cursor: pointer;
}
.verdict .stamp small { display: block; font-family: var(--font-serif); font-size: 13px; letter-spacing: .3em; color: var(--text-paper-dim); margin-top: 4px; }
@keyframes stamp { from { opacity: 0; transform: rotate(-8deg) scale(2.2); } to { opacity: 1; transform: rotate(-8deg) scale(1); } }

.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--text-paper); color: var(--paper); padding: 10px 18px; border-radius: 999px; font-size: 14px; letter-spacing: .1em;
  transition: .3s; z-index: 10; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 900px) {
  .play { grid-template-columns: 1fr; }
  .wrap { padding: 18px 16px 40px; }
}
