/* ============================================================
   HSL Rulebook Trainer — Robotedge visual identity
   Palette sampled from assets/robotedge_logo.png:
   navy #004a6e · ocean #0078a8 · teal #00a8b4
   aqua #78cccc · green #60a83c · lime #c0d86c
   ============================================================ */

:root {
  /* brand constants — identical in both themes */
  --navy:  #004a6e;
  --ocean: #0078a8;
  --teal:  #00a8b4;
  --aqua:  #78cccc;
  --green: #60a83c;
  --lime:  #c0d86c;

  /* dark theme (default) */
  --bg:        #0a1620;
  --bg-soft:   #0e1e2a;
  --card:      #102532;
  --card-2:    #15303f;
  --line:      #1e4155;
  --line-soft: #17323f;
  --text:      #e6f1f6;
  --muted:     #8fabbd;
  --accent:    #16c4d4;
  --accent-2:  #2f9fdc;
  --good:      #7cc94a;
  --wrong:     #ff7070;
  --warn:      #ffc04d;

  --radius:    16px;
  --radius-sm: 11px;
  --shadow:    0 10px 30px -12px rgba(0, 12, 20, .7);
  --shadow-lg: 0 24px 60px -20px rgba(0, 10, 18, .8);
  --ring:      0 0 0 1px var(--line);

  --ease: cubic-bezier(.22, .61, .36, 1);
  --ease-bounce: cubic-bezier(.34, 1.56, .64, 1);

  /* 1 = full staged entrance (first load), 0 = collapse delays on later renders */
  --stagger: 1;
}

html[data-theme="light"] {
  --bg:        #eef4f7;
  --bg-soft:   #f7fbfc;
  --card:      #ffffff;
  --card-2:    #f2f8fa;
  --line:      #d3e3ea;
  --line-soft: #e4eff3;
  --text:      #06222e;
  --muted:     #5a7686;
  --accent:    #00849a;
  --accent-2:  #0078a8;
  --good:      #4a9c28;
  --wrong:     #d63b3b;
  --warn:      #b57500;

  --shadow:    0 10px 26px -14px rgba(0, 60, 85, .35);
  --shadow-lg: 0 26px 60px -24px rgba(0, 55, 80, .38);
}

/* ---------------- base ---------------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  transition: background .4s var(--ease), color .4s var(--ease);
}

h1, h2, h3, h4 { line-height: 1.22; margin: 0; letter-spacing: -.015em; }
button { font: inherit; cursor: pointer; color: inherit; }
img { max-width: 100%; display: block; }

svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

::selection { background: color-mix(in srgb, var(--teal) 40%, transparent); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ---------------- ambient backdrop ---------------- */
.bg-mesh {
  position: fixed; inset: 0; z-index: -1; overflow: hidden;
  pointer-events: none;
}
.orb {
  position: absolute; border-radius: 50%;
  filter: blur(90px);
  opacity: .5;
  will-change: transform;
}
html[data-theme="light"] .orb { opacity: .34; filter: blur(80px); }

.orb.o1 {
  width: 52vw; height: 52vw; min-width: 320px; min-height: 320px;
  top: -16vw; left: -12vw;
  background: radial-gradient(circle at 30% 30%, var(--ocean), transparent 68%);
  animation: drift1 26s var(--ease) infinite alternate;
}
.orb.o2 {
  width: 46vw; height: 46vw; min-width: 280px; min-height: 280px;
  top: 12vh; right: -14vw;
  background: radial-gradient(circle at 60% 40%, var(--teal), transparent 68%);
  animation: drift2 32s var(--ease) infinite alternate;
}
.orb.o3 {
  width: 40vw; height: 40vw; min-width: 240px; min-height: 240px;
  bottom: -16vw; left: 22vw;
  background: radial-gradient(circle at 50% 50%, var(--green), transparent 70%);
  animation: drift3 29s var(--ease) infinite alternate;
}

@keyframes drift1 { to { transform: translate3d(9vw, 7vh, 0) scale(1.16); } }
@keyframes drift2 { to { transform: translate3d(-11vw, 10vh, 0) scale(1.1); } }
@keyframes drift3 { to { transform: translate3d(7vw, -9vh, 0) scale(1.2); } }

