:root {
  color-scheme: light;
  font-family: Inter, ui-rounded, "Arial Rounded MT Bold", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #292136;
  --muted: #706779;
  --orange: #e86f51;
  --orange-dark: #bd4d35;
  --orange-soft: #fff0e9;
  --green: #168b63;
  --red: #c43f52;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, #ffe7dc 0, transparent 29rem),
    radial-gradient(circle at 94% 10%, #fff3c9 0, transparent 31rem),
    linear-gradient(145deg, #fff9f5, #f7f3ff);
}
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(--orange-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(104, 54, 39, .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: #6d6171; font-size: 13px; font-weight: 850; }
.progress-track { height: 8px; border-radius: 999px; background: rgba(232, 111, 81, .17); overflow: hidden; }
.progress-track span { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, #f19a70, #df6045); transition: width .3s ease; }

.quiz-panel { position: relative; width: min(740px, 100%); margin: 0 auto; padding: 30px 24px; border: 1px solid rgba(117, 55, 40, .09); border-radius: 30px; background: rgba(255, 255, 255, .95); box-shadow: 0 18px 54px rgba(104, 54, 39, .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(--orange-dark); text-transform: uppercase; letter-spacing: .13em; font-size: 12px; font-weight: 900; }
h1 { margin: 0; font-size: clamp(33px, 6vw, 52px); line-height: 1; letter-spacing: -.05em; }
.instruction { margin: 15px 0 0; color: var(--muted); font-size: clamp(16px, 2.8vw, 20px); font-weight: 750; }
.story { width: min(600px, 100%); margin: 20px auto 0; padding: 14px 17px; border-radius: 18px; background: #fff8e8; color: #625448; font-size: 16px; line-height: 1.45; text-align: left; }

.equation { display: flex; align-items: center; justify-content: center; gap: clamp(8px, 2.5vw, 20px); min-height: 160px; margin: 18px auto 16px; color: var(--orange-dark); font-size: clamp(36px, 8vw, 64px); font-weight: 950; line-height: 1; }
.operator, .equals, .unknown { color: #594d60; }
.unknown { display: grid; place-items: center; min-width: 70px; min-height: 80px; padding: 8px 12px; border: 3px dashed rgba(232, 111, 81, .42); border-radius: 20px; color: var(--orange-dark); }
.fraction { display: inline-grid; justify-items: center; gap: 5px; min-width: 1.15em; vertical-align: middle; line-height: .82; }
.fraction .bar { width: 100%; height: .09em; min-height: 4px; border-radius: 4px; background: currentColor; }

.choice-grid { display: grid; grid-template-columns: repeat(3, minmax(86px, 150px)); justify-content: center; gap: 13px; }
.choice { min-height: 108px; padding: 12px 16px; border: 3px solid rgba(170, 80, 56, .15); border-radius: 23px; background: white; box-shadow: 0 10px 26px rgba(104, 54, 39, .1); color: var(--orange-dark); font-size: clamp(34px, 7vw, 52px); font-weight: 950; cursor: pointer; transition: transform .15s ease, border-color .15s ease; }
.choice:hover:not(:disabled), .choice:focus-visible { transform: translateY(-2px); border-color: var(--orange); 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: 56px; 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, #ef8a63, #d9553d); box-shadow: 0 12px 28px rgba(217, 85, 61, .26); 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(104, 54, 39, .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(620px, 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(104, 54, 39, .08); font-size: 14px; }
.review-index { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 9px; background: #f5eee9; 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 13px; }
  .equation { gap: 8px; min-height: 135px; }
  .choice-grid { gap: 8px; }
  .choice { min-height: 92px; padding: 9px; border-radius: 18px; }
  .story { font-size: 14px; }
  .review-row { grid-template-columns: auto 1fr; }
  .review-answer { grid-column: 2; }
}
