/* ============================================================
   知识边界 · Knowledge Boundary
   视觉方向：知识星图 / 编辑部式暗色天文志
   ============================================================ */

:root {
  --ink: #080d1c;
  --ink-2: #0b1226;
  --panel: rgba(17, 26, 48, 0.72);
  --panel-solid: #111a30;
  --line: rgba(148, 163, 184, 0.14);
  --line-strong: rgba(148, 163, 184, 0.28);
  --text: #e8edf8;
  --muted: #93a2c0;
  --faint: #7c8db1;
  --accent: #7dd3fc;
  --accent-2: #c4b5fd;
  --ok: #34d399;
  --bad: #fb7185;
  --serif: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", "STSong", Georgia, serif;
  --sans: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "SF Mono", "Cascadia Code", Consolas, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---------- 背景：星野 + 暗角 ---------- */
#starfield { position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .85; }
.vignette {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(1200px 800px at 20% -10%, rgba(64, 110, 255, 0.10), transparent 60%),
    radial-gradient(1000px 700px at 90% 110%, rgba(168, 85, 247, 0.08), transparent 60%),
    radial-gradient(ellipse at center, transparent 55%, rgba(3, 6, 16, 0.85) 100%);
}
#app { position: relative; z-index: 2; max-width: 1080px; margin: 0 auto; padding: 0 24px 80px; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: relative; z-index: 3;
  max-width: 1080px; margin: 0 auto;
  padding: 22px 24px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; color: var(--text); }
.brand-mark { color: var(--accent); font-size: 20px; animation: spinSlow 40s linear infinite; }
.brand-name { font-family: var(--serif); font-size: 20px; font-weight: 700; letter-spacing: .06em; }
.brand-sub { font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--faint); }
@keyframes spinSlow { to { transform: rotate(360deg); } }

.topbar-right { display: flex; align-items: center; gap: 14px; }
.gh-link {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 12px;
  color: var(--muted); font-size: 20px;
  border: 1px solid var(--line); background: rgba(17, 26, 48, .5);
  transition: color .18s, border-color .18s, transform .18s var(--ease);
}
.gh-link:hover { color: var(--text); border-color: var(--line-strong); transform: translateY(-1px); }

.topbar-chip {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 14px; background: rgba(17, 26, 48, .5);
}
.chip-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 10px var(--ok); }