/* ---------------- top bar ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px clamp(14px, 3vw, 26px);
  background: color-mix(in srgb, var(--bg-soft) 78%, transparent);
  backdrop-filter: blur(16px) saturate(1.5);
  -webkit-backdrop-filter: blur(16px) saturate(1.5);
  border-bottom: 1px solid var(--line-soft);
  animation: slideDown .5s var(--ease) both;
}

.brand {
  display: flex; align-items: center; gap: 12px; min-width: 0;
  background: none; border: 0; padding: 4px 6px 4px 4px; border-radius: 14px;
  text-align: left;
  transition: background .25s var(--ease);
}
.brand:hover { background: color-mix(in srgb, var(--teal) 10%, transparent); }

.brand-mark-wrap {
  position: relative; flex: none;
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 12px;
}
.brand-mark-wrap::after {
  content: ""; position: absolute; inset: 0; border-radius: 12px;
  background: radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--teal) 45%, transparent), transparent 70%);
  opacity: 0; transform: scale(.6);
  transition: opacity .35s var(--ease), transform .35s var(--ease);
}
.brand:hover .brand-mark-wrap::after { opacity: 1; transform: scale(1.25); }

.brand-mark {
  width: 36px; height: 36px; position: relative; z-index: 1;
  animation: markIn .7s var(--ease-bounce) both;
  transition: transform .5s var(--ease-bounce);
}
.brand:hover .brand-mark { transform: rotate(-8deg) scale(1.08); }

.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-title { font-size: 16px; font-weight: 680; letter-spacing: -.02em; }
.sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar-actions { display: flex; align-items: center; gap: 8px; flex: none; }

.icon-btn {
  position: relative;
  width: 38px; height: 38px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card);
  display: grid; place-items: center;
  transition: background .25s var(--ease), border-color .25s var(--ease), transform .25s var(--ease-bounce);
}
.icon-btn:hover { border-color: var(--accent); transform: translateY(-2px); }
.icon-btn:active { transform: translateY(0) scale(.94); }
.icon-btn svg { transition: transform .5s var(--ease-bounce), opacity .3s var(--ease); }
html[data-theme="dark"]  .ico-moon,
html[data-theme="light"] .ico-sun { display: none; }
.icon-btn:hover svg { transform: rotate(35deg); }
.ico-sun .rays { transform-origin: 12px 12px; animation: spinSlow 14s linear infinite; }

/* ---------------- layout ---------------- */
main { max-width: 980px; margin: 0 auto; padding: 30px clamp(14px, 3vw, 22px) 80px; }
/* no delay here, so no backwards fill — the element must never depend on the
   animation running in order to be visible */
.view { animation: viewIn .45s var(--ease); }

/* ---------------- hero ---------------- */
.hero { text-align: center; margin-bottom: 38px; }

.banner-plate {
  position: relative; overflow: hidden;
  display: inline-block;
  max-width: min(560px, 100%);
  padding: 22px clamp(20px, 5vw, 40px);
  margin-bottom: 26px;
  border-radius: 22px;
  background: linear-gradient(135deg, #ffffff 0%, #f0f8fa 55%, #e6f3f6 100%);
  box-shadow: var(--shadow-lg), 0 0 0 1px color-mix(in srgb, var(--teal) 22%, transparent);
  animation: plateIn .85s var(--ease-bounce) both;
  animation-delay: calc(.1s * var(--stagger));
  transition: transform .5s var(--ease);
}
.banner-plate:hover { transform: translateY(-4px) scale(1.012); }

/* light sweep across the brand plate */
.banner-plate::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: -60%;
  width: 45%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.85), transparent);
  transform: skewX(-18deg);
  animation: sheen 6.5s var(--ease) infinite;
}

.banner { width: 100%; height: auto; position: relative; z-index: 1; }

.hero-title {
  font-size: clamp(26px, 5.2vw, 40px);
  font-weight: 720; letter-spacing: -.035em;
  animation: rise .6s var(--ease) both;
  animation-delay: calc(.3s * var(--stagger));
}
.grad {
  background: linear-gradient(100deg, var(--ocean), var(--teal) 45%, var(--green));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  background-size: 200% auto;
  animation: gradShift 7s linear infinite;
}
.hero-sub {
  max-width: 620px; margin: 12px auto 0;
  color: var(--muted); font-size: 15px;
  animation: rise .6s var(--ease) both;
  animation-delay: calc(.4s * var(--stagger));
}

