/* MADA V109 — responsive interior-layout repair, based on the real V108 source.
   Prevents title columns collapsing to one word, preserves instruments and worksheets. */
:root{--mada109-navigation-height:76px}
html,body{max-width:100%;}
body.academy-shell-active #app,body.academy-shell-active .mada-shell,
body.academy-shell-active #main{min-width:0;max-width:100%;}
body.mada-unified-content #main.mada-unified-main,
body.mada-unified-content #main.mada-unified-main>*{min-width:0;}
body.mada-unified-content #main.mada-unified-main :is(.panel,.card,.lesson-card,.foundation-stage-work,.foundation-lab,.foundation-stage-host){min-width:0;max-width:100%;}
/* Foundation / game activity heading: the former flex layout gave the entire line
   to the 'back' button and crushed the heading into a 1-character column. */
body #main .foundation-focus-page,body #main .game-focus-page{
 display:grid;grid-template-columns:minmax(0,1fr);width:100%;max-width:100%;min-width:0;gap:clamp(12px,2vw,20px);
}
body #main .foundation-focus-page>* ,body #main .game-focus-page>*{min-width:0;max-width:100%;}
body #main .foundation-focus-top,body #main .game-focus-top{
 display:grid;grid-template-columns:max-content minmax(0,1fr);gap:clamp(12px,2vw,22px);
 align-items:center;justify-content:stretch;width:100%;min-width:0;max-width:100%;
 padding:clamp(13px,2vw,22px);overflow:hidden;
}
body #main .foundation-focus-top>button,body #main .game-focus-top>button{
 min-width:0;max-width:100%;justify-self:start;white-space:normal;line-height:1.45;
}
body #main .foundation-focus-top>div,body #main .game-focus-top>div{
 display:block;min-width:0;width:100%;max-width:100%;flex:initial;
}
body #main :is(.foundation-focus-top,.game-focus-top) :is(h1,h2,h3,p,.eyebrow){
 max-width:100%;min-width:0;white-space:normal;overflow-wrap:break-word;word-break:normal;
 line-height:1.55;
}
body #main :is(.foundation-focus-top,.game-focus-top) h1{font-size:clamp(22px,2.9vw,34px);font-weight:900;}
body #main :is(.foundation-focus-top,.game-focus-top) p{font-size:clamp(14px,1.6vw,17px);}
body #main .foundation-stage-work,body #main .foundation-stage-focus{
 width:100%;max-width:100%;min-width:0;overflow:visible;contain:none;
}
body #main .foundation-stage-head.v78{grid-template-columns:clamp(45px,6vw,65px) minmax(0,1fr) auto;min-width:0;max-width:100%;}
body #main .foundation-stage-head.v78>div:nth-child(2){min-width:0;max-width:100%;}
body #main .foundation-stage-head.v78 :is(h2,p){max-width:100%;overflow-wrap:break-word;word-break:normal;}
body #main .foundation-stage-host{min-width:0;max-width:100%;}
/* General content: preserve two-column desktops, make lesson detail readable on tablets. */
@media (max-width:960px){
 body:not(.number-practice-landscape) #main :is(.twocol,.fieldrow){grid-template-columns:minmax(0,1fr);}
 body:not(.number-practice-landscape) #main .foundation-stage-head.v78{grid-template-columns:54px minmax(0,1fr);}
 body:not(.number-practice-landscape) #main .foundation-stage-head.v78 .foundation-step-flow{grid-column:1/-1;justify-content:center;}
}
@media (max-width:767px){
 body #main .foundation-focus-top,body #main .game-focus-top{
   display:flex;flex-direction:column;flex-wrap:nowrap;align-items:stretch;
   gap:11px;padding:15px;border-radius:19px;
 }
 body #main .foundation-focus-top>button,body #main .game-focus-top>button{
   flex:0 0 auto;align-self:stretch;width:100%;max-width:100%;min-height:46px!important;
   padding:9px 12px!important;font-size:clamp(14px,4vw,17px)!important;
   text-align:center;justify-content:center;overflow-wrap:normal;
 }
 body #main .foundation-focus-top>div,body #main .game-focus-top>div{
   flex:0 0 auto!important;display:block;width:100%;min-width:0;
 }
 body #main :is(.foundation-focus-top,.game-focus-top) h1{font-size:clamp(22px,6vw,30px);line-height:1.4;margin:4px 0 9px;}
 body #main :is(.foundation-focus-top,.game-focus-top) :is(.eyebrow,p){font-size:clamp(13px,3.7vw,16px);line-height:1.7;margin:0;}
 body #main .foundation-stage-head.v78{grid-template-columns:48px minmax(0,1fr)!important;gap:12px;padding:12px;}
 body #main .foundation-stage-head.v78>span{width:48px;height:48px;font-size:28px;}
 body #main .foundation-stage-head.v78 h2{font-size:clamp(19px,5vw,25px);}
 body #main .foundation-stage-head.v78 p{font-size:clamp(13px,3.5vw,16px);}
 body #main .foundation-stage-focus{padding:clamp(12px,3.4vw,20px)!important;}
 body #main .toolbar{max-width:100%;flex-wrap:wrap;}
 body #main .toolbar>button{max-width:100%;white-space:normal;}
 body #main .foundation-number-pads{grid-template-columns:repeat(4,minmax(0,1fr));}
 body #main .foundation-path-grid{grid-template-columns:repeat(2,minmax(0,1fr));}
 body #main .foundation-path-card{min-width:0;}
 body #main .foundation-path-card div{min-width:0;overflow-wrap:break-word;}
 body #main .v103-lessons-grid,body #main .cards,body #main .game-grid{min-width:0;}
 body #main .question,body #main #quiz .choice{min-width:0;overflow-wrap:break-word;}
 body #main .lesson-audio-transport{justify-content:flex-start;}
}
@media(max-width:430px){
 body #main .foundation-focus-page,body #main .game-focus-page{gap:12px;}
 body #main .foundation-focus-top,body #main .game-focus-top{padding:12px;}
 body #main .foundation-path-card{grid-template-columns:34px minmax(0,1fr);padding:10px;}
 body #main .foundation-path-card>span{font-size:27px;}
 body #main .foundation-path-card>strong{grid-column:2;}
 body #main .foundation-path-card b{font-size:14px;}
 body #main .foundation-number-pads button{padding:7px 2px;min-height:58px;}
 body:not(.number-practice-landscape) #main .fieldrow{grid-template-columns:minmax(0,1fr)!important;}
}
/* Child panels with actual tablature/keyboard widths scroll IN their panel, never crush text. */
body #main :is(.staff-wrap,.tablewrap,.piano-keys,.notation-scroll,.score-wrap){max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;}
body #main :is(img,video,canvas,svg){max-width:100%;}
/* Keep the bottom nav anchored; don't overlap Android/iOS system gestures or content. */
@media(max-width:1199px){
 body.mada-unified-content #main.mada-unified-main{padding-bottom:calc(102px + env(safe-area-inset-bottom,0px))!important;}
 body.mada-unified-content .mada-unified-bottom,body[data-mada-page="home"] .mada105-bottom{
   position:fixed!important;bottom:0!important;top:auto!important;inset-inline:0!important;
   width:100%!important;max-width:100%!important;transform:none!important;z-index:9500!important;
   padding-bottom:max(6px,env(safe-area-inset-bottom,0px))!important;
 }
 body[data-mada-v109-focus="true"] #main{padding-bottom:calc(103px + env(safe-area-inset-bottom,0px))!important;}
 body[data-mada-v109-focus="true"] #mobile-simple-back{display:none!important;}
 .mada109-focus-nav{
   position:fixed;inset-inline:0;bottom:0;top:auto;display:flex;align-items:stretch;justify-content:space-around;
   z-index:9600;background:#fffeff;box-shadow:0 -5px 25px #25364a24;
   border:1px solid #e3e8f2;border-radius:17px 17px 0 0;min-height:64px;
   padding:5px max(6px,env(safe-area-inset-right)) max(6px,env(safe-area-inset-bottom)) max(6px,env(safe-area-inset-left));
 }
 .mada109-focus-nav button{display:flex;flex:1;min-width:0;align-items:center;justify-content:center;flex-direction:column;gap:1px;
   border:0;background:transparent!important;color:#34465d!important;box-shadow:none!important;
   font-size:11px;font-weight:800;min-height:52px;padding:3px 2px;border-radius:12px;white-space:normal;line-height:1.22;}
 .mada109-focus-nav button span{font-size:21px;line-height:1.1;}
 .mada109-focus-nav button:first-child{color:#ba166f!important;background:#fff0f8!important;}
}
@media(min-width:1200px){.mada109-focus-nav{display:none!important;}}
/* Dedicated landscape practice players own the screen: never overlay a tab bar. */
body.number-practice-landscape .mada109-focus-nav,
body.number-immersive-body .mada109-focus-nav,
body.studio-play-landscape .mada109-focus-nav{display:none!important;}
@media (orientation:landscape) and (max-height:530px){
 body[data-mada-v109-focus="true"] .mada109-focus-nav{display:none!important;}
 body[data-mada-v109-focus="true"] #main{padding-bottom:14px!important;}
}
