:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --ink: #1a2233;
  --muted: #5b6577;
  --brand: #0f766e;   /* teal */
  --brand-dark: #0b5d57;
  --accent: #f59e0b;  /* amber */
  --ok: #16a34a;
  --bad: #dc2626;
  --line: #e4e8ef;
  --radius: 14px;
  --shadow: 0 4px 20px rgba(20,40,80,.08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.55;
}
button { font-family: inherit; cursor: pointer; }
h1, h2, h3 { line-height: 1.2; }

/* ---------------- topbar ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; gap: 12px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.15rem; }
.logo { font-size: 1.3rem; }
.accent { color: var(--accent); }
.topnav { display: flex; gap: 6px; flex-wrap: wrap; }
.nav-btn {
  background: transparent; border: 1px solid transparent; color: var(--muted);
  padding: 8px 12px; border-radius: 9px; font-weight: 600; font-size: .9rem;
}
.nav-btn:hover { background: #eef1f6; color: var(--ink); }
.nav-btn.active { background: var(--brand); color: #fff; }

.container { max-width: 920px; margin: 0 auto; padding: 24px 16px 60px; }
.view { display: none; }
.view.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

/* ---------------- hero / home ---------------- */
.hero { text-align: center; padding: 36px 12px 20px; }
.hero h1 { font-size: clamp(1.8rem, 5vw, 2.8rem); margin-bottom: 12px; }
.lead { color: var(--muted); font-size: 1.1rem; max-width: 640px; margin: 0 auto 26px; }
.hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.btn {
  background: var(--brand); color: #fff; border: none; padding: 14px 24px;
  border-radius: 12px; font-size: 1.05rem; font-weight: 700; transition: transform .1s, background .2s;
}
.btn:hover { background: var(--brand-dark); transform: translateY(-2px); }
.btn-alt { background: var(--accent); }
.btn-alt:hover { background: #d97706; }
.btn-lg { padding: 16px 30px; font-size: 1.1rem; }
.btn.secondary { background: #e8ebf1; color: var(--ink); }

.feat-grid, .card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin: 28px 0; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); text-align: left;
}
.card.feat h3 { margin-bottom: 6px; font-size: 1.05rem; }
.card.feat p { color: var(--muted); font-size: .95rem; }

.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 8px 0 24px; }
.stat { text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat b { display: block; font-size: 1.8rem; color: var(--brand); }
.stat span { color: var(--muted); font-size: .85rem; }

.info-card h3 { margin-bottom: 10px; }
.test-facts { list-style: none; display: grid; gap: 10px; }
.test-facts li { padding-left: 24px; position: relative; color: var(--ink); }
.test-facts li::before { content: "✔"; position: absolute; left: 0; color: var(--ok); font-weight: 700; }
.test-facts .note::before { content: "ℹ"; color: var(--accent); }
.test-facts .note { color: var(--muted); font-size: .9rem; }

/* ---------------- landing / mode cards ---------------- */
.back { background: transparent; border: none; color: var(--muted); font-weight: 600; padding: 6px 0; margin-bottom: 8px; }
.back:hover { color: var(--ink); }
h2 { font-size: 1.7rem; margin-bottom: 6px; }
.lic-sub { color: var(--muted); margin-bottom: 20px; }
.mode-card { text-align: left; border: 2px solid transparent; }
.mode-card:hover { border-color: var(--brand); transform: translateY(-3px); }
.mode-card h3 { margin-bottom: 6px; color: var(--brand); }
.mode-card p { color: var(--muted); font-size: .95rem; }

/* ---------------- section picker ---------------- */
.section-head { color: var(--muted); margin-bottom: 14px; }
.sec-card { text-align: center; border: 2px solid transparent; }
.sec-card:hover { border-color: var(--brand); }
.sec-card h4 { color: var(--brand); margin-bottom: 4px; }
.sec-card .sec-count { font-size: .8rem; color: var(--muted); }

/* ---------------- quiz ---------------- */
.quiz-topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.quiz-score b { color: var(--brand); }
.progress-bar { background: #e8ebf1; border-radius: 20px; height: 8px; margin-bottom: 20px; overflow: hidden; }
.progress-fill { background: var(--brand); height: 100%; width: 0%; border-radius: 20px; transition: width .3s; }

.quiz-body { display: flex; flex-direction: column; gap: 14px; }
.q-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.q-cat { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); font-weight: 700; margin-bottom: 8px; }
.sign-pic { text-align: center; margin: 4px 0 14px; }
.sign-pic img { width: 150px; height: 150px; object-fit: contain; border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: #fff; box-shadow: var(--shadow); }
.q-text { font-size: 1.08rem; font-weight: 600; margin-bottom: 18px; }
.opt {
  display: block; width: 100%; text-align: left; background: #fff; border: 2px solid var(--line);
  border-radius: 10px; padding: 14px 16px; margin-bottom: 10px; font-size: 1rem; transition: border-color .15s, background .15s;
}
.opt:hover { border-color: var(--brand); }
.opt.selected { border-color: var(--brand); background: #f0fdfa; font-weight: 600; }
.opt.correct { border-color: var(--ok); background: #ecfdf3; }
.opt.wrong { border-color: var(--bad); background: #fef2f2; }
.opt.reveal-correct { border-color: var(--ok); background: #f0fdf4; }
.opt:disabled { cursor: default; }
.explanation {
  margin-top: 4px; padding: 12px 14px; background: #fff7ed; border-left: 4px solid var(--accent);
  border-radius: 8px; color: #7c4a03; font-size: .95rem;
}
.nav-row { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; }
.nav-row .btn { padding: 12px 20px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* ---------------- results ---------------- */
.result-body { text-align: center; }
.result-score {
  font-size: clamp(3rem, 12vw, 5rem); font-weight: 800; line-height: 1;
}
.result-score.ok { color: var(--ok); }
.result-score.fail { color: var(--bad); }
.result-label { font-size: 1.3rem; margin: 8px 0 4px; font-weight: 700; }
.result-pass { margin-bottom: 20px; }
.result-pass.ok { color: var(--ok); font-weight: 700; }
.result-pass.fail { color: var(--bad); font-weight: 700; }
.result-msg { color: var(--muted); max-width: 520px; margin: 0 auto 24px; }
.result-section-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 12px; margin-bottom: 24px; }
.result-section { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.result-section h4 { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.result-section .big { font-size: 1.5rem; font-weight: 800; }
.result-section .big.ok { color: var(--ok); } .result-section .big.fail { color: var(--bad); }

/* ---------------- challenge / history ---------------- */
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.history-row {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 10px; display: flex; justify-content: space-between;
  align-items: center; box-shadow: var(--shadow);
}
.history-row .pct { font-size: 1.3rem; font-weight: 800; }
.history-row .pct.ok { color: var(--ok); } .history-row .pct.fail { color: var(--bad); }
.history-row .meta { color: var(--muted); font-size: .85rem; }
.badge { font-size: .75rem; padding: 3px 9px; border-radius: 20px; font-weight: 700; }
.badge.pass { background: #ecfdf3; color: var(--ok); }
.badge.fail { background: #fef2f2; color: var(--bad); }

/* ---------------- footer ---------------- */
.footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 30px 16px; }

/* ---------------- topic sign image ---------------- */
.topic-sign { text-align: center; margin: 6px 0 16px; }
.topic-sign img { width: 168px; height: 168px; object-fit: contain; border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: #fff; box-shadow: var(--shadow); }

/* ---------------- responsive ---------------- */
@media (max-width: 560px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .nav-btn { font-size: .8rem; padding: 6px 9px; }
  .stats-row { grid-template-columns: 1fr; }
}