:root {
  --ink: #1f2040;
  --muted: #6e6f88;
  --purple: #6547b8;
  --purple-dark: #422b89;
  --violet: #ece5ff;
  --yellow: #ffd65a;
  --blue: #2d80c7;
  --green: #15805a;
  --red: #c94959;
  --paper: #fffefa;
  --line: #ddd8ee;
  --shadow: 0 20px 60px rgba(47, 33, 95, .14);
}
* { box-sizing: border-box; }
html { min-height: 100%; background: #eee9ff; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(circle at 10% 12%, rgba(255,255,255,.92) 0 5px, transparent 6px),
    radial-gradient(circle at 90% 18%, rgba(255,214,90,.7) 0 4px, transparent 5px),
    linear-gradient(150deg, #f4f0ff 0%, #e9e1ff 55%, #fff2b9 150%);
  background-size: 125px 125px, 165px 165px, auto;
}
button, input { font: inherit; }
a { color: inherit; }
.maths-shell, .quiz-shell { width: min(100%, 920px); min-height: 100vh; margin: 0 auto; padding: max(28px, env(safe-area-inset-top)) 20px max(34px, env(safe-area-inset-bottom)); }
.crumb { display: inline-flex; color: var(--purple); font-size: .9rem; font-weight: 900; text-decoration: none; }
.maths-head { max-width: 690px; margin: 38px 0 30px; }
.kicker { margin: 0 0 8px; color: var(--purple); font-size: .82rem; font-weight: 950; letter-spacing: .08em; text-transform: uppercase; }
h1 { margin: 0; color: var(--purple-dark); font-size: clamp(2.3rem, 8vw, 4.5rem); line-height: .98; letter-spacing: -.055em; }
.maths-head > p:last-child { margin: 15px 0 0; color: var(--muted); font-size: 1.06rem; font-weight: 720; }
.mode-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.mode-card { position: relative; min-height: 260px; padding: 25px; border: 3px solid white; border-radius: 28px; background: rgba(255,255,255,.78); box-shadow: var(--shadow); text-decoration: none; overflow: hidden; transition: transform .16s ease, box-shadow .16s ease; }
.mode-card:hover { transform: translateY(-4px); box-shadow: 0 26px 68px rgba(47,33,95,.18); }
.mode-card.diagnostic { grid-row: span 2; min-height: 536px; background: linear-gradient(150deg, #6d4fc2, #422b89); color: white; }
.mode-card.fractions { background: linear-gradient(145deg, #fffefa, #ffed9d); }
.mode-card.quick { background: linear-gradient(145deg, #f7f5ff, #ded2ff); }
.mode-card.statistics { background: linear-gradient(145deg, #edfff8, #c8f4e1); }
.mode-icon { width: 62px; height: 62px; display: grid; place-items: center; margin-bottom: 30px; border-radius: 20px; background: white; color: var(--purple-dark); font-size: 1.9rem; font-weight: 950; box-shadow: 0 7px 0 rgba(28,21,61,.12); }
.diagnostic .mode-icon { color: var(--purple); }
.fraction-icon { font-family: Georgia, serif; }
.mode-meta { display: block; margin-bottom: 8px; color: var(--purple); font-size: .75rem; font-weight: 950; letter-spacing: .04em; text-transform: uppercase; }
.diagnostic .mode-meta { color: #dacfff; }
.mode-card h2 { margin: 0; font-size: clamp(1.45rem, 4vw, 2.05rem); line-height: 1.08; letter-spacing: -.035em; }
.mode-card p { max-width: 380px; margin: 10px 0 0; color: var(--muted); font-weight: 700; line-height: 1.45; }
.diagnostic p { color: #e6e0fa; }
.go { position: absolute; left: 25px; bottom: 24px; font-weight: 950; }

.quiz-shell { display: flex; flex-direction: column; gap: 16px; }
.quiz-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.quiz-title { margin: 0; color: var(--purple-dark); font-size: clamp(1.15rem, 4vw, 1.55rem); }
.timer-toggle { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .8rem; font-weight: 850; cursor: pointer; }
.timer-toggle input { width: 19px; height: 19px; accent-color: var(--purple); }
.timer { min-width: 58px; color: var(--purple); font-variant-numeric: tabular-nums; }
.progress-line { display: flex; align-items: center; gap: 12px; }
.progress-track { flex: 1; height: 11px; overflow: hidden; border: 2px solid white; border-radius: 99px; background: rgba(255,255,255,.7); }
.progress-fill { height: 100%; width: 5%; border-radius: inherit; background: linear-gradient(90deg, #8b6fe0, var(--purple)); transition: width .3s ease; }
.progress-text { min-width: 74px; color: var(--muted); text-align: right; font-size: .83rem; font-weight: 900; }
.quiz-card { flex: 1; min-height: 500px; padding: clamp(22px, 5vw, 42px); border: 3px solid white; border-radius: 30px; background: var(--paper); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.category { width: fit-content; margin: 0 0 26px; padding: 7px 11px; border-radius: 99px; background: var(--violet); color: var(--purple); font-size: .75rem; font-weight: 950; letter-spacing: .035em; text-transform: uppercase; }
.question { margin: auto 0 28px; font-size: clamp(1.55rem, 5vw, 2.35rem); line-height: 1.25; letter-spacing: -.025em; }
.question small { display: block; margin-top: 10px; color: var(--muted); font-size: .9rem; font-weight: 700; letter-spacing: 0; }
.answer-zone { margin-bottom: auto; }
.answer-wrap { display: flex; align-items: stretch; gap: 9px; max-width: 430px; }
.answer-input { width: 100%; min-height: 58px; border: 3px solid var(--line); border-radius: 16px; padding: 8px 15px; color: var(--ink); background: white; font-size: 1.35rem; font-weight: 900; outline: none; }
.answer-input:focus { border-color: var(--purple); box-shadow: 0 0 0 4px rgba(101,71,184,.13); }
.answer-suffix { display: grid; place-items: center; min-width: 55px; border-radius: 14px; color: var(--purple-dark); background: var(--violet); font-size: 1.1rem; font-weight: 950; }
.choices { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.choice { min-height: 55px; border: 3px solid var(--line); border-radius: 16px; padding: 8px 12px; color: var(--ink); background: white; cursor: pointer; font-weight: 900; }
.choice:hover, .choice.selected { border-color: var(--purple); background: var(--violet); }
.choice:disabled { cursor: default; }
.answer-input.correct, .choice.correct { border-color: var(--green); background: #ebfaf3; color: var(--green); }
.answer-input.wrong, .choice.wrong { border-color: var(--red); background: #fff1f3; color: var(--red); }
.feedback { min-height: 58px; margin: 22px 0 15px; padding: 12px 14px; border-radius: 14px; color: var(--muted); background: #f3f1f7; font-weight: 750; line-height: 1.4; }
.feedback.correct { color: var(--green); background: #ebfaf3; }
.feedback.wrong { color: #a53747; background: #fff1f3; }
.actions { display: flex; gap: 10px; justify-content: flex-end; }
.btn { min-height: 51px; border: 0; border-radius: 16px; padding: 0 22px; cursor: pointer; font-weight: 950; }
.btn-primary { color: white; background: var(--purple); box-shadow: 0 6px 0 var(--purple-dark); }
.btn-primary:active { transform: translateY(3px); box-shadow: none; }
.btn-secondary { color: var(--purple); background: white; border: 2px solid var(--line); }

.result-card { padding: clamp(24px, 5vw, 42px); border: 3px solid white; border-radius: 30px; background: var(--paper); box-shadow: var(--shadow); }
.result-hero { text-align: center; }
.result-stars { font-size: 2.7rem; letter-spacing: 5px; }
.result-hero h1 { margin-top: 12px; font-size: clamp(2.1rem, 8vw, 3.5rem); }
.result-hero p { max-width: 540px; margin: 12px auto 24px; color: var(--muted); font-weight: 750; line-height: 1.5; }
.score-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 560px; margin: 0 auto 28px; }
.score-box { padding: 15px 8px; border: 2px solid var(--line); border-radius: 17px; text-align: center; background: white; }
.score-value { display: block; color: var(--purple-dark); font-size: 1.6rem; font-weight: 950; }
.score-label { display: block; margin-top: 4px; color: var(--muted); font-size: .72rem; font-weight: 850; }
.breakdown { max-width: 650px; margin: 0 auto 26px; }
.breakdown h2, .review h2 { margin: 0 0 12px; font-size: 1.1rem; }
.skill-row { display: grid; grid-template-columns: minmax(130px, 1fr) 2fr 55px; align-items: center; gap: 10px; margin: 9px 0; font-size: .82rem; font-weight: 850; }
.skill-bar { height: 10px; border-radius: 99px; overflow: hidden; background: #ece9f4; }
.skill-fill { height: 100%; border-radius: inherit; background: var(--purple); }
.recommendation { max-width: 650px; margin: 0 auto 28px; padding: 14px 16px; border-left: 5px solid var(--yellow); border-radius: 12px; color: #71530a; background: #fff7d8; font-weight: 800; line-height: 1.45; }
.review { max-width: 650px; margin: 0 auto 28px; }
.review-row { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 9px; padding: 10px 5px; border-top: 1px solid #ebe7f2; font-size: .85rem; }
.review-number { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: var(--violet); color: var(--purple); font-weight: 950; }
.review-result { font-weight: 900; }
.review-result.ok { color: var(--green); }
.review-result.no { color: var(--red); }
.result-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

@media (max-width: 650px) {
  .maths-shell, .quiz-shell { padding-left: 13px; padding-right: 13px; }
  .mode-grid { grid-template-columns: 1fr; }
  .mode-card, .mode-card.diagnostic { grid-row: auto; min-height: 245px; }
  .quiz-card { min-height: 475px; padding: 22px 16px; }
  .choices { grid-template-columns: 1fr; }
  .score-grid { grid-template-columns: repeat(3, 1fr); }
  .score-value { font-size: 1.3rem; }
  .score-label { font-size: .65rem; }
  .skill-row { grid-template-columns: 105px 1fr 45px; gap: 7px; }
  .review-row { grid-template-columns: 30px 1fr; }
  .review-result { grid-column: 2; }
}
@media (prefers-reduced-motion: reduce) { * { transition-duration: .01ms !important; } }
