/* Fix80: viewport-safe student activity screens. Specifically excludes the working flash/sequence modes. */
@media (max-width:720px){
  body:has(#fun.sa80TrainingFit:not(.hidden)) #safeR10Bottom {display:none!important}
  #fun.safeR27ActivityMode.sa80TrainingFit{position:fixed!important;inset:0!important;width:100%!important;height:100dvh!important;min-height:0!important;max-height:100dvh!important;overflow:hidden!important;padding:0!important;background:#f9f6ef!important}
  #fun.safeR27ActivityMode.sa80TrainingFit #activityArea{
    display:flex!important;flex-direction:column!important;gap:0!important;
    height:100%!important;min-height:0!important;max-height:100%!important;
    width:100%!important;padding:0!important;margin:0!important;
    overflow:hidden!important;overscroll-behavior:none!important;
  }
  #fun.safeR27ActivityMode.sa80TrainingFit .safeR27ActivityBar{
    position:relative!important;top:auto!important;z-index:5!important;flex:0 0 52px!important;
    min-height:52px!important;height:52px!important;margin:0!important;padding:5px 10px!important;
    display:flex!important;flex-wrap:nowrap!important;gap:6px!important;
  }
  #fun.safeR27ActivityMode.sa80TrainingFit .safeR27ActivityBar b{font-size:clamp(15px,4.5vw,19px)!important;white-space:nowrap!important;overflow:hidden!important;text-overflow:ellipsis!important}
  #fun.safeR27ActivityMode.sa80TrainingFit .safeR27ActivityBack{min-height:37px!important;padding:5px 9px!important;font-size:clamp(12px,3.4vw,16px)!important;flex-shrink:0!important}
  #fun.safeR27ActivityMode.sa80TrainingFit .sa80BarTimer{display:inline-flex!important;align-items:center!important;white-space:nowrap!important;padding:4px 6px!important;margin-inline-start:auto!important;font-size:13px!important;min-width:0!important;flex:none!important}
  #fun.safeR27ActivityMode.sa80TrainingFit #activityArea>.activitypanel{
    display:flex!important;flex-direction:column!important;flex:1 1 0!important;
    min-height:0!important;max-height:none!important;height:auto!important;
    overflow:hidden!important;padding:7px!important;margin:0 6px 6px!important;
    border-radius:13px!important;
  }
  /* The header already holds the activity name and countdown; don't repeat it. */
  #fun.safeR27ActivityMode.sa80TrainingFit #activityArea>.activitypanel>.head,
  #fun.safeR27ActivityMode.sa80TrainingFit #activityArea>.activitypanel>.kidActivityTop,
  #fun.safeR27ActivityMode.sa80TrainingFit #activityArea>.activitypanel>.note{display:none!important}
  #fun.safeR27ActivityMode.sa80TrainingFit .actTimerTrack{flex:0 0 5px!important;min-height:5px!important;height:5px!important;margin:4px 0 6px!important;}
  #fun.safeR27ActivityMode.sa80TrainingFit .activitypanel>.feedback{min-height:0!important;margin:3px 0!important;padding:0 4px!important;flex:0 0 auto!important}
  /* Numeric input games: reserve real space for the fixed internal keypad and never scroll the content behind it. */
  #fun.safeR27ActivityMode.sa80TrainingFit.sa80NumberFit #activityArea>.activitypanel{
    margin-bottom:calc(clamp(181px,29dvh,239px) + env(safe-area-inset-bottom,0px) + 4px)!important;
  }
  #fun.safeR27ActivityMode.sa80TrainingFit #saFix02NumPad{
    height:calc(clamp(180px,29dvh,238px) + env(safe-area-inset-bottom,0px))!important;
    box-sizing:border-box!important;grid-template-rows:repeat(4,minmax(0,1fr))!important;
  }
  #fun.safeR27ActivityMode.sa80TrainingFit .bigcenter{flex:0 0 auto!important;max-height:25dvh!important;font-size:clamp(23px,5.5vw,39px)!important;line-height:1.25!important;overflow:hidden!important}
  #fun.safeR27ActivityMode.sa80TrainingFit .field{margin:5px 0!important;flex:0 0 auto!important}
  #fun.safeR27ActivityMode.sa80TrainingFit .field input{height:43px!important;min-height:43px!important;padding:5px!important;font-size:20px!important}
  #fun.safeR27ActivityMode.sa80TrainingFit .choices{flex:0 0 auto!important}
  #fun.safeR27ActivityMode.sa80TrainingFit .choices button{min-height:40px!important}
  /* Reading the abacus: the full board, the answer and the submit button are always visible. */
  #fun.safeR27ActivityMode.sa80ReadFit .sa78ReadLayout{display:flex!important;flex-direction:column!important;min-height:0!important;flex:1 1 0!important;gap:5px!important;overflow:hidden!important}
  #fun.safeR27ActivityMode.sa80ReadFit .sa78ReadHint{display:none!important}
  #fun.safeR27ActivityMode.sa80ReadFit .sa78ReadBoard{
    flex:1 1 0!important;min-height:0!important;max-height:none!important;
    height:auto!important;overflow:hidden!important;padding:3px!important;
  }
  #fun.safeR27ActivityMode.sa80ReadFit .sa78ReadBoard svg{width:100%!important;height:100%!important;max-height:100%!important;object-fit:contain!important}
  #fun.safeR27ActivityMode.sa80ReadFit .sa78ReadAnswer{flex:0 0 auto!important;gap:3px!important;margin:0!important}
  #fun.safeR27ActivityMode.sa80ReadFit .sa78ReadAnswer label{font-size:12px!important}
  #fun.safeR27ActivityMode.sa80ReadFit .sa78ReadAnswerRow{grid-template-columns:minmax(0,1fr) 102px!important;gap:5px!important}
  #fun.safeR27ActivityMode.sa80ReadFit #readInput,#fun.safeR27ActivityMode.sa80ReadFit #sa78ReadCheck{height:41px!important;min-height:41px!important}
  #fun.safeR27ActivityMode.sa80ReadFit .sa78ReadFeedback{flex:0 0 auto!important;min-height:24px!important;max-height:26px!important;overflow:hidden!important;padding:4px!important;font-size:11px!important}
  #fun.safeR27ActivityMode.sa80ReadFit #actFeedback{display:none!important}
  #sa80ReadOverlay{position:fixed!important;inset:0!important;z-index:5100!important;background:#072d255c!important;display:grid!important;place-items:center!important;padding:18px!important}
  #sa80ReadOverlay .sa80ReadResult{width:min(100%,330px);background:#fffdf8;border:1px solid #bddacb;border-radius:24px;padding:22px;text-align:center;box-shadow:0 15px 55px #12382d44}
  #sa80ReadOverlay .sa80Stars{font-size:29px;margin-bottom:9px}
  #sa80ReadOverlay strong{display:block;font-size:25px;color:#11674e}
  #sa80ReadOverlay p{font-size:15px;color:#526158}
  #sa80ReadOverlay button{min-width:160px;min-height:48px}
  /* Repetitive addition: arithmetic only, never create or show an abacus. */
  #fun.safeR27ActivityMode.sa80RepeatFit .sa80RepeatWrap{display:flex;flex:1 1 auto;min-height:0;flex-direction:column;align-items:stretch;justify-content:space-evenly;gap:6px;overflow:hidden;padding:8px 3px}
  #fun.safeR27ActivityMode.sa80RepeatFit .sa80RepeatPrompt{text-align:center;font-size:clamp(15px,4vw,20px);font-weight:800;color:#13624e}
  #fun.safeR27ActivityMode.sa80RepeatFit .sa80RepeatNumbers{display:flex;flex-wrap:wrap;align-content:center;align-items:center;justify-content:center;gap:5px;font-size:clamp(24px,7.4vw,44px);font-weight:900;line-height:1.3;direction:ltr;color:#154d3f;flex:1 1 0;min-height:0;overflow:hidden}
  #fun.safeR27ActivityMode.sa80RepeatFit .sa80Plus{font-weight:700;color:#147a60;font-size:.85em}
  #fun.safeR27ActivityMode.sa80RepeatFit .sa80RepeatAnswer{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:6px;flex:0 0 auto}
  #fun.safeR27ActivityMode.sa80RepeatFit .sa80RepeatAnswer label{grid-column:1/-1;font-weight:800;font-size:13px;margin:0}
  #fun.safeR27ActivityMode.sa80RepeatFit .sa80RepeatAnswer input{height:44px;min-width:0;font-size:22px;text-align:center}
  #fun.safeR27ActivityMode.sa80RepeatFit .sa80RepeatAnswer button{height:44px;min-width:94px}
  /* Mental visualization: keep the board and answer box visible above keypad. */
  #fun.safeR27ActivityMode.sa80MentalFit .ab-mini{min-height:0!important;flex:1 1 0!important;max-height:none!important;overflow:hidden!important;margin:2px 0!important}
  #fun.safeR27ActivityMode.sa80MentalFit .ab-mini .abframe{height:100%!important;max-height:100%!important;overflow:hidden!important}
  #fun.safeR27ActivityMode.sa80MentalFit #mentalAb{max-height:100%!important;height:min(23dvh,180px)!important}
  #fun.safeR27ActivityMode.sa80MentalFit #mentalAnswerBox:not(.hidden){flex:0 0 45px!important;margin:4px 0!important;display:flex!important;gap:5px!important}
  #fun.safeR27ActivityMode.sa80MentalFit #mentalAnswerBox .field{flex:1 1 auto!important;min-width:0}
  /* Difference images: use all available width, with no duplicate titles or page scroll. */
  #fun.safeR27ActivityMode.sa80DiffFit .diffImageGrid{flex:1 1 0!important;min-height:0!important;align-items:center!important;gap:4px!important;margin:2px 0!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;overflow:hidden!important}
  #fun.safeR27ActivityMode.sa80DiffFit .diffImageWrap{width:100%!important;min-width:0!important;max-height:100%!important;overflow:hidden!important;position:relative!important}
  #fun.safeR27ActivityMode.sa80DiffFit .diffImageWrap img{width:100%!important;height:auto!important;max-height:min(100%,50dvh)!important;object-fit:contain!important}
  #fun.safeR27ActivityMode.sa80DiffFit .activitypanel>.feedback:not(#actFeedback){flex:0 0 auto!important}
  /* Keep working maze engine intact; fit only its surrounding activity panel. */
  #fun.safeR27ActivityMode.sa80MazeFit .mazeShell{flex:1 1 auto!important;min-height:0!important;overflow:hidden!important;margin:2px auto!important}
  #fun.safeR27ActivityMode.sa80MazeFit .mazeBoardV10{max-height:100%!important}
}
/* Independent number reader: make upper/lower bead movement visibly distinct without changing calculation. */
#r55NumberPage.soroNRPage .soroNRUpper:not(.on) span{transform:translateY(-40%)}
#r55NumberPage.soroNRPage .soroNRUpper.on span{transform:translateY(55%)}
#r55NumberPage.soroNRPage .soroNRBead:not(.on) span{transform:translateY(16%)}
#r55NumberPage.soroNRPage .soroNRBead.on span{transform:translateY(-30%)}
