/* UI 017.3P.2.5 — Battle battery + hard Safari viewport lock.
   Goal: Battle is static/cheap between exchanges, never follows iOS viewport pan,
   and keeps the accepted top geometry. Terminal ordering belongs only to A6/A6.1.
   No combat/economy/state mutations. */

/* Freeze only visible HEIGHT. Do not reuse visualViewport.offsetTop/offsetLeft:
   Safari already maps the layout viewport to the visible page, and applying those
   offsets to a fixed game root a second time can clip the Battle top edge. */
html.arena-battle014-lock{
  --b14-vv-left:0px!important;
  --b14-vv-width:100vw!important;
  --b14-vv-center:50vw!important;
  --b14-vv-top:0px!important;
  --b14-vv-height:var(--b173p2-vv-height,100svh)!important;
  --b14-vv-bottom:0px!important;
}

body.arena-battle014-active{
  position:fixed!important;
  inset:0!important;
  width:100%!important;
  height:100%!important;
  overflow:hidden!important;
  overscroll-behavior:none!important;
  touch-action:none!important;
}

body.arena-battle014-active #app-main,
body.arena-battle014-active #battle014-root{
  position:fixed!important;
  left:0!important;
  right:0!important;
  top:0!important;
  bottom:auto!important;
  width:100vw!important;
  max-width:100vw!important;
  height:var(--b173p2-vv-height,100svh)!important;
  min-height:0!important;
  overflow:hidden!important;
  overscroll-behavior:none!important;
  touch-action:none!important;
  transform:none!important;
}

body.arena-battle014-active #battle014-root .battle014{
  height:100%!important;
  min-height:0!important;
  overflow:hidden!important;
  overscroll-behavior:none!important;
  touch-action:none!important;
  -webkit-overflow-scrolling:auto!important;
}

body.arena-battle014-active>nav:not(.b14-dock):not(.i13-dock){
  left:0!important;
  right:auto!important;
  bottom:0!important;
  width:100vw!important;
  max-width:100vw!important;
  transform:none!important;
  touch-action:manipulation!important;
}

/* Safari/WebKit selection stability.
   Legacy Battle014 scales every zone on :active. Inside the fixed full-screen
   compositor that temporary transform can promote/re-raster a descendant layer.
   Selection keeps its purple/blue state, only press-time geometry changes are gone. */
body.arena-battle014-active #battle014-root .b14-tactics{
  contain:paint!important;
  isolation:isolate!important;
  overscroll-behavior:none!important;
  touch-action:none!important;
}
body.arena-battle014-active #battle014-root .b14-zone{
  -webkit-tap-highlight-color:transparent!important;
  touch-action:manipulation!important;
  -webkit-user-select:none!important;
  user-select:none!important;
}
body.arena-battle014-active #battle014-root .b14-zone:active{
  transform:none!important;
  translate:none!important;
  scale:none!important;
}

/* Journal list is the one intentional vertical scroller inside Battle. */
body.arena-battle014-active #battle014-root #battle014-journal .b14-journal-sheet ol{
  overflow-y:auto!important;
  overscroll-behavior:contain!important;
  touch-action:pan-y!important;
  -webkit-overflow-scrolling:touch!important;
}

/* The legacy page ambience is completely covered by Battle014, but without this it
   keeps animating full-screen blur/fog/embers underneath and wakes WebKit/GPU. */
body.arena-battle014-active::before,
body.arena-battle014-active::after{
  content:none!important;
  display:none!important;
  animation:none!important;
  filter:none!important;
  -webkit-filter:none!important;
}

body.arena-battle014-active > .arena-ambience{
  display:none!important;
  visibility:hidden!important;
  animation:none!important;
}

body.arena-battle014-active > .arena-ambience *,
body.arena-battle014-active > .arena-ambience *::before,
body.arena-battle014-active > .arena-ambience *::after{
  animation:none!important;
}

/* Decorative particles were running forever even while the player was idle. */
body.arena-battle014-active #battle014-root .b14-sparks{
  display:none!important;
}

/* Idle fighters must not request a permanent 60fps compositing loop.
   016.1 owns actual exchange motion through transforms/transitions. */
html:not(.arena-cinematic0161-active) body.arena-battle014-active #battle014-root .b14-fighter img{
  animation:none!important;
}

/* The enraged aura can stay visually enraged without pulsing forever. */
html:not(.arena-cinematic0161-active) body.arena-battle014-active #battle014-root .b14-stage-enraged .b14-enemy .b14-aura{
  animation:none!important;
}

/* Static blur layers are needlessly expensive on mobile Safari; keep the same
   gradient/glow geometry but avoid an extra filtered compositor surface. */
body.arena-battle014-active #battle014-root .b14-scene-glow{
  filter:none!important;
  -webkit-filter:none!important;
  opacity:.78;
}
body.arena-battle014-active #battle014-root .b14-stage-badge{
  backdrop-filter:none!important;
  -webkit-backdrop-filter:none!important;
  background:rgba(5,5,11,.94)!important;
}

/* Cool mode: prioritise battery between exchanges. These are presentation-only
   shadows; actual cinematic transforms, impact shake and HP effects are untouched. */
html.arena-cool-mode:not(.arena-cinematic0161-active) body.arena-battle014-active #battle014-root .b14-aura,
html[data-performance="cool"]:not(.arena-cinematic0161-active) body.arena-battle014-active #battle014-root .b14-aura{
  box-shadow:none!important;
}

/* A hidden/background tab should never keep decorative Battle animations alive. */
html.arena-page-hidden body.arena-battle014-active #battle014-root *,
html.arena-page-hidden body.arena-battle014-active #battle014-root *::before,
html.arena-page-hidden body.arena-battle014-active #battle014-root *::after{
  animation-play-state:paused!important;
}
