/* UI 016.5.1 — Round & Victory Cinematics
   Additive presentation only. Existing combat, AUTO, HP and layout logic are untouched. */

/* New-round cue lives inside the scene and never takes layout space. */
.b165-round-cue{
  position:absolute;
  z-index:36;
  left:50%;
  top:46%;
  min-width:150px;
  translate:-50% -50%;
  pointer-events:none;
  text-align:center;
  opacity:0;
  filter:drop-shadow(0 4px 12px rgba(0,0,0,.92));
  animation:b165RoundCue 1080ms cubic-bezier(.16,.75,.2,1) both;
}
.b165-round-cue:before,
.b165-round-cue:after{
  content:"";
  position:absolute;
  left:50%;
  width:128px;
  height:1px;
  translate:-50% 0;
  background:linear-gradient(90deg,transparent,rgba(236,194,103,.82),transparent);
  box-shadow:0 0 8px rgba(221,158,73,.42);
}
.b165-round-cue:before{top:-8px}
.b165-round-cue:after{bottom:-9px}
.b165-round-cue small{
  display:block;
  margin-bottom:3px;
  color:#c8b698;
  font:800 8px/1.05 system-ui,-apple-system,sans-serif;
  letter-spacing:.22em;
}
.b165-round-cue b{
  display:block;
  color:#f4dfad;
  font:900 24px/.96 Georgia,serif;
  letter-spacing:.08em;
  text-shadow:0 0 9px rgba(255,215,124,.46),0 2px 3px #000;
}
@keyframes b165RoundCue{
  0%{opacity:0;scale:.78;filter:blur(4px) drop-shadow(0 4px 12px rgba(0,0,0,.9))}
  14%{opacity:1;scale:1.06;filter:blur(0) drop-shadow(0 4px 12px rgba(0,0,0,.9))}
  30%{opacity:1;scale:1}
  74%{opacity:1;scale:1}
  100%{opacity:0;scale:1.035;translate:-50% -57%}
}

/* Finale is a short-lived copy of the last active battle screen. It sits over the
   already-rendered finished card, then disappears so native progression continues. */
.b165-finale{
  position:absolute;
  z-index:2147482000;
  inset:0;
  overflow:hidden;
  pointer-events:none;
  isolation:isolate;
  background:#09080d;
  opacity:1;
  animation:b165FinaleIn 150ms ease-out both;
}
.b165-finale-snapshot{
  position:absolute!important;
  z-index:1!important;
  inset:0!important;
  width:100%!important;
  height:100%!important;
  min-height:0!important;
  margin:0!important;
  pointer-events:none!important;
  overflow:hidden!important;
}
.b165-finale-snapshot button,
.b165-finale-snapshot input,
.b165-finale-snapshot label{pointer-events:none!important}
.b165-finale-snapshot .b14-journal{display:none!important}
.b165-finale-snapshot .b14-tactics{
  opacity:.38!important;
  filter:saturate(.55) brightness(.62)!important;
  transition:none!important;
}
.b165-finale-snapshot .b14-topline{
  opacity:.62!important;
  filter:saturate(.66) brightness(.78)!important;
}
.b165-finale-snapshot .b14-scene{
  filter:saturate(.88) brightness(.88);
}

.b165-final-shade{
  position:absolute;
  z-index:12;
  inset:0;
  pointer-events:none;
  background:
    radial-gradient(circle at 50% 43%,transparent 0 19%,rgba(5,4,9,.10) 42%,rgba(2,2,5,.60) 100%),
    linear-gradient(180deg,rgba(3,3,7,.08),rgba(2,2,6,.40));
  animation:b165Shade 1550ms ease both;
}
.b165-finale.is-loss .b165-final-shade{
  background:
    radial-gradient(circle at 50% 43%,rgba(102,16,25,.08),rgba(12,4,8,.26) 48%,rgba(1,1,4,.72) 100%),
    linear-gradient(180deg,rgba(22,3,7,.08),rgba(4,2,5,.52));
}