/* ---------- 通用按钮 ---------- */
.btn {
  font-family: inherit; font-size: 15px; cursor: pointer;
  border-radius: 12px; border: 1px solid transparent;
  padding: 11px 22px; transition: transform .18s var(--ease), background .18s, box-shadow .18s, border-color .18s, color .18s;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { transform: translateY(1px); }
.btn.is-muted { opacity: .45; cursor: pointer; }
.btn.is-muted:hover { opacity: .45; transform: none; border-color: var(--line); color: var(--muted); }

/* 键盘焦点可见性 */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.btn-lg { padding: 15px 32px; font-size: 16px; }
.btn-primary {
  background: linear-gradient(135deg, #38bdf8, #6366f1); color: #fff;
  box-shadow: 0 8px 30px -10px rgba(99, 102, 241, .7);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 14px 40px -10px rgba(99, 102, 241, .85); }
.btn-secondary {
  background: rgba(125, 211, 252, .12); color: var(--accent); border-color: rgba(125, 211, 252, .35);
}
.btn-secondary:hover { background: rgba(125, 211, 252, .2); transform: translateY(-1px); }
.btn-ghost {
  background: transparent; color: var(--muted); border-color: var(--line);
}
.btn-ghost:hover { color: var(--text); border-color: var(--line-strong); }
.btn-danger-ghost {
  background: transparent; color: var(--bad); border-color: rgba(251, 113, 133, .3);
}
.btn-danger-ghost:hover { background: rgba(251, 113, 133, .1); }

/* ============================================================
   首页
   ============================================================ */
.view { animation: viewIn .5s var(--ease); }
@keyframes viewIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.hero { padding: 72px 0 40px; max-width: 720px; }
.hero-kicker {
  font-size: 13px; letter-spacing: .28em; text-transform: uppercase; color: var(--accent);
  margin: 0 0 18px;
}
.hero-title {
  font-family: var(--serif); font-weight: 700; font-size: clamp(40px, 8vw, 68px);
  line-height: 1.12; margin: 0 0 26px; letter-spacing: .02em;
}
.hero-title .accent {
  color: transparent;
  background: linear-gradient(120deg, #7dd3fc, #c4b5fd, #f9a8d4);
  -webkit-background-clip: text; background-clip: text;
  text-shadow: 0 0 60px rgba(125, 211, 252, .25);
}
.hero-lead { font-size: 17px; color: var(--muted); max-width: 600px; margin: 0 0 34px; }
.hero-lead b { color: var(--text); font-weight: 600; }
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; }
.hero-note { margin-top: 14px; font-size: 13px; color: var(--faint); }

/* ---------- 领域地图 ---------- */
.domain-map { margin-top: 72px; }
.section-head { margin-bottom: 20px; }
.section-head h2 {
  font-family: var(--serif); font-size: 26px; margin: 0 0 4px; letter-spacing: .03em;
}
.section-head p { margin: 0; color: var(--faint); font-size: 13px; }

.domain-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(228px, 1fr));
  gap: 14px;
}
.domain-card {
  position: relative; overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line); border-radius: 18px;
  padding: 18px 18px 16px;
  transition: transform .25s var(--ease), border-color .25s, background .25s, box-shadow .25s;
  display: flex; flex-direction: column; gap: 8px;
  cursor: default;
}
.domain-card::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(400px 140px at 20% -20%, var(--card-glow, rgba(125,211,252,.18)), transparent 70%);
  opacity: 0; transition: opacity .3s;
}
.domain-card:hover { transform: translateY(-4px); border-color: var(--line-strong); }
.domain-card:hover::before { opacity: 1; }
.dc-top { display: flex; align-items: center; gap: 10px; position: relative; }
.dc-icon { font-size: 26px; line-height: 1; filter: drop-shadow(0 2px 10px var(--card-glow)); }
.dc-name { font-family: var(--serif); font-weight: 700; font-size: 17px; }
.dc-meta { font-size: 12px; color: var(--faint); display: flex; gap: 12px; }
.dc-bar { height: 4px; border-radius: 99px; background: rgba(148,163,184,.12); position: relative; overflow: hidden; }
.dc-bar i {
  position: absolute; inset: 0; border-radius: 99px;
  background: linear-gradient(90deg, var(--card-accent, #7dd3fc), transparent);
  width: 0%; transition: width .6s var(--ease);
  box-shadow: 0 0 12px var(--card-glow);
}
.dc-done { font-size: 12px; color: var(--muted); }

/* ============================================================
   答题页
   ============================================================ */
.quiz-layout { max-width: 760px; margin: 34px auto 0; }
.quiz-progress { margin-bottom: 26px; }
.progress-meta {
  display: flex; justify-content: space-between;
  font-size: 13px; color: var(--muted); margin-bottom: 8px;
  font-family: var(--mono);
}
.progress-track { position: relative; height: 6px; border-radius: 99px; background: rgba(148,163,184,.12); }
/* 100 题里程碑刻度 */
.progress-tick {
  position: absolute; left: 16.8%; top: 50%; transform: translate(-50%, -50%);
  width: 2px; height: 18px; pointer-events: none; z-index: 1;
}
.progress-tick::before { content: ""; position: absolute; inset: 0; background: rgba(125, 211, 252, .6); border-radius: 2px; }
.progress-tick i { position: absolute; left: 50%; top: 100%; transform: translateX(-50%); margin-top: 3px; font-style: normal; font-size: 11px; color: var(--faint); white-space: nowrap; }
.progress-fill {
  height: 100%; width: 0%; border-radius: 99px;
  background: linear-gradient(90deg, #38bdf8, #a78bfa);
  transition: width .4s var(--ease);
  box-shadow: 0 0 16px rgba(56, 189, 248, .5);
}

.q-card {
  background: var(--panel);
  border: 1px solid var(--line); border-radius: 22px;
  padding: 30px 30px 22px;
  backdrop-filter: blur(8px);
  box-shadow: 0 24px 60px -30px rgba(0, 0, 0, .8);
}
.q-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.tag {
  font-size: 12px; padding: 4px 12px; border-radius: 999px;
  border: 1px solid var(--line-strong); color: var(--muted);
  letter-spacing: .04em;
}
.tag-domain { color: var(--accent); border-color: rgba(125,211,252,.35); background: rgba(125,211,252,.08); }
.tag-diff-hard { color: var(--bad); border-color: rgba(251,113,133,.4); background: rgba(251,113,133,.08); }
.tag-diff-medium { color: #fbbf24; border-color: rgba(251,191,36,.4); background: rgba(251,191,36,.08); }
.tag-diff-easy { color: var(--ok); border-color: rgba(52,211,153,.4); background: rgba(52,211,153,.08); }

.q-text {
  font-family: var(--serif); font-size: clamp(21px, 3vw, 26px);
  line-height: 1.55; font-weight: 600; margin: 0 0 26px;
}

.q-options { display: grid; gap: 12px; }
.opt {
  display: flex; align-items: flex-start; gap: 14px;
  text-align: left; width: 100%;
  background: rgba(148, 163, 184, .05);
  border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; cursor: pointer; color: var(--text);
  font-family: inherit; font-size: 15.5px; line-height: 1.6;
  transition: border-color .16s, background .16s, transform .16s var(--ease);
}
.opt:hover { border-color: var(--line-strong); background: rgba(148,163,184,.09); transform: translateX(3px); }
.opt-key {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 8px;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700; color: var(--muted);
  background: rgba(148,163,184,.12); transition: all .16s;
  margin-top: 2px;
}
.opt:hover .opt-key { color: var(--accent); background: rgba(125,211,252,.15); }
.opt.is-correct { border-color: var(--ok); background: rgba(52,211,153,.1); }
.opt.is-correct .opt-key { background: var(--ok); color: #04210f; }
.opt.is-wrong { border-color: var(--bad); background: rgba(251,113,133,.08); }
.opt.is-wrong .opt-key { background: var(--bad); color: #fff; }
.opt.is-forgiven { border-color: #fbbf24; background: rgba(251,191,36,.1); }
.opt.is-forgiven .opt-key { background: #fbbf24; color: #1f1300; }
.opt.is-dim { opacity: .45; }

.btn-forgive {
  margin-top: 14px;
  background: rgba(251, 191, 36, .12); color: #fbbf24; border-color: rgba(251, 191, 36, .4);
}
.btn-forgive:hover { background: rgba(251, 191, 36, .2); transform: translateY(-1px); }

.q-feedback { margin-top: 22px; border-top: 1px dashed var(--line); padding-top: 18px; }
.fb-text { margin: 0 0 18px; font-size: 14.5px; color: var(--muted); }
.fb-text .fb-head { color: var(--ok); font-weight: 700; margin-right: 6px; }
.fb-text .fb-head.bad { color: var(--bad); }
.q-nav { display: flex; gap: 10px; align-items: center; margin-top: 22px; }
.nav-spacer { flex: 1; }
#btn-skip { margin-left: auto; }

/* ============================================================
   结果页
   ============================================================ */
.result-head { text-align: center; padding: 56px 0 40px; }
.result-title {
  font-family: var(--serif); font-size: clamp(34px, 6vw, 54px);
  margin: 0 0 34px; font-weight: 700;
}
.result-score-row { display: flex; gap: 34px; align-items: center; justify-content: center; flex-wrap: wrap; }
.score-ring {
  width: 190px; height: 190px; border-radius: 50%;
  /* 实心弧 = 得分；浅色段 = ±浮动范围；其余为底 */
  background: conic-gradient(
    var(--ring-color, #38bdf8) var(--ring-score, 0%),
    var(--ring-range, rgba(125, 211, 252, .35)) var(--ring-score, 0%),
    var(--ring-range, rgba(125, 211, 252, .35)) var(--ring-score-max, 0%),
    rgba(148, 163, 184, .1) var(--ring-score-max, 0%),
    rgba(148, 163, 184, .1) 100%
  );
  display: grid; place-items: center;
  box-shadow: 0 0 60px -18px var(--ring-color, #38bdf8);
  transition: background .6s var(--ease);
}
.score-warn {
  margin: 22px auto 0; max-width: 600px;
  font-size: 14px; color: #fbbf24;
  background: rgba(251, 191, 36, .08); border: 1px solid rgba(251, 191, 36, .3);
  border-radius: 12px; padding: 10px 18px;
}
.score-warn.strong { color: var(--bad); background: rgba(251, 113, 133, .08); border-color: rgba(251, 113, 133, .35); }
.score-warn i { margin-right: 8px; }
.score-ring-inner {
  width: 156px; height: 156px; border-radius: 50%;
  background: var(--ink-2); display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 1px solid var(--line);
}
.score-num { font-family: var(--mono); font-size: 44px; font-weight: 700; color: var(--text); line-height: 1; }
.score-margin { font-family: var(--mono); font-size: 15px; font-weight: 600; color: var(--faint); margin-top: 5px; }
.score-label { font-size: 12px; color: var(--faint); margin-top: 8px; letter-spacing: .1em; }
.score-meta { text-align: left; max-width: 340px; }
.score-meta p { margin: 6px 0; font-size: 15px; color: var(--muted); }
.score-meta b { color: var(--text); }
.score-desc { font-size: 13.5px !important; color: var(--faint) !important; }

.result-body { display: grid; grid-template-columns: minmax(340px, 1.1fr) minmax(300px, 1fr); gap: 20px; align-items: start; }
@media (max-width: 820px) { .result-body { grid-template-columns: 1fr; } }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 22px;
  padding: 26px;
  backdrop-filter: blur(8px);
}
.radar-wrap { display: flex; flex-direction: column; align-items: center; }
/* 固定 1:1，随容器缩放不变形（内部按 DPR 高清绘制） */
#radar { display: block; width: min(560px, 100%); height: auto; aspect-ratio: 1 / 1; }
.radar-legend { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 12px; max-width: 520px; }
.legend-item { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; }

.rank-list { display: grid; gap: 10px; }

/* 疆域明细：可见滑条，提示可滚动 */
.domain-rank {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.domain-rank::-webkit-scrollbar { width: 8px; }
.domain-rank::-webkit-scrollbar-track { background: transparent; }
.domain-rank::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; }
.domain-rank::-webkit-scrollbar-thumb:hover { background: var(--muted); }
.rank-row {
  display: grid; grid-template-columns: 34px 1fr 58px;
  gap: 12px; align-items: center;
  padding: 9px 12px; border-radius: 12px;
  background: rgba(148,163,184,.04); border: 1px solid var(--line);
}
.rank-idx { font-family: var(--mono); font-size: 12px; color: var(--faint); }
.rank-main { min-width: 0; }
.rank-name { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.rank-name .ic { font-size: 16px; }
.rank-bar { position: relative; height: 7px; border-radius: 99px; background: rgba(148,163,184,.1); overflow: hidden; margin-top: 4px; }
.rank-bar i { position: absolute; inset: 0; border-radius: 99px; background: var(--row-color); width: 0%; transition: width .6s var(--ease); }
.rank-name small { color: var(--faint); font-weight: 400; font-size: 11px; }
.rank-num { font-family: var(--mono); font-size: 15px; text-align: right; color: var(--text); }
.rank-num small { color: var(--faint); font-size: 11px; display: block; }
.rank-num.low { color: var(--faint); }
.rank-row.low .rank-bar i { background: repeating-linear-gradient(45deg, var(--row-color), var(--row-color) 4px, transparent 4px, transparent 8px); opacity: .6; }

.result-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 34px; }

.footer { position: relative; z-index: 2; text-align: center; padding: 40px 24px 30px; color: var(--faint); font-size: 12.5px; }
.footer p { margin: 4px 0; }
.footer-links { display: flex; gap: 10px; justify-content: center; align-items: center; font-size: 13px; }
.footer-links a { color: var(--muted); text-decoration: none; transition: color .18s; }
.footer-links a:hover { color: var(--accent); }

/* 首页信息区 */
.home-info {
  margin-top: 72px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px;
}
@media (max-width: 820px) { .home-info { grid-template-columns: 1fr; } }
.info-block {
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
  padding: 26px 26px 22px;
}
.info-block h2 {
  font-family: var(--serif); font-size: 19px; margin: 0 0 14px;
  display: flex; align-items: center; gap: 10px; color: var(--accent);
}
.info-block ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.info-block li { font-size: 14.5px; color: var(--muted); line-height: 1.7; }
.info-block li b { color: var(--text); }
.info-block p { font-size: 14.5px; color: var(--muted); line-height: 1.8; margin: 0 0 12px; }
.info-block p:last-child { margin-bottom: 0; }
.info-block p b { color: var(--text); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%);
  background: var(--panel-solid); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 12px;
  padding: 12px 22px; font-size: 14px; z-index: 99;
  box-shadow: 0 14px 40px -12px rgba(0,0,0,.8);
  animation: toastIn .3s var(--ease);
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

#score-avg { color: var(--faint); font-size: 13.5px !important; }

/* 低对比提示 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .brand-mark { animation: none; }
}
