/* ============================================================
   科举刷题 · H5 网页版样式
   设计语言：宣纸底 + 墨色字 + 朱砂点缀 + 金榜质感
   ============================================================ */
:root {
  --paper: #f6f1e7;
  --paper-2: #efe7d8;
  --ink: #22262b;
  --ink-2: #4c535c;
  --ink-3: #8a919b;
  --line: rgba(34, 38, 43, 0.1);
  --vermilion: #b3423a;
  --vermilion-soft: rgba(179, 66, 58, 0.1);
  --gold: #b98829;
  --gold-soft: rgba(185, 136, 41, 0.12);
  --jade: #2f6f6a;
  --jade-soft: rgba(47, 111, 106, 0.12);
  --card: #fffdf8;
  --radius: 18px;
  --shadow-sm: 0 1px 2px rgba(34, 38, 43, 0.06), 0 4px 14px rgba(34, 38, 43, 0.05);
  --shadow: 0 2px 6px rgba(34, 38, 43, 0.07), 0 12px 32px rgba(34, 38, 43, 0.08);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 18% 12%, rgba(185, 136, 41, 0.07), transparent 42%),
    radial-gradient(circle at 82% 78%, rgba(47, 111, 106, 0.06), transparent 46%);
  z-index: 0;
}

h1, h2, h3, h4, .serif {
  font-family: "Songti SC", "Noto Serif SC", "SimSun", serif;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ---------------- 外壳 ---------------- */
.app-shell {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
}

@media (min-width: 900px) {
  body { background: #e9e2d4; }
  .app-shell {
    margin: 24px auto;
    min-height: calc(100vh - 48px);
    height: calc(100vh - 48px);
    border-radius: 26px;
    box-shadow: var(--shadow);
    overflow: hidden;
  }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 10px;
  position: sticky;
  top: 0;
  background: linear-gradient(var(--paper) 72%, rgba(246, 241, 231, 0));
  z-index: 20;
}

.topbar-title {
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.topbar-right { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); }

.page {
  flex: 1;
  padding: 0 16px 96px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.loading { padding: 60px 0; text-align: center; color: var(--ink-3); }

/* ---------------- 底部导航 ---------------- */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 8px 8px calc(8px + var(--safe-bottom));
  background: rgba(255, 253, 248, 0.9);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  z-index: 30;
}

.tab {
  border: 0;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  font-size: 11px;
  color: var(--ink-3);
  cursor: pointer;
  transition: color 0.16s ease;
}

.tab-icon { font-size: 19px; filter: grayscale(0.6); transition: filter 0.16s ease; }
.tab.active { color: var(--vermilion); font-weight: 600; }
.tab.active .tab-icon { filter: none; }

@media (min-width: 900px) {
  .tabbar { position: sticky; bottom: 0; transform: none; left: auto; }
}

/* ---------------- 通用卡片 ---------------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}

.card-tight { padding: 12px 14px; }

.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 10px; }

.muted { color: var(--ink-3); font-size: 12.5px; }
.strong { font-weight: 600; }
.small { font-size: 12.5px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--paper-2);
  color: var(--ink-2);
}
.pill-gold { background: var(--gold-soft); color: #8a6415; }
.pill-vermilion { background: var(--vermilion-soft); color: var(--vermilion); }
.pill-jade { background: var(--jade-soft); color: var(--jade); }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 13px 18px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.16s ease, background 0.16s ease;
  background: var(--paper-2);
  color: var(--ink);
}
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(160deg, #b8483f, #9a352d);
  color: #fff;
  box-shadow: 0 6px 18px rgba(179, 66, 58, 0.26);
}
.btn-gold {
  background: linear-gradient(160deg, #c9a227, #a8801c);
  color: #fff;
  box-shadow: 0 6px 18px rgba(185, 136, 41, 0.26);
}
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink-2); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 11px; }

/* ---------------- 首页：段位 ---------------- */
.rank-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(150deg, #2b2f36, #1d2026 62%);
  color: #f2ecdd;
  border-radius: 22px;
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.rank-card::after {
  content: "";
  position: absolute;
  right: -42px;
  top: -52px;
  width: 170px;
  height: 170px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201, 162, 39, 0.34), transparent 66%);
}
.rank-name {
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.14em;
  margin: 2px 0 0;
}
.rank-sub { font-size: 12px; color: rgba(242, 236, 221, 0.62); letter-spacing: 0.06em; }
.rank-bar {
  position: relative;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
  margin-top: 12px;
}
.rank-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #c9a227, #e7cf74);
  transition: width 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}
