/* Keep the active play field and controls inside the visible viewport. Help/results may scroll. */
@media(max-width:1000px){
 .game-modal .sky-game[data-learning=true] .sky-field{grid-row:1 / 3;align-self:start}
 .game-modal .sky-game[data-learning=true] .sky-quiz>h3{position:absolute;left:4px;bottom:52px;width:32%;min-height:32px;display:flex;align-items:center}
 .game-modal .sky-game[data-learning=true] .sky-word{position:absolute;right:3px;bottom:55px;width:65%}
 .game-modal .sky-game[data-learning=true] .sky-feedback{bottom:99px}
 .game-modal .sky-game[data-learning=true] .sky-modifier-status{top:64px}
}
/* Sky Word portrait: use the visible browser viewport, with touch dragging instead of four redundant arrows. */
@media(max-width:1000px){
 .game-overlay:has(.sky-game){padding:0!important;align-items:stretch;top:var(--eco-sky-viewport-top,0px)!important;height:var(--eco-sky-viewport-height,100dvh)!important;bottom:auto!important}
 .game-overlay .game-modal:has(.sky-game){width:100%!important;max-width:100%!important;height:100%!important;max-height:100%!important;border-radius:0;border:0}
 .game-modal:has(.sky-game) .game-modal-head{padding:2px 10px!important;min-height:48px;padding-top:max(2px,env(safe-area-inset-top))!important}
 .game-modal:has(.sky-game) .game-modal-head small{display:none!important}
 .game-modal:has(.sky-game) .game-modal-head>button{width:44px;height:44px}
 .game-modal:has(.sky-game) .eco-screen-options{padding:2px 6px!important;gap:4px}
 .game-modal:has(.sky-game) .eco-screen-options>button{min-height:44px;padding:5px 9px;font-size:11px}
 .game-modal:has(.sky-game) .eco-screen-options>small{display:none!important}
 .game-modal:has(.sky-game) .game-body{flex:1;overflow:hidden;padding:4px max(4px,env(safe-area-inset-right)) max(4px,env(safe-area-inset-bottom)) max(4px,env(safe-area-inset-left))!important}
 .game-modal .sky-game{height:100%;min-height:0}
 .game-modal .sky-game .sky-topline{display:none}
 .game-modal .sky-game .sky-layout{position:relative;height:100%;min-height:0;grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:44px minmax(0,1fr) 44px;gap:4px;align-items:center}
 .game-modal .sky-game .sky-flight,.game-modal .sky-game .sky-quiz{display:contents}
 .game-modal .sky-game .sky-quiz>h3{grid-row:1;grid-column:1;margin:0;padding-left:5px;font-size:15px;line-height:1.25;overflow-wrap:anywhere}
 .game-modal .sky-game .sky-word{grid-row:1;grid-column:2 / -1;justify-content:center;margin:0;gap:2px;flex-wrap:nowrap;min-width:0}
 .game-modal .sky-game .sky-word>span{min-width:0;flex:0 1 26px}
 .game-modal .sky-game .sky-word b{width:100%;height:30px;box-sizing:border-box;font-size:15px}
 .game-modal .sky-game .sky-upgrade-status,.game-modal .sky-game .sky-word small{display:none!important}
 .game-modal .sky-game .sky-field{grid-column:1 / -1;grid-row:2;align-self:center;justify-self:center;width:var(--eco-sky-width,100%)!important;height:var(--eco-sky-height,50dvh)!important;box-sizing:border-box;margin:0;max-height:100%;border-width:3px;border-radius:14px}
 .game-modal .sky-game .sky-controls{grid-row:3;grid-column:3;margin:0;padding:0;width:100%;grid-template-columns:minmax(0,1fr);background:transparent}
 .game-modal .sky-game .sky-controls>button:not(.sky-shield){display:none}
 .game-modal .sky-game .sky-controls>.sky-shield,.game-modal .sky-game .sky-actions>button{height:44px;min-height:44px;font-size:11px}
 .game-modal .sky-game .sky-actions{grid-row:3;grid-column:1 / 3;gap:4px;width:100%;margin:0}
 .game-modal .sky-game .sky-label,.game-modal .sky-game .sky-emoji,.game-modal .sky-game .sky-mission-meter,.game-modal .sky-game .sky-tier,.game-modal .sky-game .sky-clue{display:none!important}
 .game-modal .sky-game .sky-feedback{position:absolute;left:8px;right:8px;bottom:52px;z-index:4;margin:0;padding:3px 5px;min-height:0;max-height:36px;overflow:hidden;pointer-events:none;font-size:10px;line-height:1.4;background:#092737dc;color:#e7fff2;text-align:center}
 .game-modal .sky-game .sky-modifier-status{position:absolute;top:110px;left:8px;right:8px;z-index:4;margin:0;pointer-events:none;display:flex;flex-wrap:wrap;justify-content:center;gap:3px}
 .game-modal .sky-game .sky-modifier-status>*{margin:0;padding:3px 5px;font-size:10px}
 html.eco-game-open:has(.sky-game) .eco-experience-panel{top:max(2px,env(safe-area-inset-top));right:60px}
 .game-modal .sky-game .sky-overlay p{font-size:12px;line-height:1.6}
 .game-modal .sky-game .sky-overlay small{display:block;font-size:10px}
}
@media(min-width:681px) and (max-width:1000px) and (max-height:500px){
 .game-modal .sky-game .sky-layout{grid-template-columns:minmax(0,1fr) 190px 100px}
 .game-modal .sky-game .sky-field{grid-column:1;grid-row:1 / -1}
 .game-modal .sky-game .sky-quiz>h3{grid-column:2 / -1;text-align:center;font-size:20px}
 .game-modal .sky-game .sky-word{grid-column:2 / -1;grid-row:2;align-self:start;padding-top:8px}
 .game-modal .sky-game .sky-actions{grid-column:2}
 .game-modal .sky-game .sky-controls{grid-column:3}
 .game-modal .sky-game .sky-modifier-status{left:auto;right:8px;width:276px;top:96px}
 .game-modal .sky-game .sky-feedback{left:auto;right:8px;width:276px;bottom:56px;max-height:64px;font-size:11px}
 .game-modal .sky-game .sky-overlay{padding:12px;overflow:auto;justify-content:safe center}
 .game-modal .sky-game .sky-overlay-icon{display:none}
 .game-modal .sky-game .sky-overlay h3{font-size:18px;margin-bottom:5px}
 .game-modal .sky-game .sky-overlay p{font-size:10px;margin-bottom:6px}
 .game-modal .sky-game .sky-overlay small{display:none}
 .game-modal .sky-game .sky-hud{top:25px;left:4px;right:4px;font-size:10px}
 .game-modal .sky-game .sky-hud span:first-child{font-size:12px}
}
.game-overlay .game-modal{height:calc(100dvh - 20px)}
html.eco-game-open,html.eco-game-open body{overflow:hidden}
@media(max-width:680px){html.eco-game-open .eco-experience-panel{left:auto;right:12px;top:62px;bottom:auto}html.eco-game-open .eco-experience-panel:not([open]){width:44px}html.eco-game-open .eco-experience-panel summary{font-size:0;padding:8px;display:grid;place-items:center}html.eco-game-open .eco-experience-panel summary::after{content:'⚙';font-size:20px}html.eco-game-open .eco-experience-panel[open]{width:min(310px,calc(100vw - 24px))}}
@media(max-height:500px) and (min-width:681px){.eco-link-grid .eco-link-card{height:52px!important}.eco-link-guide{margin:4px 0!important;font-size:10px!important;line-height:1.3!important}}
@media(max-height:500px) and (min-width:681px){.game-modal:has(.word-game),.game-modal:has(.energy-game),.game-modal:has(.sentence-game),.game-modal:has(.eco-link-grid),.game-modal:has(.trash-stage){width:min(840px,calc(100vw - 20px))!important;max-width:840px!important}.game-stats{padding:6px 8px!important;margin:0 0 8px!important}.trash-stage{height:65px!important}.trash-stage .trash-object{font-size:40px!important}.bins-grid button{min-height:44px!important;padding:5px!important}.bins-grid button>span{font-size:20px!important}.energy-game{display:grid!important;grid-template-columns:1fr 1fr;gap:6px}.energy-game .eco-city{height:115px;grid-row:span 3}.energy-game .energy-meter{margin:4px 0}.energy-game .charge-button{min-height:44px;padding:5px;grid-column:2}.word-game{display:grid!important;grid-template-columns:180px minmax(0,1fr);gap:8px}.word-scene{height:140px!important;grid-row:span 3}.word-scene>span{font-size:40px!important}.word-options{margin:0!important}.word-options button{min-height:44px!important;padding:8px!important}.learning-feedback{padding:5px 8px!important;margin:0!important;font-size:10px!important}.sentence-prompt{padding:5px 8px!important}.sentence-board{min-height:44px!important;padding:5px!important;margin:5px 0!important}.token-pool{margin:5px 0!important}.sentence-actions{margin:5px 0!important}.sentence-actions button,.token-pool button,.sentence-board button{min-height:44px}.eco-link-grid{grid-template-columns:repeat(8,minmax(0,1fr))!important;gap:5px!important}.eco-link-card{height:62px!important;aspect-ratio:auto!important}.eco-link-card>span{font-size:22px!important}.eco-link-result{margin:5px 0!important}}
.wb-game .wb-controls{position:static!important}.wb-board-overlay{overflow:auto;justify-content:safe center}
@media(max-height:700px) and (max-width:680px){.wb-game .wb-stage-launch{display:none!important}.wb-game .wb-grid{gap:1px!important;padding:3px!important}.wb-game .wb-mini-grid{grid-template-columns:repeat(4,6px)!important;grid-template-rows:repeat(4,6px)!important}.wb-piece-preview>small{font-size:7px!important}.wb-game .wb-live{margin:3px 0!important;padding:3px 6px!important}.wb-game .wb-controls{margin-top:5px!important}}
@media(max-width:680px){.wb-game .wb-stage-launch{min-height:0!important;height:30px!important;margin:0 0 4px!important}.wb-stage-launch .wb-stage-emblem{font-size:20px}.wb-stage-launch small{display:none}.wb-game .wb-board-title{display:none}.wb-game .wb-layout{gap:6px}.wb-game .wb-next{padding-top:2px}.wb-game .wb-quiz{padding:7px}.wb-game .wb-next>span{font-size:8px}.wb-game .wb-board-overlay{padding:9px;gap:5px}.wb-game .wb-board-overlay>span,.wb-game .wb-board-overlay>p{display:none}.wb-game .wb-board-overlay b{font-size:12px}.wb-game .wb-board-overlay .wb-primary{padding:8px 12px;min-height:44px}}
.sky-game .sky-quiz,.wb-game .wb-quiz{max-height:var(--eco-side-height,70dvh)!important;overflow:auto}@media(max-width:680px){.sky-game .sky-quiz,.wb-game .wb-quiz{max-height:none!important;overflow:visible!important}}@media(max-height:500px) and (min-width:681px){.safari-study-grid{grid-template-columns:repeat(8,minmax(0,1fr))!important}}
@media(max-height:500px){.game-modal-head small,.eco-screen-options small{display:none!important}.game-modal-head{padding:6px 12px!important}.eco-screen-options{padding:4px 12px!important}.wb-tier-track,.wb-stage-launch,.wb-board-title,.wb-progress,.wb-eyebrow{display:none!important}.wb-heading{margin-bottom:4px!important}.wb-metrics{font-size:9px}.wb-game .wb-grid{padding:4px;gap:2px}.wb-game .wb-controls{margin-top:5px}.wb-game .wb-quiz{max-height:calc(100dvh - 135px)!important;overflow:auto!important}.sky-game .sky-topline{display:none}.sky-game .sky-quiz{max-height:calc(100dvh - 135px)!important;overflow:auto!important}.safari-study-guide,.safari-study-feedback{display:none!important}.safari-study-stats{padding:5px 8px!important;font-size:10px!important}.safari-mode-row{margin-bottom:4px!important}.safari-study-grid{gap:3px}.safari-mode-row>b{font-size:12px}.safari-study-actions{margin-top:4px}.safari-study-card .safari-card-front small{display:none}.eco-screen-options button{padding:6px 10px;font-size:11px}}
.game-overlay{padding:10px!important;overscroll-behavior:contain}.game-overlay .game-modal{display:flex;flex-direction:column;max-height:calc(100dvh - 20px)!important;overflow:hidden}.game-modal-head,.eco-screen-options{flex-shrink:0}.game-modal .game-body{min-height:0;overflow:auto;padding:12px 18px!important;overscroll-behavior:contain}.game-modal-head{padding:12px 18px!important}.sky-game .sky-field{height:var(--eco-sky-height,50dvh)!important;width:auto!important;max-width:100%;aspect-ratio:480/680}.sky-game .sky-instructions,.sky-game .sky-key-guide{display:none}.sky-game .sky-quiz{max-height:calc(100dvh - 260px);overflow:auto}.sky-game .sky-controls{position:static}.wb-game .wb-grid{grid-template-rows:repeat(var(--wb-rows,12),var(--eco-brick-row,30px))!important}.wb-game .wb-key-guide,.wb-game .wb-help{display:none}.wb-game .wb-quiz{max-height:calc(100dvh - 210px);overflow:auto}.wb-game .wb-cell img{max-height:var(--eco-brick-row,28px);max-width:100%}.safari-study .safari-study-card{height:var(--eco-memory-card,78px);min-height:var(--eco-memory-card,78px)!important}.safari-study .safari-card-front img{height:calc(var(--eco-memory-card,78px) - 24px);min-height:20px}.safari-study-note{display:none}.memory-grid .memory-card{height:var(--eco-classic-card,78px)!important;min-height:var(--eco-classic-card,78px)!important}.game-modal:has(.eco-arcade-frame){height:calc(100dvh - 20px);max-width:1100px}.game-modal:has(.eco-arcade-frame) .game-body{padding:0!important;flex:1;overflow:hidden}.eco-arcade-frame{height:100%!important;min-height:0!important}.game-body:has(.eco-arcade-frame){min-height:160px}.eco-expanded .game-modal{height:calc(100dvh - 8px);max-height:calc(100dvh - 8px)!important}@media(max-width:680px){.game-overlay{padding:5px!important}.game-overlay .game-modal{width:calc(100vw - 10px)!important;max-width:calc(100vw - 10px)!important;max-height:calc(100dvh - 10px)!important}.game-modal-head{padding:8px 12px!important}.game-modal .game-body{padding:8px 12px!important}.sky-game .sky-quiz{max-height:none;overflow:visible}.sky-upgrade-status{display:none!important}.sky-game .sky-topline{margin-bottom:5px}.sky-game .sky-overlay{overflow:auto;justify-content:safe center}.sky-game .sky-overlay p{font-size:10px;margin-bottom:8px}.sky-game .sky-overlay small{display:none}.wb-tier-track{display:none!important}.wb-stage-launch{min-height:0!important;padding:5px 8px!important;margin-bottom:5px!important}.wb-quiz{max-height:none!important;overflow:visible!important}.safari-study-guide{margin:5px 0;font-size:9px}.safari-mode-row{margin-bottom:5px}.safari-study-feedback{margin:5px 0;padding:5px}.safari-card-back small{font-size:7px}.safari-card-back b{font-size:18px}.safari-card-front{padding:3px!important;gap:2px!important}.safari-study-grid{gap:4px}.safari-study-actions button{min-height:44px}}
/* Touch-first shell, including unfolded Fold: one header row, optional settings popover. */
@media(max-width:1000px) and (min-height:501px){
 .safari-study-grid{grid-template-columns:repeat(4,minmax(0,1fr))!important;gap:6px}
 .safari-study .safari-card-front img{max-height:none}
}
@media(max-width:680px){
 .wb-game .wb-stage-launch,.wb-game .wb-progress,.wb-game .wb-eyebrow{display:none!important}
 .wb-game .wb-heading{margin-bottom:2px}
 .wb-game .wb-quiz{position:relative;padding:4px 6px!important;grid-template-columns:30px minmax(0,1fr) 80px}
 .wb-game .wb-next{grid-column:3;grid-row:1 / 3;display:flex;flex-direction:column;padding:0}
 .wb-game .wb-next>span{display:none}
 .wb-game .wb-mini-grid{grid-template-columns:repeat(4,7px)!important;grid-template-rows:repeat(4,7px)!important}
 .wb-game .wb-live{max-height:24px;overflow:hidden;padding:2px 4px;margin:2px 0!important;line-height:1.3}
 .wb-game .wb-actions{gap:3px}
 .wb-game .wb-quiz h3{font-size:16px;margin:0}
 .wb-game .wb-answer-slots{margin:2px 0}
}
.eco-screen-toggle{display:none}
@media(max-width:1000px){
 .game-overlay{padding:0!important;top:var(--eco-sky-viewport-top,0px)!important;height:var(--eco-sky-viewport-height,100dvh)!important;bottom:auto!important;align-items:stretch}
 .game-overlay .game-modal{width:100%!important;max-width:100%!important;height:100%!important;max-height:100%!important;border:0;border-radius:0}
 .game-modal .game-modal-head,.game-modal:has(.sky-game) .game-modal-head{min-height:48px;height:48px;padding:2px 8px!important;position:relative;flex-shrink:0}
 .game-modal-head small{display:none!important}
 .game-modal-head>div{max-width:calc(100% - 160px)}
 .game-modal-head b{font-size:15px!important;white-space:nowrap}
 .game-modal-head>button{width:44px;height:44px;min-width:44px}
 .game-modal .eco-screen-options{position:absolute;top:2px;right:106px;padding:0!important;z-index:30;display:block;background:none}
 .game-modal .eco-screen-options>:not(.eco-screen-toggle){display:none!important}
 .game-modal .eco-screen-options>.eco-screen-toggle{display:block;min-height:44px;height:44px;padding:6px 8px}
 .game-modal .eco-screen-options[data-open=true]{top:48px;right:6px;width:min(320px,calc(100vw - 12px));padding:8px!important;border:1px solid #628a83;border-radius:12px;background:#102e36;box-shadow:0 8px 25px #0008}
 .game-modal .eco-screen-options[data-open=true]>:not(.eco-screen-toggle){display:inline-flex!important;min-height:44px}
 .game-modal .eco-screen-options[data-open=true]>.eco-screen-toggle{position:absolute;top:-46px;right:100px}
 html.eco-game-open .eco-experience-panel,html.eco-game-open:has(.sky-game) .eco-experience-panel{top:2px;right:56px;left:auto;bottom:auto;z-index:150}
 html.eco-game-open .eco-experience-panel:not([open]){width:44px}
 html.eco-game-open .eco-experience-panel summary{font-size:0;padding:8px;display:grid;place-items:center}
 html.eco-game-open .eco-experience-panel summary::after{content:'⚙';font-size:20px}
 html.eco-game-open .eco-experience-panel[open]{width:min(310px,calc(100vw - 64px))}
 .game-modal .game-body{flex:1;min-height:0;padding:4px!important}
 .game-modal:has(.sky-game) .game-body{padding:2px max(2px,env(safe-area-inset-right)) max(2px,env(safe-area-inset-bottom)) max(2px,env(safe-area-inset-left))!important}
 .game-modal .sky-game .sky-layout{grid-template-rows:36px minmax(0,1fr) 44px;gap:2px}
 .game-modal .sky-game .sky-quiz{max-height:none!important;overflow:visible!important}
 .game-modal .sky-game .sky-field{border-width:1px;border-radius:8px}
 .game-modal .sky-game[data-learning=true] .sky-field{grid-row:2;align-self:center}
 .game-modal .sky-game[data-learning=true] .sky-quiz>h3,.game-modal .sky-game[data-learning=true] .sky-word{position:static;width:auto}
 .game-modal .sky-game[data-learning=true] .sky-feedback{bottom:49px}
 .game-modal .sky-game .sky-modifier-status,.game-modal .sky-game[data-learning=true] .sky-modifier-status{top:76px}
 .game-modal .sky-game .sky-feedback{bottom:49px}
}
@media(min-width:681px) and (max-width:1000px) and (max-height:500px){
 .game-modal .sky-game .sky-layout{grid-template-columns:minmax(0,1fr) 180px 100px}
 .game-modal .sky-game .sky-field,.game-modal .sky-game[data-learning=true] .sky-field{grid-column:1;grid-row:1 / -1}
}
