/* Web 8.95. Screen-local scrolling, safe areas and touch-sized controls. */
:root{--hud-height:68px}
html,body{height:100%;min-height:0!important}
#game{height:100vh;height:100dvh;min-height:0!important}
button,a{-webkit-tap-highlight-color:transparent}
button:focus-visible,a:focus-visible{outline:3px solid #fff4a3;outline-offset:3px}
.settings-popover,.info-popover{max-height:calc(100dvh - 90px);overflow-y:auto;overscroll-behavior:contain}
#gameCanvas{touch-action:none}
#storyBody{user-select:text;-webkit-user-select:text}
@media(max-width:900px),(max-height:600px){
 :root{--hud-height:calc(62px + env(safe-area-inset-top))}
 #game{width:100%;max-width:none!important}
 #game .hud{display:flex!important;top:0!important;left:0!important;right:0!important;gap:6px!important;height:var(--hud-height);padding:calc(6px + env(safe-area-inset-top)) max(8px,env(safe-area-inset-right)) 6px max(8px,env(safe-area-inset-left))!important;align-items:center!important}
 #game .hud button{flex:0 0 44px!important;width:44px!important;height:44px!important;min-width:44px;min-height:44px;margin:0!important;font-size:22px!important}
 #game .hud .back-btn.hidden,#game:has(#homeScreen.active) #backBtn,#game:has(#ageScreen.active) #backBtn{display:none!important}
 #game .hud .yawn-btn{display:none!important}
 #game .hud .mobile-hud-title{display:block!important;flex:1 1 auto!important;min-width:0!important;max-width:none!important;margin:0!important;padding:0!important;background:none!important;border:0!important;box-shadow:none!important;color:#fff8df!important;text-shadow:0 2px 3px #321a10;font-size:14px!important;line-height:1.2!important;white-space:normal!important;text-align:left!important}
 #game .hud-spacer{display:none!important}
 #game:has(#homeScreen.active) .mobile-hud-title,#game:has(#ageScreen.active) .mobile-hud-title{display:block!important}
 #game .coin-pill{flex:none;font-size:14px!important;gap:3px!important;padding:6px!important;max-width:84px;overflow:hidden;margin:0!important}
 #game .coin-pill img{width:22px!important;height:22px;object-fit:contain}
 #game .screen.active{padding:calc(var(--hud-height) + 10px) max(12px,env(safe-area-inset-right)) max(16px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left))!important;overflow-x:hidden!important;overflow-y:auto!important;overscroll-behavior:contain;scroll-padding-top:12px;-webkit-overflow-scrolling:touch}
 #game .screen>.screen-title,#game .screen>.page-art-title{display:none!important}
 #game .settings-popover,#game .info-popover{position:absolute!important;top:var(--hud-height)!important;left:auto!important;right:8px!important;width:min(340px,calc(100% - 16px))!important;max-height:calc(100dvh - var(--hud-height) - 16px)!important;z-index:150}
 #game .settings-row,#game .age-buttons button{min-height:44px}
 /* Home: visible mascot, readable greeting and all four menu actions. */
 #game #homeScreen.active{display:grid!important;grid-template-columns:minmax(0,1fr) minmax(0,1fr)!important;grid-template-rows:auto auto auto!important;gap:8px!important;align-content:center!important;align-items:center!important;justify-items:center!important}
 #homeScreen #livingHome{display:none!important}
 #game #homeScreen.active .game-logo{display:block!important;position:static!important;inset:auto!important;transform:none!important;grid-area:1/1/2/3;width:min(76%,300px)!important;max-width:300px!important;max-height:100px!important;height:auto!important;object-fit:contain!important;margin:0!important}
 #game #homeScreen.active .hero-beaver{display:block!important;visibility:visible!important;position:static!important;inset:auto!important;grid-area:2/1/3/2;justify-self:end;width:min(100%,180px)!important;height:auto!important;max-height:none!important;max-width:180px!important;aspect-ratio:1;transform:none!important;margin:0!important}
 #game #homeScreen.active .home-talk{display:block!important;position:static!important;inset:auto!important;grid-area:2/2/3/3;justify-self:start;transform:none!important;max-width:170px!important;width:100%!important;margin:0!important;font-size:13px!important;line-height:1.3;padding:10px!important}
 #game #homeScreen.active .v8-home-actions{position:static!important;inset:auto!important;transform:none!important;grid-area:3/1/4/3;display:flex!important;flex-direction:column!important;align-items:center!important;gap:4px!important;width:min(100%,320px)!important;max-width:320px!important;margin:0!important;padding:0!important}
 #game #homeScreen.active .v8-secondary-actions{display:flex!important;flex-direction:column!important;align-items:center!important;width:100%!important;max-width:none!important;gap:4px!important;margin:0!important}
 #game #homeScreen.active .menu-art-btn{display:block!important;width:100%!important;max-width:100%!important;min-height:48px!important;height:auto!important;padding:0!important;margin:0!important;flex:none!important;background:none!important;border:0!important;box-shadow:none!important;transform:none!important}
 #game #homeScreen.active .menu-art-btn img{display:block!important;width:100%!important;height:76px!important;max-height:none!important;object-fit:contain!important}
 #game #homeScreen.active .menu-art-play img{height:86px!important}
 /* Age selection is in flow, including the shortest phones. */
 #game #ageScreen .age-card{position:relative!important;inset:auto!important;transform:none!important;width:min(100%,650px)!important;margin:auto!important;display:flex!important;flex-direction:column!important;padding:20px 14px!important;gap:12px!important;max-height:none!important}
 #game #ageScreen .age-beaver{width:140px!important;height:140px!important;object-fit:contain}
 #game #ageScreen h1{font-size:26px!important;margin:8px 0}
 #game #ageScreen .age-copy{min-width:0;text-align:center}
 #game #ageScreen .age-first-buttons{display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px!important}
 #game #ageScreen .age-first-buttons button{width:auto!important;min-width:0!important;min-height:68px;padding:10px!important}
 /* Questions never crop the title, visual exercise or last answer. */
 #game #questionScreen .question-head{position:static!important;inset:auto!important;transform:none!important;display:flex!important;justify-content:center;gap:8px;margin:0 auto 12px!important}
 #game #questionScreen .question-world,#game #questionScreen .question-step{font-size:13px!important;padding:6px 10px!important}
 #game #questionScreen .quiz-wrap{position:static!important;inset:auto!important;transform:none!important;display:flex!important;flex-direction:column!important;width:min(100%,680px)!important;max-width:100%!important;max-height:none!important;gap:14px!important;margin:0 auto!important;padding:0!important}
 #game #questionScreen .paper-card{position:relative!important;inset:auto!important;transform:none!important;width:100%!important;min-width:0!important;max-height:none!important;overflow:visible!important;padding:18px 14px!important}
 #game #questionScreen #questionTitle{font-size:clamp(19px,4.5vw,26px)!important;line-height:1.3!important;margin:12px 0!important;overflow-wrap:anywhere}
 #game #questionScreen .visual-task{height:auto!important;max-height:none!important;overflow:visible!important;margin:12px auto!important;font-size:30px!important}
 #game #questionScreen .visual-task img{max-width:100%;object-fit:contain}
 #game #questionScreen .answers{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:10px!important}
 #game #questionScreen .answer{min-width:0!important;min-height:56px!important;width:100%!important;padding:12px 8px!important;font-size:18px!important;line-height:1.3!important;white-space:normal!important;overflow-wrap:anywhere}
 #game #questionScreen .coach{position:static!important;inset:auto!important;display:flex!important;flex-direction:row!important;align-items:center!important;gap:8px;width:100%!important;max-width:100%!important;transform:none!important;margin:0!important}
 #game #questionScreen .coach img{width:76px!important;height:76px!important;object-fit:contain;flex:none}
 #game #questionScreen .speech{position:static!important;inset:auto!important;transform:none!important;font-size:14px!important;max-width:none!important;flex:1;padding:12px!important}
 /* Menus and books use normal document flow and local scrolling. */
 #game #miniSelectScreen .mini-lobby,#game #storiesScreen .story-library,#game #beaverWorldScreen .adventure-grid,#game #worldsScreen .world-grid{position:static!important;inset:auto!important;transform:none!important;width:min(100%,760px)!important;max-width:100%!important;max-height:none!important;height:auto!important;margin:0 auto!important;overflow:visible!important}
 #game #miniSelectScreen .mini-select-card{display:grid!important;grid-template-columns:1fr!important;gap:14px!important}
 #game #miniSelectScreen .mini-lobby-head{margin:0 0 14px!important}
 #game #miniSelectScreen .mini-lobby-copy b{font-size:22px!important}
 #game #miniSelectScreen .mini-lobby-copy span{font-size:13px!important}
 #game #miniSelectScreen .mini-choice{width:100%!important;height:auto!important;min-height:200px!important;padding:14px!important;overflow:hidden!important}
 #game #miniSelectScreen .mini-card-copy b{font-size:20px!important}
 #game #miniSelectScreen .mini-card-copy span{display:block!important;font-size:13px!important;line-height:1.4!important}
 #game #miniSelectScreen .mini-card-art{height:90px!important;min-height:90px!important}
 #game #miniSelectScreen .mini-stats{position:static!important;margin:14px 0!important}
 #game #storiesScreen .story-library{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:12px!important;padding:0 0 12px!important}
 #game #storiesScreen .story-book{min-width:0!important;width:100%!important;min-height:0!important;height:auto!important;padding:8px!important}
 #game #storiesScreen .story-cover{min-height:165px!important;height:auto!important;padding:12px 6px!important}
 #game #storiesScreen .story-cover b{font-size:17px!important;line-height:1.25!important}
 #game #storiesScreen .story-book p{font-size:13px!important;line-height:1.4!important}
 #game #storyReaderScreen .story-top{position:static!important;inset:auto!important;transform:none!important;display:flex;gap:8px;width:100%!important;margin-bottom:12px;padding:0!important}
 #game #storyReaderScreen .story-top>b{font-size:16px!important;min-width:0;flex:1}
 #game #storyReaderScreen .story-scene{position:relative!important;inset:auto!important;transform:none!important;width:100%!important;height:auto!important;min-height:0!important;overflow:visible!important;display:flex!important;flex-direction:column!important}
 #game #storyReaderScreen .story-art{position:relative!important;inset:auto!important;width:100%!important;height:auto!important;aspect-ratio:16/10;background-size:contain!important;background-repeat:no-repeat;background-position:center!important;flex:none}
 #game #storyReaderScreen .story-text{position:relative!important;inset:auto!important;transform:none!important;width:100%!important;max-width:none!important;max-height:none!important;height:auto!important;padding:14px!important;overflow:visible!important;opacity:1!important}
 #game #storyReaderScreen .story-text-content{max-height:none!important;overflow:visible!important}
 #game #storyReaderScreen .story-text h2{font-size:22px!important}
 #game #storyReaderScreen .story-text p{font-size:17px!important;line-height:1.6!important}
 #game #storyReaderScreen .story-nav-arrow{top:60px!important;bottom:auto!important;width:44px!important;height:44px!important}
 #game #storyReaderScreen .story-choices{display:flex;flex-direction:column;gap:8px}
 #game #storyReaderScreen .story-choices button,#game #storyReaderScreen .green-btn{min-height:48px!important;font-size:16px!important;white-space:normal!important}
 #game #adventureScreen .adventure-card{position:relative!important;inset:auto!important;transform:none!important;width:min(100%,720px)!important;max-height:none!important;height:auto!important;margin:auto!important;overflow:visible!important;padding:16px!important}
 #game #adventureScreen .adventure-illustration{height:auto!important;aspect-ratio:16/9;min-height:0!important;background-size:contain!important;background-repeat:no-repeat}
 #game #adventureScreen h2{font-size:23px!important}
 #game #adventureScreen p{font-size:16px!important;line-height:1.5!important}
 #game #adventureScreen button{min-height:48px!important;white-space:normal!important}
 #game #rewardScreen.active{display:flex!important;flex-direction:column;align-items:center;gap:14px}
 #game #rewardScreen .reward-title,#game #rewardScreen .reward-beaver,#game #rewardScreen .reward-card,#game #rewardScreen #rewardNextBtn{position:static!important;inset:auto!important;transform:none!important;margin:0!important;max-width:100%!important}
 #game #rewardScreen .reward-title{font-size:32px!important}
 #game #rewardScreen .reward-beaver{width:150px!important;height:150px!important;object-fit:contain}
 #game #rewardScreen .reward-card{width:100%!important;padding:16px!important}
 #game #rewardScreen #rewardNextBtn{min-height:48px!important;font-size:18px!important}
 /* Map remains pan-able; fixed controls occupy their own bottom strip. */
 #game #pathScreen.active{padding:0!important;overflow:hidden!important}
 #game #pathScreen .map-title-wood,#game #pathScreen .map-bottom-hint{display:none!important}
 #game #pathScreen .map-topbar{position:absolute!important;top:var(--hud-height)!important;left:12px!important;right:12px!important;bottom:auto!important;height:48px!important;transform:none!important;pointer-events:none}
 #game #pathScreen .map-progress-hud{width:100%!important;max-width:300px!important;margin:auto!important;padding:6px 12px!important}
 #game #pathScreen .map-viewport{position:absolute!important;inset:calc(var(--hud-height) + 60px) 0 80px!important;width:100%!important;height:auto!important;overflow:auto!important;touch-action:pan-x pan-y}
 #game #pathScreen .map-next-task-fixed{position:absolute!important;inset:auto 12px max(12px,env(safe-area-inset-bottom)) auto!important;width:190px!important;height:54px!important;max-width:60%!important;transform:none!important}
 #game #pathScreen .map-next-task-fixed img{width:100%;height:100%;object-fit:contain}
 #game #pathScreen .map-to-beaver{position:absolute!important;inset:auto auto max(16px,env(safe-area-inset-bottom)) 12px!important;min-height:44px!important;transform:none!important}
 /* House gets a minimum usable height instead of squashing furniture. */
 #game #collectionScreen.active{padding:0!important}
 #game #collectionScreen .house-scene{position:relative!important;inset:auto!important;min-height:600px!important;height:100%!important}
 #game #collectionScreen .living-house{top:calc(var(--hud-height) + 8px)!important}
 #game #collectionScreen .house-dialog{font-size:12px!important}
 #game #collectionScreen .furniture-label{font-size:12px!important;min-height:36px;display:flex;align-items:center;justify-content:center}
 #game #collectionScreen .house-talk-btn{min-height:44px!important;font-size:12px!important}
 #game #collectionScreen .house-drawer{position:fixed!important;inset:calc(var(--hud-height) + 4px) 8px 12px!important;height:auto!important;max-height:none!important;width:auto!important;max-width:520px!important}
 /* Canvas stays proportionate; controls remain outside the playfield. */
 #game #miniScreen.active{display:flex!important;flex-direction:column;align-items:center;gap:8px}
 #game #miniScreen .mini-hud,#game #miniScreen .mini-tip,#game #miniScreen .mini-continue{position:static!important;inset:auto!important;transform:none!important;margin:0!important}
 #game #miniScreen .mini-hud{display:flex!important;flex-wrap:wrap;justify-content:center;gap:8px!important;font-size:13px!important}
 #game #miniScreen #gameCanvas{position:static!important;inset:auto!important;transform:none!important;display:block;width:auto!important;height:auto!important;max-width:100%!important;max-height:calc(100dvh - var(--hud-height) - 130px)!important;aspect-ratio:420/620;flex:none;object-fit:contain}
 #game #miniScreen .mini-tip{font-size:13px!important;text-align:center}
 #game #miniScreen .mini-continue{min-height:44px!important;font-size:17px!important}
 #game #bvlMiniScreen .bvl-wrap{position:relative!important;inset:auto!important;transform:none!important;width:min(100%,620px)!important;max-height:none!important;height:auto!important;margin:auto!important;padding:12px!important}
 #game #bvlMiniScreen .bvl-arena{display:grid!important;grid-template-columns:1fr 30px 1fr!important;gap:6px!important;height:auto!important}
 #game #bvlMiniScreen .bvl-pick{width:100%!important;height:120px!important;min-height:0!important}
 #game #bvlMiniScreen .bvl-pick img{max-width:100%!important;max-height:100%!important;object-fit:contain}
 #game #bvlMiniScreen .bvl-buttons{display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr))!important;gap:8px!important}
 #game #bvlMiniScreen .bvl-buttons button{width:100%!important;min-width:0!important;min-height:100px!important;padding:8px 4px!important}
 #game #bvlMiniScreen .bvl-buttons img{width:64px!important;height:64px!important;max-width:100%;object-fit:contain}
 #game #bvlMiniScreen .bvl-buttons b{font-size:12px!important}
 #game #bvlMiniScreen .bvl-rules{display:flex!important;flex-wrap:wrap;justify-content:center;gap:8px;font-size:12px!important}
 #game #bvlMiniScreen .bvl-score{font-size:15px!important;gap:8px}
 #game #bvlMiniScreen .bvl-score>span{font-size:12px!important}
 #game #bvlMiniScreen .bvl-message{font-size:17px!important}
 #game #racesMiniScreen .races-wrap{position:relative!important;inset:auto!important;transform:none!important;width:100%!important;height:auto!important;min-height:0!important;margin:0!important;display:flex!important;flex-direction:column!important;gap:12px!important}
 #game #racesMiniScreen .races-top{flex-wrap:wrap;gap:8px!important}
 #game #racesMiniScreen .races-rank{flex-wrap:wrap;gap:6px}
 #game #racesMiniScreen .races-board{position:relative!important;inset:auto!important;width:100%!important;height:auto!important;aspect-ratio:1;flex:none!important}
 #game #racesMiniScreen .races-controls{position:static!important;inset:auto!important;display:flex!important;gap:10px!important;width:100%!important}
 #game #racesMiniScreen .race-message{font-size:15px!important;flex:1}
 #game #racesMiniScreen .race-die{min-width:88px;min-height:76px}
 #game #racesMiniScreen .race-color-picker{position:fixed!important;inset:var(--hud-height) 0 0!important;overflow-y:auto!important;display:block;padding:12px!important}
 #game #racesMiniScreen .race-picker-card{width:min(100%,620px)!important;margin:auto!important;max-height:none!important;padding:16px!important;overflow:visible!important}
 #game #racesMiniScreen .race-picker-title{font-size:21px!important}
 #game #racesMiniScreen .race-color-options{display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr))!important;gap:8px!important}
 #game #racesMiniScreen .race-color-option{min-width:0!important;padding:8px 4px!important}
 #game #racesMiniScreen .race-color-option img{width:100%!important;height:90px!important;object-fit:contain}
 #game #racesMiniScreen .race-color-option b{font-size:12px!important}
 #game #racesMiniScreen .race-duel-options{grid-template-columns:1fr!important;display:grid!important;gap:10px!important}
 #game #racesMiniScreen .race-picker-start{min-height:48px!important}
}
@media(max-width:360px){
 #game #homeScreen.active .game-logo{max-height:75px!important}
 #game #homeScreen.active .hero-beaver{max-width:125px!important}
 #game #homeScreen.active .home-talk{font-size:12px!important}
 #game #homeScreen.active .menu-art-btn img{height:60px!important}
 #game #homeScreen.active .menu-art-play img{height:68px!important}
 #game #storiesScreen .story-library{grid-template-columns:1fr!important}
 #game .hud{gap:4px!important}
 #game .hud .mobile-hud-title{font-size:12px!important}
 #game .coin-pill{max-width:64px}
}
@media(orientation:landscape) and (max-height:600px){
 #game #homeScreen.active{grid-template-columns:45% 55%!important;grid-template-rows:auto auto!important;align-content:center!important;gap:4px!important}
 #game #homeScreen.active .game-logo{grid-area:1/1/2/2;width:90%!important;max-height:85px!important}
 #game #homeScreen.active .hero-beaver{grid-area:2/1/3/2;justify-self:center;width:130px!important;max-width:130px!important}
 #game #homeScreen.active .home-talk{display:none!important}
 #game #homeScreen.active .v8-home-actions{grid-area:1/2/3/3;width:min(100%,300px)!important}
 #game #homeScreen.active .menu-art-btn img{height:53px!important}
 #game #homeScreen.active .menu-art-play img{height:60px!important}
 #game #collectionScreen .house-scene{min-height:420px!important}
 #game #questionScreen .quiz-wrap{max-width:760px!important}
 #game #miniSelectScreen .mini-select-card{grid-template-columns:repeat(3,minmax(0,1fr))!important}
 #game #storiesScreen .story-library{grid-template-columns:repeat(3,minmax(0,1fr))!important}
 #game #racesMiniScreen .races-board{max-width:480px!important;align-self:center}
}
@media(prefers-reduced-motion:reduce){
 .screen.active,.screen.screen-exit-soft{animation:none!important}
 .menu-art-btn,.toy-card,.costume-card{animation:none!important;transition:none!important}
}
@media(max-width:900px),(max-height:600px){
 #game #homeScreen.active .home-talk:before,#game #homeScreen.active .home-talk:after{display:none!important}
 #game #homeScreen.active .home-talk{opacity:1!important;visibility:visible!important}
 #game #collectionScreen .house-object img{flex:1 1 0!important;min-height:0!important;height:0!important;width:100%!important}
 #game #collectionScreen .house-object .furniture-label{flex:none!important}
 #game #collectionScreen .house-grand-chest img{height:64px!important;min-height:64px!important}
 #game #collectionScreen .house-shelf-object{align-self:stretch!important}
}
@media(max-width:900px),(max-height:600px){
 #game #storyReaderScreen .story-art{aspect-ratio:auto!important;height:auto!important;min-height:0!important;flex:none!important}
 #game #storyReaderScreen .story-art img{position:static!important;inset:auto!important;display:block!important;width:100%!important;height:auto!important;max-height:none!important;object-fit:contain!important;border-radius:18px!important}
 #game #storyReaderScreen #storyBody{display:block!important;-webkit-line-clamp:unset!important;line-clamp:unset!important;overflow:visible!important;white-space:normal!important;text-overflow:clip!important}
 #game #storyReaderScreen .story-text-toggle{position:static!important;min-height:44px!important;margin:0 0 12px auto!important;display:block!important}
 #game #storyReaderScreen .story-text.is-collapsed{padding:8px!important}
 #game #storyReaderScreen #storyNextBtn{display:block!important;width:100%!important;margin:12px 0 0!important;min-width:0!important}
 #game #storyReaderScreen .story-choices{flex-direction:column!important}
 #game #storyReaderScreen .story-top>b{white-space:normal!important;max-width:none!important;overflow:visible!important}
 #game #storyReaderScreen .story-fullscreen-btn{width:44px!important;height:44px!important}
 #game #storyReaderScreen .story-scene:fullscreen{height:100dvh!important;overflow-y:auto!important;padding:12px!important}
}
@media(max-width:900px),(max-height:600px){
 #game #storyReaderScreen #storyNextBtn,#game #adventureScreen #adventureContinueBtn,#game #bvlMiniScreen #bvlRestartBtn{position:static!important;inset:auto!important;transform:none!important}
 #game #storyReaderScreen .story-text-content{height:auto!important;max-height:none!important}
}
@media(orientation:landscape) and (max-height:600px){
 #game #homeScreen.active .v8-home-actions{grid-row:1 / 3!important;grid-column:2!important;align-self:center!important}
 #game #homeScreen.active{grid-template-rows:90px 140px!important;align-content:center!important}
}
@media(orientation:portrait) and (max-width:900px){
 #game #homeScreen.active .game-logo{grid-area:1 / 1 / 2 / 3!important}
 #game #homeScreen.active .hero-beaver{grid-area:2 / 1 / 3 / 2!important}
 #game #homeScreen.active .home-talk{grid-area:2 / 2 / 3 / 3!important}
 #game #homeScreen.active .v8-home-actions{grid-area:3 / 1 / 4 / 3!important}
}
@media(orientation:landscape) and (max-height:600px){
 #game #homeScreen.active{grid-template-columns:minmax(0,45fr) minmax(0,55fr)!important}
}
