/* v2.71 battle flow polish: consistent portrait framing and impact-first damage staging. */

/* Battle intro portraits use one shared frame instead of inheriting mixed generic portrait sizes. */
.battle-screen-v271 .duel .fighter > .portrait-wrap,
.battle-screen-v271.battle-visual-upgraded .fighter-visual-slot > .portrait-wrap {
  position: relative;
  display: block;
  width: min(168px, 82%);
  aspect-ratio: 4 / 5;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid rgba(218, 181, 112, .32);
  border-radius: 12px;
  background: #110e0c;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .38), inset 0 0 0 1px rgba(255, 255, 255, .03);
}

.battle-screen-v271.battle-visual-upgraded .fighter-visual-slot {
  min-height: 222px;
}

.battle-screen-v271 .duel .fighter > .portrait-wrap .portrait-lg,
.battle-screen-v271.battle-visual-upgraded .fighter-visual-slot > .portrait-wrap .portrait-lg {
  display: block;
  width: 100% !important;
  min-width: 100%;
  max-width: none !important;
  height: 100% !important;
  object-fit: cover !important;
  object-position: 50% 16% !important;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

/*
 * Preserve the pre-hit troop state until impact, then animate to the new value.
 * Do not make width !important: an important width declaration outranks the
 * keyframe animation and leaves the bar frozen until the next round rerender.
 */
.battle-screen-v271 .battle-hp-apply-v271 {
  width: var(--hp-from);
  transition: none !important;
  animation: v271-hp-apply .38s 1.76s ease-out forwards;
}

/* Result wording should not arrive before the cards have actually collided. */
.battle-screen-v271 .round-sequence .card-resolution-banner {
  animation-delay: 1.68s;
}

.battle-damage-feedback-v271 {
  position: absolute;
  z-index: 16;
  top: 72px;
  display: grid;
  justify-items: center;
  gap: 3px;
  min-width: 54px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px) scale(.94);
  animation: v271-damage-feedback .78s 1.76s cubic-bezier(.2, .76, .24, 1) both;
}

.battle-damage-feedback-v271.left { right: 6px; }
.battle-damage-feedback-v271.right { left: 6px; }

.battle-damage-feedback-v271 strong {
  color: #ff8a76;
  font-size: clamp(22px, 3vw, 32px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -.03em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, .92), 0 0 12px rgba(231, 81, 54, .42);
}

.battle-damage-feedback-v271 span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 20px;
  padding: 3px 7px;
  border: 1px solid rgba(225, 187, 114, .42);
  border-radius: 999px;
  color: #f0d9a8;
  background: rgba(13, 12, 12, .88);
  box-shadow: 0 4px 12px rgba(0, 0, 0, .3);
  font-size: 9px;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: .015em;
  white-space: nowrap;
}

.battle-damage-feedback-v271.critical span {
  border-color: rgba(232, 120, 76, .58);
  color: #ffd4b8;
  background: rgba(65, 26, 18, .88);
}

.battle-damage-feedback-v271.scheme span {
  border-color: rgba(94, 184, 205, .56);
  color: #c9f1f7;
  background: rgba(14, 42, 49, .88);
}

.battle-damage-feedback-v271.critical.scheme span {
  border-color: rgba(213, 167, 98, .62);
  color: #f8e2b7;
  background: linear-gradient(90deg, rgba(69, 27, 19, .9), rgba(15, 45, 50, .9));
}

@keyframes v271-damage-feedback {
  0% { opacity: 0; transform: translateY(8px) scale(.94); }
  24% { opacity: 1; transform: translateY(0) scale(1); }
  72% { opacity: 1; transform: translateY(-4px) scale(1); }
  100% { opacity: 0; transform: translateY(-18px) scale(.98); }
}

@keyframes v271-hp-apply {
  from { width: var(--hp-from); }
  to { width: var(--hp-to); }
}

/* 2x playback preserves the same logical order at half the delay. */
.battle-screen-v271.battle-speed-2 .round-sequence .strike-left,
.battle-screen-v271.battle-speed-2 .round-sequence .strike-right {
  animation-duration: .26s;
  animation-delay: .75s;
}

.battle-screen-v271.battle-speed-2 .round-sequence .clash-flash {
  animation-delay: .78s;
}

.battle-screen-v271.battle-speed-2 .round-sequence .card-resolution-banner {
  animation-delay: .84s;
}

.battle-screen-v271.battle-speed-2 .battle-impact-vfx-v267 {
  animation-duration: .34s;
  animation-delay: .74s;
}

.battle-screen-v271.battle-speed-2 .battle-damage-feedback-v271 {
  animation-duration: .39s;
  animation-delay: .88s;
}

.battle-screen-v271.battle-speed-2 .battle-hp-apply-v271 {
  animation-duration: .19s;
  animation-delay: .88s;
}

@media (max-width: 760px) {
  .battle-screen-v271 .duel .fighter > .portrait-wrap,
  .battle-screen-v271.battle-visual-upgraded .fighter-visual-slot > .portrait-wrap {
    width: min(124px, 88%);
    border-radius: 10px;
  }

  .battle-screen-v271.battle-visual-upgraded .fighter-visual-slot {
    min-height: 164px;
  }

  .battle-damage-feedback-v271 {
    top: 56px;
    min-width: 46px;
  }

  .battle-damage-feedback-v271 strong {
    font-size: clamp(19px, 6vw, 26px);
  }

  .battle-damage-feedback-v271 span {
    min-height: 18px;
    padding: 3px 6px;
    font-size: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .battle-screen-v271 .battle-hp-apply-v271 {
    animation-duration: .01ms !important;
    animation-delay: 0ms !important;
  }

  .battle-screen-v271 .battle-damage-feedback-v271 {
    opacity: 1;
    transform: none;
    animation-duration: .01ms !important;
    animation-delay: 0ms !important;
  }
}
