/* ПДД Тренажёр - нейтральный стиль (брендинг позже). Mobile-first, MAX webview. */
:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #17233b;
  --muted: #6b7690;
  --line: #e3e8f2;
  --accent: #1c64f2;
  --accent-soft: #e8f0fe;
  --good: #16a34a;
  --good-soft: #e6f7ec;
  --bad: #dc2626;
  --bad-soft: #fdecec;
  --warn: #d97706;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(23, 35, 59, .08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10151f;
    --card: #1a2130;
    --text: #e8edf7;
    --muted: #8b95ab;
    --line: #2a3348;
    --accent: #4d82f3;
    --accent-soft: #1d2a45;
    --good: #34c467;
    --good-soft: #14301f;
    --bad: #f26363;
    --bad-soft: #3a1a1a;
    --shadow: 0 1px 3px rgba(0, 0, 0, .35);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
  overscroll-behavior-y: contain;
}
.hidden { display: none !important; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }

/* ===== Шапка ===== */
#topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: var(--bg);
}
#top-title { font-weight: 700; font-size: 18px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 40px; height: 40px; flex: none;
  border-radius: 12px; background: var(--card); box-shadow: var(--shadow);
  font-size: 20px; line-height: 1;
}
#cat-switch { display: flex; background: var(--card); border-radius: 12px; padding: 3px; box-shadow: var(--shadow); }
.cat-btn { padding: 7px 12px; border-radius: 9px; font-weight: 700; font-size: 14px; color: var(--muted); }
.cat-btn.on { background: var(--accent); color: #fff; }

/* ===== Экраны ===== */
.screen { padding: 6px 14px 28px; max-width: 640px; margin: 0 auto; }

/* Гейт подписки */
.gate-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 34px 20px 22px; margin-top: 10vh; text-align: center;
}
.gate-icon { font-size: 46px; }
.gate-card h2 { margin: 12px 0 10px; font-size: 21px; line-height: 1.3; }
.gate-card p { color: var(--muted); font-size: 15px; margin: 0 0 22px; }
.gate-card .big-btn { margin-top: 10px; text-decoration: none; box-sizing: border-box; }
a.big-btn { display: block; }
.gate-note { margin-top: 14px; color: var(--bad); font-size: 14px; }

/* Главная */
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 6px; }
.menu-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 14px 16px; text-align: left;
  display: flex; flex-direction: column; gap: 4px;
  min-height: 118px; transition: transform .06s;
}
.menu-card:active { transform: scale(.97); }
.menu-card.accent { background: var(--accent); color: #fff; }
.menu-card.accent .mc-sub { color: rgba(255,255,255,.75); }
.mc-icon { font-size: 26px; }
.mc-name { font-weight: 700; font-size: 17px; }
.mc-sub { font-size: 13px; color: var(--muted); }
.home-stats { margin-top: 18px; color: var(--muted); font-size: 14px; text-align: center; }

/* Билеты */
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); margin: 4px 2px 12px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; }
.dot-none { background: var(--line); }
.dot-pass { background: var(--good); }
.dot-fail { background: var(--bad); }
.ticket-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.ticket-btn {
  aspect-ratio: 1; border-radius: 12px; background: var(--card); box-shadow: var(--shadow);
  font-weight: 700; font-size: 17px; position: relative;
}
.ticket-btn:active { transform: scale(.94); }
.ticket-btn.pass { background: var(--good-soft); color: var(--good); }
.ticket-btn.fail { background: var(--bad-soft); color: var(--bad); }
.ticket-btn .tb-mark { position: absolute; right: 6px; top: 5px; font-size: 10px; }

/* Темы */
.theme-list { display: flex; flex-direction: column; gap: 10px; }
.theme-item {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 13px 14px; text-align: left; display: block; width: 100%;
}
.theme-item:active { transform: scale(.985); }
.ti-name { font-weight: 600; font-size: 15px; }
.ti-sub { font-size: 13px; color: var(--muted); margin-top: 3px; }
.ti-bar { height: 4px; border-radius: 2px; background: var(--line); margin-top: 9px; overflow: hidden; }
.ti-bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }

/* Экзамен-интро */
.exam-intro { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 18px; margin-top: 8px; }
.exam-intro h2 { margin: 0 0 10px; }
.exam-intro ul { margin: 0 0 18px; padding-left: 20px; color: var(--muted); }
.exam-intro li { margin: 7px 0; }
.exam-intro b { color: var(--text); }

/* Вопрос */
.quiz-top { display: flex; align-items: center; justify-content: space-between; margin: 2px 2px 8px; }
.quiz-label { font-size: 14px; font-weight: 600; color: var(--muted); }
.quiz-timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 16px; color: var(--accent); }
.quiz-timer.low { color: var(--bad); }
.quiz-dots { display: flex; flex-wrap: wrap; gap: 5px; margin: 0 2px 12px; }
.qdot { width: 12px; height: 12px; border-radius: 4px; background: var(--line); flex: none; }
.qdot.cur { outline: 2px solid var(--accent); outline-offset: 1px; }
.qdot.ok { background: var(--good); }
.qdot.bad { background: var(--bad); }
.qdot.extra { border-radius: 50%; }

.q-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.q-imgwrap { margin: -14px -14px 12px; border-radius: var(--radius) var(--radius) 0 0; overflow: hidden; background: #000; }
.q-imgwrap img { display: block; width: 100%; max-height: 46vh; object-fit: contain; }
.q-text { font-size: 16.5px; font-weight: 600; margin-bottom: 14px; }
.q-answers { display: flex; flex-direction: column; gap: 9px; }
.ans-btn {
  text-align: left; padding: 13px 14px; border-radius: 12px;
  background: var(--bg); border: 1.5px solid var(--line);
  font-size: 15.5px; line-height: 1.4; transition: transform .05s;
}
.ans-btn:active { transform: scale(.985); }
.ans-btn.picked { border-color: var(--accent); background: var(--accent-soft); }
.ans-btn.right { border-color: var(--good); background: var(--good-soft); }
.ans-btn.wrong { border-color: var(--bad); background: var(--bad-soft); }
.ans-btn:disabled { cursor: default; }
.q-comment {
  margin-top: 14px; padding: 12px 13px; border-radius: 12px;
  background: var(--accent-soft); font-size: 14.5px; color: var(--text);
}
.q-comment b { color: var(--accent); }
.quiz-nav { margin-top: 14px; }
.big-btn {
  display: block; width: 100%; padding: 15px; border-radius: 14px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 16px;
  box-shadow: var(--shadow);
}
.big-btn:active { transform: scale(.98); }
.big-btn.secondary { background: var(--card); color: var(--text); }

/* Результат */
.result-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px 18px 18px; text-align: center; margin-top: 8px; }
.res-emoji { font-size: 44px; }
.res-title { font-size: 22px; font-weight: 800; margin-top: 8px; }
.res-sub { color: var(--muted); margin-top: 6px; font-size: 15px; }
.res-actions { display: flex; gap: 10px; margin-top: 20px; }
.res-actions .big-btn { flex: 1; }
.res-review { margin-top: 18px; display: flex; flex-direction: column; gap: 12px; }
.rev-item { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.rev-q { font-weight: 600; font-size: 15px; }
.rev-img { width: 100%; border-radius: 10px; margin: 10px 0 2px; }
.rev-ans { margin-top: 8px; font-size: 14.5px; }
.rev-ans .ok { color: var(--good); font-weight: 600; }
.rev-ans .bad { color: var(--bad); text-decoration: line-through; }
.rev-c { margin-top: 8px; font-size: 14px; color: var(--muted); }
.res-review h3 { margin: 8px 2px 0; }

/* Лайтбокс */
.lightbox {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.92);
  display: flex; align-items: center; justify-content: center;
}
.lightbox img { max-width: 100vw; max-height: 100vh; }

/* Лоадер */
.loader {
  position: fixed; inset: 0; z-index: 40; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 15px;
}
