/* UI 016.1.6 — Safari-safe motion + single-owner exchange presentation
   Sequential presentation only. Server combat logic and layout geometry stay untouched. */

body.arena-battle014-active #battle014-root .b14-scene.b161-active{
  isolation:isolate!important;
}

/* 016.1/016.2/A.5 are the accepted exchange presentation owners. 014 may still
   rebuild its legacy event DOM from fight.events on the next choice render, but
   that historical layer must never become visible again once the cinematic stack
   is installed. This is intentionally persistent across scene replacement. */
html.arena-battle-motion-enabled body.arena-battle014-active #battle014-root .b14-impact-flash,
html.arena-battle-motion-enabled body.arena-battle014-active #battle014-root .b14-float-stack,
html.arena-battle-motion-enabled body.arena-battle014-active #battle014-root .b14-hp-loss{
  display:none!important;
  opacity:0!important;
  animation:none!important;
  visibility:hidden!important;
}

/* Legacy 014 fighter reaction classes may also be recreated for 2.8 s from the
   previous fight.events. They are presentation history, not the next choice phase. */
html.arena-battle-motion-enabled body.arena-battle014-active #battle014-root .b14-scene:not(.b161-active) .b14-fighter.is-attacking,
html.arena-battle-motion-enabled body.arena-battle014-active #battle014-root .b14-scene:not(.b161-active) .b14-fighter.is-hit,
html.arena-battle-motion-enabled body.arena-battle014-active #battle014-root .b14-scene:not(.b161-active) .b14-fighter.is-dodging,
html.arena-battle-motion-enabled body.arena-battle014-active #battle014-root .b14-scene:not(.b161-active) .b14-fighter.is-defending,
html.arena-battle-motion-enabled body.arena-battle014-active #battle014-root .b14-scene:not(.b161-active) .b14-fighter.is-attacking img,
html.arena-battle-motion-enabled body.arena-battle014-active #battle014-root .b14-scene:not(.b161-active) .b14-fighter.is-hit img,
html.arena-battle-motion-enabled body.arena-battle014-active #battle014-root .b14-scene:not(.b161-active) .b14-fighter.is-dodging img,
html.arena-battle-motion-enabled body.arena-battle014-active #battle014-root .b14-scene:not(.b161-active) .b14-fighter.is-defending img{
  animation:none!important;
}

body.arena-battle014-active #battle014-root .b14-scene.b161-active .b14-fighter,
body.arena-battle014-active #battle014-root .b14-scene.b161-active .b14-fighter img{
  animation:none!important;
}

/* iOS Safari fix: use ONE transform pipeline for parallax + cinematic movement.
   The previous individual translate property could be swallowed when 0151 had already
   established transform-based parallax. */
body.arena-battle014-active #battle014-root .b14-scene.b161-active .b14-fighter{
  --b161-x:0px;
  --b161-y:0px;
  --b161-r:0deg;
  --b161-sx:1;
  --b161-sy:1;
  transform:translate3d(
    calc(var(--b14-parallax-x,0px) + var(--b161-x)),
    calc(var(--b14-parallax-y,0px) + var(--b161-y)),
    0
  ) rotate(var(--b161-r)) scale(var(--b161-sx),var(--b161-sy))!important;
  transition:transform 150ms cubic-bezier(.22,.75,.25,1),filter 130ms ease!important;
  will-change:transform,filter;
}
body.arena-battle014-active #battle014-root .b14-scene.b161-active .b14-fighter img{
  transition:filter 130ms ease!important;
}

/* Readable anticipation: the whole fighter loads the strike before releasing forward. */
body.arena-battle014-active #battle014-root .b14-player.b161-windup{
  --b161-x:-13px;
  --b161-y:3px;
  --b161-r:-2.8deg;
  --b161-sx:.985;
  --b161-sy:1.01;
  transition-duration:225ms!important;
}
body.arena-battle014-active #battle014-root .b14-enemy.b161-windup{
  --b161-x:13px;
  --b161-y:3px;
  --b161-r:2.8deg;
  --b161-sx:.985;
  --b161-sy:1.01;
  transition-duration:225ms!important;
}
body.arena-battle014-active #battle014-root .b14-fighter.b161-windup img{
  filter:brightness(.9) contrast(1.03)!important;
}

