/* Phone layout for the four Math Practice operation pages. */
@media (max-width: 760px) {
  .math-worksheet .site-header {
    padding: 8px 0;
  }

  .math-worksheet .main-navigation ul {
    align-items: center;
    flex-wrap: nowrap;
    gap: 6px;
    justify-content: flex-start;
    overflow-x: auto;
    padding: 4px 12px 8px;
    scrollbar-width: thin;
  }

  .math-worksheet .main-navigation li {
    flex: 0 0 auto;
  }

  .math-worksheet .main-navigation a {
    display: block;
    padding: 8px 12px;
    white-space: nowrap;
  }

  .math-worksheet .main-navigation a[aria-current="page"] {
    background: rgba(255, 255, 255, 0.28);
    font-weight: 700;
  }

  .math-worksheet .page-content {
    padding: 8px;
  }

  .math-worksheet .addition-container,
  .math-worksheet .subtraction-container,
  .math-worksheet .division-container {
    padding: 0;
  }

  .math-worksheet .title-container,
  .math-addition .container.title-container {
    margin: 0 0 8px;
    padding: 10px 12px;
  }

  .math-worksheet .page-title {
    font-size: 1.35rem;
    line-height: 1.2;
    margin: 0;
  }

  .math-worksheet .page-description {
    font-size: 0.9rem;
    line-height: 1.3;
    margin: 2px 0 0;
  }

  .math-worksheet .dual-container {
    gap: 8px;
    grid-template-columns: minmax(0, 1fr);
    margin: 0;
  }

  .math-worksheet .main-problem-container,
  .math-worksheet .sub-problem-container,
  .math-worksheet .left-container,
  .math-worksheet .right-container {
    min-width: 0;
    min-height: 0;
    max-height: none;
    overflow: visible;
    padding: 10px;
  }

  .math-worksheet .main-problem-container h3,
  .math-worksheet .sub-problem-container h3,
  .math-worksheet .left-container h3,
  .math-worksheet .right-container h3 {
    font-size: 1rem;
    margin: 0 0 6px;
    padding-bottom: 4px;
    position: static;
  }

  .math-worksheet button {
    touch-action: manipulation;
  }

  .math-addition .problem-grid {
    grid-template-columns: 26px repeat(3, minmax(0, 48px));
    grid-template-rows: repeat(5, 36px);
    justify-content: center;
    max-width: 100%;
  }

  .math-addition .sub-problem-display {
    margin-top: 4px;
  }

  .math-addition .sub-input-container,
  .math-addition .simple-number-controls {
    gap: 6px;
    margin-top: 6px;
    padding: 0;
  }

  .math-addition .number-buttons {
    gap: 4px;
  }

  .math-addition .number-btn {
    min-height: 44px;
    min-width: 0;
    padding: 7px 2px;
  }

  .math-addition #currentNumber {
    min-height: 44px;
    padding: 2px 12px;
  }

  .math-addition .combined-action-btn {
    min-height: 44px;
    max-width: none;
  }

  .math-addition .sub-feedback {
    min-height: 0;
    padding: 4px;
  }

  .math-addition .container.ratio-container,
  .math-subtraction .enhanced-score-container,
  .math-division .enhanced-score-container {
    margin-top: 12px;
    padding: 12px;
  }

  .math-addition .score-display {
    margin: 0;
  }

  .math-addition .score-stats,
  .math-subtraction .score-stats,
  .math-division .score-stats {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 8px 0;
  }

  .math-worksheet .score-stats .stat {
    max-width: none;
    min-width: 0;
    padding: 8px;
  }

  .math-subtraction .problem-grid {
    grid-template-columns: 25px repeat(3, minmax(0, 48px));
    grid-template-rows: repeat(5, 42px);
    justify-content: center;
    margin: 6px auto;
    max-width: 100%;
    padding: 8px;
  }

  .math-subtraction .grid-cell {
    font-size: 1.45rem;
  }

  .math-subtraction .current-column-display {
    gap: 8px;
  }

  .math-subtraction .top-digit,
  .math-subtraction .bottom-digit {
    min-width: 52px;
    padding: 8px 10px;
  }

  .math-subtraction .yes-no-buttons {
    gap: 8px;
    margin: 10px 0;
  }

  .math-subtraction .btn-decision {
    flex: 1;
    min-height: 44px;
    min-width: 0;
    padding: 8px;
  }

  .math-subtraction .number-buttons {
    gap: 4px;
    margin: 8px 0;
  }

  .math-subtraction .number-btn {
    min-height: 44px;
    min-width: 0;
    padding: 6px 2px;
  }

  .math-subtraction .number-display,
  .math-subtraction .subtraction-display {
    margin: 8px 0;
    min-height: 44px;
    padding: 6px;
  }

  .math-subtraction .combined-action-btn {
    min-height: 44px;
    margin-top: 8px;
    padding: 8px;
  }

  .math-subtraction .sub-feedback {
    margin: 6px 0 0;
    min-height: 0;
    padding: 4px;
  }

  .math-division {
    --cell-size: clamp(26px, calc((100vw - 64px) / 9), 36px);
  }

  .math-division .main-problem,
  .math-division .equation-display,
  .math-division .main-problem:has(.current-step-container.hidden) .equation-display,
  .math-division .main-problem:has(.current-step-container.hidden):has(.work-feedback.hidden) .equation-display {
    height: auto;
    min-height: 0;
  }

  .math-division .large-equation {
    font-size: clamp(1.5rem, 7vw, 2rem);
    padding: 8px;
  }

  .math-division .current-step-container {
    margin-top: 8px;
    padding: 8px;
  }

  .math-division .current-step-container,
  .math-division .work-feedback {
    transition: none;
  }

  .math-division .current-step-container.hidden,
  .math-division .work-feedback.hidden {
    border: 0;
    margin: 0;
    padding: 0;
  }

  .math-division .right-container {
    overflow-x: auto;
  }

  .math-division .division-work-layout {
    max-width: 100%;
  }

  .math-division .division-table {
    font-size: clamp(0.85rem, 4vw, 1.1rem);
  }

  .math-division .control-grid {
    gap: 4px;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    margin: 8px 0;
    width: 100%;
  }

  .math-division .grid-btn {
    height: 44px;
    width: 100%;
  }

  .math-division .control-buttons {
    gap: 8px;
  }

  .math-division .primary-btn,
  .math-division .secondary-btn,
  .math-division .commit-btn {
    flex: 1 1 130px;
    min-height: 44px;
    padding: 8px;
  }

  .math-multiplication .wrap {
    padding: 20px 0 28px;
  }

  .math-multiplication .hero {
    margin-bottom: 8px;
  }

  .math-multiplication .map-surface {
    margin-top: 8px;
    padding: 8px;
  }

  .math-multiplication .portal-grid {
    gap: 8px;
  }

  .math-multiplication .portal-card {
    gap: 8px;
    min-height: 0;
    padding: 14px;
  }

  .math-multiplication .portal-card p {
    line-height: 1.4;
  }

  .math-multiplication .portal-spacer {
    display: none;
  }
}