/* ---------------- stat tiles ---------------- */
.stats-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; margin-bottom: 26px;
}
.stat {
  position: relative; overflow: hidden;
  background: color-mix(in srgb, var(--card) 82%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 15px 17px;
  animation: rise .55s var(--ease) both;
  animation-delay: calc((.45s + var(--i, 0) * .07s) * var(--stagger));
  transition: transform .35s var(--ease), border-color .35s var(--ease);
}
.stat:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--teal) 45%, var(--line)); }
.stat::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: linear-gradient(var(--teal), var(--green));
  transform: scaleY(0); transform-origin: bottom;
  transition: transform .45s var(--ease);
}
.stat:hover::before { transform: scaleY(1); }
.stat b {
  display: block; font-size: 24px; font-weight: 700; letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.stat b em { font-style: normal; font-size: 15px; font-weight: 550; color: var(--muted); }
/* direct child only — the count-up <span> lives inside <b> and must keep the big type */
.stat > span {
  display: block;
  font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .08em; font-weight: 550;
}

/* ---------------- mode cards ---------------- */
.mode-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 13px; }

.mode-card {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  text-align: left; padding: 19px 18px 17px;
  background: linear-gradient(158deg, var(--card-2), var(--card));
  border: 1px solid var(--line-soft); border-radius: var(--radius);
  animation: rise .55s var(--ease) both;
  animation-delay: calc((.6s + var(--i, 0) * .09s) * var(--stagger));
  transition: transform .4s var(--ease), border-color .4s var(--ease), box-shadow .4s var(--ease);
}
.mode-card::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(340px circle at 50% -30%, color-mix(in srgb, var(--teal) 22%, transparent), transparent 65%);
  opacity: 0; transition: opacity .45s var(--ease);
}
.mode-card:hover {
  transform: translateY(-5px);
  border-color: color-mix(in srgb, var(--teal) 55%, var(--line));
  box-shadow: var(--shadow);
}
.mode-card:hover::before { opacity: 1; }
.mode-card:active { transform: translateY(-1px) scale(.99); }
.mode-card > * { position: relative; }

.mode-ico {
  width: 42px; height: 42px; border-radius: 13px; margin-bottom: 9px;
  display: grid; place-items: center;
  color: var(--accent);
  background: color-mix(in srgb, var(--teal) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--teal) 26%, transparent);
  transition: transform .5s var(--ease-bounce), background .35s var(--ease);
}
.mode-card:hover .mode-ico {
  transform: translateY(-2px) rotate(-7deg) scale(1.08);
  background: color-mix(in srgb, var(--teal) 24%, transparent);
}
.mode-title { font-weight: 650; font-size: 15.5px; }
.mode-desc { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.mode-go {
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 12px; font-size: 12.5px; font-weight: 600; color: var(--accent);
  opacity: 0; transform: translateX(-6px);
  transition: opacity .35s var(--ease), transform .35s var(--ease);
}
.mode-card:hover .mode-go { opacity: 1; transform: none; }
.mode-go svg { transition: transform .35s var(--ease); }
.mode-card:hover .mode-go svg { transform: translateX(3px); }
/* touch devices never hover — don't hide the affordance behind it */
@media (hover: none) {
  .mode-go { opacity: 1; transform: none; }
}

/* ---------------- section head + toggle ---------------- */
.section-head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  flex-wrap: wrap; margin: 38px 0 14px;
  animation: rise .55s var(--ease) both;
  animation-delay: calc(.8s * var(--stagger));
}
.section-head h2 { font-size: 17px; font-weight: 660; }

.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  position: relative; width: 40px; height: 23px; border-radius: 999px; flex: none;
  background: var(--line); border: 1px solid var(--line);
  transition: background .3s var(--ease);
}
.switch-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 17px; height: 17px; border-radius: 50%; background: var(--muted);
  transition: transform .35s var(--ease-bounce), background .3s var(--ease);
}
.switch input:checked + .switch-track { background: color-mix(in srgb, var(--teal) 65%, transparent); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(17px); background: #fff; }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 3px; }
.switch-label { font-size: 13px; color: var(--muted); }

/* ---------------- section grid ---------------- */
.section-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(258px, 1fr)); gap: 11px; }

