:root {
  --ink: #0F1E33;
  --ink-2: #5A6B82;
  --ink-3: #94A2B6;
  --line: #E7EDF5;
  --line-2: #D9E3F0;
  --bg: #F3F6FA;
  --card: #FFFFFF;
  --brand: #1557C0;
  --brand-d: #11469B;
  --brand-l: #EAF1FD;
  --ok: #0C9A6C;
  --ok-l: #E8F7F1;
  --bad: #DC4A4A;
  --bad-l: #FDEEEE;
  --warn: #C77A11;
  --radius: 16px;
  --shadow: 0 2px 14px rgba(15, 30, 51, .05);
  --shadow-2: 0 8px 30px rgba(15, 30, 51, .10);
}

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

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

body {
  min-height: 100vh;
}

#app {
  width: 100%;
  max-width: 430px;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  animation: fadeUp .28s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- 通用 ---------- */
.pad { padding: 0 20px; }
.mt8 { margin-top: 8px; }
.mt12 { margin-top: 12px; }
.mt16 { margin-top: 16px; }
.mt24 { margin-top: 24px; }
.muted { color: var(--ink-2); }
.tiny { font-size: 12.5px; color: var(--ink-3); line-height: 1.7; }
.center { text-align: center; }
.hidden { display: none !important; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  height: 52px;
  border: 0;
  border-radius: 14px;
  background: var(--brand);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .3px;
  font-family: inherit;
  cursor: pointer;
  transition: background .18s, transform .12s, opacity .18s;
}
.btn:active { transform: scale(.985); background: var(--brand-d); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.ghost {
  background: #fff;
  color: var(--brand);
  border: 1px solid var(--line-2);
}
.btn.ghost:active { background: var(--brand-l); }
.btn.sm { height: 42px; font-size: 14.5px; border-radius: 12px; }

/* ---------- 首页 ---------- */
.hero {
  background: linear-gradient(170deg, #EAF1FD 0%, #F3F6FA 62%);
  padding: 34px 20px 26px;
  border-radius: 0 0 26px 26px;
}

.brand-line {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  color: var(--brand);
  font-weight: 600;
  letter-spacing: 1.4px;
}
.brand-mark {
  width: 24px; height: 24px;
  border-radius: 7px;
  background: var(--brand);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

.hero h1 {
  font-size: 26px;
  line-height: 1.32;
  margin: 18px 0 8px;
  letter-spacing: -.4px;
  font-weight: 700;
}
.hero .sub {
  color: var(--ink-2);
  font-size: 14px;
  margin: 0;
}

.stats-row {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}
.stat {
  flex: 1;
  background: rgba(255,255,255,.78);
  border: 1px solid rgba(255,255,255,.9);
  border-radius: 14px;
  padding: 12px 10px;
  text-align: center;
  backdrop-filter: blur(6px);
}
.stat b {
  display: block;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -.5px;
  font-variant-numeric: tabular-nums;
}
.stat span { font-size: 11.5px; color: var(--ink-2); }

.rule-list { margin: 0; padding: 0; list-style: none; }
.rule-list li {
  display: flex;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 14px;
  color: var(--ink);
}
.rule-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.rule-list li .k {
  flex: 0 0 auto;
  color: var(--ink-3);
  width: 76px;
  font-size: 13.5px;
}
.rule-list li .v { flex: 1; }

.section-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title::before {
  content: "";
  width: 3px; height: 14px;
  border-radius: 2px;
  background: var(--brand);
}

.footer-note {
  text-align: center;
  font-size: 12px;
  color: var(--ink-3);
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
}

/* ---------- 表单 ---------- */
.form-head {
  padding: 26px 20px 14px;
}
.form-head h2 { font-size: 21px; margin: 0 0 6px; font-weight: 700; letter-spacing: -.3px; }
.form-head p { margin: 0; color: var(--ink-2); font-size: 13.5px; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--ink-2);
  margin-bottom: 7px;
  font-weight: 500;
}
.field .req { color: var(--bad); }
.field input {
  width: 100%;
  height: 50px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: #fff;
  padding: 0 15px;
  font-size: 16px;
  font-family: inherit;
  color: var(--ink);
  transition: border-color .18s, box-shadow .18s;
  -webkit-appearance: none;
}
.field input::placeholder { color: #B6C1D1; font-size: 15px; }
.field input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(21, 87, 192, .10);
}
.field.err input { border-color: var(--bad); }
.field .tip {
  font-size: 12px;
  color: var(--bad);
  margin-top: 5px;
  display: none;
}
.field.err .tip { display: block; }

.form-foot {
  padding: 8px 20px calc(20px + env(safe-area-inset-bottom));
}

/* ---------- 答题 ---------- */
.quiz-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 12px 20px 10px;
}
.quiz-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--ink-2);
}
.quiz-meta .idx b { color: var(--ink); font-size: 15px; font-variant-numeric: tabular-nums; }
.timer {
  display: flex;
  align-items: center;
  gap: 5px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  font-weight: 600;
  font-size: 14px;
  padding: 3px 10px;
  border-radius: 8px;
  background: var(--brand-l);
}
.timer.danger { color: var(--bad); background: var(--bad-l); }