/* Strike: fast release after the longer wind-up. */
body.arena-battle014-active #battle014-root .b14-player.b161-strike{
  --b161-x:clamp(24px,7vw,40px);
  --b161-y:-3px;
  --b161-r:1.4deg;
  --b161-sx:1.012;
  --b161-sy:.994;
  transition-duration:115ms!important;
}
body.arena-battle014-active #battle014-root .b14-enemy.b161-strike{
  --b161-x:clamp(-40px,-7vw,-24px);
  --b161-y:-3px;
  --b161-r:-1.4deg;
  --b161-sx:1.012;
  --b161-sy:.994;
  transition-duration:115ms!important;
}

/* Recovery is deliberately softer than the outgoing lunge. */
body.arena-battle014-active #battle014-root .b14-fighter.b161-recover{
  --b161-x:0px;
  --b161-y:0px;
  --b161-r:0deg;
  --b161-sx:1;
  --b161-sy:1;
  transition-duration:215ms!important;
}

/* Receiving states. Stage 016.4 will later make each result visually richer. */
body.arena-battle014-active #battle014-root .b14-player.b161-hit{--b161-x:-10px;--b161-y:0px}
body.arena-battle014-active #battle014-root .b14-enemy.b161-hit{--b161-x:10px;--b161-y:0px}
body.arena-battle014-active #battle014-root .b14-fighter.b161-hit img{
  filter:brightness(1.28) saturate(.82) drop-shadow(0 0 11px rgba(255,89,108,.6))!important;
}
body.arena-battle014-active #battle014-root .b14-player.b161-dodge{--b161-x:-23px;--b161-y:-3px}
body.arena-battle014-active #battle014-root .b14-enemy.b161-dodge{--b161-x:23px;--b161-y:-3px}
body.arena-battle014-active #battle014-root .b14-fighter.b161-guard img{
  filter:brightness(1.16) saturate(.86) drop-shadow(0 0 10px rgba(106,199,255,.52))!important;
}
body.arena-battle014-active #battle014-root .b14-fighter.b161-guard:after{
  content:"";
  position:absolute;
  z-index:22;
  left:50%;
  top:48%;
  width:50px;
  height:62px;
  translate:-50% -50%;
  border:2px solid rgba(130,216,255,.72);
  border-radius:50% 50% 46% 46%;
  opacity:.82;
  box-shadow:0 0 16px rgba(87,185,255,.42),inset 0 0 14px rgba(115,211,255,.18);
  pointer-events:none;
}