.sec {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: 48px 1fr; gap: 13px; align-items: center;
  text-align: left; padding: 13px 15px;
  background: color-mix(in srgb, var(--card) 85%, transparent);
  border: 1px solid var(--line-soft); border-radius: var(--radius);
  animation: rise .5s var(--ease) both;
  animation-delay: calc((.85s + var(--i, 0) * .035s) * var(--stagger));
  transition: transform .35s var(--ease), border-color .35s var(--ease), box-shadow .35s var(--ease);
}
.sec::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent, color-mix(in srgb, var(--teal) 12%, transparent), transparent);
  transform: translateX(-100%);
  transition: transform .7s var(--ease);
}
.sec:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--teal) 50%, var(--line));
  box-shadow: var(--shadow);
}
.sec:hover::before { transform: translateX(100%); }
.sec:active { transform: translateY(-1px) scale(.995); }
.sec > * { position: relative; }

/* §N badge doubles as a completion donut */
.sec-num {
  position: relative; width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center; flex: none;
  background: conic-gradient(var(--teal) calc(var(--p, 0) * 1%), var(--line) 0);
  transition: transform .45s var(--ease-bounce);
}
.sec:hover .sec-num { transform: scale(1.07) rotate(-4deg); }
.sec-num::after {
  content: ""; position: absolute; inset: 3.5px; border-radius: 50%;
  background: var(--card);
}
.sec-num i {
  position: relative; z-index: 1; font-style: normal;
  font-weight: 700; font-size: 13.5px; color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.sec-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sec-name { font-weight: 620; font-size: 14px; }
.sec-meta { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sec.done .sec-num i { color: var(--good); }
.sec.done .sec-num { background: conic-gradient(var(--green) calc(var(--p,0) * 1%), var(--line) 0); }

/* ---------------- footer ---------------- */
.foot {
  margin-top: 44px; padding-top: 20px;
  border-top: 1px solid var(--line-soft);
  display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: start;
  animation: rise .55s var(--ease) both;
  animation-delay: calc(1.1s * var(--stagger));
}
.foot-mark { opacity: .55; grid-row: span 2; transition: opacity .3s var(--ease); }
.foot:hover .foot-mark { opacity: 1; }
.foot p { font-size: 12px; color: var(--muted); margin: 0; }
.link-btn {
  justify-self: start; background: none; border: none; padding: 0;
  color: var(--wrong); font-size: 12px; text-decoration: underline; text-underline-offset: 3px;
  transition: opacity .25s var(--ease);
}
.link-btn:hover { opacity: .7; }

/* ---------------- quiz ---------------- */
.quiz-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.quiz-head > div:first-child { flex: 1; min-width: 0; }
.eyebrow {
  margin: 0 0 9px; font-size: 11.5px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
}

.progress { height: 7px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress-fill {
  position: relative; height: 100%; width: 0; border-radius: 99px;
  background: linear-gradient(90deg, var(--ocean), var(--teal) 55%, var(--green));
  transition: width .45s var(--ease);
}
.progress-fill::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.45), transparent);
  animation: shimmer 1.8s linear infinite;
}
.quiz-meta { font-size: 13px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.quiz-meta .ok { color: var(--good); font-weight: 600; }
.dot { opacity: .45; margin: 0 5px; }

.card {
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line-soft); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px;
}
.question-card { animation: cardIn .4s var(--ease); }