/* Result title. */
.b165-final-title{
  position:absolute;
  z-index:18;
  left:50%;
  top:44%;
  width:min(88%,440px);
  translate:-50% -50%;
  text-align:center;
  pointer-events:none;
  opacity:0;
  animation:b165Title 1250ms 330ms cubic-bezier(.14,.72,.2,1) both;
}
.b165-final-title small{
  display:block;
  margin-bottom:7px;
  color:#d5c39b;
  font:900 9px/1 system-ui,-apple-system,sans-serif;
  letter-spacing:.27em;
  text-transform:uppercase;
}
.b165-final-title strong{
  display:block;
  color:#ffe5a1;
  font:900 clamp(32px,9vw,49px)/.94 Georgia,serif;
  letter-spacing:.075em;
  text-shadow:0 0 8px #fff1b7,0 0 24px rgba(235,174,61,.64),0 4px 5px rgba(0,0,0,.96);
}
.b165-final-title:before,
.b165-final-title:after{
  content:"";
  position:absolute;
  left:50%;
  width:min(72vw,310px);
  height:1px;
  translate:-50% 0;
  background:linear-gradient(90deg,transparent,rgba(242,202,107,.94),transparent);
  box-shadow:0 0 10px rgba(238,174,68,.55);
}
.b165-final-title:before{top:-13px}
.b165-final-title:after{bottom:-15px}
.b165-finale.is-loss .b165-final-title small{color:#bca4a4}
.b165-finale.is-loss .b165-final-title strong{
  color:#e4c5c5;
  text-shadow:0 0 10px rgba(173,62,72,.38),0 4px 5px rgba(0,0,0,.96);
}
.b165-finale.is-loss .b165-final-title:before,
.b165-finale.is-loss .b165-final-title:after{
  background:linear-gradient(90deg,transparent,rgba(151,69,75,.76),transparent);
  box-shadow:0 0 8px rgba(132,40,50,.38);
}

/* Victory halo / boss pulse stays behind the title but above the copied scene. */
.b165-victory-halo{
  position:absolute;
  z-index:15;
  left:50%;
  top:43%;
  width:170px;
  height:170px;
  translate:-50% -50%;
  border-radius:50%;
  opacity:0;
  pointer-events:none;
  border:1px solid rgba(255,215,105,.52);
  box-shadow:0 0 22px rgba(255,192,56,.35),inset 0 0 26px rgba(255,222,122,.12);
  animation:b165Halo 1100ms 260ms cubic-bezier(.12,.72,.2,1) both;
}
.b165-victory-halo:before,
.b165-victory-halo:after{
  content:"";
  position:absolute;
  inset:50%;
  width:220px;
  height:2px;
  translate:-50% -50%;
  background:linear-gradient(90deg,transparent,rgba(255,228,145,.78),transparent);
  box-shadow:0 0 11px rgba(255,201,70,.48);
}
.b165-victory-halo:before{rotate:24deg}
.b165-victory-halo:after{rotate:-34deg}
.b165-finale.is-boss .b165-victory-halo{
  width:210px;
  height:210px;
  border-width:2px;
  box-shadow:0 0 28px rgba(255,191,47,.50),inset 0 0 35px rgba(255,226,129,.16);
}
.b165-finale.is-loss .b165-victory-halo{display:none}

/* The defeated art itself reacts; wrapper positioning/parallax remains untouched. */
.b165-finale.is-win .b14-enemy img.b165-defeated-art{
  animation:b165EnemyDefeated 1450ms 120ms cubic-bezier(.16,.72,.2,1) both!important;
  transform-origin:50% 94%!important;
}
.b165-finale.is-loss .b14-player img.b165-defeated-art{
  animation:b165PlayerDefeated 1450ms 120ms cubic-bezier(.16,.72,.2,1) both!important;
  transform-origin:50% 94%!important;
}
@keyframes b165EnemyDefeated{
  0%{transform:translate3d(0,0,0) rotate(0) scale(1);filter:brightness(1) saturate(1);opacity:1}
  18%{transform:translate3d(18px,-2px,0) rotate(2deg) scale(1.015);filter:brightness(1.28) saturate(.88);opacity:1}
  42%{transform:translate3d(11px,4px,0) rotate(1.2deg) scale(.995);filter:brightness(.78) saturate(.62);opacity:.92}
  100%{transform:translate3d(15px,15px,0) rotate(2.2deg) scale(.975);filter:brightness(.30) saturate(.20) grayscale(.38);opacity:.34}
}
@keyframes b165PlayerDefeated{
  0%{transform:translate3d(0,0,0) rotate(0) scale(1);filter:brightness(1) saturate(1);opacity:1}
  20%{transform:translate3d(-13px,1px,0) rotate(-1.5deg) scale(.995);filter:brightness(.8) saturate(.7);opacity:1}
  100%{transform:translate3d(-9px,13px,0) rotate(-2deg) scale(.975);filter:brightness(.28) saturate(.2) grayscale(.42);opacity:.36}
}

@keyframes b165FinaleIn{0%{opacity:.72}100%{opacity:1}}
@keyframes b165Shade{0%{opacity:.25}38%{opacity:.48}100%{opacity:.9}}
@keyframes b165Title{
  0%{opacity:0;scale:.74;filter:blur(5px)}
  18%{opacity:1;scale:1.075;filter:blur(0)}
  58%{opacity:1;scale:1}
  100%{opacity:.96;scale:1.018}
}
@keyframes b165Halo{0%{opacity:0;scale:.28;rotate:-10deg}24%{opacity:.9;scale:.82}100%{opacity:0;scale:1.72;rotate:9deg}}

.b165-finale.is-leaving{animation:b165FinaleOut 260ms ease-in both}
@keyframes b165FinaleOut{to{opacity:0;filter:brightness(.72)}}

@media(max-width:430px){
  .b165-final-title{top:43.5%}
  .b165-round-cue b{font-size:22px}
  .b165-victory-halo{width:150px;height:150px}
  .b165-finale.is-boss .b165-victory-halo{width:185px;height:185px}
}

@media(prefers-reduced-motion:reduce){
  .b165-round-cue{animation:b165RoundReduced 650ms ease both!important}
  .b165-finale.is-win .b14-enemy img.b165-defeated-art,
  .b165-finale.is-loss .b14-player img.b165-defeated-art{animation:none!important;filter:brightness(.48) saturate(.42)!important;opacity:.55!important}
  .b165-victory-halo{animation-duration:420ms!important}
  .b165-final-title{animation:b165TitleReduced 700ms 100ms ease both!important}
  @keyframes b165RoundReduced{0%,100%{opacity:0}16%,80%{opacity:1}}
  @keyframes b165TitleReduced{0%{opacity:0}22%,100%{opacity:1}}
}