/* Cinematic overlay never participates in layout. */
.b161-layer{
  position:absolute;
  z-index:23;
  inset:0;
  overflow:hidden;
  pointer-events:none;
}
.b161-slash{
  position:absolute;
  z-index:2;
  top:51%;
  width:34%;
  height:3px;
  border-radius:99px;
  opacity:0;
  background:linear-gradient(90deg,transparent,rgba(255,238,188,.96) 35%,#fff 58%,transparent);
  box-shadow:0 0 8px rgba(255,226,157,.85),0 0 18px rgba(176,93,235,.55);
  transform-origin:center;
}
.b161-slash.is-player{left:34%;rotate:-16deg}
.b161-slash.is-enemy{right:34%;rotate:196deg}
.b161-slash.is-live{animation:b161Slash 270ms cubic-bezier(.16,.76,.24,1) both}
@keyframes b161Slash{
  0%{opacity:0;scale:.35 1;filter:blur(2px)}
  28%{opacity:1;scale:1.08 1;filter:blur(0)}
  68%{opacity:.92;scale:1.22 1}
  100%{opacity:0;scale:1.35 .6;filter:blur(1.5px)}
}

/* Every result is an independent two-second projectile. The direction is intentionally
   INWARD: damage from the player flies right, damage from the enemy flies left.
   This keeps even wide labels like BLOCK/PARRY inside the battlefield. */
.b161-result{
  --b161-trail-x:0px;
  --b161-trail-y:-48px;
  --b161-trail-rotate:0deg;
  position:absolute;
  z-index:4;
  top:43%;
  display:flex;
  min-width:70px;
  flex-direction:column;
  align-items:center;
  opacity:0;
  translate:-50% 0;
  rotate:0deg;
  filter:drop-shadow(0 3px 5px rgba(0,0,0,.9));
  pointer-events:none;
  will-change:translate,opacity,scale,rotate;
}
.b161-result.is-player{--b161-trail-x:64px!important}
.b161-result.is-enemy{--b161-trail-x:-64px!important}
.b161-result.is-live{animation:b161ResultTrail 2000ms cubic-bezier(.16,.72,.22,1) both}
.b161-result small{
  padding:3px 7px;
  border:1px solid rgba(238,210,157,.5);
  border-radius:10px;
  color:#eadfcf;
  background:rgba(6,5,12,.83);
  font-size:8px;
  font-weight:900;
  line-height:1;
  letter-spacing:.045em;
  white-space:nowrap;
}
.b161-result b{
  margin-top:2px;
  color:#ff687b;
  font:900 25px/1 Georgia,serif;
  text-shadow:0 0 10px rgba(255,73,102,.72),0 2px 3px #000;
}
.b161-result.is-crit small,.b161-result.is-crit b{color:#ffd96c}
.b161-result.is-defense small,.b161-result.is-defense b{color:#83d9ff}
.b161-result.is-dodge small,.b161-result.is-dodge b{color:#9af3ff}
@keyframes b161ResultTrail{
  0%{opacity:0;translate:-50% 4px;rotate:0deg;scale:.68}
  9%{opacity:1;scale:1.08}
  28%{opacity:1;scale:1.02}
  68%{opacity:.92;scale:.97}
  100%{opacity:0;translate:calc(-50% + var(--b161-trail-x)) var(--b161-trail-y);rotate:var(--b161-trail-rotate);scale:.87}
}

/* Manual combat controls are frozen only during the tiny presentation window.
   AUTO remains in the top bar and can still be stopped immediately. */
body.arena-battle014-active #battle014-root .b14-scene.b161-active~.b14-tactics button{
  pointer-events:none!important;
}
body.arena-battle014-active #battle014-root .b14-scene.b161-active~.b14-tactics{
  filter:saturate(.92);
}

@media(max-width:430px){
  body.arena-battle014-active #battle014-root .b14-player.b161-windup{--b161-x:-11px;--b161-y:2px}
  body.arena-battle014-active #battle014-root .b14-enemy.b161-windup{--b161-x:11px;--b161-y:2px}
  body.arena-battle014-active #battle014-root .b14-player.b161-strike{--b161-x:clamp(20px,6vw,31px);--b161-y:-1px}
  body.arena-battle014-active #battle014-root .b14-enemy.b161-strike{--b161-x:clamp(-31px,-6vw,-20px);--b161-y:-1px}
  .b161-result b{font-size:22px}.b161-slash{width:31%}
  .b161-result.is-player{--b161-trail-x:58px!important}
  .b161-result.is-enemy{--b161-trail-x:-58px!important}
}

@media(prefers-reduced-motion:reduce){
  body.arena-battle014-active #battle014-root .b14-scene.b161-active .b14-fighter{
    --b161-x:0px!important;
    --b161-y:0px!important;
    --b161-r:0deg!important;
    --b161-sx:1!important;
    --b161-sy:1!important;
    transition:none!important;
  }
  .b161-slash{display:none!important}
  .b161-result.is-live{animation:b161ResultReduced 700ms ease both!important}
  @keyframes b161ResultReduced{
    0%{opacity:0;scale:.92}
    18%,72%{opacity:1;scale:1}
    100%{opacity:0;scale:.96}
  }
}

/* UI 016.1.3 — hard Safari fallback: animate the ART, not the positioned/parallax container.
   The fighter wrapper is now neutral during the cinematic, while its image performs
   anticipation, lunge, reaction and recovery. This bypasses every transform conflict
   in the legacy positioning stack. */
body.arena-battle014-active #battle014-root .b14-scene.b161-active .b14-fighter{
  --b161-x:0px!important;
  --b161-y:0px!important;
  --b161-r:0deg!important;
  --b161-sx:1!important;
  --b161-sy:1!important;
}
body.arena-battle014-active #battle014-root .b14-scene.b161-active .b14-fighter img{
  transform:translate3d(0,0,0) rotate(0deg) scale(1,1)!important;
  transform-origin:50% 94%!important;
  transition:transform 155ms cubic-bezier(.18,.78,.22,1),filter 130ms ease!important;
  will-change:transform,filter!important;
  backface-visibility:hidden!important;
  -webkit-backface-visibility:hidden!important;
}

