/* Тренажёр ПДД — светлая тема */
:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel2: #f8f9fb;
  --text: #1a1f2e;
  --muted: #6b7280;
  --ok: #16a34a;
  --bad: #dc2626;
  --warn: #d97706;
  --border: #e2e6ed;
  --accent: #1d4ed8;
  --accent-bg: #eff6ff;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow-wrap: break-word;
  word-break: break-word;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
}

code {
  background: #eef1f6;
  padding: 0.1rem 0.35rem;
  border-radius: 5px;
  font-size: 0.88em;
}

.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; flex-direction: column;
  padding: 8px 16px 6px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  gap: 6px;
}
.topbar-row1 {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.brand { display: flex; gap: 10px; align-items: center; min-width: 0; }
.brand > div { min-width: 0; overflow: hidden; }
.logo { font-size: 24px; }
.title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.subtitle { color: var(--muted); font-size: 11px; margin-top: 1px; }

.nav {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  width: 100%;
}
.nav-btn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
  flex: 1;
  text-align: center;
  transition: background 0.15s, border-color 0.15s;
}
.nav-btn:hover { background: var(--bg); }
.nav-btn.active {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.back-btn {
  text-decoration: none;
  background: linear-gradient(135deg, #1d4ed8, #2563eb);
  color: #fff !important;
  border: 1px solid transparent;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(29,78,216,0.35);
}
.back-btn:hover { background: linear-gradient(135deg, #1e40af, #1d4ed8); }
.back-short { display: none; }

.container { max-width: 940px; margin: 0 auto; padding: 20px 16px 48px; }
.footer {
  padding: 16px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: #ffffff;
  font-size: 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.footer a { color: var(--muted); }
.footer a:hover { color: var(--accent); }

.footer-disclaimer {
  font-size: 11px;
  color: #9ca3af;
  max-width: 800px;
  margin: 0 auto;
  line-height: 1.6;
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
}
.card {
  grid-column: span 12;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.card h2, .card h3 { margin: 0 0 12px; }
.card h2 { font-size: 1.2rem; }
.card h3 { font-size: 1rem; }
.muted { color: var(--muted); }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { height: 10px; }

.btn {
  background: #f1f3f7;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s;
}
.btn:hover { background: #e6e9f0; }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn.primary:hover { background: #1e40af; }
.btn.danger {
  background: #fee2e2;
  color: var(--bad);
  border-color: #fca5a5;
}
.btn.danger:hover { background: #fecaca; }
.btn.btn-next {
  background: #16a34a;
  color: #fff;
  border-color: #16a34a;
}
.btn.btn-next:hover:not(:disabled) { background: #15803d; }

.ticket-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  margin-top: 14px;
}
.ticket {
  padding: 10px 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel2);
  cursor: pointer;
  text-align: center;
  font-size: 13px;
  transition: background 0.15s, border-color 0.15s;
}
.ticket:hover {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
}

.qimg {
  max-width: 100%;
  max-height: 300px;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel2);
  display: block;
  margin: 12px auto 0;
}
.options { display: grid; gap: 8px; margin-top: 14px; }
.option {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel2);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.option:hover:not(.correct):not(.wrong) { background: var(--accent-bg); border-color: var(--accent); }
.option input { margin-top: 3px; flex-shrink: 0; }
.option.correct {
  border-color: #86efac;
  background: #f0fdf4;
  color: var(--ok);
}
.option.wrong {
  border-color: #fca5a5;
  background: #fef2f2;
  color: var(--bad);
}

.pill {
  display: inline-flex; gap: 6px; align-items: center;
  padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  font-size: 12px;
}
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kv .pill { justify-content: space-between; }

.mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid #bfdbfe;
}

.q-text {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 10px 0 0;
  line-height: 1.45;
}

.feedback-box {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.feedback-box.correct {
  background: #f0fdf4;
  border: 1px solid #86efac;
  color: #15803d;
}
.feedback-box.wrong {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #b91c1c;
}

.explanation {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.5;
  opacity: 0.85;
}

.topic-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(0,0,0,0.06);
  color: inherit;
  margin-left: 4px;
  vertical-align: middle;
}

@media (min-width: 860px) {
  .card.half { grid-column: span 6; }
}

/* ── Desktop — alt-33.ru brand style ────────────────── */
@media (min-width: 1024px) {

  /* ── Типографика: Montserrat (Tilda/alt-33.ru фирменный шрифт) ── */
  body {
    font-family: 'Montserrat', 'Segoe UI', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.65;
    color: #1a1a1a;
    background: #f5f5f5;
  }

  h1 {
    font-family: 'Montserrat', 'Segoe UI', Arial, sans-serif;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.25;
    color: #1a1a1a;
    margin: 0 0 20px;
  }
  h2 {
    font-family: 'Montserrat', 'Segoe UI', Arial, sans-serif;
    font-size: 1.45rem;
    font-weight: 700;
    line-height: 1.3;
    color: #1a1a1a;
    margin: 0 0 16px;
  }
  h3 {
    font-family: 'Montserrat', 'Segoe UI', Arial, sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.4;
    color: #1a1a1a;
    margin: 0 0 12px;
  }

  /* ── Шапка (topbar) ──────────────────────────────── */
  .topbar {
    padding: 0 40px;
    background: #ffffff;
    border-bottom: 1px solid #e8e8e8;
    box-shadow: 0 1px 6px rgba(0,0,0,0.07);
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0;
    min-height: 64px;
  }
  .topbar-row1 {
    flex: 1;
    gap: 20px;
  }
  .brand {
    gap: 14px;
  }
  .logo {
    font-size: 28px;
  }
  .title {
    font-family: 'Montserrat', 'Segoe UI', Arial, sans-serif;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.01em;
    white-space: nowrap;
  }
  .subtitle {
    font-family: 'Montserrat', 'Segoe UI', Arial, sans-serif;
    font-size: 12px;
    color: #888888;
    font-weight: 400;
  }
  /* Лого-бренд автошколы в шапке — только десктоп */
  .topbar-school-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: #1a1a1a;
    font-family: 'Montserrat', 'Segoe UI', Arial, sans-serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.01em;
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid #e8e8e8;
    background: #fafafa;
    margin-right: 16px;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s;
  }
  .topbar-school-brand:hover {
    background: #f0f0f0;
    border-color: #cccccc;
  }
  .topbar-school-brand .school-icon {
    font-size: 16px;
  }

  .nav {
    flex: 0 0 auto;
    gap: 8px;
    width: auto;
    margin-left: 24px;
  }
  .nav-btn {
    font-family: 'Montserrat', 'Segoe UI', Arial, sans-serif;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 18px;
    border-radius: 8px;
    flex: 0 0 auto;
    border: 1px solid #e8e8e8;
    background: transparent;
  }
  .nav-btn:hover {
    background: #f5f5f5;
    border-color: #d0d0d0;
  }
  .nav-btn.active {
    background: #eff6ff;
    border-color: #1d4ed8;
    color: #1d4ed8;
    font-weight: 600;
  }

  .back-btn {
    font-family: 'Montserrat', 'Segoe UI', Arial, sans-serif;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 22px;
    border-radius: 8px;
    letter-spacing: 0.01em;
    /* цвет не меняем — только форма */
  }

  /* ── Контейнер ───────────────────────────────────── */
  .container {
    max-width: 1060px;
    padding: 36px 40px 72px;
    margin: 0 auto;
  }

  /* ── Сетка карточек ──────────────────────────────── */
  .grid {
    gap: 20px;
  }

  /* ── Карточки — Tilda-style ──────────────────────── */
  .card {
    border-radius: 16px;
    padding: 28px 32px;
    border: 1px solid #e8e8e8;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    background: #ffffff;
  }
  .card h2 {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0 0 16px;
  }
  .card h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0 0 12px;
  }

  /* Чередование фонов секций */
  .card:nth-child(even) {
    background: #fafafa;
  }

  /* ── Вопрос (q-text) ─────────────────────────────── */
  .q-text {
    font-size: 1.15rem;
    font-weight: 600;
    line-height: 1.5;
    color: #1a1a1a;
  }

  /* ── Варианты ответов ────────────────────────────── */
  .options {
    gap: 10px;
    margin-top: 18px;
  }
  .option {
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid #e8e8e8;
    background: #fafafa;
    font-family: 'Montserrat', 'Segoe UI', Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  }
  .option:hover:not(.correct):not(.wrong) {
    background: #eff6ff;
    border-color: #1d4ed8;
    box-shadow: 0 0 0 3px rgba(29,78,216,0.08);
  }

  /* ── Кнопки — форма Tilda-style (цвет не меняем) ── */
  .btn {
    font-family: 'Montserrat', 'Segoe UI', Arial, sans-serif;
    font-size: 15px;
    font-weight: 600;
    padding: 12px 24px;
    border-radius: 10px;
    letter-spacing: 0.01em;
    transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
  }
  .btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  }
  .btn:active:not(:disabled) {
    transform: translateY(0);
  }

  /* ── Билеты ──────────────────────────────────────── */
  .ticket-grid {
    gap: 10px;
    margin-top: 18px;
  }
  .ticket {
    padding: 14px 10px;
    border-radius: 12px;
    font-family: 'Montserrat', 'Segoe UI', Arial, sans-serif;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid #e8e8e8;
    background: #fafafa;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  }
  .ticket:hover {
    background: #eff6ff;
    border-color: #1d4ed8;
    box-shadow: 0 2px 8px rgba(29,78,216,0.1);
  }

  /* ── Feedback / объяснение ───────────────────────── */
  .feedback-box {
    padding: 16px 20px;
    border-radius: 12px;
    font-size: 15px;
    margin-top: 18px;
  }
  .explanation {
    font-size: 14px;
    line-height: 1.6;
  }

  /* ── Пиллы и бейджи ──────────────────────────────── */
  .pill {
    font-family: 'Montserrat', 'Segoe UI', Arial, sans-serif;
    font-size: 13px;
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid #e8e8e8;
  }
  .mode-badge {
    font-family: 'Montserrat', 'Segoe UI', Arial, sans-serif;
    font-size: 13px;
    font-weight: 600;
    padding: 5px 14px;
  }

  /* ── Изображение вопроса ─────────────────────────── */
  .qimg {
    max-height: 360px;
    border-radius: 12px;
    margin: 16px auto 0;
  }

  /* ── Spacer больше ───────────────────────────────── */
  .spacer {
    height: 18px;
  }

  /* ── Разделительные линии ────────────────────────── */
  .row {
    gap: 12px;
  }

  /* ── Футер ───────────────────────────────────────── */
  .footer {
    font-family: 'Montserrat', 'Segoe UI', Arial, sans-serif;
    font-size: 13px;
    padding: 24px 40px;
    border-top: 1px solid #e8e8e8;
    background: #ffffff;
  }
  .footer-disclaimer {
    font-size: 12px;
    color: #aaaaaa;
    line-height: 1.7;
  }

  /* ── KV-grid: 3 колонки на десктопе ─────────────── */
  .kv {
    grid-template-columns: 1fr 1fr 1fr;
  }

  /* Логотип автошколы в шапке скрыт на мобильном — показываем только здесь */
  .topbar-school-brand {
    display: flex;
  }
}

/* Скрываем школьный бренд-блок на мобильном */
.topbar-school-brand {
  display: none;
}

/* ── Tablet ──────────────────────────────────────────── */
@media (max-width: 700px) {
  .container { padding: 12px 10px 48px; }
  .grid { gap: 10px; }
  .card { padding: 14px 14px; }
}

/* ── Mobile ──────────────────────────────────────────── */
@media (max-width: 640px) {
  .topbar { padding: 6px 10px; gap: 4px; }
  .logo { font-size: 20px; }
  .title { font-size: 13px; }
  .subtitle { font-size: 10px; }
  .subtitle { display: none; }
  .back-long { display: none; }
  .back-short { display: inline; }
  .back-btn { padding: 6px 10px; font-size: 13px; }
  .nav { gap: 4px; }
  .nav-btn { padding: 6px 0; font-size: 11px; border-radius: 8px; }

  /* Home mode buttons: one row, equal width */
  .btn-row-modes { flex-wrap: nowrap; width: 100%; }
  .btn-row-modes .btn { flex: 1; padding: 10px 4px; font-size: 13px; text-align: center; }

  /* Cards */
  .container { padding: 10px 8px 56px; }
  .card { padding: 12px 12px; border-radius: 10px; }

  .q-text { font-size: 0.88rem; }

  /* Answer options: bigger touch target */
  .option {
    padding: 13px 12px;
    min-height: 44px;
  }

  /* Action buttons: full-width column on mobile */
  .btn-row-session {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }
  .btn-row-session .btn-finish {
    grid-column: span 2;
  }

  /* All buttons: minimum 44px touch height */
  .btn { min-height: 44px; font-size: 15px; }

  /* Stats kv grid: single column on very small screens */
  .kv { grid-template-columns: 1fr; }

  /* Ticket grid: smaller cells */
  .ticket-grid {
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    gap: 6px;
  }
  .ticket { padding: 8px 4px; font-size: 12px; }

  /* Image: limit height */
  .qimg { max-height: 220px; }

  /* Pills wrap nicely */
  .pill { font-size: 11px; padding: 4px 8px; }

  /* Footer disclaimer readable */
  .footer-disclaimer { font-size: 10px; }
}
