:root {
  --ink: #18283d;
  --muted: #687987;
  --paper: #fffefa;
  --canvas: #f5f8f3;
  --aqua: #39bfc2;
  --pink: #e95b8b;
  --yellow: #f6cf4d;
  --line: #dce6e1;
  --success: #148c68;
  --danger: #d94e62;
  --shadow: 0 18px 45px rgba(24, 40, 61, .12);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; color: var(--ink); font-family: 'Nunito', sans-serif; background-color: var(--canvas); background-image: linear-gradient(135deg, rgba(255,255,255,.82) 25%, transparent 25%), linear-gradient(315deg, rgba(214,240,231,.5) 25%, transparent 25%); background-size: 30px 30px; }
button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.site-shell { max-width: 1120px; margin: auto; padding: 25px 32px 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 35px; }
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; }
.brand-mark { position: relative; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; box-shadow: 0 10px 18px rgba(24, 40, 61, .12), inset 0 0 0 2px rgba(24, 40, 61, .08); }
.brand-mark svg { display: block; width: 100%; height: 100%; filter: drop-shadow(0 4px 8px rgba(24, 40, 61, .08)); }
.brand strong, .brand small { display: block; line-height: .95; }
.brand strong { font: 800 22px 'Baloo 2', sans-serif; }
.brand small { margin-top: 4px; color: var(--pink); font-size: 9px; font-weight: 800; letter-spacing: 1.2px; }
.topbar-note { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: 1.8px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--aqua); box-shadow: 0 0 0 4px rgba(57,191,194,.15); }
.screen { min-height: 555px; }
.setup-screen { display: grid; grid-template-columns: .95fr 1.05fr; gap: 66px; align-items: center; padding: 23px 5.5% 62px; }
.intro-copy { position: relative; padding-top: 8px; }
.eyebrow { margin: 0 0 8px; color: var(--pink); font-size: 10px; font-weight: 800; letter-spacing: 2.2px; }
.intro-copy h1, .result-screen h1 { max-width: 475px; margin: 0 0 15px; font: 800 62px/.95 'Baloo 2', sans-serif; }
.intro-copy h1 em { color: var(--aqua); font-style: normal; }
.intro-text { max-width: 400px; margin: 0; color: var(--muted); font-size: 16px; line-height: 1.55; }
.fraction-preview { position: relative; display: flex; align-items: center; width: 270px; height: 215px; margin: 23px auto 8px 7px; }
.preview-pie { width: 165px; height: 165px; filter: drop-shadow(0 8px 10px rgba(24,40,61,.1)); transform: rotate(-8deg); }
.preview-fraction { display: grid; justify-items: center; gap: 2px; margin-left: -1px; font: 800 31px/1 'Baloo 2', sans-serif; }
.preview-fraction span { width: 39px; height: 3px; border-radius: 2px; background: var(--ink); }
.preview-caption { position: absolute; bottom: 5px; left: 107px; color: var(--muted); font-size: 11px; font-weight: 800; }
.spark { position: absolute; color: var(--pink); font-size: 23px; }
.spark-one { top: 8px; left: 122px; }
.spark-two { top: 49px; right: 4px; color: var(--aqua); font-size: 27px; }
.track-mark { display: flex; gap: 9px; margin-top: 18px; }
.track-mark span { width: 13px; height: 13px; border: 3px solid var(--pink); border-radius: 50%; }
.track-mark span:nth-child(2) { border-color: var(--aqua); transform: translateY(10px); }
.track-mark span:nth-child(3) { border-color: var(--yellow); transform: translateY(20px); }
.setup-panel { padding: 30px; border: 1px solid rgba(24,40,61,.07); border-radius: 7px; background: var(--paper); box-shadow: var(--shadow); }
.panel-heading { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 24px; }
.panel-number { color: var(--pink); font: 800 31px/1 'Baloo 2', sans-serif; }
.panel-heading h2, .ranking h2 { margin: 0; font: 800 26px/1 'Baloo 2', sans-serif; }
.setup-panel label, .setup-panel legend { display: block; margin-bottom: 7px; font-size: 11px; font-weight: 800; }
.setup-panel input, .setup-panel select { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 4px; outline-color: var(--aqua); background: #fff; color: var(--ink); font-size: 14px; font-weight: 700; }
.setup-panel input::placeholder { color: #96a3ac; font-weight: 600; }
.mode-setting { margin-top: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
.setup-panel fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.time-fields { display: flex; align-items: center; gap: 6px; }
.time-fields label { flex: 1; }
.time-fields input { text-align: center; padding-inline: 3px; }
.extra-settings { align-items: end; }
.sound-toggle { display: flex !important; align-items: center; gap: 9px; min-height: 44px; margin: 0 !important; color: var(--muted); cursor: pointer; }
.sound-toggle input { width: 18px; min-height: 18px; accent-color: var(--pink); }
.rules { margin: 19px 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.rules strong { color: var(--ink); }
.primary-button { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 48px; padding: 12px 18px; border: 0; border-radius: 4px; background: var(--ink); color: #fff; font-size: 13px; font-weight: 800; cursor: pointer; transition: transform .18s, background .18s; }
.primary-button:hover { transform: translateY(-2px); background: var(--pink); }
.primary-button:focus-visible, .hint-button:focus-visible, .text-button:focus-visible { outline: 3px solid rgba(57,191,194,.55); outline-offset: 3px; }
.primary-button span { font-size: 19px; line-height: .7; }
.game-screen { max-width: 840px; min-height: 560px; margin: 0 auto; padding: 5px 0 45px; }
.game-meta { display: flex; align-items: end; justify-content: space-between; margin-bottom: 13px; }
.game-meta .eyebrow { margin-bottom: 3px; }
.progress-label { margin: 0; font: 700 21px 'Baloo 2', sans-serif; }
.progress-label strong { color: var(--pink); }
.progress-label span { color: var(--muted); font: 700 12px 'Nunito', sans-serif; }
.game-indicators { display: flex; align-items: center; gap: 17px; }
.score-pill { display: flex; align-items: center; gap: 5px; color: var(--ink); font: 800 19px 'Baloo 2', sans-serif; }
.score-pill span { color: #e1ad22; font-size: 21px; }
.timer { display: flex; align-items: center; gap: 6px; color: var(--pink); font: 800 23px 'Baloo 2', sans-serif; }
.timer span { font-size: 26px; }
.timer.warning { color: var(--danger); animation: pulse 1s infinite; }
.progress-track { height: 7px; margin-bottom: 18px; overflow: hidden; border-radius: 99px; background: #dce7e4; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--aqua); transition: width .35s; }
.question-card { padding: 28px 34px 31px; border-top: 5px solid var(--aqua); border-radius: 7px; background: var(--paper); box-shadow: var(--shadow); }
.question-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 18px; }
.question-tag { color: var(--aqua); font-size: 9px; font-weight: 800; letter-spacing: 2px; }
.question-heading h1 { margin: 5px 0 0; font: 800 29px/1.05 'Baloo 2', sans-serif; }
.question-stamp { padding: 7px 13px; border-radius: 2px; background: #fff1c7; color: #8a6810; font: 800 12px 'Baloo 2', sans-serif; transform: rotate(3deg); }
.challenge-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; align-items: center; }
.visual-panel { display: grid; justify-items: center; min-height: 315px; padding: 17px 12px; border-radius: 5px; background: #eef8f3; }
.pie-wrap { display: grid; place-items: center; width: min(100%, 285px); aspect-ratio: 1; }
.pie-wrap svg { display: block; width: 100%; height: 100%; filter: drop-shadow(0 7px 8px rgba(24,40,61,.09)); animation: arrive .4s ease-out both; }
.visual-caption { margin: 4px 0 0; color: var(--muted); font-size: 11px; font-weight: 800; }
.answer-form { width: 100%; }
.response-panel { min-width: 0; }
.builder-form { width: 100%; }
.answer-prompt { margin: 0 0 16px; font: 700 17px 'Baloo 2', sans-serif; }
.target-fraction { display: grid; justify-items: center; gap: 1px; width: 110px; margin: 0 auto 15px; color: var(--ink); font: 800 29px/1 'Baloo 2', sans-serif; }
.target-fraction span { margin-bottom: 4px; color: var(--muted); font: 800 9px 'Nunito', sans-serif; }
.target-fraction i { width: 48px; height: 3px; margin: 2px 0; border-radius: 2px; background: var(--ink); }
.block-controls { display: flex; align-items: center; justify-content: center; gap: 15px; margin: 0 0 13px; }
.block-adjust { display: grid; place-items: center; width: 42px; aspect-ratio: 1; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--ink); font: 800 25px/1 'Nunito', sans-serif; cursor: pointer; }
.block-adjust:hover:not(:disabled) { border-color: var(--aqua); background: #eef8f3; }
.block-adjust:disabled { cursor: default; opacity: .45; }
.block-controls output { min-width: 75px; color: var(--muted); text-align: center; font-size: 11px; font-weight: 800; }
.fraction-blocks { display: grid; grid-template-columns: repeat(4, minmax(38px, 54px)); place-content: center; gap: 9px; width: 100%; min-height: 212px; padding: 12px; }
.fraction-block { width: 100%; aspect-ratio: 1; border: 2px solid #b9ccc3; border-radius: 4px; background: #fffefa; cursor: pointer; transition: background .15s, border-color .15s, transform .15s; }
.fraction-block:hover { transform: translateY(-2px); border-color: var(--success); }
.fraction-block.painted { border-color: var(--success); background: #38ad78; box-shadow: inset 0 0 0 3px rgba(255,255,255,.28); }
.fraction-block:focus-visible, .block-adjust:focus-visible { outline: 3px solid rgba(57,191,194,.55); outline-offset: 2px; }
.fraction-entry { display: grid; justify-items: center; gap: 5px; width: 155px; margin: 0 auto 15px; }
.fraction-entry label { display: grid; justify-items: center; gap: 3px; color: var(--muted); font-size: 10px; font-weight: 800; }
.fraction-entry input { width: 90px; height: 51px; border: 1px solid var(--line); border-radius: 4px; outline-color: var(--aqua); background: #fff; color: var(--ink); text-align: center; font: 800 28px 'Baloo 2', sans-serif; appearance: textfield; }
.fraction-entry input::-webkit-inner-spin-button, .fraction-entry input::-webkit-outer-spin-button { margin: 0; appearance: none; }
.fraction-line { width: 100px; height: 3px; border-radius: 2px; background: var(--ink); }
.hint-button { display: flex; align-items: center; gap: 7px; margin: 0 auto 13px; padding: 6px 0; border: 0; background: none; color: var(--muted); font-size: 11px; font-weight: 800; cursor: pointer; }
.hint-button span { color: var(--pink); font-size: 16px; }
.hint-text { margin: 0 0 13px; padding: 10px 12px; border-left: 3px solid var(--yellow); background: #fff8dc; color: var(--ink); font-size: 11px; line-height: 1.45; }
.answer-submit { min-height: 44px; }
.answer-submit:disabled { cursor: default; opacity: .72; transform: none; }
.feedback { min-height: 40px; margin: 12px 0 0; color: var(--muted); text-align: center; font-size: 11px; font-weight: 800; line-height: 1.45; }
.feedback.correct { color: var(--success); }
.feedback.incorrect { color: var(--danger); }
.mistakes { display: flex; align-items: center; gap: 10px; margin-top: 16px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: 1.3px; }
#mistake-dots { display: flex; gap: 6px; }
.mistake-dot { width: 12px; height: 12px; border: 2px solid var(--pink); border-radius: 50%; }
.mistake-dot.filled { background: var(--pink); }
.mistake-limit { margin-left: auto; letter-spacing: 0; }
.result-screen { padding: 45px 5% 55px; text-align: center; }
.result-screen h1 { max-width: none; margin: 0 0 7px; font-size: 55px; }
.result-screen h1 span { color: var(--aqua); }
.result-message { color: var(--muted); font-size: 15px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); max-width: 740px; margin: 31px auto 25px; overflow: hidden; border-radius: 7px; background: var(--paper); box-shadow: var(--shadow); }
.stat { padding: 20px 10px; border-right: 1px solid var(--line); }
.stat:last-child { border: 0; }
.stat span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .5px; }
.stat strong { font: 800 27px 'Baloo 2', sans-serif; }
.stat.highlight strong { color: var(--pink); }
.result-actions { max-width: 260px; margin: auto; }
.text-button { padding: 13px; border: 0; background: none; color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer; }
.ranking { max-width: 440px; margin: 36px auto 0; padding-top: 22px; border-top: 1px solid var(--line); text-align: left; }
.ranking h2 { margin-bottom: 12px; }
.ranking ol { margin: 0; padding-left: 22px; color: var(--muted); font-size: 12px; line-height: 1.9; }
.ranking li::marker { color: var(--pink); font-weight: 800; }
.ranking li strong { color: var(--ink); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
footer { display: flex; justify-content: space-between; padding: 20px 0; border-top: 1px solid rgba(24,40,61,.12); color: var(--muted); font-size: 10px; font-weight: 800; }
[hidden] { display: none !important; }
@keyframes pulse { 50% { opacity: .48; } }
@keyframes arrive { from { opacity: .6; transform: scale(.94) rotate(-2deg); } to { opacity: 1; transform: scale(1) rotate(0); } }
@media (max-width: 760px) {
  .site-shell { padding: 18px 18px 0; }
  .topbar { margin-bottom: 18px; }
  .topbar-note { font-size: 8px; letter-spacing: 1px; }
  .setup-screen { display: block; padding: 12px 0 40px; }
  .intro-copy { margin-bottom: 26px; }
  .intro-copy h1 { font-size: 52px; }
  .intro-text { max-width: 500px; font-size: 14px; }
  .fraction-preview { width: 240px; height: 170px; margin: 12px auto 4px 0; }
  .preview-pie { width: 135px; height: 135px; }
  .preview-caption { left: 85px; }
  .setup-panel { padding: 24px 20px; }
  .game-screen { padding-top: 6px; }
  .question-card { padding: 24px 20px; }
  .challenge-layout { gap: 19px; }
  .visual-panel { min-height: 255px; }
  .pie-wrap { width: min(100%, 235px); }
  .question-heading h1 { font-size: 25px; }
  .result-screen { padding: 35px 0 45px; }
  .result-screen h1 { font-size: 45px; }
}
@media (max-width: 540px) {
  .topbar-note { display: none; }
  .form-grid { gap: 10px; }
  .setup-panel select { font-size: 12px; }
  .game-meta { align-items: center; }
  .progress-label { font-size: 18px; }
  .game-indicators { gap: 10px; }
  .timer { gap: 3px; font-size: 19px; }
  .timer span { font-size: 21px; }
  .score-pill { font-size: 17px; }
  .question-card { padding: 21px 16px; }
  .question-heading { margin-bottom: 13px; }
  .question-heading h1 { font-size: 23px; }
  .question-stamp { padding: 5px 8px; font-size: 10px; }
  .challenge-layout { grid-template-columns: 1fr; gap: 17px; }
  .visual-panel { grid-template-columns: minmax(0, 1fr) auto; min-height: 0; padding: 10px 14px; }
  .pie-wrap { width: min(56vw, 205px); }
  .visual-caption { grid-column: 1 / -1; margin-top: 1px; }
  .answer-form { max-width: 330px; margin: 0 auto; }
  .response-panel { max-width: 360px; margin: 0 auto; }
  .builder-form .answer-prompt { margin-bottom: 9px; }
  .fraction-blocks { grid-template-columns: repeat(4, minmax(38px, 48px)); min-height: 165px; gap: 7px; }
  .answer-prompt { margin-bottom: 9px; text-align: center; }
  .fraction-entry { grid-template-columns: 1fr auto 1fr; width: 100%; gap: 8px; margin-bottom: 11px; }
  .fraction-entry input { width: 72px; height: 44px; font-size: 24px; }
  .fraction-line { width: 3px; height: 48px; }
  .fraction-entry label { font-size: 9px; }
  .feedback { min-height: 35px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat:nth-child(2) { border-right: 0; }
  .stat:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  footer { gap: 12px; font-size: 9px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }