/* MADA V115 — Foundations have two deliberately separate views: explanation,
   then one-screen activity. Scope everything to Foundations; don't alter other games. */
:root{--mada115-nav:var(--mada112-nav-space,78px)}
#main .mada115-intro-page{width:min(100%,930px);max-width:100%;margin:0 auto;display:grid;gap:14px;box-sizing:border-box;min-width:0}
#main .mada115-intro-top{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:8px 2px;font-size:clamp(12px,2.5vw,16px);color:#4d6280;font-weight:800}
#main .mada115-intro-top>button{flex:0 0 auto;min-height:44px;font-size:clamp(12px,2.6vw,15px);padding:9px 12px}
#main .mada115-intro-card{min-height:min(480px,calc(100dvh - 210px));box-sizing:border-box;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:clamp(10px,2vh,22px);padding:clamp(20px,5vw,45px);border-radius:28px;border:1px solid #e6e9f2;background:linear-gradient(135deg,#fffef3 0%,#fff 38%,#eef8ff 100%);box-shadow:0 13px 35px rgba(39,56,83,.08);text-align:center;color:#1d344d}
#main .mada115-intro-icon{width:clamp(66px,13vw,106px);height:clamp(66px,13vw,106px);display:grid;place-items:center;font-size:clamp(38px,7vw,58px);background:#fff4c9;border-radius:30px;flex-shrink:0}
#main .mada115-intro-eyebrow{color:#a91368;font-size:clamp(13px,3vw,18px);font-weight:900}
#main .mada115-intro-card h1{font-size:clamp(25px,5vw,43px);line-height:1.25;color:#1e3959;margin:0}
#main .mada115-intro-sub{font-size:clamp(14px,3vw,19px);line-height:1.5;color:#526377;margin:0}
#main .mada115-intro-tip{display:flex;align-items:center;gap:12px;text-align:start;width:min(100%,650px);padding:12px 16px;background:#e9f6ff;border:1px solid #d4eaf9;border-radius:17px;box-sizing:border-box}
#main .mada115-intro-tip span{font-size:25px;flex:0 0 auto}
#main .mada115-intro-tip p{font-size:clamp(13px,2.7vw,17px);color:#23455e;line-height:1.45;margin:0}
#main .mada115-intro-start{width:min(100%,390px);min-height:clamp(48px,8vh,64px);padding:9px 20px;font-weight:900;font-size:clamp(17px,4vw,22px);border-radius:17px;color:#fff!important;background:linear-gradient(100deg,#c51e80,#f77a1a)!important;box-shadow:0 7px 20px rgba(214,45,128,.21)}
#main .mada115-intro-note{font-size:12px;color:#6e7e91}
/* The exercise shell is independent from page content and never rotates itself. */
body.mada115-foundation-playing{overflow:hidden!important;overscroll-behavior:none!important}
body.mada115-foundation-playing #main{min-width:0!important}
body.mada115-foundation-playing #main .mada115-play-page{
 position:fixed!important;top:0!important;right:0!important;left:0!important;bottom:var(--mada115-nav)!important;
 display:flex!important;flex-direction:column!important;gap:5px!important;z-index:52001!important;
 width:100vw!important;max-width:100vw!important;height:calc(100dvh - var(--mada115-nav))!important;
 max-height:calc(100dvh - var(--mada115-nav))!important;min-height:0!important;min-width:0!important;
 padding:max(5px,env(safe-area-inset-top,0px)) max(6px,env(safe-area-inset-right,0px)) 4px max(6px,env(safe-area-inset-left,0px))!important;
 margin:0!important;box-sizing:border-box!important;background:#f6f9ff!important;overflow:hidden!important;
 transform:none!important;border:0!important;border-radius:0!important;direction:rtl
}
body.mada115-foundation-playing #main .mada115-play-top{width:100%;min-width:0;flex:0 0 auto;display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:7px;min-height:44px;max-height:53px;padding:4px 7px;background:#fff;border-radius:14px;border:1px solid #e5eaf3;box-sizing:border-box;overflow:hidden}
body.mada115-foundation-playing #main .mada115-play-top strong{display:flex;align-items:center;justify-content:center;gap:5px;min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;font-size:clamp(15px,3vw,21px);color:#203b5c}
body.mada115-foundation-playing #main .mada115-play-top button{flex:0 0 auto;min-width:0!important;min-height:35px!important;max-height:42px!important;padding:3px 9px!important;font-weight:800!important;font-size:clamp(11px,2.7vw,15px)!important;border-radius:10px!important;color:#193e64!important;background:#edf6ff!important;border:1px solid #cee2f0!important;box-shadow:none!important}
body.mada115-foundation-playing #main .mada115-play-window{width:100%;flex:1 1 0;min-height:0;min-width:0;overflow:hidden;position:relative;border-radius:15px;background:#fff;border:1px solid #e2eaf5;box-sizing:border-box}
body.mada115-foundation-playing #main .mada115-play-canvas{position:absolute;inset:0;overflow:hidden;padding:clamp(5px,1.1vw,12px);box-sizing:border-box;min-width:0;direction:rtl}
body.mada115-foundation-playing #main .foundation-stage-focus{height:auto!important;max-height:none!important;min-height:0!important;max-width:none!important;width:100%!important;display:block!important;box-sizing:border-box!important;padding:clamp(5px,1.3vw,12px)!important;margin:0!important;overflow:visible!important;border:0!important;box-shadow:none!important}
body.mada115-foundation-playing #main .foundation-stage-focus :is(.foundation-stage-head,.foundation-step-flow,.game-try-piano){display:none!important}
body.mada115-foundation-playing #main .foundation-stage-focus .game-head{display:flex!important;justify-content:flex-end!important;min-height:0!important;padding:0!important;margin:0 0 4px!important;gap:2px!important;align-items:center!important;flex-wrap:nowrap!important}
body.mada115-foundation-playing #main .foundation-stage-focus .game-head>div:first-child{display:none!important}
body.mada115-foundation-playing #main .foundation-stage-focus .game-score{font-size:clamp(12px,2.5vw,15px)!important;padding:3px 9px!important;min-height:0!important}
body.mada115-foundation-playing #main .foundation-stage-focus :is(h2,h3){font-size:clamp(16px,3vw,22px)!important;line-height:1.2!important;margin:3px 0 5px!important}
body.mada115-foundation-playing #main .foundation-stage-focus p{font-size:clamp(12px,2.4vw,15px)!important;line-height:1.3!important;margin:4px 0!important}
body.mada115-foundation-playing #main .foundation-stage-focus :is(.toolbar,.game-choices,.foundation-answer-row){display:flex!important;align-items:stretch!important;justify-content:center!important;flex-wrap:wrap!important;gap:6px!important;margin:6px 0!important;min-width:0!important}
body.mada115-foundation-playing #main .foundation-stage-focus :is(.toolbar,.game-choices,.foundation-answer-row)>button{flex:1 1 100px!important;min-width:0!important;width:auto!important;min-height:clamp(42px,7vh,53px)!important;max-height:none!important;font-size:clamp(12px,2.7vw,17px)!important;padding:6px!important;white-space:normal!important;line-height:1.2!important}
body.mada115-foundation-playing #main .foundation-stage-focus .game-result{min-height:25px!important;max-height:65px!important;overflow:hidden!important;background:#f0f8ff!important;border-radius:11px;padding:6px 8px!important;font-size:clamp(12px,2.7vw,15px)!important}
body.mada115-foundation-playing #main .foundation-stage-focus .micro-card{display:flex!important;align-items:center!important;justify-content:center!important;gap:14px!important;min-height:0!important;margin:4px 0 7px!important;padding:7px!important;max-height:95px!important}
body.mada115-foundation-playing #main .foundation-stage-focus .micro-card .micro-symbol{font-size:clamp(32px,7vw,52px)!important;min-width:60px!important;min-height:55px!important;flex-shrink:0!important;display:grid!important;place-items:center!important}
body.mada115-foundation-playing #main .foundation-stage-focus .micro-card p{display:none!important}
body.mada115-foundation-playing #main .foundation-stage-focus .micro-card h3{margin:0!important}
body.mada115-foundation-playing #main .foundation-stage-focus :is(.foundation-beat-dots,.titi-touch-pair){display:flex!important;justify-content:center!important;gap:8px!important;margin:6px 0!important}
body.mada115-foundation-playing #main .foundation-stage-focus .foundation-beat-dots button{width:clamp(43px,9vw,65px)!important;height:clamp(43px,9vw,65px)!important;min-height:0!important}
body.mada115-foundation-playing #main .foundation-stage-focus .tap-pad{min-height:clamp(62px,13vh,92px)!important;max-height:100px!important;margin:4px auto!important;width:min(100%,420px)!important;font-size:clamp(16px,4vw,22px)!important}
body.mada115-foundation-playing #main .foundation-stage-focus .foundation-number-pads{display:grid!important;grid-template-columns:repeat(8,minmax(0,1fr))!important;gap:5px!important;margin:7px 0!important}
body.mada115-foundation-playing #main .foundation-stage-focus .foundation-number-pads button{min-width:0!important;min-height:clamp(45px,8vh,73px)!important;padding:5px 2px!important}
body.mada115-foundation-playing #main .foundation-stage-focus .foundation-number-pads button b{font-size:clamp(18px,3.4vw,25px)!important}
body.mada115-foundation-playing #main .foundation-stage-focus .foundation-melody-seq{margin:6px 0!important}
body.mada115-foundation-playing #main .foundation-stage-focus .clef-canvas{display:block;width:min(100%,500px)!important;height:min(42vh,250px)!important;max-height:250px!important;margin:auto!important;touch-action:none}
body.mada115-foundation-playing #main .foundation-stage-focus .interactive-staff-v78{height:clamp(120px,28vh,215px)!important}
body.mada115-foundation-playing #main .foundation-stage-focus .foundation-info-grid{grid-template-columns:repeat(3,minmax(0,1fr))!important;gap:4px!important;margin:4px 0!important}
body.mada115-foundation-playing #main .foundation-stage-focus .foundation-info-grid article{padding:6px!important}
body.mada115-foundation-playing #main .foundation-stage-focus .foundation-info-grid b{font-size:18px!important}
body.mada115-foundation-playing #main .foundation-stage-focus .rhythm-train{max-height:145px!important;min-height:85px!important;margin:2px 0!important}
body.mada115-foundation-playing #main .foundation-stage-focus .rhythm-car{width:clamp(43px,8vw,70px)!important;height:clamp(46px,8vw,65px)!important}
body.mada115-foundation-playing #main .foundation-stage-focus .rhythm-engine{font-size:32px!important}
body.mada115-foundation-playing #main .foundation-stage-focus .staff-wrap{height:min(30vh,160px)!important;overflow:hidden!important}
body.mada115-foundation-playing #main .foundation-stage-focus .staff-wrap svg{max-height:150px!important}
/* Very small screens: prioritise large hit targets and a legible single activity. */
@media(max-width:460px){
 #main .mada115-intro-page{gap:7px}
 #main .mada115-intro-top{gap:5px;padding:3px}
 #main .mada115-intro-card{min-height:min(410px,calc(100dvh - 180px));gap:9px;padding:12px;border-radius:20px}
 #main .mada115-intro-tip{padding:10px}
 #main .mada115-intro-note{display:none}
 body.mada115-foundation-playing #main .foundation-stage-focus .foundation-number-pads{grid-template-columns:repeat(4,minmax(0,1fr))!important}
 body.mada115-foundation-playing #main .foundation-stage-focus .foundation-number-pads button{min-height:44px!important}
 body.mada115-foundation-playing #main .foundation-stage-focus .micro-card .micro-symbol{min-width:45px!important}
 body.mada115-foundation-playing #main .foundation-stage-focus .game-result{max-height:48px!important}
}
@media(orientation:landscape) and (max-height:540px){
 body.mada115-foundation-playing #main .mada115-play-top{min-height:35px!important;max-height:40px!important;padding:1px 5px!important}
 body.mada115-foundation-playing #main .mada115-play-top button{min-height:31px!important}
 body.mada115-foundation-playing #main .foundation-stage-focus .micro-card{max-height:60px!important;min-height:0!important;padding:2px!important;margin:2px!important}
 body.mada115-foundation-playing #main .foundation-stage-focus .micro-card .micro-symbol{min-height:35px!important;font-size:31px!important}
 body.mada115-foundation-playing #main .foundation-stage-focus .tap-pad{min-height:45px!important;max-height:55px!important}
 body.mada115-foundation-playing #main .foundation-stage-focus .foundation-number-pads button{min-height:38px!important}
 body.mada115-foundation-playing #main .foundation-stage-focus .clef-canvas{height:min(35vh,150px)!important}
 body.mada115-foundation-playing #main .foundation-stage-focus :is(.toolbar,.game-choices,.foundation-answer-row)>button{min-height:36px!important}
 body.mada115-foundation-playing #main .foundation-stage-focus .interactive-staff-v78{height:110px!important}
}
/* Safeguard: if a particularly complex activity cannot fit without tiny
   controls, scroll only its own play canvas, never the entire page. */
body.mada115-foundation-playing .mada115-play-canvas.mada115-needs-internal-scroll{overflow:auto!important;overscroll-behavior:contain!important;-webkit-overflow-scrolling:touch}
@media(prefers-reduced-motion:reduce){#main .mada115-intro-page *,#main .mada115-play-page *{animation:none!important}}
/* The older wide-mode stylesheet has an unusually specific !important rule;
   hide duplicated FoundationPath headers even under landscape mode. */
body.mada115-foundation-playing #main [data-mada115-exercise] .foundation-stage-focus .foundation-stage-head.v78,
body.mada115-foundation-playing.mada110-wide-mode #main [data-mada110-wide] .foundation-stage-focus .foundation-stage-head.v78{display:none!important}
/* Older universal button styles gave pale cards white text. Keep choices legible. */
body.mada115-foundation-playing #main .foundation-stage-focus .rhythm-choice-big{
 display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr))!important;gap:7px!important;margin:5px 0!important
}
body.mada115-foundation-playing #main .foundation-stage-focus .rhythm-choice-big button{
 min-width:0!important;width:100%!important;height:clamp(52px,11vh,78px)!important;min-height:0!important;
 padding:4px!important;margin:0!important;font-size:clamp(20px,5vw,32px)!important;line-height:1!important;
 display:flex!important;flex-direction:column!important;align-items:center!important;justify-content:center!important;gap:2px!important;
 color:#213f63!important;background:#edf7ff!important;border:2px solid #c8deef!important;border-radius:15px!important;box-shadow:none!important;
}
body.mada115-foundation-playing #main .foundation-stage-focus .rhythm-choice-big button b{color:#213f63!important;font-size:clamp(11px,2.5vw,14px)!important;line-height:1.1!important}
body.mada115-foundation-playing #main .foundation-stage-focus .rhythm-road.mini{margin:4px auto!important;gap:5px!important;flex-wrap:nowrap!important}
body.mada115-foundation-playing #main .foundation-stage-focus .rhythm-road span{width:clamp(42px,11vw,71px)!important;min-width:0!important;height:clamp(49px,10vh,70px)!important;min-height:0!important;border-radius:13px!important;font-size:clamp(22px,5vw,37px)!important}
body.mada115-foundation-playing #main .foundation-stage-focus .rhythm-train-stage{padding:7px!important;margin:5px 0!important;min-height:75px!important;overflow-x:auto!important;border-radius:18px!important}
body.mada115-foundation-playing #main .foundation-stage-focus .subdivision-track{padding:5px!important;margin:6px 0!important;border-radius:13px!important}
body.mada115-foundation-playing #main .foundation-stage-focus .subdivision-track :is(b,span){min-height:35px!important}
body.mada115-foundation-playing #main .foundation-stage-focus .titi-touch-pair button{min-height:clamp(58px,13vh,96px)!important;max-height:110px!important;padding:8px!important;font-size:clamp(20px,5vw,29px)!important;color:#293f5f!important}
body.mada115-foundation-playing #main .foundation-stage-focus .giant-tap{display:block;width:min(100%,530px)!important;min-height:clamp(85px,17vh,150px)!important;max-height:155px!important;margin:10px auto!important;font-size:clamp(18px,4vw,26px)!important}
body.mada115-foundation-playing #main .foundation-stage-focus .game-result{max-height:55px!important}
@media(max-height:550px){
 body.mada115-foundation-playing #main .foundation-stage-focus .rhythm-choice-big button{height:47px!important;font-size:20px!important}
 body.mada115-foundation-playing #main .foundation-stage-focus .rhythm-road span{height:42px!important;font-size:23px!important}
 body.mada115-foundation-playing #main .foundation-stage-focus .titi-touch-pair button{min-height:43px!important;max-height:55px!important}
 body.mada115-foundation-playing #main .foundation-stage-focus .subdivision-track :is(b,span){min-height:28px!important}
 body.mada115-foundation-playing #main .foundation-stage-focus .giant-tap{min-height:70px!important;max-height:85px!important}
 body.mada115-foundation-playing #main .foundation-stage-focus .micro-card{max-height:48px!important}
 body.mada115-foundation-playing #main .foundation-stage-focus .rhythm-train-stage{min-height:57px!important}
}
/* Explanations belong on the pre-activity card, not duplicated above drawing. */
body.mada115-foundation-playing #main [data-mada115-id="clef"] .foundation-stage-host>h2,
body.mada115-foundation-playing #main [data-mada115-id="clef"] .foundation-stage-host>p:first-of-type{display:none!important}
body.mada115-foundation-playing #main [data-mada115-id="clef"] .foundation-stage-host>[data-mode]{font-size:12px!important}
/* Piano target challenge: the oversized target tile formerly pushed its
   actual action buttons below the viewport in short landscape displays. */
body.mada115-foundation-playing #main [data-mada115-id="keyboard"] .note-rush-target{
 display:grid!important;place-items:center!important;min-height:clamp(45px,10vh,76px)!important;
 height:clamp(45px,10vh,76px)!important;max-height:76px!important;margin:4px auto!important;
 padding:3px 12px!important;font-size:clamp(20px,4.5vw,34px)!important;line-height:1.1!important;
 width:min(100%,440px)!important;box-sizing:border-box!important
}
body.mada115-foundation-playing #main [data-mada115-id="keyboard"] [data-answer-piano]{max-height:clamp(50px,13vh,98px)!important;overflow:hidden!important;margin:2px 0!important}
body.mada115-foundation-playing #main [data-mada115-id="keyboard"] [data-answer-piano] :is(.keyboard,.piano-keys,.mini-keyboard,.keys){max-height:100%!important}
body.mada115-foundation-playing #main [data-mada115-id="keyboard"] .game-result{margin:2px 0!important;padding:3px 5px!important}
/* The four-beat explanation is already on the separate intro screen.
   The exercise keeps only its four-slot measure and the choices. */
body.mada115-foundation-playing #main [data-mada115-id="meter"] .meter-card-v78{display:none!important}
body.mada115-foundation-playing #main [data-mada115-id="meter"] .rhythm-choice-big{grid-template-columns:repeat(4,minmax(0,1fr))!important}
body.mada115-foundation-playing #main [data-mada115-id="meter"] .rhythm-choice-big button:last-child{grid-column:auto!important}
body.mada115-foundation-playing #main [data-mada115-id="meter"] .bar44-board{margin:5px 0!important;padding:7px!important;min-height:70px!important}
body.mada115-foundation-playing #main [data-mada115-id="meter"] .bar44-board :is(button,.empty-slot){min-height:45px!important}
@media(orientation:landscape) and (max-height:500px){
 body.mada115-foundation-playing #main [data-mada115-id="meter"] .bar44-board{min-height:52px!important}
 body.mada115-foundation-playing #main [data-mada115-id="meter"] .bar44-board :is(button,.empty-slot){min-height:35px!important}
}
