/* =========================================================================
   内部训练赛 · 样式表
   设计基调：宣纸底色 + 深墨绿主色 + 陶土色点缀，棋盘木头质感。
   ========================================================================= */

:root {
  --paper: #f7f3ea;
  --paper-deep: #efe8d9;
  --card: #fffdf8;
  --ink: #23231f;
  --ink-soft: #4a4740;
  --muted: #857f73;
  --line: #e5ddcc;
  --line-strong: #d6ccb6;
  --green: #2c5c49;
  --green-deep: #1e4437;
  --green-soft: #e7efe8;
  --clay: #b4502f;
  --clay-soft: #f8e9e2;
  --gold: #a8801f;
  --blue: #2f6f9f;
  /* 分色系统：一组低饱和但各有性格的点缀色，用于统计卡 / 榜单 / 表头 */
  --jade: #2c5c49;
  --jade-soft: #eaf1ec;
  --jade-line: #d8e4dc;
  --jade-ink: #23503f;
  --azure: #2f6f9f;
  --azure-soft: #eaf2f9;
  --azure-line: #d7e4ef;
  --azure-ink: #2a5f88;
  --amber: #a8801f;
  --amber-soft: #faf2e0;
  --amber-line: #e9dcbe;
  --amber-ink: #8a6818;
  --clay-ink: #9a4426;
  --clay-line: #edd7cc;
  --shadow-sm: 0 1px 2px rgba(45, 38, 25, 0.05);
  --shadow-md: 0 6px 20px -8px rgba(45, 38, 25, 0.22);
  --shadow-lg: 0 24px 60px -20px rgba(35, 30, 20, 0.35);
  --radius: 16px;
  --radius-sm: 10px;
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", "宋体", serif;
  --sans: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Source Han Sans SC", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background-color: var(--paper);
  /* 三层晕染（琥珀暖光 / 墨绿 / 陶土）+ 一层极淡的点阵纹理，模拟宣纸和棋盘的质感 */
  background-image:
    radial-gradient(1100px 540px at 86% -14%, rgba(196, 148, 66, 0.20), transparent 62%),
    radial-gradient(900px 640px at -10% 18%, rgba(44, 92, 73, 0.16), transparent 58%),
    radial-gradient(820px 520px at 104% 96%, rgba(180, 80, 47, 0.12), transparent 62%),
    radial-gradient(rgba(96, 78, 46, 0.055) 1px, transparent 1.4px),
    linear-gradient(180deg, #fbf7ee 0%, #f7f3ea 45%, #f2ecdf 100%);
  background-size: auto, auto, auto, 22px 22px, auto;
  background-repeat: no-repeat, no-repeat, no-repeat, repeat, no-repeat;
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0;
}

a { color: var(--green); }
button { font-family: inherit; }
::selection { background: #cfe0d6; }

/* ------------------------------------------------------------- 布局 --- */

.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 28px;
  height: 66px;
  background: rgba(255, 253, 248, 0.86);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 220px; }

.brand-mark {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(145deg, #3b3b36, #171714);
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.25), 0 2px 6px rgba(0, 0, 0, 0.25);
  display: grid;
  place-items: center;
}
.brand-mark i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fffdf6, #ddd6c6);
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.15);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-family: var(--serif); font-size: 17px; letter-spacing: 0.04em; }
.brand-text small { color: var(--muted); font-size: 11.5px; letter-spacing: 0.02em; }