.tags { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.tag {
  font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  background: var(--card-2); border: 1px solid var(--line); color: var(--muted);
  letter-spacing: .02em;
}
.tag.diff[data-d="easy"]   { color: var(--good);  border-color: color-mix(in srgb, var(--good) 45%, var(--line)); }
.tag.diff[data-d="medium"] { color: var(--warn);  border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.tag.diff[data-d="hard"]   { color: var(--wrong); border-color: color-mix(in srgb, var(--wrong) 45%, var(--line)); }

.qtext { font-size: 19px; font-weight: 620; margin-bottom: 18px; }

.options { display: grid; gap: 10px; }
.opt {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: 28px 1fr; gap: 13px; align-items: center;
  text-align: left; padding: 13px 15px; width: 100%;
  background: var(--card-2); border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  animation: optIn .35s var(--ease) both calc(var(--i) * .055s);
  transition: border-color .25s var(--ease), background .25s var(--ease), transform .25s var(--ease);
}
.opt:hover:not(:disabled) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--teal) 10%, var(--card-2));
  transform: translateX(4px);
}
.opt:active:not(:disabled) { transform: translateX(2px) scale(.995); }
.opt:disabled { cursor: default; }

.opt .key {
  width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center;
  background: var(--card); border: 1px solid var(--line);
  font-size: 12px; font-weight: 650; color: var(--muted);
  transition: all .25s var(--ease);
}
.opt:hover:not(:disabled) .key { border-color: var(--accent); color: var(--accent); }

.opt.correct {
  border-color: var(--good);
  background: color-mix(in srgb, var(--good) 15%, var(--card-2));
  animation: popCorrect .5s var(--ease-bounce);
}
.opt.correct .key { border-color: var(--good); color: var(--good); background: color-mix(in srgb, var(--good) 18%, transparent); }
.opt.wrong {
  border-color: var(--wrong);
  background: color-mix(in srgb, var(--wrong) 14%, var(--card-2));
  animation: shake .45s var(--ease);
}
.opt.wrong .key { border-color: var(--wrong); color: var(--wrong); }

.feedback {
  margin-top: 18px; padding-top: 15px;
  border-top: 1px dashed var(--line);
  animation: rise .35s var(--ease) both;
}
.verdict { margin: 0 0 6px; font-weight: 680; font-size: 15px; }
.verdict.ok { color: var(--good); }
.verdict.no { color: var(--wrong); }
.explain { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.6; }

.quiz-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; }

.primary-btn {
  position: relative; overflow: hidden;
  padding: 12px 26px; border-radius: var(--radius-sm); border: none;
  background: linear-gradient(120deg, var(--ocean), var(--teal));
  color: #fff; font-weight: 650;
  box-shadow: 0 6px 18px -8px color-mix(in srgb, var(--teal) 90%, transparent);
  transition: transform .3s var(--ease-bounce), box-shadow .3s var(--ease), filter .3s var(--ease);
}
.primary-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.08);
  box-shadow: 0 12px 26px -10px color-mix(in srgb, var(--teal) 95%, transparent);
}
.primary-btn:active:not(:disabled) { transform: translateY(0) scale(.97); }
.primary-btn:disabled { opacity: .38; cursor: not-allowed; box-shadow: none; }

.ghost-btn {
  padding: 12px 20px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: color-mix(in srgb, var(--card) 70%, transparent);
  font-weight: 550;
  transition: background .25s var(--ease), border-color .25s var(--ease), transform .3s var(--ease-bounce);
}
.ghost-btn:hover { background: var(--card-2); border-color: var(--accent); transform: translateY(-2px); }
.ghost-btn:active { transform: translateY(0) scale(.97); }

.hint { text-align: center; font-size: 12px; color: var(--muted); margin-top: 16px; }
kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px;
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px;
  padding: 2px 6px; background: var(--card); color: var(--text);
}

/* ---------------- result ---------------- */
.result-card { text-align: center; position: relative; overflow: hidden; }

.score-ring {
  position: relative;
  width: 148px; height: 148px; border-radius: 50%; margin: 10px auto 16px;
  display: grid; place-items: center;
  background: conic-gradient(var(--teal) calc(var(--p, 0) * 1%), var(--line) 0);
  animation: ringIn .6s var(--ease-bounce) both;
}
.score-ring::before {
  content: ""; position: absolute; inset: 11px; border-radius: 50%;
  background: var(--card);
}
.score-ring::after {
  content: ""; position: absolute; inset: -6px; border-radius: 50%;
  background: conic-gradient(var(--teal) calc(var(--p, 0) * 1%), transparent 0);
  filter: blur(14px); opacity: .5; z-index: -1;
}
.score-ring span {
  position: relative; font-size: 32px; font-weight: 730;
  letter-spacing: -.04em; font-variant-numeric: tabular-nums;
}
.score-line { color: var(--muted); font-size: 14.5px; margin: 0 0 20px; }
.result-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i {
  position: absolute; top: -12px;
  width: 8px; height: 13px; border-radius: 2px;
  opacity: 0;
  animation: confetti 2.4s var(--ease) forwards;
}