.progress {
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  margin-top: 10px;
  overflow: hidden;
}
.progress i {
  display: block;
  height: 100%;
  background: var(--brand);
  border-radius: 2px;
  transition: width .3s ease;
}

.q-body {
  flex: 1;
  padding: 22px 20px 130px;
}
.q-type {
  display: inline-block;
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--brand-l);
  color: var(--brand);
  font-weight: 600;
  letter-spacing: .5px;
  margin-bottom: 12px;
}
.q-type.multi { background: #FFF4E5; color: var(--warn); }
.q-title {
  font-size: 17.5px;
  line-height: 1.62;
  font-weight: 600;
  margin: 0 0 20px;
  letter-spacing: -.1px;
  word-break: break-word;
}

.opts { display: flex; flex-direction: column; gap: 11px; }
.opt {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 15px 16px;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  transition: border-color .16s, background .16s, box-shadow .16s;
  font-size: 15px;
  line-height: 1.55;
  word-break: break-word;
}
.opt:active { background: #FAFCFF; }
.opt .key {
  flex: 0 0 24px;
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--line-2);
  color: var(--ink-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 12.5px;
  font-weight: 600;
  transition: all .16s;
  margin-top: 1px;
}
.opt.sel {
  border-color: var(--brand);
  background: var(--brand-l);
  box-shadow: 0 0 0 3px rgba(21,87,192,.07);
}
.opt.sel .key {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.quiz-foot {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 430px;
  background: rgba(255,255,255,.97);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  z-index: 30;
}
.quiz-foot .btn { flex: 1; }
.quiz-foot .btn.ghost { flex: 0 0 92px; }
.quiz-foot .btn.sheet-btn {
  flex: 0 0 68px;
  flex-direction: column;
  gap: 0;
  padding: 0;
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--ink-2);
}
.quiz-foot .btn.sheet-btn b {
  font-size: 13px;
  font-weight: 600;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}

/* 答题卡 */
.sheet-mask {
  position: fixed; inset: 0;
  background: rgba(15,30,51,.42);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s;
}
.sheet-mask.on { opacity: 1; pointer-events: auto; }
.sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform .26s cubic-bezier(.3,.8,.4,1);
  max-height: 72vh;
  overflow-y: auto;
}
.sheet-mask.on .sheet { transform: translateY(0); }
.sheet h3 { margin: 0 0 4px; font-size: 16px; font-weight: 600; }
.grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-top: 16px;
}
.grid button {
  aspect-ratio: 1;
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 11px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.grid button.done { background: var(--brand-l); border-color: #C6D9F7; color: var(--brand); }
.grid button.cur { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- 结果 ---------- */
.result-wrap { padding: 26px 20px 0; }
.score-card {
  background: linear-gradient(165deg, #1557C0 0%, #11469B 100%);
  border-radius: 20px;
  padding: 26px 22px 22px;
  color: #fff;
  text-align: center;
  box-shadow: 0 10px 28px rgba(21,87,192,.24);
  position: relative;
  overflow: hidden;
}
.score-card::after {
  content: "";
  position: absolute;
  right: -46px; top: -56px;
  width: 150px; height: 150px;
  background: rgba(255,255,255,.07);
  border-radius: 50%;
}
.score-label { font-size: 12.5px; opacity: .82; letter-spacing: 1.6px; }
.score-num {
  font-size: 58px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -2px;
  font-variant-numeric: tabular-nums;
  margin: 6px 0 2px;
}
.score-num small { font-size: 17px; font-weight: 500; opacity: .72; letter-spacing: 0; margin-left: 4px; }
.rank-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.22);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13.5px;
  margin-top: 12px;
}
.rank-chip b { font-size: 17px; font-weight: 700; }

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line);
  border-radius: 14px;
  overflow: hidden;
  margin-top: 16px;
}
.metric { background: #fff; padding: 15px 8px; text-align: center; }
.metric b {
  display: block;
  font-size: 19px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.3px;
}
.metric span { font-size: 11.5px; color: var(--ink-3); }

/* 解析 */
.detail-item {
  border-bottom: 1px solid var(--line);
  padding: 16px 0;
}
.detail-item:last-child { border-bottom: 0; }
.detail-q {
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.6;
  margin-bottom: 10px;
  display: flex;
  gap: 8px;
}
.detail-q .no { color: var(--ink-3); font-weight: 500; flex: 0 0 auto; }
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 5px;
  font-weight: 600;
  margin-left: 6px;
  vertical-align: 2px;
}
.badge.ok { background: var(--ok-l); color: var(--ok); }
.badge.bad { background: var(--bad-l); color: var(--bad); }
.badge.none { background: #F1F4F9; color: var(--ink-3); }
.detail-opt {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13.5px;
  color: var(--ink-2);
  padding: 6px 10px;
  border-radius: 8px;
  margin-bottom: 3px;
  border: 1px solid transparent;
  line-height: 1.6;
}
.detail-opt .mk {
  margin-left: auto;
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  opacity: .9;
}
.detail-opt.right { background: var(--ok-l); color: var(--ok); border-color: #CBEBDE; font-weight: 500; }
.detail-opt.wrong { background: var(--bad-l); color: var(--bad); border-color: #F7D5D5; }
.analysis {
  margin-top: 10px;
  font-size: 13px;
  color: var(--ink-2);
  background: #F7F9FC;
  border-radius: 10px;
  padding: 10px 12px;
  line-height: 1.7;
}
.analysis b { color: var(--ink); }

/* ---------- 排行榜 ---------- */
.rank-head {
  padding: 24px 20px 8px;
  text-align: center;
}
.rank-head h2 { font-size: 21px; margin: 0 0 5px; font-weight: 700; }
.rank-head p { margin: 0; font-size: 13px; color: var(--ink-2); }

.podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  padding: 22px 14px 6px;
}
.pod {
  flex: 1;
  text-align: center;
  max-width: 116px;
}
.pod .ava {
  width: 46px; height: 46px;
  border-radius: 50%;
  margin: 0 auto 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700;
  background: var(--brand-l);
  color: var(--brand);
  border: 2px solid #fff;
  box-shadow: var(--shadow);
}
.pod.p1 .ava { width: 56px; height: 56px; font-size: 19px; background: linear-gradient(160deg,#FFD874,#F0AE2C); color: #7A4E00; }
.pod.p2 .ava { background: linear-gradient(160deg,#E4EBF4,#C7D3E2); color: #5A6B82; }
.pod.p3 .ava { background: linear-gradient(160deg,#F3D6BE,#DDB18D); color: #7A4E2E; }
.pod .nm { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pod .sc { font-size: 12.5px; color: var(--brand); font-weight: 700; font-variant-numeric: tabular-nums; }
.pod .tm { font-size: 11px; color: var(--ink-3); }
.pod .bar {
  margin-top: 8px;
  border-radius: 10px 10px 0 0;
  background: linear-gradient(180deg, rgba(21, 87, 192, .11), rgba(21, 87, 192, .02));
}
.pod.p1 .bar { height: 74px; }
.pod.p2 .bar { height: 56px; }
.pod.p3 .bar { height: 44px; }

.rank-list {
  background: #fff;
  border-radius: 16px 16px 0 0;
  margin-top: 10px;
  padding: 6px 0 0;
  flex: 1;
}
.rrow {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 20px;
  border-bottom: 1px solid #F2F5F9;
}
.rrow:last-child { border-bottom: 0; }
.rrow .no {
  flex: 0 0 26px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.rrow .no.top { color: var(--brand); }
.rrow .who { flex: 1; min-width: 0; }
.rrow .who .n {
  font-size: 14.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rrow .who .d { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rrow .rt { text-align: right; flex: 0 0 auto; }
.rrow .rt b { font-size: 16px; font-variant-numeric: tabular-nums; color: var(--ink); }
.rrow .rt span { display: block; font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.rrow.me { background: var(--brand-l); }

.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-3);
  font-size: 13.5px;
}

/* ---------- 弹窗 ---------- */
.dialog-mask {
  position: fixed; inset: 0;
  background: rgba(15,30,51,.45);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.dialog-mask.on { opacity: 1; pointer-events: auto; }
.dialog {
  background: #fff;
  border-radius: 18px;
  padding: 24px 22px 20px;
  width: 100%;
  max-width: 320px;
  box-shadow: var(--shadow-2);
  transform: scale(.96);
  transition: transform .2s;
}
.dialog-mask.on .dialog { transform: scale(1); }
.dialog h3 { margin: 0 0 8px; font-size: 17px; font-weight: 700; }
.dialog p { margin: 0 0 20px; font-size: 14px; color: var(--ink-2); line-height: 1.65; }
.dialog .acts { display: flex; gap: 10px; }
.dialog .acts .btn { height: 46px; font-size: 15px; }

/* toast */
.toast {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: rgba(15,30,51,.9);
  color: #fff;
  padding: 11px 18px;
  border-radius: 12px;
  font-size: 13.5px;
  z-index: 90;
  max-width: 300px;
  text-align: center;
  line-height: 1.6;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.toast.on { opacity: 1; }

/* 顶部返回 */
.topnav {
  display: flex;
  align-items: center;
  height: 52px;
  padding: 0 12px;
  gap: 4px;
}
.topnav button {
  border: 0;
  background: transparent;
  width: 40px; height: 40px;
  border-radius: 10px;
  font-size: 20px;
  color: var(--ink);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-family: inherit;
}
.topnav button:active { background: rgba(15,30,51,.05); }
.topnav .t { font-size: 16px; font-weight: 600; }

.loading-line {
  height: 2px;
  background: var(--brand);
  position: fixed;
  top: 0; left: 0;
  width: 0;
  z-index: 100;
  transition: width .3s, opacity .3s;
}
.loading-line.on { width: 70%; }