.tabs { display: flex; gap: 4px; flex: 1; }
.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
}
.tab:hover { background: var(--paper-deep); }
.tab.is-active { background: var(--green); color: #fff; box-shadow: 0 4px 12px -6px rgba(44, 92, 73, 0.8); }

.topbar-right { display: flex; align-items: center; gap: 14px; }
.today { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }

/* 窄屏用的导航菜单按钮（宽屏隐藏） */
.nav-toggle {
  display: none;
  appearance: none;
  margin-left: auto;
  width: 40px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: linear-gradient(180deg, #fffefa 0%, #fdf9f1 100%);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: none;
}
.nav-toggle span {
  display: block;
  width: 17px;
  height: 2px;
  border-radius: 2px;
  background: var(--ink);
  transition: transform 0.18s, opacity 0.18s;
}
.nav-toggle.is-open { border-color: var(--green); background: var(--green-soft); }
.nav-toggle.is-open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle.is-open span:nth-child(2) { opacity: 0; }
.nav-toggle.is-open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.engine-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line-strong);
  background: var(--card);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12.5px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color 0.18s, color 0.18s, box-shadow 0.18s, background 0.18s;
}
/* 待机 / 就绪时点一下有反应，hover 给个绿圈提示可点 */
.engine-pill.is-action:hover {
  border-color: var(--green);
  color: var(--green-deep);
  background: linear-gradient(180deg, #fffefa, #f6faf7);
  box-shadow: 0 0 0 3px rgba(44, 92, 73, 0.1);
}
.engine-pill:active { transform: translateY(1px); }

/* 右上角管理员入口 */
.admin-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #fffefa, #fdf9f1);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12.5px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color 0.18s, color 0.18s, box-shadow 0.18s, background 0.18s;
}
.admin-btn:hover {
  border-color: var(--amber);
  color: var(--amber-ink);
  box-shadow: 0 0 0 3px rgba(168, 128, 31, 0.12);
}
.admin-btn.is-admin {
  border-color: #bcd3c5;
  background: var(--jade-soft);
  color: var(--jade-ink);
}
.admin-btn.is-admin:hover { border-color: var(--green); box-shadow: 0 0 0 3px rgba(44, 92, 73, 0.12); }
.admin-btn .lock { font-size: 11px; line-height: 1; font-variant-emoji: text; }
.engine-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: #c9c2b3; }
.engine-pill .dot.ready { background: #3f9d6b; box-shadow: 0 0 0 3px rgba(63, 157, 107, 0.16); }
.engine-pill .dot.busy { background: #d99a2b; box-shadow: 0 0 0 3px rgba(217, 154, 43, 0.18); animation: pulse 1.4s infinite; }
.engine-pill .dot.error { background: #c05a44; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.view {
  flex: 1;
  width: 100%;
  max-width: 1220px;
  margin: 0 auto;
  padding: 30px 28px 60px;
}

.footer {
  border-top: 1px solid var(--line);
  padding: 14px 28px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 12px;
}

/* --------------------------------------------------------- 通用元件 --- */

.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #fffefa, #fdf9f1);
  color: var(--ink);
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 13.5px;
  cursor: pointer;
  transition: transform 0.12s, background 0.18s, border-color 0.18s, box-shadow 0.18s, color 0.18s;
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 1px 2px rgba(45, 38, 25, 0.05);
}
.btn:hover { border-color: #bcd3c5; color: var(--jade-ink); }
.btn:active { transform: translateY(1px); }
/* 主按钮：墨绿渐变 + 顶部高光 + 投影，按下去有实感 */
.btn.primary {
  border-color: #1d4536;
  background: linear-gradient(180deg, #3a7358 0%, #2c5c49 55%, #24503f 100%);
  color: #fff;
  font-weight: 500;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24), 0 8px 18px -10px rgba(31, 72, 57, 0.85);
}
.btn.primary:hover {
  border-color: #1a4535;
  background: linear-gradient(180deg, #418264 0%, #306754 60%, #275946 100%);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 12px 24px -12px rgba(31, 72, 57, 0.9);
}
.btn.primary:active { transform: translateY(1px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 4px 10px -8px rgba(31, 72, 57, 0.8); }
/* 次要按钮：给一层浅色底，不再只是"描边文字" */
.btn.ghost {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink-soft);
}
.btn.ghost:hover {
  background: var(--jade-soft);
  border-color: #bcd3c5;
  color: var(--jade-ink);
}
/* 琥珀色：新增 / 编辑类动作 */
.btn.amber {
  border-color: #8a6818;
  background: linear-gradient(180deg, #c39a2c 0%, #a8801f 60%, #96701a 100%);
  color: #fff;
  font-weight: 500;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.26), 0 8px 18px -10px rgba(140, 105, 25, 0.8);
}
.btn.amber:hover {
  background: linear-gradient(180deg, #d0a733 0%, #b3891f 60%, #a37a1b 100%);
  color: #fff;
  transform: translateY(-1px);
}
/* 靛蓝色：导出 / 复盘类动作 */
.btn.azure {
  border-color: #24587f;
  background: linear-gradient(180deg, #3b7fae 0%, #2f6f9f 60%, #28608b 100%);
  color: #fff;
  font-weight: 500;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.26), 0 8px 18px -10px rgba(40, 88, 130, 0.8);
}
.btn.azure:hover {
  background: linear-gradient(180deg, #4289b9 0%, #3277a8 60%, #2a6693 100%);
  color: #fff;
  transform: translateY(-1px);
}
.btn.sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn.icon { width: 38px; height: 36px; padding: 0; display: grid; place-items: center; font-size: 13px; border-color: var(--line-strong); background: linear-gradient(180deg, #fffefa, #fdf9f1); }
/* ⏮ ⏭ ▶ 这类字符在部分手机上会按彩色 emoji 渲染，强制用文字形态 */
.btn.icon, .play-btn i, .board-try .btn { font-variant-emoji: text; }
.btn.icon:hover { background: var(--jade-soft); border-color: #bcd3c5; color: var(--jade-ink); }
.btn.icon.primary { background: linear-gradient(180deg, #3a7358, #2c5c49); color: #fff; border-color: #1d4536; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.danger { color: var(--clay); border-color: #e6c5b9; }
.btn.danger:hover { background: var(--clay-soft); border-color: #e0b9a9; color: var(--clay-ink); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11.5px;
  line-height: 1.7;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge.win { background: var(--green-soft); color: var(--green-deep); border-color: #cfe0d4; }
.badge.loss { background: var(--clay-soft); color: #8e3c22; border-color: #eed3c7; }
.badge.draw { background: #f4efe2; color: #7a6a3a; border-color: #e3d9bd; }
.badge.sgf { background: #eef2f8; color: #2f5f8c; border-color: #d5e0ee; }
.badge.pending { background: #f3f1ec; color: var(--muted); border-color: var(--line); }
.badge.dot-before::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; opacity: 0.7;
}

.muted { color: var(--muted); }
.grow { flex: 1; }
.mono { font-variant-numeric: tabular-nums; }

.card {
  background: linear-gradient(180deg, #fffefa 0%, #fffdf8 45%, #fdfaf2 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 10px;
}
.card-head h2 { font-size: 16px; }
.card-head .sub { color: var(--muted); font-size: 12.5px; }
.card-body { padding: 0 20px 18px; }
.card-body.flush { padding: 0 0 6px; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 16px;
}
.section-title h1 { font-size: 24px; display: flex; align-items: center; gap: 10px; }
.section-title h1::before {
  content: "";
  width: 4px;
  height: 20px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--green), var(--gold));
}
.section-title .sub { color: var(--muted); font-size: 13px; }

/* -------------------------------------------------------------- 总览 --- */

.hero {
  position: relative;
  overflow: hidden;
  padding: 26px 28px;
  border-radius: 20px;
  color: #f4f0e6;
  background:
    radial-gradient(800px 260px at 85% 0%, rgba(255, 255, 255, 0.1), transparent 60%),
    linear-gradient(135deg, #244c3d 0%, #1b3a2f 60%, #16302a 100%);
  box-shadow: var(--shadow-md);
  margin-bottom: 20px;
}
.hero::after {
  content: "";
  position: absolute;
  right: -40px;
  bottom: -80px;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 0 40px rgba(255, 255, 255, 0.03), 0 0 0 90px rgba(255, 255, 255, 0.02);
  pointer-events: none;
}
.hero h1 { font-size: 28px; letter-spacing: 0.02em; }
.hero .hero-sub { margin-top: 8px; color: rgba(244, 240, 230, 0.72); font-size: 13.5px; }
.hero .hero-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.hero .hero-tag {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12.5px;
  color: rgba(244, 240, 230, 0.9);
}
.hero-progress {
  margin-top: 22px;
  max-width: 560px;
}
.hero-progress .bar {
  height: 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}
.hero-progress .bar i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #8fc7a5, #d8c68a);
  transition: width 0.6s ease;
}
.hero-progress .cap { display: flex; justify-content: space-between; font-size: 12px; color: rgba(244, 240, 230, 0.6); margin-top: 7px; }

.stat-card {
  position: relative;
  overflow: hidden;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: linear-gradient(180deg, var(--accent-soft, var(--card)) 0%, var(--card) 52%);
  border-color: var(--accent-line, var(--line));
}
/* 顶部一道分色细线，让四张卡各有一点自己的颜色 */
.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--accent, var(--green));
  opacity: 0.9;
}
.stat-card.accent-1 { --accent: var(--jade); --accent-soft: var(--jade-soft); --accent-line: var(--jade-line); --accent-ink: var(--jade-ink); }
.stat-card.accent-2 { --accent: var(--azure); --accent-soft: var(--azure-soft); --accent-line: var(--azure-line); --accent-ink: var(--azure-ink); }
.stat-card.accent-3 { --accent: var(--amber); --accent-soft: var(--amber-soft); --accent-line: var(--amber-line); --accent-ink: var(--amber-ink); }
.stat-card.accent-4 { --accent: var(--clay); --accent-soft: var(--clay-soft); --accent-line: var(--clay-line); --accent-ink: var(--clay-ink); }
.stat-card .num { font-family: var(--serif); font-size: 30px; line-height: 1.15; font-variant-numeric: tabular-nums; color: var(--accent-ink, var(--ink)); }
.stat-card .num small { font-size: 14px; color: var(--muted); margin-left: 3px; font-family: var(--sans); }
.stat-card .label { color: var(--muted); font-size: 12.5px; }
.stat-card .spark { margin-top: 8px; display: flex; gap: 3px; }
.stat-card .spark i { height: 4px; flex: 1; border-radius: 2px; background: var(--paper-deep); }
.stat-card .spark i.on { background: var(--accent, var(--green)); opacity: 0.8; }

.rank-list { list-style: none; margin: 0; padding: 0 8px 8px; }
.rank-item {
  display: grid;
  grid-template-columns: 30px 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 12px;
}
.rank-item:hover { background: var(--paper); }
/* 前三名给一点底色，一眼能分出来 */
.rank-item.top1 { background: linear-gradient(90deg, #fdf4df, rgba(255, 253, 248, 0) 76%); }
.rank-item.top2 { background: linear-gradient(90deg, #f1f3f5, rgba(255, 253, 248, 0) 76%); }
.rank-item.top3 { background: linear-gradient(90deg, #fbeee3, rgba(255, 253, 248, 0) 76%); }
.rank-item.top1:hover { background: linear-gradient(90deg, #fbeed0, #f8f2e4 76%); }
.rank-item.top2:hover { background: linear-gradient(90deg, #e9edf0, #f4f4f2 76%); }
.rank-item.top3:hover { background: linear-gradient(90deg, #f9e5d5, #f7f0e8 76%); }
.rank-item.top1 .pts { color: var(--amber-ink); }
.rank-item.top2 .pts { color: #4c5459; }
.rank-item.top3 .pts { color: #96603a; }
.rank-item .pos {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 999px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  background: var(--paper-deep);
}
.rank-item.top1 .pos { background: linear-gradient(140deg, #d7b46a, #b8860b); color: #fff; }
.rank-item.top2 .pos { background: #cfd3d6; color: #4a4a4a; }
.rank-item.top3 .pos { background: #d9b08c; color: #fff; }
.rank-item .name { font-size: 14.5px; }
.rank-item .name small { color: var(--muted); font-size: 11.5px; margin-left: 6px; }
.rank-item .pts { font-variant-numeric: tabular-nums; font-size: 15px; }
.rank-item .pts small { color: var(--muted); font-size: 11px; }

.recent-list { list-style: none; margin: 0; padding: 0 10px 12px; }
.recent-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 10px;
  border-radius: 12px;
  cursor: pointer;
  border: 1px solid transparent;
}
.recent-item:hover { background: var(--paper); border-color: var(--line); }
.recent-item .res {
  width: 34px; height: 34px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 12px;
  background: var(--paper-deep);
  color: var(--ink-soft);
  flex: none;
}
.recent-item .res.w { background: #fbf7ee; color: #7a5c2e; box-shadow: inset 0 0 0 1px #e9dcc1; }
.recent-item .res.b { background: #2c3330; color: #f0ece0; }
.recent-item .who { flex: 1; min-width: 0; }
.recent-item .who strong { font-weight: 500; font-size: 14px; }
.recent-item .who .meta { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 20px 18px; }
.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  color: var(--ink-soft);
  background: var(--paper);
}
.chip.ven {
  background: #fbf7ee;
  color: #7a5c2e;
  border-color: #ebdfc4;
}

/* --------------------------------------------------------- 对局列表 --- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  margin-bottom: 14px;
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.7);
  border: 1px solid var(--line);
}
.toolbar .search {
  flex: 1 1 220px;
  min-width: 180px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line-strong);
  background: var(--card);
  border-radius: 10px;
  padding: 0 12px;
  height: 38px;
}
.toolbar .search input { border: 0; outline: 0; background: transparent; width: 100%; font-size: 13.5px; color: var(--ink); }
.toolbar .search svg { flex: none; opacity: 0.45; }

/* 工具栏里的自定义下拉（棋手 / 直播人员） */
.pick { position: relative; display: inline-flex; flex: none; max-width: 100%; }
.pick-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 11px 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: linear-gradient(180deg, #fffefa 0%, #fdf9f1 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}
.pick-btn:hover { border-color: #bcd3c5; background: #fffefb; }
.pick.is-open .pick-btn {
  border-color: var(--green);
  background: #fffefb;
  box-shadow: 0 0 0 3px rgba(44, 92, 73, 0.1);
}
.pick-label { font-size: 11.5px; color: var(--muted); letter-spacing: 0.02em; }
.pick-value {
  font-weight: 500;
  max-width: 132px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pick-caret {
  width: 0;
  height: 0;
  flex: none;
  margin-left: 2px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--muted);
  transition: transform 0.18s;
}
.pick.is-open .pick-caret { transform: rotate(180deg); border-top-color: var(--green); }

.pick-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 40;
  min-width: 100%;
  max-height: 288px;
  overflow: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 18px 40px -18px rgba(45, 38, 25, 0.35), 0 2px 6px rgba(45, 38, 25, 0.06);
  animation: pickIn 0.14s ease;
}
@keyframes pickIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}
.pick-menu[hidden] { display: none; }
.pick-menu li {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.14s, color 0.14s;
}
.pick-menu li:hover { background: var(--jade-soft); color: var(--jade-ink); }
.pick-menu li.is-active {
  background: var(--green);
  color: #fff;
  font-weight: 500;
}
.pick-menu li.is-active:hover { background: var(--green-deep); color: #fff; }
@media (max-width: 560px) {
  .pick { flex: 1 1 100%; }
  .pick-btn { width: 100%; justify-content: space-between; }
  .pick-value { max-width: none; flex: 1; text-align: left; }
}

/* 表单里的下拉：铺满整格，跟 input 同款外观 */
.field .pick { display: flex; width: 100%; }
.field .pick-btn {
  width: 100%;
  height: 36px;
  justify-content: space-between;
  padding: 0 10px;
  background: #fffefb;
  box-shadow: none;
}
.field .pick-btn:hover { background: #fffefb; }
.field .pick-value { max-width: none; flex: 1; text-align: left; font-weight: 400; }
.field .pick-menu { min-width: 100%; }

.seg {
  display: inline-flex;
  background: var(--paper-deep);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.seg button {
  border: 0;
  background: transparent;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--ink-soft);
  cursor: pointer;
}
.seg button.is-active { background: var(--card); color: var(--ink); box-shadow: var(--shadow-sm); }
.seg button .count { color: var(--muted); font-size: 11px; margin-left: 4px; }

.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.data {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
}
table.data thead th {
  text-align: left;
  font-weight: 500;
  color: var(--jade-ink);
  font-size: 12px;
  padding: 11px 12px;
  background: linear-gradient(180deg, #f3f7f4, #edf3ee);
  border-bottom: 1px solid var(--jade-line);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
table.data tbody td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background 0.15s; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover { background: #fbf7ee; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .player { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.stone-dot { width: 13px; height: 13px; border-radius: 50%; flex: none; }
.stone-dot.b { background: linear-gradient(145deg, #44443e, #12120f); box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.25); }
.stone-dot.w { background: linear-gradient(145deg, #fffefa, #e2dbca); box-shadow: inset 0 0 0 1px #d5cdbb; }
.stone-dot.none { background: transparent; box-shadow: inset 0 0 0 1px #bdb4a0; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.result-pill { font-variant-numeric: tabular-nums; }

/* 对局列表里的黑白评分对比 */
.score-pair { display: inline-flex; align-items: center; gap: 10px; font-variant-numeric: tabular-nums; }
.score-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--ink-soft); }
.score-chip b { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.score-empty { color: #c2b9a6; letter-spacing: 1.5px; }

.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
}
.empty h3 { font-size: 16px; margin-bottom: 6px; color: var(--ink-soft); }

/* --------------------------------------------------------- 积分榜 --- */

.standing-table tbody tr.top1 td { background: linear-gradient(90deg, #fdf8ea, transparent 70%); }
/* 名次列：桌面 56px，手机端在 ≤720px 的块里收窄到 30px */
.standing-table .col-rank { width: 56px; }
.standing-table .name-cell { display: flex; align-items: center; gap: 9px; }
.standing-table .name-cell button {
  border: 0; background: transparent; padding: 0; font: inherit; color: var(--ink); cursor: pointer;
  border-bottom: 1px dashed var(--line-strong);
}
.standing-table .name-cell button:hover { color: var(--green); border-color: var(--green); }
.form-dots { display: inline-flex; gap: 3px; }
.form-dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--paper-deep); }
.form-dots i.w { background: #4e8f70; }
.form-dots i.l { background: #d08a72; }

.matrix-wrap { overflow: auto; padding: 4px 4px 12px; }
table.matrix {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
  min-width: 100%;
}
table.matrix th, table.matrix td {
  text-align: center;
  padding: 0;
  width: 52px;
  height: 40px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
table.matrix thead th {
  font-weight: 500;
  color: var(--ink-soft);
  background: #fbf8f1;
  font-size: 12px;
  position: sticky;
  top: 0;
  z-index: 2;
}
table.matrix tbody th {
  position: sticky;
  left: 0;
  background: #fbf8f1;
  text-align: center;
  padding: 0 8px;
  white-space: nowrap;
  font-weight: 500;
  font-size: 12.5px;
  z-index: 1;
}
/* 行名那一列定死宽度并居中，避免长名字把格子挤歪 */
table.matrix th:first-child { width: 84px; min-width: 84px; }
table.matrix th.corner { font-size: 11px; color: var(--muted); white-space: nowrap; }
table.matrix thead th:first-child { left: 0; z-index: 3; }
table.matrix td.diag { background: repeating-linear-gradient(45deg, #f6f1e5, #f6f1e5 5px, #efe8d8 5px, #efe8d8 10px); color: #b9b09c; }
table.matrix td.win { background: var(--green-soft); color: var(--green-deep); font-weight: 600; cursor: pointer; }
table.matrix td.win:hover { background: #d6e6da; }
table.matrix td.loss { background: var(--clay-soft); color: #8e3c22; cursor: pointer; }
table.matrix td.loss:hover { background: #f2d8cd; }
table.matrix td.blank { color: #c8c0ae; }
table.matrix td.has-sgf::after {
  content: "";
  display: block;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--blue);
  margin: 0 auto;
  opacity: 0.8;
}

/* --------------------------------------------------------- 比赛日历 --- */

/* 总览里日历与交叉表并排：日历定宽，交叉表吃掉剩下的空间 */
.overview-duo {
  display: grid;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
  gap: 20px;
  align-items: stretch;
  margin-bottom: 20px;
}
/* 宽的那张放左边时用这个（交叉表在左、积分榜在右） */
.overview-duo.is-flipped { grid-template-columns: minmax(0, 1fr) minmax(320px, 380px); }
/* 两张卡等高，底部元素沉到底边 */
.overview-duo > .card { display: flex; flex-direction: column; }
.cal-note { margin-top: auto; }
.overview-duo .card-foot { margin-top: auto; }
@media (max-width: 1080px) {
  .overview-duo,
  .overview-duo.is-flipped { grid-template-columns: minmax(0, 1fr); }
  .cal-note, .overview-duo .card-foot { margin-top: 0; }
  /* 上下排的时候日历会变宽，限制一下格子别铺满整屏 */
  .overview-duo .cal-grid { max-width: 520px; }
}

.cal-head { display: flex; align-items: center; gap: 8px; padding: 0 16px 10px; }
.cal-nav {
  width: 26px;
  height: 26px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: linear-gradient(180deg, #fffefa, #fdf9f1);
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.18s, color 0.18s, background 0.18s;
}
.cal-nav:hover:not(:disabled) { border-color: var(--green); color: var(--green-deep); background: var(--jade-soft); }
.cal-nav:disabled { opacity: 0.35; cursor: not-allowed; }
.cal-title { font-family: var(--serif); font-size: 15px; letter-spacing: 0.02em; }
.cal-sub { font-size: 12px; color: var(--muted); }
.cal-back {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  font: inherit;
  font-size: 12px;
  color: var(--green);
  cursor: pointer;
  border-bottom: 1px dashed currentColor;
}
.cal-back:hover { color: var(--green-deep); }
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  padding: 0 16px 10px;
}
.cal-wd { text-align: center; font-size: 11px; color: var(--muted); padding-bottom: 2px; }
.cal-day {
  position: relative;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 12.5px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.cal-day.has-matches {
  background: linear-gradient(180deg, #f0f6f2, var(--jade-soft));
  border-color: #cfe0d6;
  color: var(--jade-ink);
  font-weight: 600;
  cursor: pointer;
}
.cal-day.has-matches:hover { background: #dcebe2; border-color: #b7d1c2; }
.cal-day.is-today { box-shadow: inset 0 0 0 2px rgba(44, 92, 73, 0.35); }
.cal-count {
  position: absolute;
  top: 3px;
  right: 5px;
  font-size: 10px;
  font-weight: 600;
  color: var(--jade);
  opacity: 0.85;
}
@media (max-width: 560px) {
  .cal-head { padding: 0 14px 10px; flex-wrap: wrap; }
  .cal-sub { flex: 1 1 100%; }
  .cal-grid { gap: 4px; padding: 0 14px 10px; max-width: none; }
  .cal-day { font-size: 12px; border-radius: 8px; }
}

/* 点日历弹出的当天对局列表 */
.day-list { list-style: none; margin: 0; padding: 0; }
.day-item {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 12px;
  padding: 11px 8px;
  border-bottom: 1px solid var(--line);
  border-radius: 10px;
}
.day-item:last-child { border-bottom: 0; }
.day-item.has-sgf { cursor: pointer; }
.day-item.has-sgf:hover { background: var(--jade-soft); }
.day-no { font-size: 11.5px; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.day-pair { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 560px) {
  .day-item { grid-template-columns: 22px minmax(0, 1fr) auto; gap: 6px 8px; }
  .day-score { grid-column: 2 / 3; }
  .day-flag { display: none; }
}

/* --------------------------------------------------------- 统计页 --- */

.name-cell { display: flex; align-items: center; gap: 9px; white-space: nowrap; }
.broadcaster-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--clay);
  box-shadow: 0 0 0 3px rgba(180, 80, 47, 0.12);
  flex: none;
}
.ratio-cell { display: flex; align-items: center; gap: 8px; }
.stat-bars {
  flex: 1;
  min-width: 70px;
  height: 7px;
  border-radius: 99px;
  background: var(--paper-deep);
  overflow: hidden;
}
.stat-bars i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #8fc7a5, #2c5c49);
}
.ratio-text { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip-btn {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11.5px;
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.chip-btn:hover { border-color: var(--green); color: var(--green); background: var(--green-soft); }
.chip-more { font-size: 11.5px; color: var(--muted); align-self: center; }

/* --------------------------------------------------------- 设置页 --- */

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

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 12.5px; color: var(--muted); }
.field input[type="text"], .field input[type="number"], .field input[type="password"], .field select {
  border: 1px solid var(--line-strong);
  background: #fffefb;
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--ink);
  outline: none;
  font-family: inherit;
  width: 100%;
}
.field input:focus, .field select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(44, 92, 73, 0.1); }
.field.inline { flex-direction: row; align-items: center; gap: 8px; margin: 0; }
.field.inline > span { white-space: nowrap; }
.field.inline select { width: auto; padding: 5px 8px; }

.kv { display: grid; grid-template-columns: 88px 1fr; gap: 8px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.kv.wide { grid-template-columns: 76px minmax(0, 1fr) 76px minmax(0, 1.4fr); gap: 10px 14px; }
@media (max-width: 860px) {
  .kv.wide { grid-template-columns: 76px 1fr; }
}

.engine-box { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: #fcfaf4; }
.engine-box .line { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.engine-log {
  margin-top: 10px;
  max-height: 130px;
  overflow: auto;
  background: #1f2320;
  color: #b9d3c3;
  border-radius: 8px;
  padding: 8px 10px;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 11px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.note {
  background: #fbf7ee;
  border: 1px solid #eadfc7;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 12.5px;
  color: #6d5b36;
  line-height: 1.7;
}
.note b { color: #5a4a26; }

/* --------------------------------------------------------- 弹层 --- */
.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(28, 25, 18, 0.45); backdrop-filter: blur(3px); animation: fade 0.2s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-body {
  position: relative;
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: rise 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(0.995); } to { opacity: 1; transform: none; } }

.modal-body.viewer { width: min(1240px, calc(100vw - 40px)); height: min(860px, calc(100vh - 40px)); }
.modal-body.sheet { width: min(720px, calc(100vw - 40px)); max-height: min(760px, calc(100vh - 40px)); }
.modal-body.confirm { width: min(420px, calc(100vw - 40px)); padding: 22px 24px 18px; }
.modal-body.confirm h2 { font-size: 16px; margin-bottom: 8px; }
.confirm-text { margin: 0 0 18px; font-size: 13.5px; color: var(--ink-soft); line-height: 1.75; white-space: pre-line; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }

.viewer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fffdf8, #fbf7ee);
}
.vs-line { display: flex; align-items: center; gap: 9px; font-size: 16px; }
.vs-line .stone-chip { width: 15px; height: 15px; border-radius: 50%; display: inline-block; }
.stone-chip.black { background: linear-gradient(145deg, #4a4a44, #101010); }
.stone-chip.white { background: linear-gradient(145deg, #ffffff, #e4ddcc); box-shadow: inset 0 0 0 1px #d8d0be; }
.vs-line .vs { color: var(--muted); font-family: var(--serif); font-size: 13px; }
.viewer-meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.viewer-actions { display: flex; gap: 8px; }

.viewer-body { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 344px; min-height: 0; }
.board-column { padding: 16px; display: flex; flex-direction: column; gap: 12px; min-height: 0; background: #fbf7ee; }
.board-wrap { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; }
#boardCanvas { width: 100%; height: 100%; max-width: 100%; max-height: 100%; aspect-ratio: 1 / 1; border-radius: 10px; box-shadow: 0 10px 30px -14px rgba(80, 52, 20, 0.5); touch-action: manipulation; }
.board-hint {
  position: absolute;
  bottom: 8px; left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 26, 18, 0.78);
  color: #f2ecdc;
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  white-space: nowrap;
}
.board-hint.show { opacity: 1; }

.board-controls { display: flex; flex-direction: column; gap: 8px; }
.control-row { display: flex; align-items: center; gap: 6px; }
.nav-group { display: flex; align-items: center; gap: 6px; }
.play-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid #1d4536;
  border-radius: 10px;
  background: linear-gradient(180deg, #3a7358 0%, #2c5c49 55%, #24503f 100%);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s, transform 0.12s, box-shadow 0.18s;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24), 0 8px 18px -10px rgba(31, 72, 57, 0.85);
}
.play-btn:hover { background: linear-gradient(180deg, #418264, #306754 60%, #275946); transform: translateY(-1px); }
.play-btn.is-playing { background: linear-gradient(180deg, #c4633f, #b4502f 60%, #9e4526); border-color: #8e3c22; }
.play-btn.is-playing:hover { background: linear-gradient(180deg, #cf6f4a, #bb5734); }
.play-btn i { font-style: normal; font-size: 11px; line-height: 1; }
.control-divider { width: 1px; height: 20px; background: var(--line-strong); margin: 0 4px; flex: none; }
.toggles { display: flex; align-items: center; gap: 10px; }
.move-counter { font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--muted); margin-left: 6px; min-width: 70px; }
.slider { width: 100%; accent-color: var(--green); }

.switch { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-soft); cursor: pointer; user-select: none; }
.switch input { appearance: none; width: 32px; height: 18px; border-radius: 999px; background: #d9d2c2; position: relative; cursor: pointer; transition: background 0.2s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform 0.2s; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); }
.switch input:checked { background: var(--green); }
.switch input:checked::after { transform: translateX(14px); }
.switch.is-disabled { opacity: 0.55; cursor: not-allowed; }
.switch.is-disabled input { cursor: not-allowed; }

.color-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.review-match {
  margin-top: 10px;
  border-top: 1px dashed var(--line-strong);
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.match-line { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.review-match .review-title { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.match-line b { min-width: 14px; font-weight: 600; }
.match-score { font-size: 15px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; min-width: 40px; }
.match-score em { font-style: normal; font-size: 10.5px; font-weight: 400; color: var(--muted); margin-left: 1px; }
.match-meta { font-size: 11px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.match-note { font-size: 10.5px; color: var(--muted); }

.color-row .stone-dot.d { background: #b9a98a; }.color-row:last-of-type { margin-bottom: 0; }
.color-label { width: 42px; font-size: 13px; color: var(--ink-soft); }
.color-num { width: 52px; text-align: right; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.color-pct { width: 44px; text-align: right; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* AI 分析状态徽章（仅网站显示） */
.ai-state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line-strong);
  background: #fffdf8;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11.5px;
  cursor: pointer;
  color: var(--ink-soft);
  white-space: nowrap;
  flex: none;
}
.ai-state .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.75; }
.ai-state:hover { filter: brightness(0.98); border-color: var(--green); }
.ai-state.as-nosgf { color: #8b8b86; background: #f4f1ea; }
.ai-state.as-idle { color: #7a6a4a; background: #fbf7ee; border-color: #e3d8c2; }
.ai-state.as-running {
  color: #9a6414;
  background: #fdf3dc;
  border-color: #ecd39a;
}
.ai-state.as-running .dot { animation: ai-pulse 1.1s ease-in-out infinite; }
.ai-state.as-done { color: #1c6b46; background: var(--green-soft); border-color: #bcd8c6; }
@keyframes ai-pulse { 0%, 100% { opacity: 0.35; transform: scale(0.85); } 50% { opacity: 1; transform: scale(1.15); } }

.side-column { border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--card); }
.side-tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 10px; background: #fbf8f1; overflow-x: auto; }
.side-tab { border: 0; background: transparent; padding: 11px 12px; font-size: 13px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; flex: 0 0 auto; }
.side-tab.is-active { color: var(--green); border-color: var(--green); font-weight: 500; }
.side-pane { display: none; flex: 1; min-height: 0; overflow: auto; padding: 14px 16px 20px; }
.side-pane.is-active { display: block; }

.ai-status { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fcfaf4; }
.ai-head { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-soft); }
.ai-dot { width: 8px; height: 8px; border-radius: 50%; background: #c9c2b3; flex: none; }
.ai-dot.on { background: #3f9d6b; }
.ai-dot.busy { background: #d99a2b; animation: pulse 1.2s infinite; }
.ai-dot.err { background: #c05a44; }
.ai-bar { height: 3px; border-radius: 3px; background: #eee7d8; margin-top: 8px; overflow: hidden; }
.ai-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #7fb497, #4e8f70); transition: width 0.3s; }
.ai-help { font-size: 11.5px; color: #8e3c22; margin-top: 8px; line-height: 1.7; }
.ai-help a { color: var(--green); }

.eval-row { display: grid; grid-template-columns: 54px 1fr 54px; align-items: center; gap: 8px; margin-top: 14px; }
.eval-black, .eval-white { text-align: center; }
.eval-black .label, .eval-white .label { display: block; font-size: 11px; color: var(--muted); }
.eval-black strong, .eval-white strong { font-size: 17px; font-variant-numeric: tabular-nums; }
.eval-bar { height: 8px; border-radius: 99px; background: #f0ead9; overflow: hidden; box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06); }
.eval-bar i { display: block; height: 100%; width: 50%; background: linear-gradient(90deg, #2b2b26, #4a4a42); transition: width 0.35s ease; }
.eval-note { font-size: 11.5px; color: var(--muted); margin-top: 7px; line-height: 1.6; }

.ai-controls { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.ai-buttons { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-top: 10px; }

.candidates { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.candidate {
  display: block;
  padding: 7px 9px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fffdf8;
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.candidate:hover { border-color: var(--green); background: #f6faf6; }
.candidate.is-preview { border-color: var(--green); background: var(--green-soft); box-shadow: inset 2px 0 0 var(--green); }
.cand-main {
  display: grid;
  grid-template-columns: 22px 1fr 62px 58px;
  align-items: center;
  gap: 8px;
}
.cand-pv {
  margin-top: 3px;
  margin-left: 30px;
  font-size: 11px;
  color: var(--muted);
  font-family: ui-monospace, Consolas, monospace;
  line-height: 1.5;
}
.cand-stale {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  color: #8a6d33;
  background: #fbf7ee;
  border: 1px solid #eadfc7;
  border-radius: 8px;
  padding: 5px 9px;
  margin-bottom: 6px;
}
.link-btn {
  border: 0;
  background: transparent;
  color: var(--green);
  font-size: 11.5px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  white-space: nowrap;
}
.candidate .idx { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; background: var(--paper-deep); color: var(--ink-soft); }
.candidate.best .idx { background: var(--green); color: #fff; }
.candidate .coord { font-variant-numeric: tabular-nums; }
.candidate .wr { text-align: right; font-variant-numeric: tabular-nums; }
.candidate .sc { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 11.5px; }
.candidate.missed { border-color: #e6c5b9; background: var(--clay-soft); }

/* 曲线在 AI 面板最顶上，上面不留白，下面留出间隔 */
.winrate-graph { margin: 0 0 14px; }
.winrate-graph:empty { display: none; }
.worst-block:empty { display: none; }
.winrate-graph svg { width: 100%; height: 92px; display: block; border-radius: 10px; background: #fcfaf4; border: 1px solid var(--line); }
.winrate-graph .cap { font-size: 11px; color: var(--muted); margin-top: 5px; display: flex; justify-content: space-between; }
.review-score { margin-top: 14px; }
.review-score:empty { display: none; }
#reviewStatus { margin-top: 14px; }
.review-summary {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  color: var(--ink-soft);
  background: #fbf7ee;
  border: 1px solid #eadfc7;
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 8px;
}
.review-summary .review-title { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.review-line { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.review-line b { font-weight: 600; min-width: 14px; }
.review-line .rv-item { font-variant-numeric: tabular-nums; }
.review-line .rv-item.severe { color: #8c2f16; font-weight: 600; }
.review-line .rv-item.losing { color: #7d2b8f; font-weight: 600; }
.review-line .rv-item.muted { color: var(--muted); margin-left: 4px; }
.review-line .rv-dot { color: #c9c0ae; }
.cand-caption { font-size: 11px; color: var(--muted); margin-top: 6px; line-height: 1.6; }
.key-moves { margin-top: 12px; border-top: 1px dashed var(--line-strong); padding-top: 10px; }
.key-title { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.worst-block { margin-top: 12px; border-top: 1px dashed var(--line-strong); padding-top: 10px; }
.worst-tabs { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.worst-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line-strong);
  background: #fffdf8;
  border-radius: 999px;
  padding: 3px 11px;
  font-size: 12px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.worst-tab:hover { border-color: var(--green); color: var(--green); }
.worst-tab.is-active { background: var(--green); border-color: var(--green); color: #fff; }
.worst-tab.is-active .stone-dot.w { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.85); }
.worst-tab em { font-style: normal; font-size: 11px; opacity: 0.72; }
.worst-hint { font-size: 11px; color: var(--muted); }
.worst-more { font-size: 11px; margin-top: 4px; }
.worst-empty { font-size: 12px; padding: 6px 2px; }
.mistake-hint {
  margin-top: 8px;
  border: 1px solid #cfe0d4;
  background: var(--green-soft);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--ink-soft);
}
.mistake-hint .mh-head { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.worst-list .mistake-hint { margin: 6px 3px 10px; }
.mistake-hint .mh-label { font-size: 11px; color: var(--muted); margin: 6px 0 4px; }
.mistake-hint .mh-cands { display: flex; flex-wrap: wrap; gap: 6px; }
.mistake-hint .mh-cand {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 3px 10px 3px 4px;
  font-size: 12px;
  cursor: pointer;
  color: #fff;
  font-family: var(--sans);
}
.mistake-hint .mh-cand.tone-0 { background: #1c7449; border-color: #14603a; }
.mistake-hint .mh-cand.tone-1 { background: #3d8d63; border-color: #2f7a53; }
.mistake-hint .mh-cand.tone-2 { background: #67a685; border-color: #57957a; }
.mistake-hint .mh-cand.tone-3 { background: #8cbfa3; border-color: #7aae92; }
.mistake-hint .mh-cand:hover { filter: brightness(1.08); }
.mistake-hint .mh-rank {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  display: grid;
  place-items: center;
  font-size: 10.5px;
}
.mistake-hint .mh-cand .coord { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.mistake-hint .mh-wr { font-size: 11px; opacity: 0.9; font-variant-numeric: tabular-nums; }
.mistake-hint .mh-loss { color: var(--clay); font-weight: 600; font-variant-numeric: tabular-nums; }
.mistake-hint .mh-body { display: flex; flex-wrap: wrap; align-items: baseline; gap: 5px; font-size: 11.5px; }
.mistake-hint .mh-body .coord { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.mistake-hint .mh-pv { color: var(--muted); font-family: ui-monospace, Consolas, monospace; }
.mistake-hint .mh-btn { margin-top: 7px; width: 100%; }
.mistake-hint .mh-tip { margin-top: 5px; font-size: 11px; color: var(--muted); text-align: center; }
.key-move .loss.blunder { color: var(--clay); }
.key-move .loss.severe { color: #8c2f16; font-weight: 700; }
.key-move .loss.mistake { color: #b06a3a; }
.vtag {
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 999px;
  line-height: 1.6;
  white-space: nowrap;
  border: 1px solid transparent;
}
.vtag.severe { background: #f0c9bd; color: #8c2f16; border-color: #d99c8a; font-weight: 600; }
.vtag.blunder { background: #f6e2da; color: #a5432a; border-color: #e8c4b7; }
.vtag.mistake { background: #f8ece1; color: #9a5c2c; border-color: #ecd3bb; }
.vtag.inaccuracy { background: #fbf3de; color: #8a6c25; border-color: #eadfc0; }
.key-move {
  display: grid;
  grid-template-columns: 52px 14px 42px auto 1fr 44px;
  align-items: center;
  gap: 6px;
  padding: 5px 7px;
  border-radius: 7px;
  font-size: 12px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.key-move:hover { background: var(--paper); }
.key-move.is-active {
  background: var(--green-soft);
  box-shadow: inset 3px 0 0 var(--green);
}
.key-move.is-active .no { color: var(--green); font-weight: 600; }
.key-move .no { color: var(--muted); font-size: 11.5px; }
.key-move .coord { font-family: ui-monospace, Consolas, monospace; }
.key-move .loss { color: var(--clay); text-align: right; }

.try-panel { margin-top: 16px; border-top: 1px dashed var(--line-strong); padding-top: 12px; }
.side-pane > .try-panel:first-child { margin-top: 0; border-top: 0; padding-top: 0; }
/* 试下放在棋盘下面：一行紧凑排列 */
.board-try {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 0;
  border-top: 0;
  padding: 0 2px;
  font-size: 12px;
}
.board-try .try-hint {
  flex: 1 1 120px;
  min-width: 0;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.board-try .btn.sm { padding: 4px 10px; }
/* 试下的「上一手/下一手/清空」只在试下打开后出现，免得和棋谱翻页混淆 */
.try-tools { display: inline-flex; align-items: center; gap: 8px; }
.try-tools[hidden] { display: none; }
@media (max-width: 720px) {
  .board-column { gap: 6px; }
  .board-try { gap: 6px; flex-wrap: wrap; }
  .board-try .try-hint { flex: 1 1 100%; font-size: 11px; order: 9; }
  .board-try .btn.sm { padding: 4px 9px; font-size: 12px; }
}
.try-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.try-hint { font-size: 11.5px; color: var(--muted); }
.try-actions { display: flex; gap: 8px; margin-top: 9px; }

.movelist-head { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.movelist { list-style: none; margin: 0; padding: 0; }
.movelist li {
  display: grid;
  grid-template-columns: 34px 20px 1fr auto;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 7px;
  font-size: 12.5px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.movelist li:hover { background: var(--paper); }
.movelist li.is-current { background: var(--green-soft); box-shadow: inset 2px 0 0 var(--green); }
.movelist li .no { color: var(--muted); font-size: 11.5px; }
.movelist li .coord { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.movelist li .loss { font-size: 11px; color: var(--muted); }
.movelist li .loss.blunder { color: var(--clay); font-weight: 600; }
.movelist li .loss.severe { color: #8c2f16; font-weight: 700; }
.movelist li .loss.losing-move {
  color: #fff;
  background: #7d2b8f;
  border-radius: 3px;
  padding: 0 3px;
  margin-left: 3px;
  font-size: 10px;
  font-weight: 700;
}
.movelist li .loss.mistake { color: #b06a3a; }

.info-list { display: grid; grid-template-columns: 84px 1fr; gap: 9px 12px; font-size: 13px; margin: 0; }
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; }

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbf8f1;
}
.sheet-head h2 { font-size: 16px; }
.sheet-body { padding: 18px; overflow: auto; }

/* 添加 / 编辑对局的表单 */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.game-form .field { margin-bottom: 12px; }
.form-actions { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.form-hint { font-size: 12px; color: var(--muted); margin: 12px 0 0; line-height: 1.7; }
@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
}

/* --------------------------------------------------------- 场馆页 --- */

.venue-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.venue-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s, border-color 0.15s;
}
.venue-card:hover { border-color: var(--green); box-shadow: 0 6px 18px rgba(28, 25, 18, 0.08); transform: translateY(-1px); }
.venue-cover {
  position: relative;
  height: 150px;
  background: linear-gradient(160deg, #f3f0e6, #e7e2d4);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.venue-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.venue-cover.is-broken { background: #efece2; }
.venue-cover-ph { font-size: 12.5px; color: #a9a091; }
.venue-body { padding: 13px 15px 15px; }
.venue-name { font-size: 16px; font-weight: 600; color: var(--ink); margin: 0 0 6px; }
.venue-intro {
  margin: 0 0 8px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--ink-soft);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.venue-addr { font-size: 12.5px; color: var(--ink-soft); line-height: 1.5; }
.venue-coord { display: flex; align-items: center; gap: 8px; font-size: 11.5px; margin-top: 4px; }
.venue-coord .btn { padding: 1px 8px; font-size: 11px; }
.venue-photos { display: flex; gap: 6px; margin: 10px 0 0; flex-wrap: wrap; }
.venue-photo {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #f2efe6;
  display: inline-flex;
}
.venue-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.venue-photo.is-broken { display: none; }

/* 导航按钮：高德 / 百度 / 腾讯 */
.venue-nav { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.nav-btn {
  flex: 1 1 auto;
  min-width: 84px;
  text-align: center;
  text-decoration: none;
  border-radius: 9px;
  padding: 7px 10px;
  font-size: 12.5px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #fffefa 0%, #fdf9f1 100%);
  color: var(--ink);
  transition: border-color 0.15s, background 0.15s;
}
.nav-btn:hover { border-color: var(--green); background: var(--green-soft); }
.nav-btn.nav-amap { color: #1a73b7; }
.nav-btn.nav-baidu { color: #2f6bd8; }
.nav-btn.nav-qq { color: #1c6b46; }

.venue-admin { display: flex; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
.venue-admin .btn { flex: 1; justify-content: center; }

/* 场馆详情弹层 */
.venue-detail-intro { font-size: 13.5px; line-height: 1.8; color: var(--ink-soft); margin: 0 0 12px; white-space: pre-wrap; }
.venue-detail-meta { font-size: 13px; line-height: 1.9; color: var(--ink-soft); }
.venue-detail-meta .venue-coord { margin: 2px 0 0; }
.venue-detail-block { margin-top: 18px; }
.venue-detail-block h4 { font-size: 13.5px; color: var(--ink); margin: 0 0 8px; }
.venue-photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.venue-photo.big { width: 100%; height: 96px; display: block; }
.venue-photo.big img { width: 100%; height: 100%; object-fit: cover; }
.venue-detail .venue-nav { margin-top: 14px; }

/* 编辑表单里的图片选择 */
.img-picker { margin-bottom: 12px; }
.img-thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 8px; }
.img-thumb {
  position: relative;
  width: 86px;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  background: #f7f4ec;
  display: flex;
  flex-direction: column;
}
.img-thumb img { width: 100%; height: 58px; object-fit: cover; display: block; background: #eceadf; }
.img-thumb.is-new { border-color: var(--green); }
.img-name {
  font-size: 10.5px;
  color: var(--muted);
  padding: 3px 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.img-del {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: rgba(28, 25, 18, 0.55);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.img-input { font-size: 12.5px; color: var(--ink-soft); }
.venue-form textarea {
  border: 1px solid var(--line-strong);
  background: #fffefb;
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--ink);
  font-family: inherit;
  width: 100%;
  resize: vertical;
}

@media (max-width: 560px) {
  .venue-grid { grid-template-columns: 1fr; gap: 12px; }
  .venue-cover { height: 130px; }
  .nav-btn { min-width: 0; flex: 1 1 calc(33.33% - 6px); padding: 8px 4px; font-size: 12px; }
  .venue-photo-grid { grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); }
}

/* --------------------------------------------------------- 提示条 --- */

.toasts { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: #25241f;
  color: #f4efe2;
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 13px;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.22s ease;
  max-width: min(560px, calc(100vw - 40px));
}
.toast.ok { background: #234c3c; }
.toast.err { background: #6d2f1d; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.loading { display: grid; place-items: center; padding: 80px 0; color: var(--muted); font-size: 13px; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--green); animation: spin 0.8s linear infinite; margin-bottom: 10px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------- 响应式 --- */

@media (max-width: 1080px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-grid { grid-template-columns: 1fr; }
  .viewer-body { grid-template-columns: 1fr; grid-template-rows: minmax(300px, 1fr) minmax(220px, 40%); }
  .side-column { border-left: 0; border-top: 1px solid var(--line); }
}

@media (max-width: 720px) {
  html, body { overflow-x: hidden; }
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 14px; gap: 8px 10px; }
  .brand { min-width: 0; flex: 1 1 auto; }
  .brand-text small { display: none; }
  .tab { white-space: nowrap; padding: 7px 12px; }
  .topbar-right { flex: 0 0 auto; }
  .topbar-right .today { display: none; }
  .engine-pill { padding: 4px 10px; font-size: 12px; }
  .view { padding: 18px 14px 40px; min-width: 0; }
  .section-title { flex-wrap: wrap; gap: 4px; }
  .section-title .sub { width: 100%; font-size: 12.5px; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
  .hero { padding: 20px; }
  .hero h1 { font-size: 22px; }
  .toolbar { gap: 8px; padding: 12px; }
  .toolbar .search { flex: 1 1 100%; }
  .toolbar .seg { flex: 1 1 100%; min-width: 0; display: flex; overflow-x: auto; }
  .toolbar .seg button { flex: 1 0 auto; }
  .toolbar > .btn { flex: 0 0 auto; }
  .toolbar > .grow { display: none; }
  .modal-body.viewer { width: 100vw; max-width: 100vw; height: 100vh; height: 100dvh; border-radius: 0; }
  .viewer-head { padding: 6px 10px; }
  .vs-line { font-size: 15px; }
  .viewer-meta {
    font-size: 11.5px;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 62vw;
  }
  #viewerDownload { display: none; }
  .board-column { padding: 2px 2px 4px; gap: 4px; }
  .board-wrap { min-height: 0; }
  #boardCanvas { max-width: 100%; height: auto !important; }
  .board-controls { padding: 0 2px; }
  /* 手机上让棋盘吃掉更多高度，面板压到 34% */
  .viewer-body { grid-template-rows: minmax(240px, 1fr) minmax(180px, 34%); }
  .control-row { flex-wrap: wrap; row-gap: 6px; gap: 5px; }
  .btn.icon { width: 34px; height: 32px; }
  .play-btn { height: 32px; padding: 0 10px; font-size: 12px; }
  .control-divider { display: none; }
  .toggles { flex: 1 0 100%; justify-content: flex-end; }
  .move-counter { min-width: 0; }
  .switch { white-space: nowrap; }
  .ai-buttons { grid-template-columns: 1fr; }
  .side-pane { padding: 12px 14px 20px; }
  .footer { flex-direction: column; gap: 4px; padding: 12px 14px; }
  .card-head { padding: 14px 14px 8px; flex-wrap: wrap; }
  .card-body { padding: 0 14px 14px; }
  .rank-list, .recent-list { padding-left: 4px; padding-right: 4px; }
  .note { padding: 10px 12px; }
  .grid-4 .stat-card .num { font-size: 26px; }
}

/* 手机上把宽表格变成一张张卡片 */
@media (max-width: 720px) {
  table.data.responsive { min-width: 0; }
  table.data.responsive thead { display: none; }
  table.data.responsive,
  table.data.responsive tbody { display: block; width: 100%; }
  /* 卡片用 flex 排版：第一行「序号 + 结果徽章」，下面每个字段独占一行。
     不用 absolute + 负 margin 的老写法——微信内置浏览器对 tr 相对定位支持不稳，
     徽章会掉回原位叠在棋手名上。 */
  table.data.responsive tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px 14px 10px;
    margin: 0 0 10px;
    background: #fffdf8;
    box-shadow: var(--shadow-sm);
  }
  table.data.responsive tr.clickable:hover { background: #fbf7ee; }
  table.data.responsive td { border: 0; padding: 0; min-width: 0; width: auto; overflow-wrap: anywhere; }
  table.data.responsive td::before { content: none; }

  /* 序号：第一行左侧小字 */
  table.data.responsive td.num {
    order: 1;
    flex: 1 1 auto;
    text-align: left;
    font-size: 11px;
    color: var(--muted);
  }
  table.data.responsive td.num::after { content: ' 局'; }

  /* 结果徽章：第一行右侧 */
  table.data.responsive td[data-label='结果'] { order: 2; flex: 0 0 auto; }
  /* 不可见的换行垫片：卡在「结果」之后，把对阵挤到第二行 */
  table.data.responsive tr::after { content: ''; order: 2; flex: 1 1 100%; }

  /* 黑白对阵：独占一行，左对齐「●黑 对 ○白」 */
  table.data.responsive td[data-label='黑方'],
  table.data.responsive td[data-label='白方'] {
    display: flex;
    align-items: center;
    flex: 0 1 auto;
    min-width: 0;
    margin-top: 10px;
  }
  table.data.responsive td[data-label='黑方'] { order: 3; }
  table.data.responsive td[data-label='白方'] { order: 4; margin-left: 10px; }
  table.data.responsive td[data-label='白方']::before {
    content: '对';
    color: #c2b9a6;
    font-size: 12px;
    flex: none;
    margin-right: 8px;
  }
  table.data.responsive td .player { justify-content: flex-start; font-size: 14.5px; font-weight: 600; }
  /* 名字太长时截断，别把「对 ○白方」顶出卡片 */
  table.data.responsive td[data-label='黑方'] .player span:last-child,
  table.data.responsive td[data-label='白方'] .player span:last-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* 日期 / 地点 / 直播：小字字段各占一行 */
  table.data.responsive td[data-label='日期'],
  table.data.responsive td[data-label='地点'],
  table.data.responsive td[data-label='直播'] {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 100%;
    font-size: 12.5px;
    color: var(--ink-soft);
    margin-top: 6px;
  }
  table.data.responsive td[data-label='日期'] { order: 5; margin-top: 10px; }
  table.data.responsive td[data-label='地点'] { order: 6; }
  table.data.responsive td[data-label='日期']::before,
  table.data.responsive td[data-label='地点']::before,
  table.data.responsive td[data-label='直播']::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11.5px;
    flex: 0 0 42px;
  }
  table.data.responsive td[data-label='直播'] { display: none; }
  table.data.responsive td[data-label='地点']:empty::after { content: '—'; color: #c2b9a6; }

  /* AI 徽章 + 评分并排一行 */
  table.data.responsive td[data-label='AI 分析'] {
    order: 7;
    display: flex;
    /* 顶部对齐：这格现在有两行（状态徽章 + 评分），用 center 的话
       「AI」会掉到两行中间，和右边徽章差半行高 */
    align-items: flex-start;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--line);
  }
  table.data.responsive td[data-label='AI 分析']::before {
    content: 'AI';
    color: var(--muted);
    font-size: 11.5px;
    flex: 0 0 42px;
    align-self: flex-start;
    /* 和右侧 .ai-state 徽章等高（11.5px 文字 + 上下 2px padding + 1px 描边 ≈ 20px），
       这样「AI」的基线和徽章文字对齐 */
    display: flex;
    align-items: center;
    height: 20px;
    line-height: 1;
  }
  table.data.responsive td[data-label='AI 分析'] .ai-score { flex: 1; gap: 8px; }

  /* 评分：手机上单独占一行，左缘和上面的「AI」标签对齐。
     .ai-score 本身从 42px 标签位之后开始，所以用负 margin 把评分行拉回卡片左缘，
     再由 ::before 的「评分」标签占同样的 42px，两行标签就上下对齐了。 */
  table.data.responsive td[data-label='AI 分析'] .score-pair,
  table.data.responsive td[data-label='AI 分析'] .score-empty {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 calc(100% + 42px);
    margin-left: -42px;
    margin-top: 8px;
    font-size: 12.5px;
    color: var(--ink-soft);
  }
  table.data.responsive td[data-label='AI 分析'] .score-pair::before,
  table.data.responsive td[data-label='AI 分析'] .score-empty::before {
    content: '评分';
    color: var(--muted);
    font-size: 11.5px;
    flex: 0 0 42px;
  }
  table.data.responsive td[data-label='AI 分析'] .score-empty { color: #c2b9a6; letter-spacing: 1.5px; }

  /* 操作按钮：整行铺开 */
  table.data.responsive td[data-label='操作'] { order: 8; display: flex; flex: 1 1 100%; margin-top: 10px; }
  /* 访客 + 没棋谱时操作格只有一个「—」占位，直接藏掉，免得卡片底部悬一个孤字符 */
  table.data.responsive td[data-label='操作'] .muted:only-child { display: none; }
  table.data.responsive td .row-actions { width: 100%; gap: 8px; }
  table.data.responsive td .row-actions .btn { flex: 1; justify-content: center; }

  /* 积分榜：手机上不做卡片化，保持和电脑端一样的表头排版，横向滚动查看 */
  .table-wrap { overflow-x: auto; max-width: 100%; min-width: 0; }
  table.data { min-width: 0; }
  /* 注意：这条要放在 table.data { min-width: 0 } 之后，否则会被压回 0，表格会被挤扁 */
  table.standing-table { min-width: 470px; font-size: 12.5px; }
  table.standing-table th,
  table.standing-table td { padding: 9px 6px; white-space: nowrap; }
  /* 名次 / 棋手两列收窄，把横向空间让给后面的数据列 */
  table.standing-table .col-rank { width: 30px; }
  table.standing-table th:nth-child(2),
  table.standing-table td:nth-child(2) { padding-left: 2px; padding-right: 2px; }
  table.standing-table .name-cell { gap: 6px; }
  .card { min-width: 0; }
  .card-head h2 { font-size: 15px; }
  .matrix-wrap { max-width: 100%; }
  /* 手机上：行名列收窄，把横向空间让给胜负格子 */
  table.matrix { font-size: 11.5px; }
  table.matrix th, table.matrix td { width: 34px; height: 32px; }
  table.matrix th:first-child { width: 52px; min-width: 52px; padding: 0 3px; font-size: 11px; }
  .stat-bars { min-width: 40px; }
}

/* ---------------------------------------------- 窄屏导航：折叠成菜单 --- */
/* 放在文件最后，保证能盖掉前面 @media (max-width: 720px) 里对 .tabs 的旧规则 */
@media (max-width: 1080px) {
  .nav-toggle { display: inline-flex; }
  .tabs {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex: none;
    display: none;
    flex-direction: column;
    gap: 2px;
    padding: 8px 12px 12px;
    background: rgba(255, 253, 248, 0.98);
    backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 14px 28px -16px rgba(28, 25, 18, 0.35);
  }
  .tabs.is-open { display: flex; }
  .tab {
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 15px;
  }
}
@media (max-width: 560px) {
  .topbar-right #adminBtnText { display: none; }
  .topbar-right .admin-btn { padding: 5px 9px; }
}

/** 合并格：桌面端 AI 徽章 + 评分横排 */
.ai-score { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* 对局列表分页器 */
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 14px 12px 4px; }
.pager-btn {
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #fffefa 0%, #fdf9f1 100%);
  border-radius: 10px;
  padding: 7px 16px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
}
.pager-btn:hover:not(:disabled) { border-color: var(--green); color: var(--jade-ink); }
.pager-btn:disabled { opacity: 0.4; cursor: default; }
.pager-info { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
