:root {
  color-scheme: light;
  font-family: Inter, ui-rounded, "Arial Rounded MT Bold", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #20223a;
  --muted: #666b82;
  --purple: #6656d9;
  --purple-dark: #5141bd;
  --purple-soft: #eeebff;
  --green: #168b63;
  --red: #c43f52;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, #eee9ff 0, transparent 29rem),
    radial-gradient(circle at 94% 10%, #e2f7ff 0, transparent 31rem),
    linear-gradient(145deg, #faf8ff, #fffaf2);
}
button { font: inherit; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.app-shell { width: min(900px, calc(100% - 28px)); margin: 0 auto; padding: 20px 0 48px; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 48px; }
.back-link, .done-back { color: var(--purple-dark); font-weight: 850; text-decoration: none; }
.score-pill { display: flex; gap: 6px; align-items: center; padding: 9px 14px; border-radius: 999px; background: white; box-shadow: 0 8px 24px rgba(66, 53, 137, .12); font-size: 17px; }
.screen { animation: arrive .28s ease both; }
@keyframes arrive { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.game-screen { margin-top: 12px; }
.progress-row { display: grid; grid-template-columns: auto minmax(120px, 300px); justify-content: space-between; align-items: center; gap: 18px; margin: 10px 4px 18px; color: #625c78; font-size: 13px; font-weight: 850; }
.progress-track { height: 8px; border-radius: 999px; background: rgba(102, 86, 217, .16); overflow: hidden; }
.progress-track span { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, #8878ef, #5948ca); transition: width .3s ease; }

.quiz-panel { position: relative; width: min(720px, 100%); margin: 0 auto; padding: 30px 24px; border: 1px solid rgba(64, 49, 126, .09); border-radius: 30px; background: rgba(255, 255, 255, .94); box-shadow: 0 18px 54px rgba(66, 53, 137, .12); text-align: center; transition: box-shadow .2s ease; }
.quiz-panel.answered-correct { box-shadow: 0 18px 54px rgba(22, 139, 99, .22); }
.quiz-panel.answered-wrong { box-shadow: 0 18px 54px rgba(196, 63, 82, .2); }
.eyebrow { margin: 0 0 8px; color: var(--purple); text-transform: uppercase; letter-spacing: .13em; font-size: 12px; font-weight: 900; }
h1 { margin: 0; font-size: clamp(34px, 6vw, 54px); line-height: 1; letter-spacing: -.05em; }
.instruction { margin: 15px 0 0; color: var(--muted); font-size: clamp(16px, 2.8vw, 20px); font-weight: 750; }

.comparison { display: grid; grid-template-columns: minmax(90px, 1fr) auto minmax(90px, 1fr); align-items: center; gap: clamp(14px, 5vw, 34px); width: min(570px, 100%); margin: 30px auto 26px; }
.fraction { display: inline-grid; justify-items: center; gap: 7px; min-width: 100px; padding: 18px 20px; border-radius: 26px; background: linear-gradient(160deg, #f8f5ff, #ece8ff); box-shadow: inset 0 0 0 2px rgba(102, 86, 217, .13); color: var(--purple-dark); font-size: clamp(48px, 11vw, 76px); font-weight: 900; line-height: .9; }
.fraction .bar { width: 100%; min-width: 1.05em; height: 7px; border-radius: 4px; background: currentColor; }
.answer-slot { display: grid; place-items: center; width: clamp(58px, 11vw, 78px); aspect-ratio: 1; border: 3px dashed rgba(102, 86, 217, .35); border-radius: 22px; background: #faf9ff; color: #aaa3d3; font-size: clamp(38px, 8vw, 58px); font-weight: 950; transition: .2s ease; }
.answer-slot.filled { border-style: solid; border-color: var(--purple); background: var(--purple-soft); color: var(--purple-dark); }

.choice-row { display: grid; grid-template-columns: repeat(3, minmax(72px, 132px)); justify-content: center; gap: 14px; }
.choice { min-height: 86px; border: 3px solid rgba(75, 59, 151, .14); border-radius: 23px; background: white; box-shadow: 0 10px 26px rgba(66, 53, 137, .1); color: var(--purple-dark); font-size: clamp(42px, 9vw, 64px); font-weight: 950; line-height: 1; cursor: pointer; transition: transform .15s ease, border-color .15s ease; }
.choice:hover:not(:disabled), .choice:focus-visible { transform: translateY(-2px); border-color: var(--purple); outline: none; }
.choice:disabled { cursor: default; }
.choice.correct { border-color: var(--green); background: #ecfaf4; color: var(--green); }
.choice.wrong { border-color: var(--red); background: #fdeef0; color: var(--red); }

.feedback { min-height: 54px; margin: 18px 4px 0; color: var(--muted); font-size: 15px; line-height: 1.5; }
.feedback.good { color: var(--green); }
.feedback.bad { color: var(--red); }
.primary-button { min-width: 190px; margin-top: 6px; padding: 15px 28px; border: 0; border-radius: 16px; color: white; background: linear-gradient(135deg, #8272ec, #5948ca); box-shadow: 0 12px 28px rgba(89, 72, 202, .28); font-weight: 900; cursor: pointer; }
.primary-button:hover { transform: translateY(-1px); }

.done-screen { width: min(760px, 100%); margin: 30px auto 0; text-align: center; }
.hero-icon { display: grid; place-items: center; width: 82px; height: 82px; margin: 0 auto 15px; border-radius: 28px; background: white; box-shadow: 0 18px 50px rgba(66, 53, 137, .16); font-size: 42px; transform: rotate(-3deg); }
.intro { margin: 18px auto 25px; max-width: 610px; color: var(--muted); font-size: 18px; line-height: 1.55; }
.review-list { display: grid; gap: 8px; width: min(600px, 100%); margin: 6px auto 22px; text-align: left; }
.review-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 11px 15px; border-radius: 16px; background: white; box-shadow: 0 8px 22px rgba(66, 53, 137, .08); font-size: 14px; }
.review-index { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 9px; background: #f0eef9; font-weight: 900; font-size: 12px; }
.review-row.ok .review-index { background: #d9f5e8; color: var(--green); }
.review-row.no .review-index { background: #fde3e7; color: var(--red); }
.review-equation { color: var(--muted); }
.review-answer { font-weight: 950; }

@media (max-width: 560px) {
  .quiz-panel { padding: 24px 14px; }
  .comparison { gap: 9px; }
  .fraction { min-width: 78px; padding: 14px 12px; }
  .answer-slot { border-radius: 17px; }
  .choice-row { gap: 8px; }
  .choice { min-height: 72px; border-radius: 18px; }
  .review-row { grid-template-columns: auto 1fr; }
  .review-answer { grid-column: 2; }
}
