:root{--r27-phone:430px;--r27-paper:#fffaf1;--r27-line:#e4d7c1;--r27-green:#0b5e4f;--r27-shadow:0 10px 24px rgba(15,62,52,.10)}

/* Keep the whole product mobile-first on Android and Flutter Web. */
html,body{overflow-x:hidden!important}
#app{width:min(100%,var(--r27-phone))!important;max-width:var(--r27-phone)!important;margin:0 auto!important;overflow-x:hidden!important;box-sizing:border-box!important}
#app>section.wrap,#home.wrap{width:100%!important;max-width:100%!important;box-sizing:border-box!important;overflow-x:hidden!important}
#app .card,#app .sectionbox,#app .trainergrid,#app .grid{min-width:0!important;box-sizing:border-box!important}

/* Home: six medium square tiles, exactly two per row. */
#modules,#modules.grid{grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:12px!important}
#modules .safeR25Card{aspect-ratio:1/1!important;height:auto!important;min-height:0!important;max-height:none!important;border-radius:20px!important;box-shadow:var(--r27-shadow)!important}
#modules .safeR25Title{height:42px!important;min-height:42px!important;padding:10px 10px 6px!important;font-size:15px!important;line-height:1.12!important;white-space:normal!important;overflow:hidden!important}
#modules .safeR25Visual{flex:1!important;min-height:0!important;margin:0!important;padding:0!important;overflow:hidden!important}
#modules .safeR25Visual img{width:100%!important;height:100%!important;object-fit:cover!important;object-position:center!important;display:block!important}

/* Internal pages remain phone-sized but do not inherit the home card treatment. */
#app>section.wrap:not(#home){padding:12px!important;max-width:100%!important;overflow-x:hidden!important}
#app>section.wrap:not(#home)>.head{gap:8px!important;margin-bottom:10px!important}
#app>section.wrap:not(#home)>.head h2{font-size:21px!important;margin:2px 0!important}
#app>section.wrap:not(#home)>.head .toolbar{width:100%!important;display:flex!important;gap:6px!important;flex-wrap:wrap!important}
#app>section.wrap:not(#home)>.head .toolbar button{flex:1 1 auto!important;min-width:74px!important}

/* Soroban lab: no horizontal panning. The rods shrink to fit the phone. */
#abacus{overflow-x:hidden!important}
#abacus .soro-tools{gap:7px!important;margin-bottom:8px!important}
#abacus .soro-help{gap:5px!important}
#abacus>.note{font-size:11px!important;line-height:1.55!important;margin:7px 0!important}
#abacus .abstage,
#v179LabHost>#abacus .abstage,
#v180LabHost>#abacus .abstage,
#v181LabMount>#abacus .abstage,
#v182LabMount>#abacus .abstage,
#v183LabMount>#abacus .abstage{width:100%!important;max-width:100%!important;overflow:hidden!important;padding:7px!important;box-sizing:border-box!important;border-radius:20px!important}
#abacus .abframe,
#v179LabHost>#abacus .abframe,
#v180LabHost>#abacus .abframe,
#v181LabMount>#abacus .abframe,
#v182LabMount>#abacus .abframe,
#v183LabMount>#abacus .abframe{min-width:0!important;width:100%!important;max-width:100%!important;box-sizing:border-box!important;padding:12px 3px 43px!important;border-width:7px!important;border-radius:16px!important}
#abacus .abinner{width:100%!important;max-width:100%!important;height:390px!important;gap:1px!important;overflow:visible!important}
#abacus .rod{min-width:0!important;flex:1 1 0!important;border-left-width:1px!important}
#abacus[data-r27-rods="13"] .bead{width:23px!important}
#abacus[data-r27-rods="19"] .bead{width:15px!important}
#abacus .bead{max-width:26px!important;box-sizing:border-box!important}
#abacus .digit{font-size:12px!important;bottom:-29px!important}
#abacus .place{font-size:7px!important;bottom:-43px!important;overflow:hidden!important}
#abacus .readout{margin-top:8px!important;padding:9px 11px!important;min-height:46px!important}
#abacus .num{font-size:24px!important}

/* Entertainment index: compact mobile cards. */
#fun{position:relative!important;overflow-x:hidden!important}
#funGrid.activitygrid{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:9px!important}
#funGrid .activity{min-height:154px!important;padding:11px!important;border-radius:17px!important;gap:6px!important}
#funGrid .activity .ico{width:43px!important;height:43px!important;border-radius:13px!important;font-size:24px!important}
#funGrid .activity h3{font-size:14px!important;margin:6px 0 4px!important}
#funGrid .activity p{display:none!important}
#funGrid .activity .status{font-size:9px!important;padding:4px 6px!important;margin-top:2px!important}
#funGrid .activity-actions{display:flex!important;gap:5px!important;margin-top:6px!important}
#funGrid .activity-actions button{min-height:36px!important;font-size:11px!important;padding:6px 7px!important;flex:1!important}
#funGrid .activity-actions .howbtn{display:none!important}
#v25FunSummary{font-size:10px!important;margin-bottom:8px!important}

/* Each activity becomes its own screen instead of scrolling below the list. */
#fun.safeR27ActivityMode{padding:0!important;min-height:100dvh!important;background:#f8f5ee!important;overflow:hidden!important}
#fun.safeR27ActivityMode>.head,#fun.safeR27ActivityMode>#funGrid,#fun.safeR27ActivityMode>#v25FunSummary{display:none!important}
#fun.safeR27ActivityMode #activityArea{display:block!important;margin:0!important;padding:10px 10px 86px!important;width:100%!important;min-height:100dvh!important;box-sizing:border-box!important;overflow-x:hidden!important;background:linear-gradient(180deg,#fffdf8,#f5f1e8)!important}
#fun.safeR27ActivityMode #activityArea>.activitypanel{margin:0!important;padding:13px!important;border-radius:20px!important;box-shadow:none!important;border:1px solid #e3d7c4!important;max-width:100%!important;overflow-x:hidden!important}
.safeR27ActivityBar{position:sticky!important;top:0!important;z-index:20!important;display:flex!important;align-items:center!important;justify-content:space-between!important;gap:8px!important;margin:-10px -10px 10px!important;padding:10px 12px!important;background:rgba(255,250,241,.96)!important;backdrop-filter:blur(10px)!important;border-bottom:1px solid #e5d8c3!important}
.safeR27ActivityBar b{font-size:16px!important;color:#174b40!important}
.safeR27ActivityBack{border:0!important;border-radius:12px!important;background:#0b6554!important;color:#fff!important;min-height:38px!important;padding:7px 12px!important;font-weight:900!important}
#fun.safeR27ActivityMode .kidActivityTop{margin-bottom:8px!important;padding:8px 9px!important}
#fun.safeR27ActivityMode .kidActivityTop small{display:none!important}
#fun.safeR27ActivityMode .activitypanel>.head small{display:none!important}
#fun.safeR27ActivityMode .activitypanel>.head h3{font-size:19px!important}
#fun.safeR27ActivityMode .note{font-size:11px!important;line-height:1.55!important}
#fun.safeR27ActivityMode canvas{max-width:100%!important;height:auto!important}
#fun.safeR27ActivityMode .v17FlashStage{min-height:210px!important;padding:8px!important}
#fun.safeR27ActivityMode .v17FlashCard{font-size:52px!important}
#fun.safeR27ActivityMode .flashstage{min-height:190px!important;font-size:54px!important}
#fun.safeR27ActivityMode .choices{gap:6px!important;flex-wrap:wrap!important}
#fun.safeR27ActivityMode .choices button{min-width:0!important;flex:1 1 92px!important}
#fun.safeR27ActivityMode .field input,#fun.safeR27ActivityMode .field textarea{width:100%!important;box-sizing:border-box!important}
#fun.safeR27ActivityMode .mazeCanvas{width:100%!important;height:auto!important}
#fun.safeR27ActivityMode .mazeShell,#fun.safeR27ActivityMode .v17MiniAbacus,#fun.safeR27ActivityMode .ab-mini{max-width:100%!important;overflow:hidden!important}

/* Tables stay inside the phone; only the table itself may scroll when truly necessary. */
#app .card:has(table),#app .sectionbox:has(table){overflow-x:auto!important;-webkit-overflow-scrolling:touch!important}
#app table{max-width:none!important}

@media(max-width:390px){
  #modules,#modules.grid{gap:9px!important}
  #modules .safeR25Title{font-size:13.5px!important;height:39px!important;min-height:39px!important;padding:8px 8px 5px!important}
  #funGrid.activitygrid{gap:7px!important}
  #funGrid .activity{min-height:145px!important;padding:9px!important}
  #abacus[data-r27-rods="13"] .bead{width:21px!important}
  #abacus[data-r27-rods="19"] .bead{width:14px!important}
}
#v19EmbeddedGameHost{width:100%!important;max-width:100%!important;overflow:hidden!important}
#v19EmbeddedGameHost iframe{width:100%!important;max-width:100%!important}
.v183ToolPanel{width:min(390px,calc(100vw - 12px))!important;right:6px!important;box-sizing:border-box!important}