.review-head { margin: 32px 0 13px; font-size: 16px; font-weight: 660; }
.review { display: grid; gap: 11px; }
.rev {
  background: color-mix(in srgb, var(--card) 84%, transparent);
  border: 1px solid var(--line-soft); border-left: 3px solid var(--line);
  border-radius: var(--radius-sm); padding: 15px 17px;
  animation: rise .45s var(--ease) both;
  animation-delay: min(calc(var(--i, 0) * .04s), .7s);
  transition: transform .3s var(--ease), border-color .3s var(--ease);
}
.rev:hover { transform: translateX(4px); }
.rev.ok { border-left-color: var(--good); }
.rev.no { border-left-color: var(--wrong); }
.rev h4 { margin: 0 0 9px; font-size: 14.5px; font-weight: 620; line-height: 1.45; }
.rev p { margin: 3px 0; font-size: 13px; }
.rev .yours { color: var(--wrong); }
.rev .right { color: var(--good); }
.rev .why { color: var(--muted); margin-top: 8px; line-height: 1.55; }
.rev .meta {
  font-size: 10.5px; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em; margin-bottom: 5px;
}

.load-error {
  background: color-mix(in srgb, var(--wrong) 10%, var(--card));
  border: 1px solid color-mix(in srgb, var(--wrong) 40%, var(--line));
  border-radius: var(--radius); padding: 16px; font-size: 14px; color: var(--text);
}
.load-error code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
  background: var(--card-2); padding: 2px 6px; border-radius: 5px;
}

/* ---------------- keyframes ---------------- */
@keyframes viewIn   { from { opacity: 0; transform: translateY(10px); } }
@keyframes rise     { from { opacity: 0; transform: translateY(14px); } }
@keyframes cardIn   { from { opacity: 0; transform: translateY(12px) scale(.99); } }
@keyframes optIn    { from { opacity: 0; transform: translateX(-10px); } }
@keyframes slideDown{ from { opacity: 0; transform: translateY(-100%); } }
@keyframes markIn   { from { opacity: 0; transform: scale(.4) rotate(-40deg); } }
@keyframes plateIn  { from { opacity: 0; transform: translateY(20px) scale(.94); } }
@keyframes ringIn   { from { opacity: 0; transform: scale(.7); } }

@keyframes spinSlow { to { transform: rotate(360deg); } }
@keyframes gradShift { to { background-position: 200% center; } }
@keyframes shimmer  { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
@keyframes sheen {
  0%, 62% { left: -60%; }
  100%    { left: 130%; }
}

@keyframes popCorrect {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.035); }
  100% { transform: scale(1); }
}
@keyframes shake {
  10%, 90% { transform: translateX(-3px); }
  20%, 80% { transform: translateX(5px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}
@keyframes confetti {
  0%   { opacity: 1; transform: translateY(0) rotate(0deg); }
  100% { opacity: 0; transform: translateY(320px) rotate(var(--r, 540deg)); }
}

/* ---------------- responsive ---------------- */
@media (max-width: 620px) {
  .sub { display: none; }
  main { padding: 22px 14px 60px; }
  .card { padding: 17px; }
  .qtext { font-size: 17px; }
  .hero { margin-bottom: 30px; }
  .banner-plate { padding: 17px 20px; border-radius: 18px; }
  .score-ring { width: 128px; height: 128px; }
  .score-ring span { font-size: 27px; }
  .quiz-foot .ghost-btn, .quiz-foot .primary-btn { flex: 1; }
  .section-head { margin-top: 30px; }
}

@media (max-width: 400px) {
  .brand-title { font-size: 14.5px; }
  .result-actions { flex-direction: column; }
  .result-actions button { width: 100%; }
}

/* ---------------- reduced motion ---------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .orb { animation: none; }
  .banner-plate::after, .progress-fill::after { display: none; }
}