.rank-meta { display: flex; justify-content: space-between; font-size: 11.5px; margin-top: 8px; color: rgba(242, 236, 221, 0.66); }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 10px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.stat-num { font-family: "Songti SC", "Noto Serif SC", serif; font-size: 22px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.stat-num.accent { color: var(--vermilion); }
.stat-num.jade { color: var(--jade); }
.stat-num.gold { color: var(--gold); }

/* ---------------- 关卡地图 ---------------- */
.subject-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.subject-tabs::-webkit-scrollbar { display: none; }
.subject-tab {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 7px 15px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.subject-tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.level-list { display: flex; flex-direction: column; gap: 10px; position: relative; }
.level-list::before {
  content: "";
  position: absolute;
  left: 25px;
  top: 12px;
  bottom: 12px;
  width: 2px;
  background: repeating-linear-gradient(var(--line) 0 6px, transparent 6px 12px);
}
.level-node {
  position: relative;
  display: flex;
  gap: 14px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 13px 14px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}
.level-node:active { transform: scale(0.99); }
.level-node.locked { opacity: 0.56; cursor: not-allowed; }
.level-dot {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-family: "Songti SC", serif;
  background: var(--paper-2);
  color: var(--ink-2);
  border: 1px solid var(--line);
  z-index: 1;
}
.level-node.done .level-dot { background: linear-gradient(150deg, #c9a227, #a8801c); color: #fff; border-color: transparent; }
.level-title { font-weight: 600; font-size: 15px; }
.level-sub { font-size: 12px; color: var(--ink-3); margin-top: 1px; }
.stars { color: var(--gold); font-size: 13px; letter-spacing: 1px; }
.stars .off { color: rgba(34, 38, 43, 0.16); }

/* ---------------- 答题 ---------------- */
.quiz-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.progress-track { flex: 1; height: 6px; border-radius: 999px; background: var(--paper-2); overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--vermilion), #d1746c); border-radius: 999px; transition: width 0.3s ease; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 14px; color: var(--vermilion); }

.question-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}
.question-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.question-stem {
  font-size: 16.5px;
  line-height: 1.78;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.options { display: flex; flex-direction: column; gap: 9px; margin-bottom: 14px; }
.option {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  text-align: left;
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 13px 14px;
  font-size: 15px;
  line-height: 1.6;
  font-family: inherit;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease, transform 0.1s ease;
}
.option:active { transform: scale(0.995); }
.option-key {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 12.5px;
  font-weight: 700;
  background: var(--paper-2);
  color: var(--ink-2);
}
.option.correct { border-color: rgba(47, 111, 106, 0.5); background: var(--jade-soft); }
.option.correct .option-key { background: var(--jade); color: #fff; }
.option.wrong { border-color: rgba(179, 66, 58, 0.5); background: var(--vermilion-soft); }
.option.wrong .option-key { background: var(--vermilion); color: #fff; }
.option.dimmed { opacity: 0.62; }
.option.disabled { cursor: default; }

.explain {
  border-radius: 18px;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
  animation: rise 0.28s ease both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.explain-head { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 8px; }
.explain-head.ok { color: var(--jade); }
.explain-head.no { color: var(--vermilion); }
.explain-body { font-size: 14.5px; line-height: 1.8; color: var(--ink-2); white-space: pre-wrap; }
.explain-sub { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.explain-sub-title { font-size: 12px; font-weight: 700; color: var(--ink-3); letter-spacing: 0.06em; margin-bottom: 6px; }
.option-analysis { display: flex; gap: 8px; font-size: 13.5px; color: var(--ink-2); margin-bottom: 5px; }
.option-analysis b { color: var(--ink); }

.source-card {
  margin-top: 12px;
  border-radius: 14px;
  padding: 12px;
  background: var(--gold-soft);
  border: 1px solid rgba(185, 136, 41, 0.24);
}
.source-title { font-size: 13px; font-weight: 700; color: #8a6415; }
.source-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  font-size: 13px;
  color: #8a6415;
  text-decoration: none;
  border-bottom: 1px solid rgba(185, 136, 41, 0.5);
  word-break: break-all;
}

/* ---------------- 结算 ---------------- */
.result-hero { text-align: center; padding: 22px 0 8px; }
.result-stars { font-size: 40px; letter-spacing: 6px; color: var(--gold); line-height: 1.1; }
.result-stars .off { color: rgba(34, 38, 43, 0.14); }
.result-title { font-family: "Songti SC", serif; font-size: 25px; font-weight: 700; margin: 10px 0 4px; letter-spacing: 0.1em; }
.star-pop { display: inline-block; animation: starPop 0.5s cubic-bezier(0.22, 1.4, 0.4, 1) both; }
@keyframes starPop {
  from { transform: scale(0.2) rotate(-25deg); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.kv-list { display: flex; flex-direction: column; gap: 0; }
.kv { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--ink-3); }
.kv span:last-child { font-weight: 700; }

/* ---------------- 列表项 ---------------- */
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 4px;
  border-bottom: 1px dashed var(--line);
  cursor: pointer;
}
.list-item:last-child { border-bottom: 0; }
.list-main { flex: 1; min-width: 0; }
.list-title { font-size: 14.5px; font-weight: 600; }
.list-sub { font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-arrow { color: var(--ink-3); font-size: 15px; }

/* ---------------- 图表 ---------------- */
.bars { display: flex; align-items: flex-end; gap: 7px; height: 96px; padding-top: 8px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.bar {
  width: 100%;
  min-height: 3px;
  border-radius: 7px 7px 3px 3px;
  background: linear-gradient(180deg, #d1746c, var(--vermilion));
  transition: height 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.bar.zero { background: var(--paper-2); }
.bar-label { font-size: 10.5px; color: var(--ink-3); }

/* ---------------- 成就 ---------------- */
.badge-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.badge {
  text-align: center;
  padding: 10px 4px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--card);
}
.badge.locked { opacity: 0.4; }
.badge-icon { font-size: 22px; }
.badge-name { font-size: 10.5px; margin-top: 4px; color: var(--ink-2); }

/* ---------------- 排行榜 ---------------- */
.rank-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px dashed var(--line); }
.rank-row:last-child { border-bottom: 0; }
.rank-no {
  width: 26px;
  height: 26px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 12.5px;
  font-weight: 700;
  background: var(--paper-2);
  color: var(--ink-2);
}
.rank-row.top1 .rank-no { background: linear-gradient(150deg, #e2c356, #b98829); color: #fff; }
.rank-row.top2 .rank-no { background: linear-gradient(150deg, #cfd6de, #a8b3bf); color: #fff; }
.rank-row.top3 .rank-no { background: linear-gradient(150deg, #d8a97c, #b57e4f); color: #fff; }
.rank-name { flex: 1; font-size: 14.5px; font-weight: 600; }
.rank-score { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--gold); }

/* ---------------- 申论 ---------------- */
.material-excerpt {
  font-size: 14px;
  line-height: 1.85;
  color: var(--ink-2);
  border-left: 3px solid var(--gold);
  padding-left: 12px;
  margin: 10px 0;
  font-family: "Songti SC", serif;
}
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* ---------------- 空状态 ---------------- */
.empty { text-align: center; padding: 46px 20px; color: var(--ink-3); }
.empty-icon { font-size: 34px; margin-bottom: 8px; }
.empty-title { font-family: "Songti SC", serif; font-size: 16px; color: var(--ink-2); margin-bottom: 4px; }

/* ---------------- 提示 ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 92px;
  transform: translate(-50%, 14px);
  background: rgba(34, 38, 43, 0.92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 13.5px;
  max-width: 82vw;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 60;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- 登录 / 关于 ---------------- */
.login-wrap { padding: 44px 8px 20px; text-align: center; }
.login-seal {
  width: 74px;
  height: 74px;
  margin: 0 auto 18px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  font-family: "Songti SC", serif;
  font-size: 30px;
  color: #fff;
  background: linear-gradient(150deg, #b8483f, #8f2f28);
  box-shadow: 0 10px 30px rgba(179, 66, 58, 0.3);
}
.input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  background: var(--card);
  color: var(--ink);
  outline: none;
}
.input:focus { border-color: rgba(179, 66, 58, 0.5); }

.legal { font-size: 12.5px; line-height: 1.9; color: var(--ink-3); }
.legal h4 { color: var(--ink-2); margin: 14px 0 4px; font-size: 13.5px; }

.divider { height: 1px; background: var(--line); margin: 14px 0; }
.center { text-align: center; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; }
.hidden { display: none !important; }
