:root {
  --bg: #f5f7f6;
  --card: #ffffff;
  --text: #17201b;
  --muted: #5b6760;
  --line: #dde3df;
  --brand: #11734a;
  --brand-ink: #ffffff;
  --brand-soft: #e3f3ea;
  --ok: #11734a;
  --ok-soft: #e3f3ea;
  --bad: #b3261e;
  --bad-soft: #fbe9e7;
  --sel: #1d4ed8;
  --sel-soft: #e8eefc;
  --flag: #b45309;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1412; --card: #18201c; --text: #e8eee9; --muted: #9aa8a0; --line: #2b3530;
    --brand: #34b27b; --brand-ink: #06150e; --brand-soft: #173326;
    --ok: #4cc38a; --ok-soft: #153322; --bad: #f2867c; --bad-soft: #3a1916;
    --sel: #7aa2ff; --sel-soft: #1b2645; --flag: #f0a54a;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
a { color: var(--brand); }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }

header.top { background: var(--card); border-bottom: 1px solid var(--line); }
header.top .wrap { display: flex; align-items: center; justify-content: space-between; height: 56px; gap: 12px; }
.nav-r { display: flex; align-items: center; gap: 14px; }
header.top a.small { font-size: 14px; white-space: nowrap; }
.logo { font-weight: 700; color: var(--text); text-decoration: none; display: flex; align-items: center; gap: 8px; font-size: 16px; }
.logo b { background: var(--brand); color: var(--brand-ink); border-radius: 8px; padding: 2px 7px; font-size: 14px; }

