:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --text: #1b1e28;
  --muted: #646b7d;
  --border: #e2e5ee;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --ok: #16a34a;
  --ok-soft: #e8f7ee;
  --bad: #dc2626;
  --bad-soft: #fdecec;
  --warn: #d97706;
  --shadow: 0 1px 2px rgb(0 0 0 / .04), 0 4px 16px rgb(0 0 0 / .05);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117;
    --surface: #181b24;
    --text: #e8eaf0;
    --muted: #9aa1b2;
    --border: #2a2f3c;
    --accent: #8b85ff;
    --accent-soft: #23234a;
    --ok: #4ade80;
    --ok-soft: #12291c;
    --bad: #f87171;
    --bad-soft: #2e1616;
    --warn: #fbbf24;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans Myanmar", system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  max-width: 760px;
  margin: 0 auto;
}
.brand { font-weight: 700; font-size: 1.05rem; }
.brand span { color: var(--accent); }
.brand em { font-style: normal; color: var(--muted); font-weight: 400; }

.user { display: flex; align-items: center; gap: 8px; font-size: .9rem; min-width: 0; }
.user img { width: 28px; height: 28px; border-radius: 50%; }
.user #user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }

main { max-width: 760px; margin: 0 auto; padding: 8px 16px 64px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.center { text-align: center; padding-top: 20vh; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

h1 { font-size: 1.5rem; margin: 0 0 8px; line-height: 1.6; }
h2 { font-size: 1.15rem; }

.intro { margin-top: 8vh; padding: 28px 24px; }
.rules { padding: 0; margin: 20px 0 24px; list-style: none; display: grid; gap: 8px; }
.rules li {
  padding: 10px 14px;
  background: var(--accent-soft);
  border-radius: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 10px 20px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform .05s, filter .15s;
}
.btn:active { transform: scale(.99); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn.google { background: var(--surface); color: var(--text); }
.btn.google:hover { background: var(--accent-soft); }
.btn.google svg { width: 20px; height: 20px; }
.btn.big { min-height: 56px; font-size: 1.05rem; }

.link {
  background: none; border: none; padding: 4px;
  color: var(--accent); font: inherit; cursor: pointer;
}

/* ── Exam bar ── */
.exam-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0 -16px 16px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.progress { flex: 1; font-size: .9rem; }
.progress-track { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; margin-top: 4px; }
#progress-fill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.timer {
  display: flex; flex-direction: column; align-items: flex-end;
  padding: 4px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
}
.timer-label { font-size: .75rem; color: var(--muted); line-height: 1.4; }
#timer { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.4; }
.timer.warn #timer { color: var(--warn); }
.timer.danger { border-color: var(--bad); animation: pulse 1s infinite; }
.timer.danger #timer { color: var(--bad); }
@keyframes pulse { 50% { background: var(--bad-soft); } }

/* ── Questions ── */
.questions { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.question { padding: 18px; border-left: 4px solid var(--border); }
.question.answered { border-left-color: var(--accent); }
.q-text { margin: 0 0 4px; font-weight: 600; display: flex; gap: 10px; }
.q-hint { margin: 0 0 12px 40px; font-size: .85rem; color: var(--muted); }
.q-num {
  flex: none;
  display: inline-grid; place-items: center;
  min-width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent);
  font-size: .9rem;
}

.choices { display: grid; gap: 8px; }
.choice {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; min-height: 48px;
  border: 1px solid var(--border); border-radius: 10px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.choice:hover { background: var(--accent-soft); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice .letter {
  flex: none;
  display: inline-grid; place-items: center;
  width: 28px; height: 28px; border-radius: 7px;
  border: 1.5px solid var(--border); font-size: .85rem; font-weight: 600;
}
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice:has(input:checked) .letter { background: var(--accent); border-color: var(--accent); color: transparent; position: relative; }
.choice:has(input:checked) .letter::after { content: "✓"; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 1rem; }
.choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.finish-row { margin-top: 24px; }

/* ── Result ── */
.result-card { text-align: center; padding: 32px 20px; margin-top: 4vh; }
.score-ring {
  --pct: 0;
  --ring: var(--ok);
  width: 180px; height: 180px; margin: 0 auto 16px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(var(--ring) calc(var(--pct) * 1%), var(--border) 0);
}
.score-ring.fail { --ring: var(--bad); }
.score-inner {
  width: 148px; height: 148px; border-radius: 50%;
  background: var(--surface);
  display: grid; place-content: center;
}
.score-num { font-size: 2.6rem; font-weight: 700; line-height: 1.3; }
.score-num small { font-size: 1.1rem; color: var(--muted); font-weight: 400; }

.badge { display: inline-block; padding: 4px 16px; border-radius: 999px; font-weight: 600; }
.badge.pass { background: var(--ok-soft); color: var(--ok); }
.badge.fail { background: var(--bad-soft); color: var(--bad); }
.result-actions { margin-top: 20px; }

.review-title { margin: 32px 0 12px; }
.review .question.right { border-left-color: var(--ok); }
.review .question.wrong { border-left-color: var(--bad); }
.review .right .q-num { background: var(--ok-soft); color: var(--ok); }
.review .wrong .q-num { background: var(--bad-soft); color: var(--bad); }
.yours { margin: 0; color: var(--muted); font-size: .95rem; }

/* ── Misc ── */
.spinner {
  width: 36px; height: 36px; margin: 0 auto 12px;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: 16px;
  max-width: 560px; margin: 0 auto;
  padding: 12px 16px; border-radius: 12px;
  background: var(--text); color: var(--bg);
  box-shadow: 0 8px 24px rgb(0 0 0 / .2);
  z-index: 10;
}

@media (max-width: 480px) {
  h1 { font-size: 1.3rem; }
  .intro { margin-top: 4vh; padding: 22px 18px; }
  .question { padding: 14px; }
}
