/* ===== 星空刷题 · 多邻国风格 ===== */
:root {
  --green: #58cc02;
  --green-dark: #46a302;
  --blue: #1cb0f6;
  --red: #ff5b5b;
  --yellow: #ffc800;
  --purple: #ce82ff;
  --ink: #3c3c3c;
  --gray: #afafaf;
  --gray-light: #e5e5e5;
  --bg: #ffffff;
  --bg-soft: #f7f7f7;
  --border: #d9d9d9;
  --radius: 14px;
  --shadow: 0 4px 0 var(--border);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }
body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg-soft);
  line-height: 1.5;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 0 24px rgba(0,0,0,.06);
}

.hidden { display: none !important; }
[hidden] { display: none !important; }
.muted { color: var(--gray); }

.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 20px; overflow-y: auto; }
.screen.quiz { overflow: hidden; }

/* ===== 通用按钮 ===== */
.btn {
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: .5px;
  padding: 15px 20px;
  cursor: pointer;
  transition: transform .05s, filter .15s;
  text-transform: uppercase;
  color: #fff;
  background: var(--green);
  box-shadow: 0 4px 0 var(--green-dark);
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--green-dark); }
.btn-primary { background: var(--green); }
.btn-ghost { background: #fff; color: var(--green-dark); border: 2px solid var(--gray-light); box-shadow: 0 4px 0 var(--gray-light); }
.btn-block { width: 100%; margin-top: 14px; }

.icon-btn {
  border: none; background: transparent; font-size: 22px; color: var(--gray);
  cursor: pointer; width: 36px; height: 36px; border-radius: 8px;
}
.icon-btn:active { background: var(--bg-soft); }

/* ===== 主页 ===== */
.home-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { font-size: 34px; }
.brand h1 { font-size: 22px; color: var(--ink); }
.brand-sub { font-size: 12px; color: var(--gray); font-weight: 600; }
.streak-pill {
  display: flex; align-items: center; gap: 4px; font-weight: 800; color: #ff9600;
  background: #fff3e0; padding: 6px 12px; border-radius: 999px; font-size: 16px;
}
.flame { font-size: 18px; }

.hero-card {
  display: flex; gap: 20px; align-items: center;
  background: linear-gradient(135deg, #f0faff, #eafce0);
  border: 2px solid var(--gray-light);
  border-radius: 20px; padding: 20px; margin-bottom: 8px;
}
.hero-ring { position: relative; width: 120px; height: 120px; flex-shrink: 0; }
.ring-svg { width: 120px; height: 120px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--gray-light); stroke-width: 12; }
.ring-fg {
  fill: none; stroke: var(--green); stroke-width: 12; stroke-linecap: round;
  stroke-dasharray: 326.7; stroke-dashoffset: 326.7;
  transition: stroke-dashoffset .6s ease;
}
.ring-label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 2px; }
.ring-label strong { font-size: 30px; color: var(--ink); line-height: 1; }
.ring-label span { font-size: 14px; color: var(--gray); font-weight: 700; line-height: 1; }

.hero-info h2 { font-size: 20px; margin-bottom: 4px; }
.hero-info p { font-size: 13px; margin-bottom: 12px; }
.hero-stats { display: grid; grid-template-columns: auto repeat(3, 1fr); gap: 4px 14px; align-items: center; }
.hs-cell { display: flex; flex-direction: column; }
.hs-head { font-size: 11px; color: var(--gray); font-weight: 700; }
.hs-rowlabel { font-size: 12px; color: var(--gray); font-weight: 700; }
.hero-stats span { font-size: 18px; font-weight: 800; color: var(--blue); line-height: 1.1; }
.hero-stats .hs-hist { color: var(--gray); }

.stat { display: flex; flex-direction: column; }
.stat span { font-size: 18px; font-weight: 800; color: var(--blue); }
.stat small { font-size: 11px; color: var(--gray); }

.bank-note { margin-top: auto; padding-top: 24px; text-align: center; font-size: 12px; color: var(--gray); }

/* ===== 错题集卡片 ===== */
.wrong-card {
  display: flex; align-items: center; gap: 12px;
  border: 2px solid var(--gray-light); border-bottom-width: 4px; border-radius: var(--radius);
  background: #fff; padding: 12px 16px; margin-bottom: 6px;
}
.wrong-emoji { font-size: 26px; }
.wrong-info { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.wrong-info strong { font-size: 15px; }
.wrong-info small { font-size: 12px; color: var(--gray); }
.wrong-card.empty { opacity: .6; }
.btn-wrong {
  background: var(--red); box-shadow: 0 4px 0 #d64545;
  font-size: 13px; padding: 10px 14px; margin: 0; flex-shrink: 0;
}
.btn-wrong:active { transform: translateY(3px); box-shadow: 0 1px 0 #d64545; }
.btn-wrong-hist { background: #f59e0b; box-shadow: 0 4px 0 #d97706; }
.btn-wrong-hist:active { transform: translateY(3px); box-shadow: 0 1px 0 #d97706; }

/* ===== 答题页 ===== */
.quiz-top { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.progress-track { flex: 1; height: 16px; background: var(--gray-light); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--green); border-radius: 999px; transition: width .3s ease; }
.quiz-counter { font-weight: 800; color: var(--gray); font-size: 14px; min-width: 40px; text-align: right; }

.quiz-body { flex: 1; min-height: 0; overflow-y: auto; padding-bottom: 20px; }
.q-meta { display: flex; gap: 8px; margin-bottom: 14px; }
.badge { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.badge-source { background: #eef6ff; color: var(--blue); }
.badge-type { background: #f3e9ff; color: var(--purple); }
.q-stem { font-size: 19px; font-weight: 700; line-height: 1.55; margin-bottom: 24px; }

.q-options { display: flex; flex-direction: column; gap: 12px; }
.opt {
  border: 2px solid var(--gray-light); border-bottom-width: 4px; border-radius: var(--radius);
  background: #fff; padding: 15px 16px; font-size: 16px; cursor: pointer; text-align: left;
  display: flex; align-items: center; gap: 12px; transition: background .12s, border-color .12s;
  color: var(--ink); font-weight: 600;
}
.opt .opt-key {
  width: 26px; height: 26px; flex-shrink: 0; border-radius: 6px; border: 2px solid var(--gray-light);
  display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--gray); font-weight: 800;
}
.opt:hover { background: var(--bg-soft); }
.opt.selected { border-color: var(--blue); background: #ddf4ff; color: #1873aa; }
.opt.selected .opt-key { border-color: var(--blue); color: #1873aa; }
.opt.correct { border-color: var(--green); background: #d7ffb8; color: var(--green-dark); }
.opt.correct .opt-key { border-color: var(--green); color: var(--green-dark); }
.opt.wrong { border-color: var(--red); background: #ffdfe0; color: #c93c3c; }
.opt.wrong .opt-key { border-color: var(--red); color: #c93c3c; }
.opt:disabled { cursor: default; }

/* 判断题两个大按钮 */
.opt-judge { justify-content: center; font-size: 18px; padding: 22px; }

/* 提交按钮（多选） */
.q-submit { margin-top: 20px; }

/* ===== 反馈条 ===== */
.feedback {
  flex-shrink: 0; margin: 0 -20px -20px; padding: 18px 20px;
  border-top: 2px solid var(--gray-light); animation: slideUp .25s ease;
  max-height: 55vh; overflow-y: auto;
}
.feedback.right { background: #d7ffb8; }
.feedback.wrong { background: #ffdfe0; }
.feedback-inner { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.feedback-icon {
  width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: #fff; flex-shrink: 0;
}
.feedback.right .feedback-icon { background: var(--green-dark); }
.feedback.wrong .feedback-icon { background: var(--red); }
.feedback-text strong { display: block; font-size: 17px; }
.feedback.right .feedback-text strong { color: var(--green-dark); }
.feedback.wrong .feedback-text strong { color: #c93c3c; }
.feedback-text p { font-size: 14px; color: var(--ink); margin-top: 2px; }
.feedback-text #feedback-answer { font-weight: 700; }
.feedback-explain { font-size: 13.5px; line-height: 1.7; color: #555; margin-top: 6px; padding-top: 6px; border-top: 1px dashed rgba(0,0,0,.12); }
.feedback .btn { margin-top: 0; }
.feedback .btn-skip {
  display: block; width: 100%; margin-top: 10px; padding: 8px;
  background: transparent; border: none; box-shadow: none; cursor: pointer;
  font-size: 14px; font-weight: 700; text-transform: none;
  color: rgba(0,0,0,.5);
}
.btn-skip:active { opacity: .6; }
.feedback.right .btn-skip { color: var(--green-dark); }
.feedback.wrong .btn-skip { color: #c93c3c; }
.feedback.right .btn { background: var(--green); }
.feedback.wrong .btn { background: var(--red); box-shadow: 0 4px 0 #d64545; }

@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ===== 结果页 ===== */
.result { justify-content: center; align-items: center; text-align: center; }
.result-card { width: 100%; max-width: 360px; }
.result-emoji { font-size: 72px; margin-bottom: 12px; animation: pop .4s ease; }
.result-card h2 { font-size: 26px; margin-bottom: 22px; }
.result-score { display: flex; justify-content: center; gap: 14px; margin-bottom: 22px; }
.score-item {
  background: var(--bg-soft); border: 2px solid var(--gray-light); border-radius: 14px;
  padding: 16px 18px; min-width: 88px;
}
.score-item span { display: block; font-size: 26px; font-weight: 800; color: var(--green-dark); }
.score-item small { font-size: 12px; color: var(--gray); }
.result-card p { margin-bottom: 8px; }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

/* ===== 顶部右侧（连击 + 账号）===== */
.home-top-right { display: flex; align-items: center; gap: 10px; }
.account-btn { font-size: 20px; background: var(--bg-soft); border: 2px solid var(--gray-light); }

/* ===== 通用表单控件 ===== */
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.field > span { font-size: 14px; font-weight: 700; color: var(--ink); }
.field input[type="text"],
.field input[type="password"],
.profile-body input[type="password"] {
  font: inherit; padding: 13px 14px; border: 2px solid var(--gray-light);
  border-radius: 12px; background: #fff; color: var(--ink); outline: none;
}
.field input:focus, .profile-body input:focus { border-color: var(--blue); }

/* 年级选择卡片 */
.grade-opts { display: flex; gap: 10px; }
.grade-opt {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: 2px solid var(--gray-light); border-radius: 12px; padding: 12px 6px;
  cursor: pointer; text-align: center; background: #fff; transition: border-color .15s, background .15s;
}
.grade-opt input { accent-color: var(--green); margin-bottom: 2px; }
.grade-opt b { font-size: 15px; }
.grade-opt small { font-size: 11px; color: var(--gray); }
.grade-opt:has(input:checked) { border-color: var(--green); background: #f3fbec; }

/* ===== 登录 / 注册页 ===== */
.auth { justify-content: center; }
.auth-card { width: 100%; max-width: 400px; margin: 0 auto; }
.brand-center { justify-content: center; text-align: center; margin-bottom: 24px; }
.auth-tabs { display: flex; background: var(--bg-soft); border-radius: 12px; padding: 4px; margin-bottom: 22px; }
.auth-tab {
  flex: 1; border: none; background: transparent; padding: 10px; border-radius: 9px;
  font-weight: 800; color: var(--gray); cursor: pointer; font-size: 15px;
}
.auth-tab.active { background: #fff; color: var(--green-dark); box-shadow: 0 2px 6px rgba(0,0,0,.08); }
.auth-error { min-height: 20px; color: var(--red); font-size: 13px; font-weight: 700; margin: -6px 0 12px; }

/* ===== 账号设置页 ===== */
.profile-title { font-size: 18px; flex: 1; text-align: center; }
.profile-body { padding-top: 8px; }
.profile-user { margin-bottom: 20px; font-size: 15px; }
.profile-user strong { color: var(--green-dark); }
.profile-body .field { border-top: 2px solid var(--gray-light); padding-top: 18px; }
.profile-body .btn { margin-top: 12px; }

/* ===== 危险按钮 ===== */
.btn-danger { background: var(--red); box-shadow: 0 4px 0 #d64545; }
.btn-danger:active { transform: translateY(3px); box-shadow: 0 1px 0 #d64545; }
