:root {
  --bg: #f3f6f4;
  --card: #fff;
  --text: #1c2b26;
  --muted: #5a6e66;
  --primary: #1a5f4a;
  --primary-press: #134638;
  --ok: #1a7a45;
  --bad: #b33a2e;
  --line: #d5e0db;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

header h1 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.muted { color: var(--muted); margin: 4px 0 0; font-size: 0.9rem; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 16px 0 0; line-height: 1.4; }
.rules {
  margin: 18px 0 0;
  padding: 0 0 0 1.1em;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.55;
}
.rules li { margin-bottom: 8px; }
.rules strong { color: var(--text); }

.panel {
  margin-top: 20px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 1px 0 rgba(26, 95, 74, 0.06);
}
.hidden { display: none !important; }

.btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
.btn:active { transform: scale(0.99); }
.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn.primary:active { background: var(--primary-press); }
.btn.ghost {
  background: transparent;
  font-weight: 500;
  color: var(--muted);
}
.btn:disabled { opacity: 0.45; cursor: default; }

.badge {
  display: inline-block;
  min-width: 1.4em;
  padding: 0 6px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--bad);
  color: #fff;
  font-size: 0.75rem;
  line-height: 1.4;
}
.badge:empty, .badge[data-zero="1"] { display: none; }

label {
  display: block;
  font-weight: 600;
  margin-bottom: 12px;
}
select {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 1rem;
  background: #fff;
}

.bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 0.9rem;
  color: var(--muted);
}
.progress-btn {
  margin: 0;
  padding: 4px 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: default;
}
.progress-btn.tappable {
  cursor: pointer;
  background: #e8f2ee;
  color: var(--primary);
  font-weight: 600;
}
.progress-btn.tappable:active { background: #d5e8df; }
.tag {
  background: #e8f2ee;
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
}

.type-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
}
.type-chip {
  flex: 1 1 auto;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fafcfb;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.type-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.type-chip:active { transform: scale(0.98); }

.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  padding: 0;
  background: rgba(20, 36, 30, 0.45);
  cursor: pointer;
}
.sheet-panel {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  max-height: min(72vh, 560px);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.12);
  padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.sheet-head h3 {
  margin: 0;
  font-size: 1rem;
}
.sheet-x {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 6px 8px;
  cursor: pointer;
}
.jump-grid {
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 6px;
  padding-bottom: 4px;
}
.jump-n {
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafcfb;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.jump-n.done {
  background: #eaf4f0;
  border-color: #b8d4c8;
  color: var(--primary);
}
.jump-n.current {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.jump-n:active { transform: scale(0.96); }
.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.02em;
}
.timer.urgent { color: var(--bad); }

.qtype {
  margin: 0 0 6px;
  font-size: 0.8rem;
}
.q {
  margin: 0 0 14px;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.5;
}

.opts { display: grid; gap: 8px; }
.opt {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafcfb;
  font-size: 0.98rem;
  cursor: pointer;
  line-height: 1.45;
}
.opt .key {
  display: inline-block;
  width: 1.4em;
  font-weight: 700;
  color: var(--primary);
}
.opt .check {
  display: inline-block;
  width: 1.3em;
  color: var(--primary);
  font-weight: 700;
}
.opt.selected { border-color: var(--primary); background: #eaf4f0; }
.opt.correct { border-color: var(--ok); background: #e8f6ee; }
.opt.wrong { border-color: var(--bad); background: #fceceb; }
.opt:disabled { cursor: default; }

.feedback {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.92rem;
}
.feedback.ok { background: #e8f6ee; color: var(--ok); }
.feedback.bad { background: #fceceb; color: var(--bad); }

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}
.actions .btn { margin-top: 0; }
.submit-early {
  margin-top: 10px;
  border-color: var(--primary);
  color: var(--primary);
  background: #eaf4f0;
}
.submit-early:active { background: #d5e8df; }
.quit { margin-top: 8px; font-size: 0.9rem; }

#result h2 {
  margin: 8px 0;
  font-size: 2rem;
  text-align: center;
  color: var(--primary);
}
#score-detail { text-align: center; margin-bottom: 16px; }
.pass-tag {
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
}
.pass-tag.ok { color: var(--ok); }
.pass-tag.bad { color: var(--bad); }
