/* ==========================================================================
   舒尔特方格训练 · 样式表
   白天 / 夜晚双主题，自适应，无外部依赖
   --------------------------------------------------------------------------
   主题由 <html data-theme="light|dark"> 控制，默认白天
   ========================================================================== */

/* ---------- 白天（默认） ---------- */
:root,
[data-theme="light"] {
  --bg: #f4f6fa;
  --bg-soft: #eef1f7;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --line: #e2e7f0;
  --line-strong: #cfd6e4;
  --text: #121a29;
  --text-2: #43516a;
  --muted: #6b7a92;

  --accent: #2563eb;
  --accent-soft: #e8efff;
  --ok: #0f9d6a;
  --warn: #c2740a;
  --bad: #dc2626;

  --board-bg: #ffffff;
  --cell-face: #ffffff;
  --cell-edge: #33415c;
  --cell-done: #e3f5ec;
  --cell-done-edge: #2f9e6f;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 6px 16px -12px rgba(16, 24, 40, .3);
  --shadow-lg: 0 24px 50px -24px rgba(16, 24, 40, .35);
  --header-bg: rgba(255, 255, 255, .86);
  --header-line: #e6eaf2;
  --page-glow: radial-gradient(50rem 30rem at 50% -10%, #e6efff 0%, rgba(255, 255, 255, 0) 70%);
  --toast-bg: #121a29;
  --toast-text: #ffffff;
}

/* ---------- 夜晚 ---------- */
[data-theme="dark"] {
  --bg: #0b0f16;
  --bg-soft: #111722;
  --surface: #151b26;
  --surface-2: #1c2431;
  --line: #26303f;
  --line-strong: #364354;
  --text: #f1f5fb;
  --text-2: #c2ccdb;
  --muted: #8b99ad;

  --accent: #6f9dff;
  --accent-soft: rgba(111, 157, 255, .16);
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;

  --board-bg: #151b26;
  --cell-face: #1b2330;
  --cell-edge: #8fa3bf;
  --cell-done: #163b30;
  --cell-done-edge: #3ddba6;

  --shadow-sm: 0 1px 0 rgba(255, 255, 255, .04), 0 8px 20px -14px #000;
  --shadow-lg: 0 26px 60px -26px #000;
  --header-bg: rgba(11, 15, 22, .84);
  --header-line: #212a38;
  --page-glow: radial-gradient(50rem 30rem at 50% -10%, rgba(64, 96, 160, .28) 0%, rgba(11, 15, 22, 0) 70%);
  --toast-bg: #f1f5fb;
  --toast-text: #0b0f16;
}

/* ---------- 基础 ---------- */
:root {
  --radius: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --tab-num: "SF Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}

[data-theme="dark"] { color-scheme: dark; }

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 84px;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color .25s ease, color .25s ease;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--page-glow);
  pointer-events: none;
}

h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; font-weight: 700; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
svg { display: block; }

.wrap {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- 顶部导航 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 60;
  backdrop-filter: blur(14px) saturate(150%);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-line);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 64px;
}

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

.brand-bg { fill: var(--text); }
.brand-cells { stroke: var(--bg); }

.brand-text { display: flex; flex-direction: column; line-height: 1.12; }
.brand-text strong { font-size: 16.5px; letter-spacing: .02em; }
.brand-text em {
  font-style: normal;
  font-size: 9.5px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}

.nav { display: flex; align-items: center; gap: 2px; }

.nav-link {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-2);
  transition: color .16s, background-color .16s;
  white-space: nowrap;
}
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link.is-active { color: var(--text); font-weight: 600; background: var(--surface-2); }

.nav-link--ghost {
  border: 1px solid var(--line-strong);
  color: var(--text);
  margin-left: 4px;
}
.nav-link--ghost:hover { border-color: var(--accent); color: var(--accent); background: transparent; }

