
/* =====================================================================
   BATTLE STAGE (painted backdrop, sprites, animations)
   ===================================================================== */
.arena.stage {
  display: grid; grid-template-columns: 1fr 1fr; align-items: end; gap: 0;
  padding: 44px 6% 18px; min-height: 400px; overflow: hidden; isolation: isolate;
  background: #14110e;
}
.stage-bg { position: absolute; inset: 0; z-index: -2; background-size: cover; transition: background-image .4s; }
.arena.stage::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.stage .combatant { justify-content: flex-end; gap: 6px; padding: 0; background: none; }
.stage .plate { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 6px 10px 7px; }
.stage .status-row { flex-wrap: wrap; justify-content: center; min-height: 0; max-width: 250px; }
.stage .status-row:empty { display: none; }
.stage .combatant .name { font-size: 17px; }
.stage .combatant .role { position: absolute; bottom: 2px; opacity: 0.8; text-shadow: 0 1px 3px #000; }
.stage .portrait-wrap { display: block; }
.stage .sprite { position: absolute; left: 0; right: 0; bottom: 14px; height: 100%; display: flex; align-items: flex-end; justify-content: center; transform-origin: 50% 100%; z-index: 1; }
.stage .sprite img { width: 100%; height: 100%; object-fit: contain; object-position: bottom; filter: drop-shadow(0 6px 10px rgba(0,0,0,0.55)); pointer-events: none; user-select: none; -webkit-user-drag: none; transition: filter .15s; }
.stage .sprite .portrait { width: 118px; height: 118px; margin-bottom: 30px; }
.stage .ground { position: absolute; left: 50%; bottom: 8px; width: 62%; height: 22px; transform: translateX(-50%); border-radius: 50%; background: radial-gradient(ellipse, rgba(0,0,0,0.6), transparent 70%); }

#enemyPanel .sprite { animation: breathe 3s ease-in-out infinite; animation-delay: -1.2s; }
#enemyPanel .portrait { animation: none; }
@keyframes breathe { 0%,100% { transform: scale(1, 1); } 50% { transform: scale(1.012, 1.028); } }
/* Hero idle: breathing + slight weight shift on the body, and a cape layer that sways from the shoulders */
.stage .sprite-art { position: relative; width: 100%; height: 100%; }
.stage .sprite-sheet { height: 100%; width: auto; max-width: 100%; flex: 0 0 auto; background-repeat: no-repeat; filter: drop-shadow(0 6px 10px rgba(0,0,0,0.55)); transition: filter .15s; }
.sprite.hurt .sprite-sheet { filter: brightness(1.5) sepia(0.6) hue-rotate(-30deg) saturate(2.5); }
.sprite.guard .sprite-sheet { filter: drop-shadow(0 0 14px rgba(110,170,240,0.95)); }
.stage .sprite-art img { position: absolute; inset: 0; }
#playerPanel .sprite { animation: heroIdle 3.6s ease-in-out infinite; }
@keyframes heroIdle { 0%,100% { transform: scale(1, 1) skewX(0deg); } 30% { transform: scale(1.01, 1.024) skewX(-0.5deg); } 60% { transform: scale(1.012, 1.028) skewX(0.3deg); } }
.stage .sprite-art img.sway { filter: none; transform-origin: 22% 26%;
  -webkit-mask-image: linear-gradient(90deg, #000 0, #000 13%, transparent 24%), linear-gradient(180deg, transparent 18%, #000 30%);
  -webkit-mask-composite: source-in; mask-image: linear-gradient(90deg, #000 0, #000 13%, transparent 24%), linear-gradient(180deg, transparent 18%, #000 30%); mask-composite: intersect;
  animation: capeSway 2.8s ease-in-out infinite; }
@keyframes capeSway { 0%,100% { transform: rotate(0deg) skewY(0deg); } 35% { transform: rotate(1.6deg) skewY(0.8deg); } 70% { transform: rotate(-0.6deg) skewY(-0.3deg); } }
body.no-fx .sprite-art img.sway { animation: none; }
#enemyPanel.elite .sprite img { filter: drop-shadow(0 0 10px rgba(255,184,107,0.45)) drop-shadow(0 6px 10px rgba(0,0,0,0.55)); }
#enemyPanel.boss .sprite img { filter: drop-shadow(0 0 14px rgba(255,90,78,0.5)) drop-shadow(0 6px 10px rgba(0,0,0,0.55)); }
#enemyPanel.final .portrait-wrap { width: 380px; height: 300px; }
#enemyPanel.final .sprite img { filter: drop-shadow(0 0 22px rgba(255,80,40,0.45)) drop-shadow(0 8px 14px rgba(0,0,0,0.6)); }
#enemyPanel.big .portrait-wrap { width: 320px; }
.stage .intent { margin-bottom: 2px; }
.stage .intent-spacer { min-height: 40px; }

/* turn banner sweeps across the stage */
.stage .turn-banner { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 3; padding: 6px 18px; font-size: 15px; background: rgba(16, 13, 10,0.7); backdrop-filter: blur(3px); white-space: nowrap; }
.stage .turn-banner:empty { display: none; }
.turn-banner.sweep { animation: bannerIn .55s cubic-bezier(.2,1.4,.4,1); }
@keyframes bannerIn { from { transform: translate(-50%, -12px) scale(0.85); opacity: 0; } }

/* log tucked into a corner */
.log-box { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); z-index: 4; width: min(300px, 40%); font-size: 12px; }
.log-box summary { cursor: pointer; list-style: none; text-align: center; color: var(--muted); font-weight: 600; padding: 3px 10px; border-radius: 999px; background: rgba(16, 13, 10,0.6); border: 1px solid rgba(255,255,255,0.08); width: max-content; margin: 0 auto; }
.log-box summary::-webkit-details-marker { display: none; }
.log-box[open] summary { margin-bottom: 6px; }
.log-box .log { min-height: 0; max-height: 170px; background: rgba(10, 8, 6,0.85); }

/* attack / hit / cast animations */
.sprite.lunge-r { animation: lungeR .42s cubic-bezier(.3,.1,.3,1) !important; }
.sprite.lunge-l { animation: lungeL .42s cubic-bezier(.3,.1,.3,1) !important; }
@keyframes lungeR { 0% { transform: none; } 25% { transform: translateX(-14px) rotate(-3deg); } 55% { transform: translateX(95px) rotate(4deg); } 100% { transform: none; } }
@keyframes lungeL { 0% { transform: none; } 25% { transform: translateX(14px) rotate(3deg); } 55% { transform: translateX(-95px) rotate(-4deg); } 100% { transform: none; } }
.sprite.cast { animation: cast .5s ease-out !important; }
@keyframes cast { 0% { transform: none; } 40% { transform: translateY(-10px) scale(1.04); } 100% { transform: none; } }
.sprite.cast img { filter: drop-shadow(0 0 16px rgba(160,190,255,0.9)) drop-shadow(0 6px 10px rgba(0,0,0,0.55)) brightness(1.15); }
.sprite.hit-l { animation: hitL .36s ease-out !important; }
.sprite.hit-r { animation: hitR .36s ease-out !important; }
@keyframes hitL { 0% { transform: none; } 20% { transform: translateX(-20px) rotate(-4deg); } 60% { transform: translateX(6px); } 100% { transform: none; } }
@keyframes hitR { 0% { transform: none; } 20% { transform: translateX(20px) rotate(4deg); } 60% { transform: translateX(-6px); } 100% { transform: none; } }
.sprite.hurt img { filter: brightness(1.5) sepia(0.6) hue-rotate(-30deg) saturate(2.5) drop-shadow(0 6px 10px rgba(0,0,0,0.55)); }
.sprite.guard img { filter: drop-shadow(0 0 14px rgba(110,170,240,0.95)) drop-shadow(0 6px 10px rgba(0,0,0,0.55)); }
.sprite.dodge { animation: dodge .45s ease-out !important; }
@keyframes dodge { 0% { transform: none; opacity: 1; } 35% { transform: translateX(-46px) skewX(-8deg); opacity: 0.45; } 100% { transform: none; opacity: 1; } }
#enemyPanel.dead .sprite { animation: die .9s ease-in .45s both !important; }
@keyframes die { 0% { transform: none; opacity: 1; filter: none; } 30% { transform: translateY(-6px); } 100% { transform: translateY(26px) scaleY(0.9); opacity: 0; filter: grayscale(1) blur(2px); } }
 }
.stage .floater { top: 34%; font-size: 34px; font-family: var(--font-display); }
.stage .floater.big { font-size: 44px; color: #ffd166; }
.stage.quake { animation: quake .35s ease; }
@keyframes quake { 0%,100% { transform: none; } 25% { transform: translate(-4px, 2px); } 50% { transform: translate(4px, -2px); } 75% { transform: translate(-2px, 1px); } }
body.no-fx .sprite, body.no-fx .sprite * { animation: none !important; }

