:root {
  --ink: #17211b;
  --muted: #6c7a70;
  --line: #dfe8df;
  --bg: #f4f8f2;
  --card: #ffffff;
  --green: #1f8a4c;
  --green-dark: #146637;
  --green-soft: #e8f5ec;
  --amber: #d7911e;
  --red: #c9453d;
  --blue: #3079b8;
  --shadow: 0 18px 50px rgba(28, 58, 38, 0.09);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  color: var(--ink); background:
    radial-gradient(circle at 12% 0%, #dff0e3 0, transparent 34%),
    radial-gradient(circle at 92% 8%, #e6f0fa 0, transparent 30%),
    var(--bg);
}
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 430px; background: var(--card);
  border: 1px solid var(--line); border-radius: 24px; padding: 28px;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center;
  background: var(--green-soft); font-size: 27px; flex: 0 0 auto;
}
.brand h1 { margin: 0; font-size: 25px; letter-spacing: .02em; }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.brand.small .brand-mark { width: 42px; height: 42px; border-radius: 13px; font-size: 22px; }
.brand.small strong { display: block; font-size: 16px; }
.brand.small span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

.auth-tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px;
  background: #f1f5f0; border-radius: 13px; margin: 22px 0 18px;
}
.tab {
  border: 0; background: transparent; color: var(--muted); padding: 9px;
  border-radius: 9px; font-weight: 700;
}
.tab.active { background: var(--card); color: var(--green-dark); box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.auth-form { display: flex; flex-direction: column; gap: 13px; }
.auth-form label { font-size: 13px; font-weight: 700; color: #405048; }
.auth-form input {
  display: block; width: 100%; margin-top: 6px; padding: 11px 12px;
  border: 1px solid #d7e2d8; border-radius: 10px; background: #fbfdfb;
  outline: none;
}
.auth-form input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(31,138,76,.12); }
.primary-btn {
  border: 0; border-radius: 11px; padding: 12px 16px; background: var(--green);
  color: #fff; font-weight: 800; letter-spacing: .03em; margin-top: 4px;
}
.primary-btn:hover { background: var(--green-dark); }
.primary-btn:disabled { opacity: .6; cursor: wait; }
.error { color: var(--red); background: #fdf0ef; border-radius: 9px; padding: 9px 11px; font-size: 13px; }
.auth-note { color: var(--muted); font-size: 12px; text-align: center; margin: 18px 0 0; line-height: 1.6; }

/* ---------- 主界面 ---------- */
.app { max-width: 1180px; margin: 0 auto; padding: 20px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 4px 20px;
}
.userbar { display: flex; align-items: center; gap: 10px; }
.user-name { font-weight: 800; font-size: 14px; }
.pill {
  background: var(--green-soft); color: var(--green-dark); border-radius: 999px;
  padding: 6px 11px; font-size: 12px; font-weight: 800;
}
.ghost-btn {
  border: 1px solid var(--line); background: #fff; color: #45554b;
  border-radius: 9px; padding: 7px 12px;
}
.ghost-btn:hover { border-color: #b9cbbd; }

.layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, .9fr); gap: 18px; align-items: start; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: var(--shadow); padding: 22px;
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.eyebrow { margin: 0 0 4px; color: var(--green); font-size: 10px; font-weight: 900; letter-spacing: .14em; }
.card h2 { margin: 0; font-size: 22px; }
.meta { color: var(--muted); font-size: 12px; text-align: right; line-height: 1.7; }
.theme-bar {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  margin: 12px 0 2px; padding: 9px 11px; border: 1px solid #e4eee4;
  border-radius: 11px; background: #f8fbf7;
}
.theme-bar label { font-size: 12px; font-weight: 800; color: #45594b; }
.theme-bar select {
  border: 1px solid #cfdfd2; border-radius: 8px; padding: 6px 9px;
  background: #fff; color: var(--ink); font-size: 13px; outline: none;
}
.theme-bar select:disabled { opacity: .55; cursor: not-allowed; }
.theme-hint { color: #839188; font-size: 11px; margin-left: auto; }
.icon-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 9px;
  width: 34px; height: 34px; font-size: 17px; color: #53665a;
}
.icon-btn:hover { background: var(--green-soft); }

/* 开始页 */
.hero { padding: 18px 0 4px; }
.hero h3 { font-size: 23px; margin: 0 0 10px; }
.hero p { color: var(--muted); line-height: 1.75; margin: 0 0 18px; font-size: 14px; }
.rule-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0 20px; }
.rule {
  background: #f7faf6; border: 1px solid #e5eee4; border-radius: 12px; padding: 12px;
}
.rule b { display: block; font-size: 17px; color: var(--green-dark); }
.rule span { color: var(--muted); font-size: 12px; }
.start-btn { width: 100%; padding: 14px; font-size: 16px; border-radius: 12px; }
.start-note { margin-top: 10px; color: var(--muted); font-size: 12px; text-align: center; }

/* 答题 */
.q-top { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin: 16px 0 10px; }
.progress-text { color: var(--muted); font-size: 12px; font-weight: 700; }
.timer-wrap { display: flex; align-items: center; gap: 9px; min-width: 142px; }
.timer-num { font-size: 22px; font-weight: 900; color: var(--green-dark); font-variant-numeric: tabular-nums; width: 31px; text-align: right; }
.timer-track { flex: 1; height: 9px; border-radius: 99px; background: #e8f0e8; overflow: hidden; }
.timer-fill { height: 100%; width: 100%; background: var(--green); border-radius: inherit; transition: width .12s linear, background .2s; }
.timer-fill.warn { background: var(--amber); }
.timer-fill.danger { background: var(--red); }
.q-theme { display: flex; gap: 7px; flex-wrap: wrap; margin: 4px 0 9px; }
.q-theme span { background: #f0f6ef; color: #52705a; border-radius: 6px; padding: 3px 7px; font-size: 11px; font-weight: 700; }
.q-text { font-size: 20px; line-height: 1.55; margin: 0 0 16px; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.option {
  display: flex; align-items: flex-start; gap: 10px; text-align: left;
  border: 1.5px solid #dbe6dd; background: #fff; border-radius: 12px;
  padding: 12px 13px; color: var(--ink); line-height: 1.5; min-height: 58px;
}
.option:hover:not(:disabled) { border-color: var(--green); background: #fbfefb; transform: translateY(-1px); }
.option:disabled { cursor: default; opacity: .78; }
.option .letter {
  width: 25px; height: 25px; border-radius: 7px; background: #eef4ee; color: #435647;
  display: grid; place-items: center; font-weight: 900; font-size: 13px; flex: 0 0 auto;
}
.option.correct { border-color: var(--green); background: #ecf8ef; }
.option.correct .letter { background: var(--green); color: #fff; }
.option.wrong { border-color: var(--red); background: #fdf1f0; }
.option.wrong .letter { background: var(--red); color: #fff; }

/* 反馈 */
.feedback { margin-top: 16px; border-radius: 13px; padding: 13px 14px; background: #f7faf6; border: 1px solid #e4eee4; }
.feedback.correct { background: #ecf8ef; border-color: #cfe9d5; }
.feedback.wrong { background: #fdf2f1; border-color: #f0d4d1; }
.feedback h3 { margin: 0 0 6px; font-size: 16px; }
.feedback p { margin: 4px 0; font-size: 14px; line-height: 1.65; color: #45544b; }
.feedback .answer { font-weight: 800; color: #203a29; }
.next-row { display: flex; justify-content: flex-end; margin-top: 14px; }
.next-btn { min-width: 130px; }

/* 完成 */
.finish { text-align: center; padding: 16px 4px 4px; }
.finish .trophy { font-size: 48px; }
.finish h3 { margin: 4px 0 8px; font-size: 24px; }
.finish p { color: var(--muted); }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0; }
.stat { background: #f7faf6; border: 1px solid #e4eee4; border-radius: 12px; padding: 12px; }
.stat b { display: block; font-size: 22px; color: var(--green-dark); }
.stat span { font-size: 12px; color: var(--muted); }

/* 排行榜 */
.board-sub { margin: 7px 0 12px; color: var(--muted); font-size: 12px; }
.leaderboard { display: flex; flex-direction: column; gap: 2px; }
.lb-row {
  display: grid; grid-template-columns: 26px 1fr 53px 82px; gap: 7px; align-items: center;
  padding: 9px 7px; border-radius: 9px; font-size: 13px;
}
.lb-row:nth-child(odd) { background: #fbfdfb; }
.lb-row.me { background: var(--green-soft); outline: 1px solid #cfe8d6; }
.lb-rank { font-weight: 900; color: var(--muted); text-align: center; }
.lb-row:nth-child(1) .lb-rank { color: #c78d1d; }
.lb-row:nth-child(2) .lb-rank { color: #79858d; }
.lb-row:nth-child(3) .lb-rank { color: #a46a3e; }
.lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 900; color: var(--green-dark); text-align: right; }
.lb-time { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; font-size: 12px; line-height: 1.35; }
.lb-meta { display: block; font-size: 10px; color: #8a978e; font-weight: 400; }
.board-note { color: #8a978e; font-size: 11px; line-height: 1.6; margin-top: 12px; }
.empty { color: var(--muted); text-align: center; padding: 30px 8px; font-size: 13px; line-height: 1.7; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #22372a; color: #fff; padding: 10px 16px; border-radius: 999px;
  font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.18); z-index: 20;
}
.spinner {
  width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff; border-radius: 50%; display: inline-block;
  animation: spin .7s linear infinite; vertical-align: -3px; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .board-card { order: 2; }
  .topbar { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 560px) {
  .app { padding: 12px; }
  .card { padding: 16px; border-radius: 15px; }
  .options { grid-template-columns: 1fr; }
  .q-text { font-size: 18px; }
  .rule-grid, .stat-row { grid-template-columns: 1fr; }
  .userbar { width: 100%; justify-content: space-between; }
  .user-name { display: none; }
  .lb-row { grid-template-columns: 24px 1fr 40px 55px; }
}