/* 昼夜切换 */
.theme-switch {
  display: inline-flex;
  padding: 3px;
  margin-left: 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
}

.theme-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  font-size: 12.5px;
  color: var(--muted);
  border-radius: 999px;
  transition: all .18s ease;
  white-space: nowrap;
}
.theme-btn svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.theme-btn:hover { color: var(--text); }
.theme-btn.is-active {
  color: #fff;
  background: var(--text);
  font-weight: 600;
}
[data-theme="dark"] .theme-btn.is-active { color: #0b0f16; background: #f1f5fb; }

/* ---------- 训练区 ---------- */
.trainer { padding: 30px 0 10px; }

/* 控制面板：三列下拉 + 昵称 */
.controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(200px, 1.25fr);
  gap: 14px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.ctrl { display: flex; flex-direction: column; gap: 7px; min-width: 0; }

.ctrl-label {
  font-size: 12px;
  letter-spacing: .04em;
  color: var(--muted);
  font-weight: 600;
}

/* 原生 select，替换箭头 */
.select-wrap { position: relative; display: block; }

.select-wrap select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 100%;
  height: 42px;
  padding: 0 34px 0 12px;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: none;
  cursor: pointer;
  transition: border-color .16s, box-shadow .16s;
}

.select-wrap select:hover { border-color: var(--accent); }

.select-wrap select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.select-wrap::after {
  content: "";
  position: absolute;
  right: 13px;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: -6px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  pointer-events: none;
}

.select-wrap select option { background: var(--surface); color: var(--text); }

/* 昵称 */
.name-field { display: flex; gap: 8px; }

.name-input {
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  font-size: 14.5px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}
.name-input::placeholder { color: var(--muted); opacity: .75; }
.name-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.name-input.is-flash {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  animation: flash 1s ease;
}
@keyframes flash {
  0%, 100% { transform: scale(1); }
  30% { transform: scale(1.02); }
}

.name-dice {
  flex: none;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--text-2);
  background: var(--surface-2);
  transition: all .16s;
}
.name-dice svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.name-dice:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

/* ---------- HUD ---------- */
.hud {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 8px;
  margin: 18px 0 12px;
  flex-wrap: wrap;
}

.hud-item {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.hud-label { font-size: 12px; color: var(--muted); }

.hud-value {
  font-family: var(--tab-num);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.hud-item--err .hud-value { color: var(--text-2); }
.hud-item--err.is-warn .hud-value { color: var(--warn); }
.hud-item--err.is-danger .hud-value { color: var(--bad); }

/* ---------- 棋盘 ---------- */
.stage {
  position: relative;
  width: min(100%, 520px);
  margin: 0 auto;
}

.stage-glow {
  position: absolute;
  inset: 10% 8% -4%;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--accent-soft), transparent 70%);
  filter: blur(26px);
  pointer-events: none;
}