main { padding: 20px 0 32px; }
h1 { font-size: clamp(26px, 6vw, 36px); line-height: 1.15; margin: 8px 0 10px; }
h2 { font-size: 20px; margin: 28px 0 12px; }
.lead { color: var(--muted); margin: 0 0 18px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.test-card h3 { margin: 0 0 2px; font-size: 20px; display: flex; gap: 8px; align-items: center; }
.test-card p { margin: 0 0 14px; }
.test-card.soon { opacity: .6; }
.badge { font-size: 12px; background: var(--line); color: var(--muted); border-radius: 99px; padding: 2px 8px; font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1 1 140px; }

.share { display: flex; gap: 10px; flex-wrap: wrap; }
.share a { flex: 1 1 150px; color: #fff; border: 0; }
.share .wa { background: #1f9d55; }
.share .fb { background: #1877f2; }
.share svg { width: 20px; height: 20px; fill: currentColor; }

.facts { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 6px; padding: 0; list-style: none; }
.facts li { background: var(--brand-soft); color: var(--text); border-radius: 99px; padding: 4px 12px; font-size: 14px; font-weight: 600; }

/* Question page */
.qbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 15px; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; }
.timer.low { color: var(--bad); }
.progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin-bottom: 16px; }
.progress span { display: block; height: 100%; background: var(--brand); }
.topic-tag { font-size: 13px; color: var(--muted); margin: 0 0 6px; }
.qtext { font-size: 20px; font-weight: 650; margin: 0 0 14px; line-height: 1.35; }
.sign { width: 140px; height: 140px; margin: 0 auto 16px; display: block; }
.sign svg { width: 100%; height: 100%; }
.opts { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.opt {
  width: 100%; text-align: left; display: flex; gap: 12px; align-items: flex-start;
  min-height: 56px; padding: 14px; border-radius: 12px; border: 2px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; cursor: pointer;
}
.opt .k { flex: 0 0 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.opt.sel { border-color: var(--sel); background: var(--sel-soft); }
.opt.sel .k { border-color: var(--sel); background: var(--sel); color: #fff; }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.right .k { border-color: var(--ok); background: var(--ok); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .k { border-color: var(--bad); background: var(--bad); color: #fff; }
.opt:disabled { cursor: default; }
.explain { margin-top: 14px; padding: 14px; border-radius: 12px; background: var(--brand-soft); }
.explain.bad { background: var(--bad-soft); }
.explain strong { display: block; margin-bottom: 4px; }
.nav { margin-top: 18px; }
.flag-btn.on { color: var(--flag); border-color: var(--flag); }

.overview { margin-top: 14px; }
.overview summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.qgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; margin-top: 8px; }
.qgrid a { display: grid; place-items: center; height: 44px; border-radius: 10px; border: 1px solid var(--line); text-decoration: none; color: var(--text); font-weight: 600; font-size: 15px; }
.qgrid a.done { background: var(--sel-soft); border-color: var(--sel); }
.qgrid a.flag { box-shadow: inset 0 -4px 0 var(--flag); }
.qgrid a.cur { outline: 2px solid var(--text); outline-offset: 1px; }

/* Ad slot: fixed reserved height so content doesn't shift */
.ad { margin: 28px 0 0; text-align: center; min-height: 120px; }
.ad-label { display: block; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
/* When Google has no ad to show, hide the whole space (label included) */
.ad:has(ins.adsbygoogle[data-ad-status="unfilled"]), ins.adsbygoogle[data-ad-status="unfilled"] { display: none !important; }
.ad-ph { height: 100px; border: 1px dashed var(--line); border-radius: 10px; display: grid; place-items: center; color: var(--muted); font-size: 14px; }

/* Results */
.result-hero { text-align: center; }
.result-hero .big { font-size: 56px; font-weight: 800; line-height: 1; margin: 6px 0; }
.pass { color: var(--ok); }
.fail { color: var(--bad); }
.bars { display: grid; gap: 10px; }
.bar-row .lbl { display: flex; justify-content: space-between; font-size: 15px; margin-bottom: 4px; }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--brand); }
.review { display: grid; gap: 12px; }
.review .card p { margin: 4px 0; }
.review .yes { color: var(--ok); font-weight: 600; }
.review .no { color: var(--bad); font-weight: 600; }
.filter { display: flex; gap: 8px; margin-bottom: 12px; }
.filter button { min-height: 40px; padding: 6px 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-size: 15px; cursor: pointer; }
.filter button.on { background: var(--text); color: var(--bg); }

.topic-list { display: grid; gap: 10px; }
.topic-list button { justify-content: space-between; text-align: left; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: grid; place-items: center; padding: 16px; z-index: 100; }
.modal-box { background: var(--card); color: var(--text); border-radius: var(--radius); padding: 20px; width: 100%; max-width: 420px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.modal-box p { margin: 0 0 16px; font-size: 18px; font-weight: 600; }
.notice { background: var(--bad-soft); color: var(--text); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; font-weight: 600; text-align: center; }

footer { border-top: 1px solid var(--line); padding: 20px 0 40px; font-size: 14px; color: var(--muted); }
footer a { color: var(--muted); }

@media (min-width: 768px) {
  .qtext { font-size: 22px; }
  .sign { width: 160px; height: 160px; }
}

/* Road signs study page */
.sign-tools { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin: 8px 0 4px; }
.toggle { display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.toggle input { width: 20px; height: 20px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { min-height: 38px; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-size: 14px; cursor: pointer; }
.chip.on { background: var(--text); color: var(--bg); }
.sign-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.sign-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 14px 10px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); font: inherit; color: var(--text); cursor: default; }
.sign-pic { width: 96px; height: 96px; display: block; }
.sign-pic svg { width: 100%; height: 100%; }
.sign-name { font-weight: 700; font-size: 15px; line-height: 1.25; }
.sign-meaning { font-size: 13px; color: var(--muted); line-height: 1.4; }
.sign-hint { display: none; font-size: 13px; color: var(--sel); font-weight: 600; }
body.quiz .sign-card { cursor: pointer; }
body.quiz .sign-card:not(.shown) .sign-name, body.quiz .sign-card:not(.shown) .sign-meaning { display: none; }
body.quiz .sign-card:not(.shown) .sign-hint { display: block; }

.signs-link { display: flex; align-items: center; gap: 14px; margin-top: 12px; text-decoration: none; color: var(--text); }
.signs-link > span:last-child { margin-left: auto; font-size: 20px; color: var(--muted); }
