/* v25.14.1 Scroll Restore
   Purpose: restore whole-page scrolling on menu/UI screens while keeping game/title fixed.
   SAVE/data logic untouched. */
:root{
  --v25141-nav-h:86px;
  --v25141-safe-bottom:env(safe-area-inset-bottom, 0px);
  --v25141-bottom-space:calc(var(--v25141-nav-h) + var(--v25141-safe-bottom) + 34px);
}

html{
  min-height:100%!important;
  height:auto!important;
  max-height:none!important;
  overflow-x:hidden!important;
  overflow-y:auto!important;
  scroll-padding-bottom:var(--v25141-bottom-space)!important;
}

body:not(.battle-active):not(.title-active){
  min-height:100%!important;
  height:auto!important;
  max-height:none!important;
  overflow-x:hidden!important;
  overflow-y:auto!important;
  position:static!important;
  touch-action:pan-y manipulation!important;
  overscroll-behavior-y:auto!important;
  padding-bottom:var(--v25141-bottom-space)!important;
}

body.battle-active,
body.title-active{
  height:100dvh!important;
  max-height:100dvh!important;
  overflow:hidden!important;
}

body:not(.battle-active):not(.title-active) .app{
  width:min(100%,520px)!important;
  min-height:100dvh!important;
  height:auto!important;
  max-height:none!important;
  overflow:visible!important;
  display:block!important;
  padding-bottom:var(--v25141-bottom-space)!important;
  box-sizing:border-box!important;
}

body:not(.battle-active):not(.title-active) .screen.active:not(#titleScreen):not(#gameScreen){
  display:block!important;
  min-height:100dvh!important;
  height:auto!important;
  max-height:none!important;
  overflow:visible!important;
  overflow-y:visible!important;
  overflow-x:hidden!important;
  padding-bottom:var(--v25141-bottom-space)!important;
  box-sizing:border-box!important;
  pointer-events:auto!important;
  touch-action:pan-y manipulation!important;
}

body:not(.battle-active):not(.title-active) .screen.active:not(#titleScreen):not(#gameScreen)>.pad,
body:not(.battle-active):not(.title-active) .screen.active:not(#titleScreen):not(#gameScreen) .homePad,
body:not(.battle-active):not(.title-active) .screen.active:not(#titleScreen):not(#gameScreen) .sortiePad,
body:not(.battle-active):not(.title-active) .screen.active:not(#titleScreen):not(#gameScreen) .prepPad,
body:not(.battle-active):not(.title-active) .screen.active:not(#titleScreen):not(#gameScreen) .stageMapPage{
  display:block!important;
  min-height:0!important;
  height:auto!important;
  max-height:none!important;
  overflow:visible!important;
  overflow-y:visible!important;
  padding-bottom:var(--v25141-bottom-space)!important;
  box-sizing:border-box!important;
}

/* Home: release the old fixed-grid layout so lower buttons are reachable by page scroll. */
body:not(.battle-active):not(.title-active) #homeScreen.screen.active .homePad{
  display:block!important;
}
body:not(.battle-active):not(.title-active) #homeScreen .homeGrid,
body:not(.battle-active):not(.title-active) #homeScreen .homeMain,
body:not(.battle-active):not(.title-active) #homeScreen .soundSettingsPanel{
  min-height:0!important;
  height:auto!important;
  max-height:none!important;
  overflow:visible!important;
}
body:not(.battle-active):not(.title-active) #homeScreen .homeGrid{
  display:grid!important;
  grid-template-columns:repeat(2,minmax(0,1fr))!important;
  gap:8px!important;
  padding-bottom:calc(var(--v25141-bottom-space) + 12px)!important;
}

/* Character/item/material screens: show every card by page scroll instead of clipping. */
body:not(.battle-active):not(.title-active) #formationRootV24,
body:not(.battle-active):not(.title-active) #trainingRootV24,
body:not(.battle-active):not(.title-active) #collectionGrid,
body:not(.battle-active):not(.title-active) #bossGrid,
body:not(.battle-active):not(.title-active) #missionList,
body:not(.battle-active):not(.title-active) #awakenPanel,
body:not(.battle-active):not(.title-active) #itemList,
body:not(.battle-active):not(.title-active) #presentList,
body:not(.battle-active):not(.title-active) #leaderList,
body:not(.battle-active):not(.title-active) #rosterList,
body:not(.battle-active):not(.title-active) #bossSupportList,
body:not(.battle-active):not(.title-active) .bossSupportGrid,
body:not(.battle-active):not(.title-active) .grid4,
body:not(.battle-active):not(.title-active) .roster,
body:not(.battle-active):not(.title-active) .list{
  min-height:0!important;
  height:auto!important;
  max-height:none!important;
  overflow:visible!important;
  overflow-y:visible!important;
}

/* Stage/result/prep need enough bottom room so fixed navigation never hides action buttons. */
body:not(.battle-active):not(.title-active) #prepScreen #startGame,
body:not(.battle-active):not(.title-active) #resultScreen .resultActions,
body:not(.battle-active):not(.title-active) #stageMapScreen .mapFooter{
  margin-bottom:var(--v25141-bottom-space)!important;
}

/* Keep bottom nav clickable above content. */
#v246BottomNav,
.v246BottomNav,
.bottomNav,
.v2487BottomNav,
.bottomNavV24,
.appBottomNav,
.mainBottomNav{
  position:fixed!important;
  left:50%!important;
  right:auto!important;
  bottom:calc(8px + var(--v25141-safe-bottom))!important;
  transform:translateX(-50%)!important;
  width:min(94vw,500px)!important;
  max-width:500px!important;
  height:74px!important;
  min-height:74px!important;
  max-height:74px!important;
  z-index:8000!important;
  overflow:hidden!important;
  pointer-events:auto!important;
  touch-action:manipulation!important;
}
#v246BottomNav *,
.v246BottomNav *,
.bottomNav *,
.v2487BottomNav *,
.bottomNavV24 *,
.appBottomNav *,
.mainBottomNav *{
  pointer-events:auto!important;
}

/* Hidden overlays must not capture taps while user scrolls. */
#v2594MokoMap:not(.show),
#nyankoEventMapScreen:not(.active),
#stageInfoPopup:not(.show),
.stageInfoPopup:not(.show),
.stagePopup:not(.show),
.modalBackdrop:not(.show),
.stageInfoOverlay:not(.show){
  pointer-events:none!important;
}

@media(max-width:430px){
  body:not(.battle-active):not(.title-active){
    padding-left:0!important;
    padding-right:0!important;
  }
  body:not(.battle-active):not(.title-active) #homeScreen .homeGrid{
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    gap:7px!important;
  }
}