.board {
  position: relative;
  padding: 12px;
  border-radius: 20px;
  background: var(--board-bg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  touch-action: manipulation;
}

.board svg { width: 100%; height: auto; display: block; }

/* 骨架 */
.board-skeleton {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  aspect-ratio: 1 / 1;
  padding: 6px;
}
.board-skeleton span {
  border-radius: 12px;
  background: var(--surface-2);
  animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer { 0%, 100% { opacity: .6; } 50% { opacity: 1; } }

/* ---------- SVG 格子 ---------- */
.cell { cursor: pointer; -webkit-tap-highlight-color: transparent; }

/* 数字对应格子的边框 —— 加粗、深色，保证清晰可辨 */
.cell .shape {
  fill: var(--cell-face);
  stroke: var(--cell-edge);
  stroke-width: 2.6;
  stroke-linejoin: round;
  transition: fill .18s ease, stroke .18s ease, stroke-width .18s ease;
}

.cell text {
  font-family: var(--font);
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
  user-select: none;
  fill: var(--text);
  transition: opacity .2s ease, fill .18s ease;
  font-variant-numeric: tabular-nums;
}

/* 单色盘 */
.color-single .cell text { fill: var(--text); }

/* 彩色盘：白底 + 高饱和深色字，边框为深中性色 */
.color-color .cell.k0 text { fill: #b3261e; }
.color-color .cell.k1 text { fill: #1565c0; }
.color-color .cell.k2 text { fill: #0b7a3e; }
.color-color .cell.k3 text { fill: #6a1b9a; }
.color-color .cell.k4 text { fill: #a85500; }
.color-color .cell.k5 text { fill: #0e7490; }
.color-color .cell.k6 text { fill: #c2185b; }
.color-color .cell.k7 text { fill: #4a3f00; }

/* 夜晚：深底上改用品红/青/黄等高亮色板，保证对比度 */
[data-theme="dark"] .color-color .cell.k0 text { fill: #ff6b6b; }
[data-theme="dark"] .color-color .cell.k1 text { fill: #5aa9ff; }
[data-theme="dark"] .color-color .cell.k2 text { fill: #4ade80; }
[data-theme="dark"] .color-color .cell.k3 text { fill: #c084fc; }
[data-theme="dark"] .color-color .cell.k4 text { fill: #fbbf24; }
[data-theme="dark"] .color-color .cell.k5 text { fill: #22d3ee; }
[data-theme="dark"] .color-color .cell.k6 text { fill: #f472b6; }
[data-theme="dark"] .color-color .cell.k7 text { fill: #a3e635; }

/* 交互 */
.cell:hover .shape { stroke: var(--accent); stroke-width: 3.4; }
.cell:active .shape { stroke: var(--accent); stroke-width: 4; }

.cell.done .shape {
  fill: var(--cell-done);
  stroke: var(--cell-done-edge);
  stroke-width: 3;
}
.cell.done text { opacity: .3; }

.cell.wrong .shape {
  fill: #ffe1e1;
  stroke: var(--bad);
  stroke-width: 4.4;
}
[data-theme="dark"] .cell.wrong .shape { fill: #3a1720; }
.cell.wrong text { fill: var(--bad); }

.cell.pop { animation: pop .32s cubic-bezier(.34, 1.56, .64, 1); }
.cell.shake { animation: shake .32s ease; }
.cell { transform-box: fill-box; transform-origin: center; }

@keyframes pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.1); }
  100% { transform: scale(1); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  22% { transform: translateX(-4px); }
  44% { transform: translateX(4px); }
  66% { transform: translateX(-2px); }
  88% { transform: translateX(2px); }
}

.board.is-idle .cell { cursor: default; }

/* ---------- 开始按钮 ---------- */
.start-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 22px 0 4px;
}

.btn-start {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-width: 200px;
  height: 52px;
  padding: 0 32px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .03em;
  color: #fff;
  border-radius: 12px;
  background: var(--text);
  box-shadow: 0 10px 24px -12px rgba(16, 24, 40, .6);
  transition: transform .16s ease, box-shadow .16s ease, opacity .16s ease;
}
[data-theme="dark"] .btn-start { color: #0b0f16; }

.btn-start:hover { transform: translateY(-1px); opacity: .92; }
.btn-start:active { transform: translateY(0) scale(.99); }

.btn-start-icon { width: 18px; height: 18px; fill: currentColor; }

.btn-start.is-running {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}

.start-hint {
  font-size: 12.5px;
  color: var(--muted);
  min-height: 18px;
  text-align: center;
}

.noscript {
  margin: 20px auto 0;
  max-width: 520px;
  padding: 12px 16px;
  text-align: center;
  font-size: 14px;
  color: var(--bad);
  background: #fdecec;
  border: 1px solid #f6c9c9;
  border-radius: 12px;
}

/* ---------- 排行榜 ---------- */
.leaderboard { padding: 46px 0 10px; }

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.section-head h2 { font-size: 20px; }
.section-sub { margin-top: 5px; font-size: 13px; color: var(--muted); }
.section-sub b { color: var(--text-2); font-family: var(--tab-num); }

.tabs {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
}

.tab {
  padding: 6px 15px;
  font-size: 13px;
  color: var(--text-2);
  border-radius: 999px;
  transition: all .16s;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: #fff; background: var(--text); font-weight: 600; }
[data-theme="dark"] .tab.is-active { color: #0b0f16; }

/* 我的成绩卡 */
.me-card[hidden] { display: none; }

.me-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 18px;
  margin-bottom: 10px;
  border-radius: 12px;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  animation: fadeUp .28s ease both;
}

.me-left { display: flex; flex-direction: column; min-width: 0; }
.me-cap { font-size: 11px; letter-spacing: .06em; color: var(--muted); }
.me-name { font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }

.me-mid { display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
.me-rank { font-family: var(--tab-num); font-size: 21px; font-weight: 700; color: var(--accent); }
.me-rank-cap { font-size: 10.5px; color: var(--muted); }

.me-right { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.me-time { font-family: var(--tab-num); font-size: 19px; font-weight: 700; }
.me-beat { font-size: 11px; color: var(--ok); }

/* 榜单：两列 */
.lb-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.lb-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  font-size: 13.5px;
  transition: background .16s, border-color .16s;
}

.lb-row:hover { border-color: var(--line-strong); background: var(--surface-2); }

.lb-rank {
  font-family: var(--tab-num);
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }

.lb-time {
  font-family: var(--tab-num);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.lb-row.is-top1 { border-color: #e8c56a; background: #fffbf0; }
.lb-row.is-top1 .lb-rank { color: #b4801a; font-weight: 700; }
.lb-row.is-top2 { border-color: #cfd6e4; background: #f8fafc; }
.lb-row.is-top2 .lb-rank { color: #64748b; font-weight: 700; }
.lb-row.is-top3 { border-color: #e5c3a5; background: #fdf6f1; }
.lb-row.is-top3 .lb-rank { color: #a4602f; font-weight: 700; }

[data-theme="dark"] .lb-row.is-top1 { border-color: #5d4a1c; background: #221d10; }
[data-theme="dark"] .lb-row.is-top1 .lb-rank { color: #f5cd6a; }
[data-theme="dark"] .lb-row.is-top2 { border-color: #35404f; background: #1b222d; }
[data-theme="dark"] .lb-row.is-top2 .lb-rank { color: #cbd5e1; }
[data-theme="dark"] .lb-row.is-top3 { border-color: #4a3626; background: #221a14; }
[data-theme="dark"] .lb-row.is-top3 .lb-rank { color: #e8ab7a; }

.lb-row.is-me { border-color: var(--accent); background: var(--accent-soft); }
.lb-row.is-me .lb-name { color: var(--text); font-weight: 700; }

.lb-empty {
  grid-column: 1 / -1;
  padding: 30px 0;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.lb-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.btn-more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  color: var(--text);
  transition: all .16s;
  background: var(--surface);
}
.btn-more svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.btn-more:hover { border-color: var(--accent); color: var(--accent); }

.lb-note { font-size: 12px; color: var(--muted); }

/* ---------- 说明 ---------- */
.guide { padding: 46px 0 20px; }
.guide h2 { font-size: 20px; margin-bottom: 16px; }

.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

.guide-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.guide-num {
  font-family: var(--tab-num);
  font-size: 12px;
  letter-spacing: .1em;
  color: var(--accent);
  font-weight: 700;
}

.guide-card h3 { font-size: 15px; margin: 6px 0 7px; }
.guide-card p { font-size: 13.5px; color: var(--text-2); line-height: 1.7; }

.faq { margin-top: 22px; display: grid; gap: 8px; }

.faq details {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 0 16px;
}
.faq details[open] { border-color: var(--line-strong); }

.faq summary {
  padding: 13px 0;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 9px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform .2s;
  flex: none;
  margin-bottom: 2px;
}
.faq details[open] summary::before { transform: rotate(45deg); border-color: var(--accent); }

.faq p { padding: 0 0 14px 15px; font-size: 13.5px; color: var(--text-2); line-height: 1.75; }

/* ---------- 页脚 ---------- */
.site-footer {
  margin-top: 40px;
  padding: 28px 0 30px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.footer-brand strong { font-size: 14.5px; }
.footer-brand p { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

.footer-nav { display: flex; gap: 16px; flex-wrap: wrap; }
.footer-nav a { font-size: 13px; color: var(--text-2); transition: color .16s; }
.footer-nav a:hover { color: var(--accent); }

.copyright {
  flex-basis: 100%;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

/* ---------- 排行榜详情页 ---------- */
.rank-page { padding: 22px 0 20px; }

.crumb {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 14px;
}
.crumb a { color: var(--text-2); }
.crumb a:hover { color: var(--accent); }

.rank-head h1 { font-size: clamp(21px, 3.4vw, 28px); }
.rank-head p { margin-top: 7px; font-size: 13px; color: var(--muted); }
.rank-head b { color: var(--text-2); font-family: var(--tab-num); }

.rank-tabs {
  display: inline-flex;
  padding: 3px;
  margin: 16px 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
}
.rank-tabs .tab { display: inline-block; }

.filters {
  display: grid;
  gap: 9px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-label {
  flex: none;
  width: 64px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--text-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  transition: all .16s ease;
  white-space: nowrap;
}
.chip:hover { color: var(--text); border-color: var(--line-strong); }
.chip.is-active {
  color: #fff;
  font-weight: 600;
  border-color: var(--text);
  background: var(--text);
}
[data-theme="dark"] .chip.is-active { color: #0b0f16; background: #f1f5fb; border-color: #f1f5fb; }

.rank-hint { margin: 12px 0 10px; font-size: 12.5px; color: var(--muted); }
.rank-hint b { color: var(--text-2); }

.lb-list--wide { gap: 6px; }
.lb-list--wide.has-meta .lb-row { grid-template-columns: 44px minmax(0, 1fr) auto auto; }

.lb-meta {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex-wrap: wrap;
  margin: 22px 0 6px;
}

.pager-btn, .pager-num {
  display: inline-grid;
  place-items: center;
  min-width: 36px;
  height: 34px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--text-2);
  background: var(--surface);
  transition: all .16s;
}
.pager-btn:hover, .pager-num:hover { color: var(--text); border-color: var(--line-strong); }
.pager-btn.is-disabled { opacity: .45; pointer-events: none; }
.pager-num.is-active { color: #fff; background: var(--text); border-color: var(--text); font-weight: 700; }
[data-theme="dark"] .pager-num.is-active { color: #0b0f16; background: #f1f5fb; border-color: #f1f5fb; }

.rank-cta { display: flex; justify-content: center; margin: 26px 0 8px; }
.lb-empty a { color: var(--accent); text-decoration: underline; }

/* ---------- 结果弹层 ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 36, .42);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn .18s ease both;
}
.modal[hidden] { display: none; }

.modal-card {
  position: relative;
  width: min(100%, 400px);
  padding: 28px 26px 22px;
  text-align: center;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: popIn .28s cubic-bezier(.22, 1.2, .4, 1) both;
}

.modal-badge {
  width: 44px;
  height: 44px;
  margin: 0 auto 10px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}
.modal-badge svg { width: 22px; height: 22px; fill: currentColor; }
.modal-badge.is-fail { background: #fdecec; color: var(--bad); }
[data-theme="dark"] .modal-badge.is-fail { background: #3a1720; }

.modal h3 { font-size: 17px; }

.modal-time {
  font-family: var(--tab-num);
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -.02em;
  margin: 4px 0 2px;
  color: var(--text);
}

.modal-meta { font-size: 13.5px; color: var(--text-2); line-height: 1.9; }
.modal-meta b { color: var(--text); font-family: var(--tab-num); font-weight: 700; }
.modal-meta .hl { color: var(--ok); font-weight: 600; }

/* 结束后提示可修改昵称 */
.nick-tip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 10px 12px;
  text-align: left;
  border-radius: 10px;
  border: 1px dashed var(--line-strong);
  background: var(--surface-2);
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.5;
}
.nick-tip[hidden] { display: none; }
.nick-tip svg {
  flex: none;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.nick-tip button {
  margin-left: auto;
  flex: none;
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: transparent;
  transition: all .16s;
}
.nick-tip button:hover { color: #fff; background: var(--accent); }

.modal-actions { display: flex; gap: 9px; margin-top: 16px; }

.btn-primary {
  flex: 1;
  height: 44px;
  border-radius: 10px;
  font-size: 14.5px;
  font-weight: 700;
  color: #fff;
  background: var(--text);
  transition: opacity .16s;
}
[data-theme="dark"] .btn-primary { color: #0b0f16; }
.btn-primary:hover { opacity: .9; }

.btn-ghost {
  flex: 1;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-size: 14.5px;
  border: 1px solid var(--line-strong);
  color: var(--text-2);
  background: var(--surface);
  transition: all .16s;
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }

.modal-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 30px;
  height: 30px;
  font-size: 20px;
  line-height: 1;
  color: var(--muted);
  border-radius: 7px;
}
.modal-close:hover { color: var(--text); background: var(--surface-2); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 120;
  transform: translate(-50%, 16px);
  padding: 9px 18px;
  font-size: 13.5px;
  border-radius: 999px;
  background: var(--toast-bg);
  color: var(--toast-text);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes popIn { from { opacity: 0; transform: scale(.95); } to { opacity: 1; transform: scale(1); } }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .controls { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ctrl--name { grid-column: 1 / -1; }
  .nav-link { padding: 7px 9px; font-size: 13.5px; }
  .theme-btn span { display: none; }
  .theme-btn { padding: 6px 9px; }
}

@media (max-width: 720px) {
  .header-inner { height: 58px; gap: 8px; }
  .brand-text em { display: none; }
  .nav { gap: 0; }
  .nav-link { padding: 6px 8px; font-size: 13px; }
  .nav-link--ghost { display: none; }
  .theme-switch { margin-left: 4px; }
  .trainer { padding-top: 20px; }
  .controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 14px;
  }
  .ctrl:first-child { grid-column: 1 / -1; }
  .ctrl--name { grid-column: 1 / -1; }
  .board { padding: 9px; border-radius: 16px; }
  .hud { gap: 6px; }
  .hud-item { padding: 5px 11px; }
  .hud-value { font-size: 14px; }
  .lb-row { padding: 8px 9px; font-size: 13px; }
  .lb-list--wide.has-meta .lb-row { grid-template-columns: 34px minmax(0, 1fr) auto; }
  .lb-list--wide.has-meta .lb-meta { display: none; }
  .me-card { padding: 11px 13px; }
  .me-name { max-width: 36vw; font-size: 14px; }
  .me-time { font-size: 17px; }
  .section-head { align-items: flex-start; }
  .filter-label { width: 100%; }
}

@media (max-width: 460px) {
  .wrap { padding: 0 14px; }
  .lb-list { grid-template-columns: 1fr; }
  .nav-link:nth-child(3) { display: none; }
  .btn-start { width: 100%; max-width: 300px; }
  .modal-actions { flex-direction: column; }
  .hud-item:nth-child(2) { display: none; }
  .nick-tip { flex-wrap: wrap; }
  .nick-tip button { margin-left: 0; }
}

/* ---------- 无障碍 / 减少动效 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}
