.math-page { --accent: #a43759; background: var(--background); }
.math-page .learning-toolbar-inner { min-height: 48px; padding-block: max(2px, env(safe-area-inset-top)) 2px; }
.math-page .learning-main { width: min(700px, calc(100% - 28px)); padding-block: 24px; }
.arithmetic { font-size: 18px; line-height: 1.6; }
.math-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.math-heading-title { display: flex; align-items: center; gap: 12px; }
.math-heading img { flex-shrink: 0; }
.math-page .math-heading h1 { font-size: 1.65rem; letter-spacing: 0; }
.math-heading .quiet-button { flex-shrink: 0; min-width: 92px; padding-inline: 12px; font-size: .9rem; }
.math-loading { color: var(--muted); }
.math-loading p { margin: 12px 0; }
.math-progress { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; margin-block: 20px 12px; color: var(--muted); font-size: .9rem; }
.math-progress p { margin: 0; font-variant-numeric: tabular-nums; }
.math-exercise { padding-block: 24px; border-block: 1px solid var(--line); text-align: center; }
.math-exercise h2 { margin: 0; font-size: 1.1rem; font-weight: 600; color: var(--muted); }
.math-exercise h2:focus { outline: none; }
.math-equation { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 100px; margin: 20px 0 28px; font-size: 2.75rem; font-weight: 750; line-height: 1.4; font-variant-numeric: tabular-nums; white-space: nowrap; }
.math-answer { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 2.2em; height: 1.7em; border-bottom: 3px solid var(--accent); border-radius: 8px; background: #fff0f4; color: var(--accent); }
.math-equation.is-solved .math-answer { color: #36603b; background: #eaf4e4; border-color: #6b946c; }
.math-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; width: min(460px, 100%); min-height: 64px; margin-inline: auto; }
.math-option { min-width: 0; min-height: 64px; border: 2px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.math-option.correct { border-color: #6b946c; background: #eaf4e4; color: #36603b; }
.math-option.wrong { border-color: #c55b65; background: #fff0f0; color: var(--accent); }
.math-option:disabled.correct, .math-option:disabled.wrong { opacity: 1; }
.math-feedback { display: flex; align-items: center; justify-content: center; min-height: 56px; margin: 14px 0; color: var(--muted); font-size: 1rem; }
.math-feedback.correct { color: #36603b; }
.math-feedback.wrong { color: var(--accent); font-weight: 700; }
.math-sound-notice { margin: 12px 0 0; color: var(--muted); font-size: .85rem; text-align: center; }
.math-confetti { position: fixed; inset: 0; z-index: 100; overflow: hidden; pointer-events: none; }
.math-confetti-ribbon { position: absolute; top: -24px; left: var(--left); width: 9px; height: 20px; border-radius: 2px; background: var(--color); animation: math-ribbon-fall var(--duration) ease-in var(--delay) both; }
@keyframes math-ribbon-fall {
  from { transform: translate3d(0, -20px, 0) rotate(0); opacity: 1; }
  to { transform: translate3d(var(--drift), 105vh, 0) rotate(var(--turn)); opacity: .2; }
}
@media (prefers-reduced-motion: reduce) {
  .math-confetti-ribbon { display: none; animation: none; }
}
.math-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; min-height: 48px; }
.arithmetic .primary-button, .arithmetic .quiet-button { min-height: 48px; padding: 10px 20px; border: 1px solid var(--line); border-radius: 8px; background: #fff6f4; color: var(--accent); font-weight: 700; }
.arithmetic .primary-button { border-color: var(--accent); background: var(--accent); color: #fff; }
.arithmetic button:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
@media (hover: hover) {
  .math-option:hover:not(:disabled) { border-color: var(--accent); background: #fff0f4; }
  .arithmetic .primary-button:hover:not(:disabled) { background: #8e2b49; }
  .arithmetic .quiet-button:hover:not(:disabled) { border-color: var(--accent); }
}
.arithmetic .primary-button:active:not(:disabled) { background: #7d243f; }
@media (max-width: 640px) {
  .math-page .learning-main { padding-block: 16px; }
  .math-page .math-heading h1 { font-size: 1.5rem; }
  .math-exercise { padding-block: 20px; }
  .math-equation { gap: 8px; font-size: 2.1rem; }
  .math-options { gap: 10px; }
  .math-feedback { font-size: .95rem; }
}
@media (max-width: 360px) {
  .math-equation { font-size: 1.7rem; }
}
@media (max-width: 280px) {
  .math-equation { font-size: 1.35rem; }
  .math-page .math-heading h1 { font-size: 1.2rem; }
}
