/* All game pages share the visual viewport, including Safari's changing toolbar. */
:root{--game-visible-height:100svh;--game-safe-bottom:max(12px,env(safe-area-inset-bottom));color-scheme:normal}
body[data-game-viewport]{min-height:var(--game-visible-height);overscroll-behavior-y:contain}
body[data-game-viewport] dialog{max-height:calc(var(--game-visible-height) - 24px - env(safe-area-inset-top))!important;overflow:auto;overscroll-behavior:contain}
body[data-game-viewport] .game-sync-bar{display:none!important}
body[data-game-viewport="2048"] main,body[data-game-viewport="card-sort"] main{height:var(--game-visible-height);min-height:var(--game-visible-height);display:flex;flex-direction:column;padding-top:max(8px,env(safe-area-inset-top));padding-bottom:var(--game-safe-bottom)}
body[data-game-viewport="2048"] main>*,body[data-game-viewport="card-sort"] main>*{flex-shrink:0}
body[data-game-viewport="2048"] .title{margin:5px 0;align-items:center}
body[data-game-viewport="2048"] h1{font-size:clamp(42px,12vw,62px);line-height:1}
body[data-game-viewport="2048"] .toolbar{margin:4px 0;font-size:13px;line-height:1.45}
body[data-game-viewport="2048"] #board{width:var(--game-board-side,100%);height:var(--game-board-side,auto);max-width:100%;align-self:center;aspect-ratio:1;margin:0;flex:none}
body[data-game-viewport="2048"] .viewport-actions{display:flex;align-items:center;justify-content:center;gap:8px;margin-top:7px;flex-wrap:wrap}
body[data-game-viewport="2048"] .viewport-actions .controls,body[data-game-viewport="2048"] .viewport-actions .game-feedback{margin:0;gap:4px}
body[data-game-viewport="2048"] .viewport-actions button{min-width:42px;min-height:44px;padding:4px 9px}
body[data-game-viewport="2048"] #status{font-size:12px;line-height:1.4;margin:5px 0;min-height:17px}
body[data-game-viewport="2048"] .game-sponsors-top{margin:6px 0}
body[data-game-viewport="2048"] .game-sponsors-bottom{margin:7px 0 0}
body[data-game-viewport="card-sort"] .head{margin-top:0}
body[data-game-viewport="card-sort"] .play-options{margin:5px 0}
body[data-game-viewport="card-sort"] .tray{flex:1;min-height:180px;display:flex;flex-direction:column;padding:2px 8px 8px}
body[data-game-viewport="card-sort"] .board{flex:1;min-height:110px;grid-auto-rows:minmax(0,1fr);gap:7px 3px}
body[data-game-viewport="card-sort"] .slot{aspect-ratio:auto;height:100%;min-height:44px}
body[data-game-viewport="card-sort"] .deal-dock{flex:none;margin-top:8px}
body[data-game-viewport="card-sort"] .deal{min-height:44px}
body[data-game-viewport="card-sort"] .hint{margin:8px 0 2px;min-height:18px;font-size:12px;line-height:1.4}
body[data-game-viewport="card-sort"] .tools{margin-top:0;padding-top:4px;gap:20px}
body[data-game-viewport="card-sort"] .game-sponsors-top{margin:6px 0}
body[data-game-viewport="card-sort"] .game-sponsors-bottom{margin:7px 0 0}
body[data-game-viewport="bridge-keeper"] #game{height:var(--game-visible-height);min-height:0;padding-bottom:var(--game-safe-bottom)}
body[data-game-viewport="bridge-keeper"] #panel{max-height:100%;overflow:auto;overscroll-behavior:contain}
body[data-game-viewport] :is(.rank-panel,#leaderboard){max-height:calc(var(--game-visible-height) - 85px)!important;overflow:auto;overscroll-behavior:contain}
@media(min-width:701px){
 body[data-game-viewport="pvz"] main,body[data-game-viewport="find-ball"] main{height:var(--game-visible-height);min-height:var(--game-visible-height);padding-top:12px;padding-bottom:var(--game-safe-bottom);display:flex;flex-direction:column}
 body[data-game-viewport="pvz"] :is(#home,#game):not([hidden]),body[data-game-viewport="find-ball"] :is(#home,#game):not([hidden]){display:flex;flex-direction:column;flex:1;min-height:0}
 body[data-game-viewport="pvz"] #home .title{margin:10px 0}
 body[data-game-viewport="pvz"] #home .title h1{font-size:36px;margin:4px 0}
 body[data-game-viewport="pvz"] #home .title p{margin:4px 0}
 body[data-game-viewport="pvz"] .adventure{flex:1;min-height:0;display:flex;flex-direction:column;padding:16px}
 body[data-game-viewport="pvz"] .chapters{margin-bottom:10px}
 body[data-game-viewport="pvz"] .chapters button{height:42px}
 body[data-game-viewport="pvz"] .road{flex:1;min-height:125px;align-content:center;gap:12px;margin:10px 0}
 body[data-game-viewport="pvz"] .road button{height:48px}
 body[data-game-viewport="pvz"] .challenge{padding:12px}
 body[data-game-viewport="pvz"] .challenge h2{margin:2px 0 6px;font-size:24px}
 body[data-game-viewport="pvz"] .challenge p{margin:4px 0}
 body[data-game-viewport="pvz"] #enter{min-height:44px;margin-top:8px}
 body[data-game-viewport="pvz"] .sponsors-top{margin:6px 0}
 body[data-game-viewport="pvz"] .sponsors-bottom{margin-top:8px}
 body[data-game-viewport="pvz"] .sponsors-bottom .sponsor-link{min-height:65px;padding:10px 20px}
 body[data-game-viewport="pvz"] .battle-hud{padding-bottom:8px;flex:none}
 body[data-game-viewport="pvz"] #stage-caption{margin:6px 0}
 body[data-game-viewport="pvz"] .combat-layout{flex:1;min-height:180px;grid-template-rows:auto minmax(0,1fr)}
 body[data-game-viewport="pvz"] .combat-layout .battle{height:100%;min-height:0;aspect-ratio:auto}
 body[data-game-viewport="pvz"] .battle-footer{flex:none;margin-top:8px;padding-top:8px}
 body[data-game-viewport="find-ball"] main>header{flex:none;padding-bottom:8px}
 body[data-game-viewport="find-ball"] .hero{flex:1;min-height:0;grid-template-rows:minmax(0,1fr) 44px;padding:12px 0;row-gap:10px}
 body[data-game-viewport="find-ball"] .hero-copy h2{font-size:38px}
 body[data-game-viewport="find-ball"] .hero-copy p{margin-top:12px;line-height:1.8}
 body[data-game-viewport="find-ball"] .home-actions{flex:none;margin-top:6px}
 body[data-game-viewport="find-ball"] .home-actions .mode{min-height:50px;padding:8px 12px}
 body[data-game-viewport="find-ball"] .footer{flex:none;margin-top:8px}
 body[data-game-viewport="find-ball"] .game-sponsors-bottom{margin-top:8px}
 body[data-game-viewport="find-ball"] .game-sponsors-top{margin:6px 0}
 body[data-game-viewport="find-ball"] .boards{flex:1;min-height:180px;align-items:center}
 body[data-game-viewport="find-ball"] .boards .board{min-height:0;max-height:100%}
}
@media(max-width:700px){
 body[data-game-viewport="pvz"] main{height:var(--game-visible-height);min-height:var(--game-visible-height);padding:8px 8px var(--game-safe-bottom);display:flex;flex-direction:column}
 body[data-game-viewport="pvz"] :is(#home,#game):not([hidden]){display:flex;flex-direction:column;flex:1;min-height:0}
 body[data-game-viewport="pvz"] #home>header{flex:none;min-height:38px}
 body[data-game-viewport="pvz"] #home .title{margin:10px 0}
 body[data-game-viewport="pvz"] #home .title h1{font-size:clamp(24px,7vw,36px);margin:3px 0}
 body[data-game-viewport="pvz"] #home .title p{margin:3px 0;font-size:11px}
 body[data-game-viewport="pvz"] .adventure{padding:12px;flex:1;min-height:0;display:flex;flex-direction:column}
 body[data-game-viewport="pvz"] .chapters{margin-bottom:10px;gap:5px}
 body[data-game-viewport="pvz"] .chapters button{height:40px;min-height:40px;padding:4px;font-size:13px}
 body[data-game-viewport="pvz"] .road{flex:1;min-height:115px;margin:8px 0;gap:12px 8px;align-content:center}
 body[data-game-viewport="pvz"] .road button{height:clamp(43px,8svh,64px);min-height:40px}
 body[data-game-viewport="pvz"] .challenge{padding:10px}
 body[data-game-viewport="pvz"] .challenge h2{font-size:19px;margin:0 0 5px}
 body[data-game-viewport="pvz"] .challenge p{font-size:12px;line-height:1.5;margin:4px 0}
 body[data-game-viewport="pvz"] #enter{min-height:44px;height:44px;margin-top:8px}
 body[data-game-viewport="pvz"] :is(#sponsor-home-top,#sponsor-game-top){margin:5px 0;flex:none}
 body[data-game-viewport="pvz"] :is(#sponsor-home-bottom,#sponsor-game-bottom){margin:7px 0 0;flex:none}
 body[data-game-viewport="pvz"] .sponsor-link--wide{min-height:40px;padding:7px 10px}
 body[data-game-viewport="pvz"] .sponsors-bottom .sponsor-link{min-height:58px;padding:9px}
 body[data-game-viewport="pvz"] .battle-hud{flex:none;padding:8px 4px;gap:6px;min-height:48px}
 body[data-game-viewport="pvz"] #stage-caption{margin:6px 0;font-size:12px}
 body[data-game-viewport="pvz"] .combat-layout{display:flex;flex-direction:column;flex:1;min-height:150px;gap:7px}
 body[data-game-viewport="pvz"] .combat-layout>.seed-rail{flex:none;min-height:0;padding:5px;order:2}
 body[data-game-viewport="pvz"] .combat-layout>.battle{flex:1;min-height:140px;height:auto;order:3;aspect-ratio:auto}
 body[data-game-viewport="pvz"] .combat-layout>[id*="sponsor"]{order:1}
 body[data-game-viewport="pvz"] .battle-footer{flex:none;margin-top:7px;padding-top:7px}
 body[data-game-viewport="pvz"] #battle-help{font-size:11px;line-height:1.4;margin:3px 0 6px;min-height:16px}
 body[data-game-viewport="pvz"] .battle-footer .hud-button{min-height:38px;padding:5px 9px;font-size:13px}
 body[data-game-viewport="find-ball"] main{height:var(--game-visible-height);min-height:var(--game-visible-height);padding:8px 14px var(--game-safe-bottom);display:flex;flex-direction:column}
 body[data-game-viewport="find-ball"] main>header{min-height:44px;padding-bottom:5px;flex:none}
 body[data-game-viewport="find-ball"] :is(#home,#game):not([hidden]){flex:1;min-height:0;display:flex;flex-direction:column}
 body[data-game-viewport="find-ball"] .hero{flex:1;min-height:160px;display:flex;flex-direction:column;padding:9px 0;gap:0}
 body[data-game-viewport="find-ball"] .hero-copy{flex:none;width:100%}
 body[data-game-viewport="find-ball"] .hero-copy h2{font-size:23px;line-height:1.4;margin:5px 0}
 body[data-game-viewport="find-ball"] .hero-copy .mobile-description{font-size:11px;line-height:1.5;margin:4px 0}
 body[data-game-viewport="find-ball"] .current-story{flex:1;min-height:95px;margin-top:9px;display:flex;flex-direction:column;width:100%}
 body[data-game-viewport="find-ball"] .hero-art-frame{flex:1;min-height:55px;display:flex;align-items:center;justify-content:center;overflow:hidden}
 body[data-game-viewport="find-ball"] .hero-art{height:100%;width:100%;min-height:0;object-fit:contain;aspect-ratio:auto}
 body[data-game-viewport="find-ball"] .gallery-caption{margin-top:6px;gap:5px;flex:none;min-height:34px}
 body[data-game-viewport="find-ball"] .continue{min-height:44px;margin-top:8px}
 body[data-game-viewport="find-ball"] .choose-levels{margin-top:5px;min-height:36px}
 body[data-game-viewport="find-ball"] .home-actions{margin-top:5px;gap:6px;flex:none}
 body[data-game-viewport="find-ball"] .home-actions .mode{min-height:44px;padding:6px 3px}
 body[data-game-viewport="find-ball"] .footer{margin-top:6px;line-height:1.4;font-size:10px;flex:none}
 body[data-game-viewport="find-ball"] .game-top{margin-top:5px;flex:none}
 body[data-game-viewport="find-ball"] .game-top h2{font-size:20px;margin:2px 0}
 body[data-game-viewport="find-ball"] .stats{padding:5px 8px;margin-top:6px;flex:none}
 body[data-game-viewport="find-ball"] .boards{flex:1;min-height:150px;grid-template-rows:repeat(2,minmax(0,1fr));gap:6px;margin-top:8px;overflow:hidden}
 body[data-game-viewport="find-ball"] .boards .board{min-height:0;height:100%;display:flex;align-items:center;justify-content:center}
 body[data-game-viewport="find-ball"] .boards canvas{width:100%;height:100%;object-fit:contain;aspect-ratio:auto}
 body[data-game-viewport="find-ball"] .caption{margin:5px 0;font-size:11px}
 body[data-game-viewport="find-ball"] .game-bottom{margin-top:5px;min-height:42px;flex:none}
 body[data-game-viewport="find-ball"] .game-sponsors-top{margin:6px 0}
 body[data-game-viewport="find-ball"] .game-sponsors-bottom{margin:6px 0 0}
 body[data-game-viewport="find-ball"] .return-gallery{margin-top:5px;min-height:36px}
 body[data-game-viewport="find-ball"] .game-sponsors-bottom .game-sponsor-card{min-height:48px;padding:7px 9px}
}
@media(max-height:580px) and (max-width:700px){
 body[data-game-viewport="pvz"] #home .title .eyebrow,body[data-game-viewport="find-ball"] .hero-copy .mobile-description{display:none}
 body[data-game-viewport="card-sort"] .tray{min-height:145px}
 body[data-game-viewport="pvz"] .adventure{padding:8px}
 body[data-game-viewport="pvz"] .challenge p{font-size:10px;line-height:1.3}
}
@media(orientation:landscape) and (max-height:500px){body[data-game-viewport]:not([data-game-viewport="bridge-keeper"]):not([data-game-viewport="pixel-clear"]) main{height:auto;min-height:var(--game-visible-height)}}
