:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --ink: #1c1d1f;
  --ink-soft: #5b5d63;
  --border: #e6e3da;
  --brand: #1f4d3e;
  --brand-soft: #e7f0ea;
  --gold: #a9822c;
  --correct: #1f8a4c;
  --correct-bg: #e7f6ec;
  --wrong: #c8402e;
  --wrong-bg: #fbeae7;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20,20,20,.04), 0 4px 16px rgba(20,20,20,.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1d2024;
    --ink: #f0f0ee;
    --ink-soft: #a3a7ad;
    --border: #2b2f35;
    --brand: #7fbf9e;
    --brand-soft: #1e2b25;
    --gold: #d6b25c;
    --correct: #58c37e;
    --correct-bg: #14261c;
    --wrong: #ef7362;
    --wrong-bg: #2b1917;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Malgun Gothic", sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 20px 18px 40px;
  position: relative;
}

.view.hidden { display: none; }

/* HOME */
.hero { padding: 12px 4px 20px; }
.eyebrow {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--gold);
}
.hero h1 {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -.01em;
}
.hero .sub {
  margin: 0;
  font-size: 15px;
  color: var(--ink-soft);
  line-height: 1.5;
}

.stats-row {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 8px;
  margin: 18px 0 22px;
}
.stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border-right: 1px solid var(--border);
}
.stat:last-child { border-right: none; }
.stat-num { font-size: 20px; font-weight: 800; color: var(--brand); }
.stat-label { font-size: 12px; color: var(--ink-soft); }

.menu-list { display: flex; flex-direction: column; gap: 10px; }
.menu-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--ink);
  transition: transform .12s ease, border-color .12s ease;
}
.menu-card:active { transform: scale(.98); }
.menu-icon {
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  background: var(--brand-soft);
  border-radius: 12px;
  font-size: 20px;
  flex-shrink: 0;
}
.menu-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.menu-text strong { font-size: 15.5px; font-weight: 700; }
.menu-text span { font-size: 13px; color: var(--ink-soft); }
.menu-arrow { font-size: 22px; color: var(--ink-soft); }

.reset-link {
  display: block;
  margin: 28px auto 0;
  background: none;
  border: none;
  color: var(--ink-soft);
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
  font-family: inherit;
}

/* SUBHEADER / BACK */
.subheader, .quiz-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0 18px;
}
.subheader h2 { font-size: 20px; margin: 0; font-weight: 800; }
.back-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 20px;
  color: var(--ink);
  cursor: pointer;
  flex-shrink: 0;
}

/* YEAR GRID */
.year-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.year-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: var(--ink);
}
.year-card strong { display: block; font-size: 17px; font-weight: 800; margin-bottom: 4px; }
.year-card span { font-size: 12.5px; color: var(--ink-soft); }

/* QUIZ */
.quiz-header { padding-top: 8px; }
.progress-wrap { flex: 1; display: flex; align-items: center; gap: 10px; }
.progress-bar {
  flex: 1; height: 8px; border-radius: 4px;
  background: var(--border); overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--brand);
  border-radius: 4px; transition: width .25s ease;
  width: 0%;
}
.progress-label { font-size: 13px; color: var(--ink-soft); font-weight: 600; white-space: nowrap; }

.q-meta { font-size: 12.5px; color: var(--gold); font-weight: 700; margin-bottom: 8px; }
.q-text {
  font-size: 17px; line-height: 1.55; font-weight: 600;
  margin: 0 0 18px; white-space: pre-wrap;
}

.choices { display: flex; flex-direction: column; gap: 10px; }
.choice-btn {
  display: flex; align-items: flex-start; gap: 10px;
  width: 100%; text-align: left;
  padding: 14px 14px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.45;
  color: var(--ink);
  cursor: pointer;
}
.choice-num {
  flex-shrink: 0;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 700; color: var(--ink-soft);
}
.choice-btn.correct {
  background: var(--correct-bg); border-color: var(--correct);
}
.choice-btn.correct .choice-num { background: var(--correct); border-color: var(--correct); color: #fff; }
.choice-btn.wrong {
  background: var(--wrong-bg); border-color: var(--wrong);
}
.choice-btn.wrong .choice-num { background: var(--wrong); border-color: var(--wrong); color: #fff; }
.choice-btn:disabled { cursor: default; }

.explain-box {
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--brand-soft);
  border-radius: 12px;
  border: 1px solid var(--border);
}
.explain-box.hidden { display: none; }
.explain-title { margin: 0 0 6px; font-size: 13.5px; font-weight: 800; color: var(--brand); }
.explain-body { margin: 0; font-size: 14px; line-height: 1.6; color: var(--ink); white-space: pre-wrap; }

.quiz-body { padding-bottom: 90px; }
.quiz-footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-width: 480px; margin: 0 auto;
  padding: 12px 18px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 60%, transparent);
}
.btn-next {
  width: 100%; padding: 15px;
  background: var(--brand); color: #fff;
  border: none; border-radius: 12px;
  font-size: 16px; font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
.btn-next:disabled { background: var(--border); color: var(--ink-soft); }

/* RESULT */
.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 20px;
  text-align: center;
  margin-bottom: 20px;
}
.result-score { font-size: 40px; font-weight: 800; color: var(--brand); margin: 0 0 8px; }
.result-desc { margin: 0; color: var(--ink-soft); font-size: 14px; }
