:root {
  --bg: #e6f1fc;
  --bg-2: #f4f9ff;
  --surface: #ffffff;
  --text: #16233a;
  --muted: #5b6b82;
  --border: #d3e2f3;
  --accent: #2563eb;
  --accent-soft: #e5efff;
  --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: #0c1626;
    --bg-2: #0f1b2e;
    --surface: #14213a;
    --text: #e6eefb;
    --muted: #93a4be;
    --border: #243453;
    --accent: #60a5fa;
    --accent-soft: #172c4f;
    --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: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 520px) fixed;
  background-color: var(--bg);
  min-height: 100vh;
  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; }

/* ── ဝင်ဝင်ချင်း မြင်ရတဲ့ Sign in စာမျက်နှာ — အစိမ်းနုနု အရောင်ပြေး ── */
body[data-view="loading"],
body[data-view="login"] {
  background: linear-gradient(135deg, #e4f9ee 0%, #c8efd9 45%, #e9f8f2 100%) fixed;
  background-color: #e4f9ee;
}
@media (prefers-color-scheme: dark) {
  body[data-view="loading"],
  body[data-view="login"] {
    background: linear-gradient(135deg, #0b2218 0%, #10301f 45%, #0c1f1a 100%) fixed;
    background-color: #0b2218;
  }
}

.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; color: var(--accent); line-height: 1.4; }
.brand em { font-style: normal; color: var(--text); font-weight: 600; font-size: .9rem; }
h1 small { display: block; font-size: 1rem; font-weight: 600; color: var(--accent); }

.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; }
}
