/* dbquiz platform. Mobile first: Pixel 10 at 412 x 915 CSS px, 16px gutter, no horizontal scroll. */
:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #1d4ed8;
  --brand-ink: #ffffff;
  --good: #15803d;
  --good-bg: #dcfce7;
  --bad: #b91c1c;
  --bad-bg: #fee2e2;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(17, 24, 39, .06), 0 4px 16px rgba(17, 24, 39, .06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1020; --card: #141b2e; --ink: #f3f4f6; --muted: #9ca3af; --line: #26304a;
    --brand: #60a5fa; --brand-ink: #0b1020; --good: #4ade80; --good-bg: #14321f;
    --bad: #f87171; --bad-bg: #3a1717; --warn: #fbbf24; --warn-bg: #3a2c10;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1020; --card: #141b2e; --ink: #f3f4f6; --muted: #9ca3af; --line: #26304a;
  --brand: #60a5fa; --brand-ink: #0b1020; --good: #4ade80; --good-bg: #14321f;
  --bad: #f87171; --bad-bg: #3a1717; --warn: #fbbf24; --warn-bg: #3a2c10; --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; justify-content: center;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
.phone {
  width: 100%; max-width: 412px; min-height: 100vh; background: var(--bg);
  display: flex; flex-direction: column; position: relative;
}
header.app {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  padding: 14px 16px 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
header.app h1 { font-size: 20px; margin: 0; letter-spacing: -.01em; }
.chip {
  font-size: 13px; color: var(--muted); background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 10px; display: inline-flex; align-items: center; gap: 6px; max-width: 60%;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.signout { margin: 0; display: inline; }
.signout button, .linkbtn {
  background: none; border: 0; color: var(--brand); font: inherit; font-size: 13px; padding: 0; cursor: pointer;
}

main { flex: 1; padding: 0 16px 96px; }
nav.tabs {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 412px; background: var(--card); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  z-index: 10;
}
nav.tabs a {
  color: var(--muted); font: 12px system-ui; text-decoration: none; display: flex; flex-direction: column;
  align-items: center; gap: 2px; padding: 6px 0; min-height: 52px; justify-content: center;
}
nav.tabs a .ico { font-size: 20px; line-height: 1; }
nav.tabs a[aria-current="page"] { color: var(--brand); font-weight: 600; }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--line); padding: 16px; margin-bottom: 12px; min-width: 0;
}
.card h2 { font-size: 17px; margin: 0 0 6px; }
.muted { color: var(--muted); font-size: 14px; }
.meta { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.notice { font-size: 14px; color: var(--warn); background: var(--warn-bg); border-radius: 12px; padding: 10px 12px; margin: 8px 0; }
.back { margin: 8px 0 0; font-size: 14px; }
.back a { color: var(--brand); }

label.field { display: block; font-size: 14px; color: var(--muted); margin: 12px 0 6px; }
input.text {
  width: 100%; font: inherit; font-size: 18px; padding: 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
}
input.pin { font-size: 28px; letter-spacing: .4em; text-align: center; }
.btn, a.btn {
  display: block; width: 100%; font: inherit; font-size: 17px; font-weight: 600; min-height: 52px; border-radius: 14px;
  border: 1px solid transparent; background: var(--brand); color: var(--brand-ink); cursor: pointer;
  margin-top: 12px; text-align: center; text-decoration: none; padding: 14px 12px;
}
.btn.secondary, a.btn.secondary { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn:disabled { opacity: .45; }
.pin-box {
  font-size: 34px; letter-spacing: .3em; font-weight: 700; text-align: center; padding: 14px;
  background: var(--warn-bg); color: var(--warn); border-radius: 14px; margin: 10px 0;
}
.hint {
  border-left: 4px solid var(--warn); background: var(--warn-bg); border-radius: 12px;
  padding: 12px 14px; font-size: 14px; margin-bottom: 12px;
}
.hint strong { color: var(--ink); }

.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.stat { text-align: center; }
.stat b { display: block; font-size: 22px; }
.stat span { font-size: 12px; color: var(--muted); }

.progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 8px 0 14px; }
.progress span { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.qnum { font-size: 13px; color: var(--muted); }
.qtext { font-size: 20px; font-weight: 600; margin: 6px 0 14px; line-height: 1.3; }
.opt {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; font: inherit; font-size: 16px;
  padding: 14px; margin-bottom: 10px; border-radius: 14px; border: 1.5px solid var(--line);
  background: var(--card); color: var(--ink); cursor: pointer; min-height: 56px; overflow-wrap: anywhere;
}
.opt .letter {
  flex: none; width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--line);
  display: grid; place-items: center; font-weight: 700; font-size: 14px; color: var(--muted);
}
.opt.chosen, .opt[aria-checked="true"] { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, var(--card)); }
.opt.chosen .letter, .opt[aria-checked="true"] .letter { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.opt.correct { border-color: var(--good); background: var(--good-bg); }
.opt.correct .letter { background: var(--good); color: #fff; border-color: var(--good); }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt.wrong .letter { background: var(--bad); color: #fff; border-color: var(--bad); }
.opt.res { cursor: default; }
.opt .tag { margin-left: auto; font-size: 12px; font-weight: 700; white-space: nowrap; }
.opt.correct .tag { color: var(--good); }
.opt.wrong .tag { color: var(--bad); }
.quiz-card { display: block; }

.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.done-banner { text-align: center; padding: 18px 8px 4px; }
.done-banner h2 { margin: 6px 0 2px; font-size: 22px; }

.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 4px 8px; }
.bar { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: var(--brand); }
.bar > span.b-good { background: var(--good); }
.bar > span.b-bad { background: var(--bad); }
.bar > span.b-brand { background: var(--brand); }
.catrow { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; margin-bottom: 12px; }
.catrow .name { font-weight: 600; font-size: 15px; min-width: 0; overflow-wrap: anywhere; }
.catrow .pct { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--muted); }
.catrow .bar { grid-column: 1 / -1; }

.h-item { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.h-item:last-child { border-bottom: 0; }
.h-item > div { min-width: 0; overflow-wrap: anywhere; }
.h-item .d { font-size: 13px; color: var(--muted); }

.gauge-wrap { display: flex; flex-direction: column; align-items: center; padding: 6px 0 2px; }
.gauge-caption { font-size: 14px; color: var(--muted); text-align: center; margin: 4px 0 0; }
.chart-box { position: relative; width: 100%; }
.chart-box canvas { width: 100% !important; height: auto !important; max-height: 220px; }

#again-msg .meta { margin-top: 8px; }
form { margin: 0; }

@media (prefers-reduced-motion: no-preference) {
  .opt { transition: border-color .15s, background .15s; }
}