body.arena-battle014-active #battle014-root .b14-scene.b161-active .b14-player.b161-windup img{
  transform:translate3d(-16px,3px,0) rotate(-4deg) scale(.985,1.018)!important;
  transition-duration:225ms!important;
}
body.arena-battle014-active #battle014-root .b14-scene.b161-active .b14-enemy.b161-windup img{
  transform:translate3d(16px,3px,0) rotate(4deg) scale(.985,1.018)!important;
  transition-duration:225ms!important;
}

body.arena-battle014-active #battle014-root .b14-scene.b161-active .b14-player.b161-strike img{
  transform:translate3d(46px,-3px,0) rotate(2deg) scale(1.018,.992)!important;
  transition-duration:115ms!important;
}
body.arena-battle014-active #battle014-root .b14-scene.b161-active .b14-enemy.b161-strike img{
  transform:translate3d(-46px,-3px,0) rotate(-2deg) scale(1.018,.992)!important;
  transition-duration:115ms!important;
}

body.arena-battle014-active #battle014-root .b14-scene.b161-active .b14-fighter.b161-recover img{
  transform:translate3d(0,0,0) rotate(0deg) scale(1,1)!important;
  transition-duration:220ms!important;
}

body.arena-battle014-active #battle014-root .b14-scene.b161-active .b14-player.b161-hit img{
  transform:translate3d(-13px,0,0) rotate(-1deg) scale(.995,1.004)!important;
}
body.arena-battle014-active #battle014-root .b14-scene.b161-active .b14-enemy.b161-hit img{
  transform:translate3d(13px,0,0) rotate(1deg) scale(.995,1.004)!important;
}
body.arena-battle014-active #battle014-root .b14-scene.b161-active .b14-player.b161-dodge img{
  transform:translate3d(-27px,-3px,0) rotate(-2deg) scale(.99,1.01)!important;
}
body.arena-battle014-active #battle014-root .b14-scene.b161-active .b14-enemy.b161-dodge img{
  transform:translate3d(27px,-3px,0) rotate(2deg) scale(.99,1.01)!important;
}
body.arena-battle014-active #battle014-root .b14-scene.b161-active .b14-player.b161-guard img{
  transform:translate3d(-5px,0,0) scale(.99,1.005)!important;
}
body.arena-battle014-active #battle014-root .b14-scene.b161-active .b14-enemy.b161-guard img{
  transform:translate3d(5px,0,0) scale(.99,1.005)!important;
}

@media(max-width:430px){
  body.arena-battle014-active #battle014-root .b14-scene.b161-active .b14-player.b161-windup img{transform:translate3d(-14px,2px,0) rotate(-3.5deg) scale(.987,1.015)!important}
  body.arena-battle014-active #battle014-root .b14-scene.b161-active .b14-enemy.b161-windup img{transform:translate3d(14px,2px,0) rotate(3.5deg) scale(.987,1.015)!important}
  body.arena-battle014-active #battle014-root .b14-scene.b161-active .b14-player.b161-strike img{transform:translate3d(40px,-2px,0) rotate(1.8deg) scale(1.015,.994)!important}
  body.arena-battle014-active #battle014-root .b14-scene.b161-active .b14-enemy.b161-strike img{transform:translate3d(-40px,-2px,0) rotate(-1.8deg) scale(1.015,.994)!important}
}

@media(prefers-reduced-motion:reduce){
  body.arena-battle014-active #battle014-root .b14-scene.b161-active .b14-fighter img{
    transform:translate3d(0,0,0)!important;
    transition:none!important;
  }
}
