/* Hands-on learning extends Number Swarm' warm-paper, painted-picnic visual system. */
#math-challenge[hidden] { display: none; }
#math-challenge { position: fixed; inset: 0; z-index: 30; overflow: auto; overscroll-behavior: contain; background: #3e463acc; padding: 28px 20px; display: grid; align-items: center; }
.math-paper { width: min(100%, 820px); margin: auto; background: #fffdf8; color: #3e463a; border-radius: 16px; padding: 28px 34px 14px; box-shadow: 0 16px 48px #2630264d; }
.math-heading { display: flex; align-items: center; gap: 18px; margin-bottom: 24px; }
.math-heading canvas { width: 88px; height: 88px; object-fit: contain; flex-shrink: 0; }
.math-heading>div { flex: 1; min-width: 0; }
.math-heading span { color: #52664b; font-size: 13px; font-weight: 800; }
.math-heading h1 { font-family: 'Lilita One', ui-rounded, sans-serif; font-weight: 400; font-size: clamp(24px, 3vw, 32px); line-height: 1.12; margin: 6px 0 0; }
.math-paper button { font: inherit; cursor: pointer; min-height: 44px; border: 0; border-radius: 12px; padding: 10px 16px; font-weight: 800; }
.math-paper button:focus-visible, .math-paper input:focus-visible, .learning-tabs button:focus-visible, .learning-difficulty button:focus-visible { outline: 3px solid #426a46; outline-offset: 4px; }
.math-paper button:hover:not(:disabled) { filter: brightness(.96); }
.math-paper button:disabled { cursor: default; opacity: .5; }
.math-read { background: #edf1e4; color: #426a46; font-size: 12px !important; }
.math-workspace { text-align: center; background: #f3f2e8; border-radius: 16px; padding: 24px; }
#math-prompt { font-size: clamp(24px, 4vw, 36px); font-weight: 900; line-height: 1.25; margin: 0 auto 12px; max-width: 32ch; text-wrap: balance; }
.math-instruction { color: #56634f; font-size: 15px; line-height: 1.5; margin: 10px auto 22px; max-width: 52ch; }
.math-collection { display: flex; justify-content: center; gap: 14px; min-height: 114px; }
.math-place { flex: 1; min-width: 0; max-width: 240px; }
.math-place>span { display: block; font-size: 12px; font-weight: 800; color: #52664b; margin-bottom: 10px; }
.math-counters { min-height: 100px; display: flex; align-content: center; align-items: center; justify-content: center; flex-wrap: wrap; gap: 5px; padding: 9px; background: #fffdf8; border-radius: 12px; }
.math-counters canvas { width: 38px; height: 38px; }
.math-tray { width: 80px; height: 32px; }
.math-tray rect { fill: #e7d4b2; stroke: #8c7351; stroke-width: 1.3; }
.math-tray circle { fill: #936c4f; }
.math-tray.math-hundred { width: 48px; height: 48px; }
.math-place small { display: block; color: #596450; font-weight: 700; margin-top: 6px; }
.math-empty { color: #66715d; font-size: 13px; padding: 20px 0; }
.math-total { display: flex; justify-content: center; align-items: baseline; gap: 12px; margin: 18px 0; font-weight: 700; color: #52664b; }
.math-total output { color: #3e463a; font-size: 32px; font-weight: 900; }
.math-build-tools { display: flex; justify-content: center; gap: 20px; }
.math-build-tools>div>span { display: block; font-size: 12px; font-weight: 800; margin-bottom: 6px; }
.math-build-tools>div>div { display: flex; gap: 6px; }
.math-build-tools button, .math-line-tools button { background: #e0e8d5; color: #36583a; min-width: 48px; }
.math-build-tools button[data-build^='-'] { background: #ebe2d3; color: #6d533c; }
.math-number-line svg { width: 100%; display: block; max-height: 180px; }
.math-track { stroke: #8c9b7e; stroke-width: 4; stroke-linecap: round; }
.math-tick { stroke: #8c9b7e; stroke-width: 2; }
.math-hops { stroke: #b27a39; stroke-width: 3; fill: none; }
.math-start { fill: #fffdf8; stroke: #587b4b; stroke-width: 3; }
.math-marker { fill: #426a46; stroke: #fffdf8; stroke-width: 3; }
.math-number-line text { fill: #3e463a; text-anchor: middle; font: 700 18px Nunito, sans-serif; }
.math-number-line .math-marker-label { font-size: 24px; font-weight: 900; }
#math-landing { display: block; width: 100%; margin: 0; height: 48px; accent-color: #426a46; cursor: pointer; }
.math-line-tools { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.math-line-tools span { font-size: 12px; color: #596450; }
.math-answer-label { display: block; font-weight: 800; font-size: 14px; margin-bottom: 8px; }
#math-answer { width: min(100%, 260px); min-height: 64px; font: 900 28px Nunito, sans-serif; text-align: center; background: #fffdf8; border: 2px solid #95a585; border-radius: 12px; color: #3e463a; }
#math-answer::placeholder { color: #68735f; font-size: 18px; font-weight: 600; }
.math-shapes { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 20px auto; max-width: 400px; }
.math-shapes svg { width: 42px; height: 42px; fill: #dfd4e8; stroke: #80638e; stroke-width: 2; }
.math-message { margin: 18px 0; min-height: 40px; font-size: 15px; line-height: 1.5; }
.math-message p { margin: 4px 0; color: #56634f; }
.math-message strong { font-weight: 800; }
.math-actions { display: flex; justify-content: space-between; gap: 14px; align-items: center; padding: 8px 0; }
.math-hint { background: #f0e3cb; color: #6c5234; }
.math-primary { background: #426a46; color: #fffdf8; flex: 1; max-width: 360px; }
.math-save-note { font-size: 11px; color: #596450; text-align: center; margin: 14px 0 0; }
.math-earned { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
.math-earned span { background: #e8eddb; color: #426a46; padding: 7px 12px; border-radius: 8px; font-weight: 800; }
.math-new-sticker { font-weight: 800; color: #765323 !important; }
.math-celebration .math-workspace { background: #eaf0df; }
.math-celebration .math-primary { margin-left: auto; }
.learning-tabs { display: flex; gap: 8px; margin: 0 0 26px; }
.learning-tabs button { min-height: 44px; padding: 10px 20px; border: 0; border-radius: 12px; font: 800 14px Nunito, sans-serif; cursor: pointer; background: #e8eddf; color: #426a46; }
.learning-tabs button[aria-current] { background: #426a46; color: #fffdf8; }
.learning-spread { display: grid; grid-template-columns: .9fr 1.1fr; background: #fffdf8; border: 1px solid #d6dccb; border-radius: 16px; margin: 28px 0 36px; overflow: hidden; }
.learning-letter { display: flex; flex-direction: column; justify-content: center; padding: 28px; background: #edf0e1; }
.learning-letter>.pal-portrait { width: 150px; height: 150px; margin: 0 auto 18px; }
.learning-letter h2 { font-size: 25px; line-height: 1.2; margin: 0 0 12px; }
.learning-letter p { color: #56634f; font-size: 15px; line-height: 1.65; }
.learning-sticker-page { padding: 28px; }
.learning-sticker-page h2 { font-size: 19px; margin: 0 0 24px; }
.learning-sticker-page h2 span { display: block; font: 600 13px Nunito, sans-serif; color: #596450; margin-top: 5px; }
.learning-first-sticker { text-align: center; padding: 14px 0 20px; }
.learning-first-sticker canvas { width: 96px; height: 96px; }
.learning-first-sticker p, .learning-next { color: #56634f; font-size: 14px; line-height: 1.6; }
.learning-stickers { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }
.learning-stickers figure { margin: 0; text-align: center; }
.learning-stickers canvas { width: 76px; height: 76px; max-width: 100%; }
.learning-stickers figcaption { font-size: 12px; font-weight: 800; line-height: 1.3; }
.learning-next { margin-top: 24px; }
.learning-skills h2 { margin-bottom: 8px; }
.learning-skills>p { color: #596450; line-height: 1.6; }
.learning-skill-list { margin: 22px 0; border-top: 1px solid #d6dccb; }
.learning-skill-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 18px; padding: 18px 0; border-bottom: 1px solid #d6dccb; }
.learning-skill-row>div strong { display: block; font-size: 16px; }
.learning-skill-row>div span { display: block; font-size: 13px; color: #596450; margin-top: 5px; }
.learning-status { font-size: 12px; font-weight: 800; color: #596450; align-self: center; }
.learning-status.has-practice { color: #426a46; }
.learning-skill-row small { grid-column: 1/-1; color: #596450; font-size: 12px; }
.learning-return { max-width: 360px; margin-top: 22px; }
.learning-difficulty { display: flex; flex-wrap: wrap; gap: 12px; }
.learning-difficulty button { flex: 1; min-width: 160px; text-align: left; background: #fffdf8; color: #3e463a; border: 1px solid #c8d2bb; border-radius: 12px; padding: 15px; min-height: 80px; cursor: pointer; font: inherit; }
.learning-difficulty button[aria-pressed='true'] { background: #e4ebda; border-color: #426a46; }
.learning-difficulty strong, .learning-difficulty span { display: block; }
.learning-difficulty span { color: #56634f; font-size: 13px; margin-top: 5px; line-height: 1.4; }
@media(max-width:600px) {
  #math-challenge { padding: 10px; align-items: start; }
  .math-paper { padding: 18px 14px 12px; }
  .math-heading { gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
  .math-heading canvas { width: 64px; height: 64px; }
  .math-heading span { font-size: 11px; }
  .math-heading h1 { font-size: 24px; }
  .math-read { margin-left: 74px; min-height: 44px !important; padding: 7px 12px !important; }
  .math-workspace { padding: 18px 10px; }
  #math-prompt { font-size: 26px; }
  .math-instruction { font-size: 14px; }
  .math-collection { gap: 6px; }
  .math-counters { padding: 5px; gap: 3px; }
  .math-counters canvas { width: 30px; height: 30px; }
  .math-tray { width: 58px; height: 24px; }
  .math-tray.math-hundred { width: 32px; height: 32px; }
  .math-place>span { font-size: 10px; }
  .math-build-tools { gap: 10px; }
  .math-build-tools>div>div { gap: 4px; }
  .math-build-tools button { padding: 10px 7px; min-width: 44px; font-size: 14px; }
  .math-line-tools { flex-wrap: wrap; }
  .math-line-tools span { order: 3; width: 100%; text-align: center; }
  .math-line-tools button { padding: 10px 9px; font-size: 13px; }
  .math-actions { position: sticky; bottom: -10px; background: #fffdf8; padding: 14px 0 8px; flex-wrap: wrap; }
  .math-actions button { flex: 1; padding: 12px 10px; font-size: 14px; }
  .math-primary { min-width: 140px; }
  .math-hint { min-width: 125px; }
  .learning-spread { grid-template-columns: 1fr; }
  .learning-letter { padding: 22px; flex-direction: row; gap: 16px; align-items: center; }
  .learning-letter>.pal-portrait { width: 90px; height: 90px; margin: 0; flex-shrink: 0; }
  .learning-letter h2 { font-size: 22px; }
  .learning-letter p { font-size: 13px; }
  .learning-sticker-page { padding: 22px; }
  .learning-tabs button { padding: 10px 16px; }
}
@media(prefers-reduced-motion:no-preference) { .math-celebration .math-earned { animation: learning-unfold 400ms cubic-bezier(.16,1,.3,1); } @keyframes learning-unfold { from { transform: translateY(8px); } to { transform: translateY(0); } } }

@media(max-height:800px) {
  #math-challenge { padding-top: 12px; padding-bottom: 12px; }
  .math-heading { margin-bottom: 16px; }
  .math-heading canvas { width: 64px; height: 64px; }
  .math-workspace { padding-top: 16px; padding-bottom: 16px; }
  .math-instruction { margin-bottom: 14px; }
  .math-collection { min-height: 90px; }
  .math-counters { min-height: 76px; }
  .math-total { margin: 10px 0; }
  .math-message { margin: 12px 0; }
}
.math-actions { position: sticky; bottom: 0; background: #fffdf8; }

@media(max-width:600px) { .math-heading>div { flex-basis: calc(100% - 74px); } }
@media(max-width:380px) { .math-three-places>div>div { flex-direction: column; } }
.learning-topic-note { color: #56634f; font-size: 13px; line-height: 1.5; }

@media(max-width:380px) {
  .math-actions { flex-wrap: nowrap; gap: 8px; }
  .math-actions button { min-width: 0; flex-basis: 0; font-size: 13px; padding: 10px 7px; }
}

.math-answer-options { display: flex; justify-content: center; gap: 12px; margin: 18px 0; }
.math-answer-options button { background: #e0e8d5; color: #36583a; min-width: 60px; font-size: 24px; }
.math-answer-options button[aria-pressed='true'] { background: #426a46; color: #fffdf8; }

@media(max-width:600px) {
  .math-build-workspace { display: flex; flex-direction: column; }
  .math-build-workspace #math-prompt { order: 0; }
  .math-build-workspace .math-instruction { order: 1; }
  .math-build-workspace .math-total { order: 2; }
  .math-build-workspace .math-build-tools { order: 3; margin-bottom: 18px; }
  .math-build-workspace .math-collection { order: 4; }
}

#math-title:focus:not(:focus-visible) { outline: none; }

/* Streak milestones remain visible above the question, without blocking its controls. */
#streak-toast { position: fixed; z-index: 40; top: calc(112px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); max-width: calc(100% - 40px); padding: 8px 16px; border-radius: 18px; background: #fffdf8; color: #426a46; box-shadow: 0 4px 12px #26302633; font-weight: 900; text-align: center; pointer-events: none; }
#streak-toast:empty { opacity: 0; }
