/*
 * ORDEN DEL ECLIPSE — Motor visual de batalla 2.5D
 * Fase: BATTLE-2.5D-C1-A5
 * Contrato de escala:
 *   héroe / enemigo común = 1.00x
 *   miniBoss              = 1.30x
 *   Boss                  = 1.50x
 *
 * Esta hoja solo modifica presentación. El motor lógico, el balance,
 * la IA, el guardado y la economía permanecen en el runtime original.
 */

:root {
  --ode25d-scale-base: 1;
  --ode25d-scale-miniboss: 1.3;
  --ode25d-scale-boss: 1.5;
}

html body #battlePanel[data-ode25d="1"] {
  --ode25d-base-art: clamp(84px, 9.8vw, 144px);
  --ode25d-miniboss-art: clamp(109.2px, 12.74vw, 187.2px);
  --ode25d-boss-art: clamp(126px, 14.7vw, 216px);
  --ode25d-base-card: clamp(112px, 11.4vw, 166px);
  --ode25d-miniboss-card: clamp(145.6px, 14.82vw, 215.8px);
  --ode25d-boss-card: clamp(168px, 17.1vw, 249px);
  --ode25d-boss-offset-y: clamp(8px, 0.8vw, 12px);
  --ode25d-parallax-x: 0px;
  --ode25d-parallax-y: 0px;
  --ode25d-bg-x: 0px;
  --ode25d-bg-y: 0px;
  --ode25d-grid-x: 0px;
  --ode25d-grid-y: 0px;
  --ode25d-fog-x: 0px;
  --ode25d-scene-tilt-x: 0deg;
  --ode25d-scene-tilt-y: 0deg;
  --ode25d-solar: #f4bd58;
  --ode25d-lunar: #91c8ff;
  --ode25d-abyss: #bd70ef;
  --ode25d-enemy: #e86d79;
  --ode25d-heal: #69e6a2;
  --ode25d-shield: #70cfff;
}

html body #battlePanel[data-ode25d="1"] .battle-top {
  isolation: isolate;
}

#battlePanel[data-ode25d="1"] .ode25d-engine-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  padding: 3px 7px;
  border: 1px solid rgba(211, 168, 87, 0.38);
  border-radius: 999px;
  background: rgba(10, 6, 15, 0.7);
  color: #d8c6a2;
  font: 800 0.44rem/1.2 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#battlePanel[data-ode25d="1"] .ode25d-engine-badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #72dba3;
  box-shadow: 0 0 9px rgba(114, 219, 163, 0.82);
}

/* Escenario estratificado. La cámara solo desplaza capas; no escala unidades. */
html body #battlePanel[data-ode25d="1"] .battlefield {
  perspective: 1100px !important;
  perspective-origin: 50% 62% !important;
  transform-style: preserve-3d !important;
  background-color: #07030b !important;
  isolation: isolate !important;
}

#battlePanel[data-ode25d="1"] .battle-background {
  z-index: 0 !important;
  transform:
    translate3d(
      var(--ode25d-bg-x),
      var(--ode25d-bg-y),
      -24px
    )
    scale(1.075) !important;
  transform-origin: center !important;
  transition: transform 180ms ease-out, filter 220ms ease !important;
  filter: saturate(0.92) contrast(1.05) brightness(0.78) !important;
  will-change: transform;
}

#battlePanel[data-ode25d="1"] .ode25d-world {
  position: absolute;
  z-index: 1;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  transform-style: preserve-3d;
}

#battlePanel[data-ode25d="1"] .ode25d-world::before {
  content: "";
  position: absolute;
  z-index: 0;
  left: -10%;
  right: -10%;
  bottom: 91px;
  height: 56%;
  transform:
    translate3d(
      var(--ode25d-grid-x),
      var(--ode25d-grid-y),
      0
    )
    perspective(620px)
    rotateX(67deg);
  transform-origin: 50% 100%;
  border-top: 1px solid rgba(204, 149, 72, 0.18);
  background:
    linear-gradient(90deg, transparent 49.7%, rgba(193, 130, 221, 0.08) 50%, transparent 50.3%),
    repeating-linear-gradient(90deg, transparent 0 78px, rgba(216, 176, 239, 0.055) 79px 80px),
    repeating-linear-gradient(0deg, transparent 0 52px, rgba(216, 176, 239, 0.048) 53px 54px),
    radial-gradient(ellipse at 50% 100%, rgba(135, 71, 172, 0.21), rgba(21, 8, 29, 0.04) 62%, transparent 76%);
  opacity: 0.68;
  mask-image: linear-gradient(180deg, transparent 0%, #000 32%, #000 100%);
}

#battlePanel[data-ode25d="1"] .ode25d-fog {
  position: absolute;
  z-index: 2;
  left: -18%;
  width: 136%;
  height: 120px;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 25% 50%, rgba(143, 98, 164, 0.13), transparent 38%),
    radial-gradient(ellipse at 72% 50%, rgba(105, 86, 145, 0.12), transparent 42%);
  filter: blur(13px);
  opacity: 0.66;
  animation: ode25dFogDrift 12s ease-in-out infinite alternate;
}

#battlePanel[data-ode25d="1"] .ode25d-fog--far {
  top: 23%;
  transform: translate3d(var(--ode25d-fog-x), 0, -10px);
}

#battlePanel[data-ode25d="1"] .ode25d-fog--near {
  z-index: 18;
  bottom: 78px;
  opacity: 0.42;
  animation-duration: 8.4s;
  animation-direction: alternate-reverse;
}

#battlePanel[data-ode25d="1"] .ode25d-embers {
  position: absolute;
  z-index: 3;
  inset: 0;
  opacity: 0.58;
  background-image:
    radial-gradient(circle at 8% 72%, rgba(243, 185, 84, 0.72) 0 1px, transparent 1.5px),
    radial-gradient(circle at 24% 41%, rgba(194, 120, 234, 0.68) 0 1px, transparent 1.5px),
    radial-gradient(circle at 42% 76%, rgba(243, 185, 84, 0.54) 0 1px, transparent 1.5px),
    radial-gradient(circle at 63% 37%, rgba(194, 120, 234, 0.6) 0 1px, transparent 1.5px),
    radial-gradient(circle at 82% 68%, rgba(243, 185, 84, 0.66) 0 1px, transparent 1.5px),
    radial-gradient(circle at 94% 29%, rgba(194, 120, 234, 0.54) 0 1px, transparent 1.5px);
  background-size: 260px 210px, 310px 260px, 280px 230px, 340px 300px, 300px 250px, 360px 280px;
  animation: ode25dEmbersRise 18s linear infinite;
}

#battlePanel[data-ode25d="1"] .ode25d-vignette {
  position: absolute;
  z-index: 20;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(4, 2, 8, 0.46), transparent 15%, transparent 85%, rgba(4, 2, 8, 0.46)),
    linear-gradient(180deg, rgba(4, 2, 8, 0.22), transparent 28%, transparent 70%, rgba(4, 2, 8, 0.5));
  box-shadow: inset 0 0 86px rgba(0, 0, 0, 0.46);
}

#battlePanel[data-ode25d="1"] .ode25d-fx-layer {
  position: absolute;
  z-index: 26;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  contain: layout paint;
}

#battlePanel[data-ode25d="1"] .ode25d-screen-flash {
  position: absolute;
  z-index: 27;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at var(--ode25d-flash-x, 50%) var(--ode25d-flash-y, 50%), rgba(255, 240, 194, 0.28), rgba(143, 69, 180, 0.12) 30%, transparent 66%);
}

#battlePanel[data-ode25d="1"] .ode25d-screen-flash.active {
  animation: ode25dScreenFlash 430ms ease-out both;
}

/*
 * Formación compacta 2-2-1.
 * Dos unidades al frente, dos en la banda media y una centrada atrás.
 * El enemigo utiliza el mismo dibujo reflejado.
 */
html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-ode25d-formation="compact-2-2-1"][data-afk-polish="1"] .ally-line,
html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-ode25d-formation="compact-2-2-1"][data-afk-polish="1"] .battlefield:not(.boss-battle) .enemy-line {
  bottom: 102px !important;
  width: 46.4% !important;
  height: clamp(340px, 51vh, 420px) !important;
  min-height: 340px !important;
  max-height: 420px !important;
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  grid-template-rows: repeat(3, minmax(106px, 1fr)) !important;
  row-gap: 0 !important;
  column-gap: clamp(4px, 1.15vw, 18px) !important;
  align-content: end !important;
  align-items: end !important;
  justify-items: center !important;
  overflow: visible !important;
}

html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-ode25d-formation="compact-2-2-1"][data-afk-polish="1"] .ally-line {
  left: 1.2% !important;
  right: auto !important;
}

html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-ode25d-formation="compact-2-2-1"][data-afk-polish="1"] .battlefield:not(.boss-battle) .enemy-line {
  right: 8.2% !important;
  left: auto !important;
  width: 43.2% !important;
}

html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-ode25d-formation="compact-2-2-1"][data-afk-polish="1"] .ally-line .battle-unit[data-formation-pos="0"] {
  grid-column: 3 !important;
  grid-row: 1 !important;
}

html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-ode25d-formation="compact-2-2-1"][data-afk-polish="1"] .ally-line .battle-unit[data-formation-pos="1"] {
  grid-column: 3 !important;
  grid-row: 3 !important;
}

html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-ode25d-formation="compact-2-2-1"][data-afk-polish="1"] .ally-line .battle-unit[data-formation-pos="2"] {
  grid-column: 2 !important;
  grid-row: 1 !important;
}

html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-ode25d-formation="compact-2-2-1"][data-afk-polish="1"] .ally-line .battle-unit[data-formation-pos="3"] {
  grid-column: 2 !important;
  grid-row: 3 !important;
}

html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-ode25d-formation="compact-2-2-1"][data-afk-polish="1"] .ally-line .battle-unit[data-formation-pos="4"] {
  grid-column: 1 !important;
  grid-row: 2 !important;
}

html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-ode25d-formation="compact-2-2-1"][data-afk-polish="1"] .battlefield:not(.boss-battle) .enemy-line .battle-unit[data-formation-pos="0"] {
  grid-column: 1 !important;
  grid-row: 1 !important;
}

html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-ode25d-formation="compact-2-2-1"][data-afk-polish="1"] .battlefield:not(.boss-battle) .enemy-line .battle-unit[data-formation-pos="1"] {
  grid-column: 1 !important;
  grid-row: 3 !important;
}

html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-ode25d-formation="compact-2-2-1"][data-afk-polish="1"] .battlefield:not(.boss-battle) .enemy-line .battle-unit[data-formation-pos="2"] {
  grid-column: 2 !important;
  grid-row: 1 !important;
}

html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-ode25d-formation="compact-2-2-1"][data-afk-polish="1"] .battlefield:not(.boss-battle) .enemy-line .battle-unit[data-formation-pos="3"] {
  grid-column: 2 !important;
  grid-row: 3 !important;
}

html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-ode25d-formation="compact-2-2-1"][data-afk-polish="1"] .battlefield:not(.boss-battle) .enemy-line .battle-unit[data-formation-pos="4"] {
  grid-column: 3 !important;
  grid-row: 2 !important;
}

html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-ode25d-formation="compact-2-2-1"][data-afk-polish="1"] .ally-line[data-ode25d-unit-count="1"] .battle-unit,
html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-ode25d-formation="compact-2-2-1"][data-afk-polish="1"] .battlefield:not(.boss-battle) .enemy-line[data-ode25d-unit-count="1"] .battle-unit {
  grid-row: 2 !important;
}

/* Actor sin tarjeta: arte libre + HUD mínimo flotante. */
html body #battlePanel[data-ode25d="1"] .battle-unit {
  --ode25d-actor-art: var(--ode25d-base-art);
  --ode25d-actor-card: var(--ode25d-base-card);
  --ode25d-glyph-size: clamp(39.48px, 4.606vw, 67.68px);
  position: relative !important;
  width: var(--ode25d-actor-card) !important;
  min-width: var(--ode25d-actor-card) !important;
  max-width: var(--ode25d-actor-card) !important;
  padding: 0 7px 7px !important;
  border: 0 !important;
  border-radius: 11px !important;
  background: transparent !important;
  box-shadow: none !important;
  overflow: visible !important;
  isolation: isolate;
  z-index: var(--ode25d-layer, 12) !important;
  transform-style: preserve-3d;
  filter: none;
  transition: opacity 220ms ease, filter 220ms ease !important;
}

html body #battlePanel[data-ode25d="1"] .battle-unit[data-template="eryon"] .unit-name {
  font-size: clamp(0.5rem, 0.62vw, 0.61rem) !important;
  letter-spacing: -0.02em;
}

html body #battlePanel[data-ode25d="1"] .battle-unit[data-ode25d-size="elite"] {
  --ode25d-actor-art: var(--ode25d-miniboss-art);
  --ode25d-actor-card: var(--ode25d-miniboss-card);
  --ode25d-glyph-size: clamp(51.324px, 5.9878vw, 87.984px);
}

/*
 * A5 aumenta únicamente al Boss principal. Los miniBoss conservan 1.30x.
 * El desplazamiento relativo mueve al Boss completo —arte y barras— para
 * separar la punta superior del HUD de vida sin alterar su anclaje lógico.
 */
html body #battlePanel[data-ode25d="1"] .battle-unit[data-ode25d-role="boss"] {
  --ode25d-actor-art: var(--ode25d-boss-art);
  --ode25d-actor-card: var(--ode25d-boss-card);
  --ode25d-glyph-size: clamp(59.22px, 6.909vw, 101.52px);
  position: relative !important;
  top: var(--ode25d-boss-offset-y) !important;
}

/*
 * BATTLE-2.5D-C1-A4 — limpieza pedida y conservada en A5:
 * - CENTER_RING_REMOVED: desactiva también el círculo heredado de battlefield::before.
 * - NAMEPLATE_BOXES_REMOVED: ninguna unidad conserva tarjeta ni cápsula de nombre.
 * Las barras siguen visibles y no cambia ningún dato de combate.
 */
html body #battlePanel[data-ode25d="1"][data-afk-polish="1"] .battlefield::before {
  content: none !important;
  display: none !important;
  border: 0 !important;
  background: none !important;
  box-shadow: none !important;
}

html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-afk-polish="1"] .battle-unit::before,
html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-afk-polish="1"] .battle-unit::after {
  content: none !important;
  display: none !important;
  border: 0 !important;
  background: none !important;
  box-shadow: none !important;
}

html body #battlePanel[data-ode25d="1"] .battle-unit .unit-visual {
  position: relative !important;
  z-index: 2 !important;
  width: 100% !important;
  height: calc(var(--ode25d-actor-art) + 10px) !important;
  min-height: calc(var(--ode25d-actor-art) + 10px) !important;
  max-height: calc(var(--ode25d-actor-art) + 10px) !important;
  margin: 0 0 2px !important;
  padding: 0 !important;
  display: flex !important;
  align-items: flex-end !important;
  justify-content: center !important;
  overflow: visible !important;
  transform: translateZ(var(--ode25d-depth-z, 0px));
  transform-origin: 50% 100%;
  animation: ode25dActorIdle var(--ode25d-idle-duration, 3.4s) ease-in-out infinite;
  animation-delay: var(--ode25d-idle-delay, 0ms);
}

html body #battlePanel[data-ode25d="1"] .battle-unit[data-ode25d-depth="rear"] .unit-visual {
  filter: brightness(0.94) saturate(0.93);
}

html body #battlePanel[data-ode25d="1"] .battle-unit[data-ode25d-depth="middle"] .unit-visual {
  filter: brightness(0.985) saturate(0.98);
}

html body #battlePanel[data-ode25d="1"] .battle-unit[data-ode25d-depth="front"] .unit-visual {
  filter: brightness(1.035) saturate(1.04);
}

html body #battlePanel[data-ode25d="1"] .battle-unit .pixel-sprite-stage {
  position: relative !important;
  z-index: 2 !important;
  width: var(--display-size) !important;
  height: var(--display-size) !important;
  min-width: var(--display-size) !important;
  min-height: var(--display-size) !important;
  max-width: var(--display-size) !important;
  max-height: var(--display-size) !important;
  margin: 0 auto !important;
  overflow: visible !important;
  transform-origin: 50% 100% !important;
  filter: drop-shadow(0 10px 8px rgba(0, 0, 0, 0.58)) !important;
}

/*
 * Normalización óptica: el marco conserva la escala contractual exacta,
 * mientras esta capa compensa el padding transparente propio de cada arte.
 * Así una imagen con mucho margen no se ve menor que otra con el mismo frame.
 */
#battlePanel[data-ode25d="1"] .ode25d-optical-frame {
  --ode25d-optical-scale: 1;
  --ode25d-optical-y: 0%;
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  transform: translateY(var(--ode25d-optical-y)) scale(var(--ode25d-optical-scale));
  transform-origin: 50% 100%;
  will-change: transform;
}

#battlePanel[data-ode25d="1"] .ode25d-optical-frame > .pixel-sprite {
  width: 100% !important;
  height: 100% !important;
}

html body #battlePanel[data-ode25d="1"] .battle-unit .pixel-sprite-stage::before {
  width: 72% !important;
  height: 72% !important;
  border-radius: 50% !important;
  background: radial-gradient(circle, rgba(119, 69, 146, 0.12), transparent 70%) !important;
  border-color: transparent !important;
  box-shadow: 0 0 28px rgba(119, 69, 146, 0.12) !important;
  opacity: 0.74 !important;
}

html body #battlePanel[data-ode25d="1"] .battle-unit .pixel-sprite-stage::after {
  display: none !important;
  content: none !important;
}

#battlePanel[data-ode25d="1"] .ode25d-actor-shadow {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: 0;
  width: 68%;
  height: 13%;
  min-height: 10px;
  transform: translateX(-50%) perspective(120px) rotateX(67deg);
  transform-origin: center;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.72), rgba(42, 19, 52, 0.33) 56%, transparent 74%);
  filter: blur(2.6px);
  opacity: 0.9;
  transition: transform 180ms ease, opacity 180ms ease;
}

#battlePanel[data-ode25d="1"] .battle-unit[data-ode25d-size="elite"] .ode25d-actor-shadow {
  width: 82%;
  height: 15%;
}

#battlePanel[data-ode25d="1"] .battle-unit.attack .ode25d-actor-shadow,
#battlePanel[data-ode25d="1"] .battle-unit.cast .ode25d-actor-shadow {
  transform: translateX(-50%) perspective(120px) rotateX(67deg) scale(1.14);
  opacity: 0.62;
}

#battlePanel[data-ode25d="1"] .battle-unit .unit-glyph {
  width: var(--ode25d-actor-art) !important;
  height: var(--ode25d-actor-art) !important;
  font-size: var(--ode25d-glyph-size) !important;
  line-height: 1 !important;
  text-shadow: 0 8px 18px rgba(0, 0, 0, 0.66), 0 0 22px currentColor;
}

#battlePanel[data-ode25d="1"] .battle-unit .unit-name {
  position: relative !important;
  z-index: 4 !important;
  display: block !important;
  min-height: 18px !important;
  margin: 0 !important;
  padding: 2px 0 0 !important;
  color: #f5e9f1 !important;
  font-size: clamp(0.52rem, 0.62vw, 0.67rem) !important;
  line-height: 1.15 !important;
  text-align: center !important;
  text-shadow: 0 2px 4px #000, 0 0 8px rgba(0, 0, 0, 0.92);
}

#battlePanel[data-ode25d="1"] .battle-unit[data-ode25d-size="elite"] .unit-name {
  color: #f5d89a !important;
}

html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-afk-polish="1"] .ally-line .battle-unit.ally-unit .unit-name,
html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-afk-polish="1"] .enemy-line .battle-unit.enemy-unit .unit-name {
  min-width: 0 !important;
  max-width: calc(var(--ode25d-actor-card) - 14px) !important;
  margin: 0 auto !important;
  padding: 2px 0 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: none !important;
  background-image: none !important;
  box-shadow: none !important;
  text-align: center !important;
}

#battlePanel[data-ode25d="1"] .battle-unit .unit-level {
  display: none !important;
}

#battlePanel[data-ode25d="1"] .battle-unit .bar,
#battlePanel[data-ode25d="1"] .battle-unit .shield-wrap,
#battlePanel[data-ode25d="1"] .battle-unit .unit-vitals,
#battlePanel[data-ode25d="1"] .battle-unit .status-row {
  position: relative !important;
  z-index: 4 !important;
  width: 100% !important;
  visibility: visible !important;
}

#battlePanel[data-ode25d="1"] .battle-unit .bar {
  height: 6px !important;
  margin-top: 2px !important;
  border: 1px solid rgba(38, 27, 44, 0.94) !important;
  background: #040207 !important;
  opacity: 1 !important;
}

#battlePanel[data-ode25d="1"] .battle-unit .hpbar i {
  background: linear-gradient(90deg, #772a36, #e45b68 70%, #f1a071) !important;
  box-shadow: 0 0 8px rgba(223, 75, 91, 0.24);
}

#battlePanel[data-ode25d="1"] .battle-unit .energybar {
  height: 4px !important;
}

#battlePanel[data-ode25d="1"] .battle-unit .energybar i {
  background: linear-gradient(90deg, #4a2870, #9c56ca 60%, #deb3ff) !important;
}

#battlePanel[data-ode25d="1"] .battle-unit .shield-wrap {
  margin-top: 2px !important;
}

#battlePanel[data-ode25d="1"] .battle-unit .shield-label {
  font-size: 0.4rem !important;
}

#battlePanel[data-ode25d="1"] .battle-unit .shieldbar {
  height: 4px !important;
}

#battlePanel[data-ode25d="1"] .battle-unit .unit-vitals {
  display: flex !important;
  justify-content: space-between !important;
  gap: 5px !important;
  margin-top: 2px !important;
  color: #b8a9bc !important;
  font: 700 clamp(0.38rem, 0.44vw, 0.46rem)/1.15 ui-monospace, SFMono-Regular, Consolas, monospace !important;
}

#battlePanel[data-ode25d="1"] .battle-unit .status-row {
  min-height: 0 !important;
  max-height: 20px !important;
  margin-top: 2px !important;
  overflow: hidden !important;
  justify-content: flex-start !important;
}

#battlePanel[data-ode25d="1"] .battle-unit .status {
  padding: 1px 3px !important;
  font-size: 0.38rem !important;
}

#battlePanel[data-ode25d="1"] .ode25d-rank {
  position: absolute;
  z-index: 7;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 7px;
  border: 1px solid rgba(231, 178, 91, 0.56);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(62, 33, 18, 0.94), rgba(19, 9, 16, 0.94));
  color: #f4d491;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.44), 0 0 16px rgba(205, 129, 49, 0.13);
  font: 900 0.41rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.08em;
  white-space: nowrap;
  pointer-events: none;
}

/* El HUD superior ya identifica al jefe; no se repite una cápsula sobre su arte. */
#battlePanel[data-ode25d="1"] .ode25d-rank {
  display: none !important;
}

#battlePanel[data-ode25d="1"] .battle-unit[data-ode25d-rank="boss"] .ode25d-rank {
  border-color: rgba(246, 194, 98, 0.78);
  background: linear-gradient(180deg, rgba(92, 45, 19, 0.97), rgba(30, 12, 19, 0.97));
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.48), 0 0 20px rgba(235, 151, 58, 0.22);
}

/* La escala exacta se aplica a --display-size desde JS con prioridad important.
   Estas reglas fijan además el contenedor para glifos/fallbacks. */
html body #battlePanel[data-ode25d="1"] .battle-unit[data-ode25d-size="base"] .pixel-sprite-stage {
  width: var(--ode25d-base-art) !important;
  height: var(--ode25d-base-art) !important;
  min-width: var(--ode25d-base-art) !important;
  min-height: var(--ode25d-base-art) !important;
  max-width: var(--ode25d-base-art) !important;
  max-height: var(--ode25d-base-art) !important;
}

html body #battlePanel[data-ode25d="1"] .battle-unit[data-ode25d-size="elite"] .pixel-sprite-stage {
  width: var(--ode25d-actor-art) !important;
  height: var(--ode25d-actor-art) !important;
  min-width: var(--ode25d-actor-art) !important;
  min-height: var(--ode25d-actor-art) !important;
  max-width: var(--ode25d-actor-art) !important;
  max-height: var(--ode25d-actor-art) !important;
}

/* Estados de combate 2.5D. */
/*
 * El motor base desplaza cualquier .attack hasta el objetivo mediante
 * afkLungeToTarget. Eso es correcto para melee, pero hacía que Lysara y los
 * demás magos abandonaran la retaguardia. Los perfiles de alcance sustituyen
 * únicamente esa animación del contenedor; el sprite, el hechizo y el impacto
 * conservan sus tiempos originales.
 */
#battlePanel[data-ode25d="1"] .battle-unit[data-ode25d-attack-profile="magic"].attack,
#battlePanel[data-ode25d="1"] .battle-unit[data-ode25d-attack-profile="projectile"].attack {
  animation-name: ode25dRangedAttackAnchor !important;
  animation-duration: var(--afk-current-attack-duration, var(--afk-attack-duration, 940ms)) !important;
  animation-timing-function: ease-out !important;
  animation-iteration-count: 1 !important;
  animation-fill-mode: both !important;
}

#battlePanel[data-ode25d="1"] .battle-unit.attack .unit-visual::before,
#battlePanel[data-ode25d="1"] .battle-unit.cast .unit-visual::before {
  content: "";
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 48%;
  width: 82%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: conic-gradient(from 25deg, transparent, currentColor 7%, transparent 16%, transparent 58%, currentColor 66%, transparent 74%);
  filter: blur(1px);
  opacity: 0;
  pointer-events: none;
  animation: ode25dCastAura 520ms ease-out both;
}

#battlePanel[data-ode25d="1"] .battle-unit.hit .unit-visual {
  animation: ode25dHitDepth 270ms ease-out both !important;
}

#battlePanel[data-ode25d="1"] .battle-unit.dead {
  opacity: 0.5 !important;
  filter: grayscale(0.72) saturate(0.45) !important;
}

#battlePanel[data-ode25d="1"] .battle-unit.dead .unit-visual {
  animation: ode25dDeathSettle 620ms cubic-bezier(0.2, 0.7, 0.2, 1) both !important;
}

#battlePanel[data-ode25d="1"] .battle-unit.dead .ode25d-actor-shadow {
  opacity: 0.18;
  transform: translateX(-50%) perspective(120px) rotateX(67deg) scale(0.7);
}

#battlePanel[data-ode25d="1"] .battle-unit.ode25d-shield-pulse .unit-visual::after {
  content: "";
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 52%;
  width: 78%;
  height: 88%;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(112, 207, 255, 0.72);
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(112, 207, 255, 0.09), transparent 65%);
  box-shadow: 0 0 22px rgba(112, 207, 255, 0.32), inset 0 0 18px rgba(112, 207, 255, 0.17);
  pointer-events: none;
  animation: ode25dShieldPulse 580ms ease-out both;
}

/* Efectos runtime por perfil de ataque. */
#battlePanel[data-ode25d="1"] .battle-unit.ode25d-melee-lunge .unit-visual {
  animation: ode25dMeleeLunge 420ms cubic-bezier(0.2, 0.75, 0.25, 1) both !important;
}

#battlePanel[data-ode25d="1"] .ode25d-melee-slash {
  position: absolute;
  z-index: 6;
  width: 54px;
  height: 30px;
  margin: -15px 0 0 -27px;
  transform: rotate(var(--ode25d-slash-angle, 0rad));
  border-top: 3px solid #fff;
  border-right: 2px solid var(--ode25d-fx-color, #f1d08b);
  border-radius: 50%;
  opacity: 0;
  filter: drop-shadow(0 0 7px var(--ode25d-fx-color, #f1d08b));
  animation: ode25dMeleeSlash 460ms ease-out both;
}

#battlePanel[data-ode25d="1"] .ode25d-melee-slash--heavy {
  width: 72px;
  height: 38px;
  margin: -19px 0 0 -36px;
  border-top-width: 5px;
}

#battlePanel[data-ode25d="1"] .ode25d-magic-sigil {
  position: absolute;
  z-index: 4;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border: 1px solid var(--ode25d-fx-color, #d6b7ee);
  border-radius: 50%;
  opacity: 0;
  background:
    conic-gradient(from 18deg, transparent 0 12%, var(--ode25d-fx-color, #d6b7ee) 13% 16%, transparent 17% 42%, var(--ode25d-fx-color, #d6b7ee) 43% 46%, transparent 47% 72%, var(--ode25d-fx-color, #d6b7ee) 73% 76%, transparent 77%),
    radial-gradient(circle, rgba(255, 255, 255, 0.92) 0 5%, transparent 7%);
  box-shadow: 0 0 16px var(--ode25d-fx-color, #d6b7ee), inset 0 0 9px var(--ode25d-fx-color, #d6b7ee);
  animation: ode25dMagicSigil 560ms ease-out both;
}

#battlePanel[data-ode25d="1"] .ode25d-magic-arc {
  position: absolute;
  z-index: 3;
  width: var(--ode25d-distance, 80px);
  height: 20px;
  transform-origin: 0 50%;
  transform: translateY(calc(-1 * var(--ode25d-arc-bend, 14px))) rotate(var(--ode25d-angle, 0rad));
  border-top: 2px solid var(--ode25d-fx-color, #d6b7ee);
  border-radius: 50%;
  opacity: 0;
  background:
    radial-gradient(circle at 16% 2px, #fff 0 2px, transparent 3px),
    radial-gradient(circle at 42% 1px, var(--ode25d-fx-color, #d6b7ee) 0 2px, transparent 3px),
    radial-gradient(circle at 71% 2px, #fff 0 1.5px, transparent 2.5px);
  filter: drop-shadow(0 0 7px var(--ode25d-fx-color, #d6b7ee));
  animation: ode25dMagicArc var(--ode25d-duration, 420ms) cubic-bezier(0.18, 0.72, 0.24, 1) both;
}

#battlePanel[data-ode25d="1"] .ode25d-magic-arc::after {
  content: "";
  position: absolute;
  right: -7px;
  top: -8px;
  width: 14px;
  height: 14px;
  border: 1px solid #fff;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0 18%, var(--ode25d-fx-color, #d6b7ee) 42%, transparent 74%);
  box-shadow: 0 0 14px var(--ode25d-fx-color, #d6b7ee);
}

#battlePanel[data-ode25d="1"] .ode25d-magic-arc--heavy {
  height: 28px;
  border-top-width: 4px;
}

/* Projectile se conserva completo, pero C1-A5 no le asigna unidades activas. */
#battlePanel[data-ode25d="1"] .ode25d-projectile {
  position: absolute;
  z-index: 2;
  width: var(--ode25d-distance, 80px);
  height: 4px;
  transform-origin: 0 50%;
  transform: rotate(var(--ode25d-angle, 0rad));
  border-radius: 999px;
  opacity: 0;
  background: linear-gradient(90deg, transparent, var(--ode25d-fx-color, #f4bd58) 24%, #fff 66%, transparent);
  filter: drop-shadow(0 0 7px var(--ode25d-fx-color, #f4bd58));
  animation: ode25dProjectile var(--ode25d-duration, 360ms) cubic-bezier(0.2, 0.75, 0.25, 1) both;
}

#battlePanel[data-ode25d="1"] .ode25d-projectile::after {
  content: "";
  position: absolute;
  right: -3px;
  top: 50%;
  width: 12px;
  height: 12px;
  transform: translateY(-50%) rotate(45deg);
  border: 1px solid #fff;
  background: radial-gradient(circle, #fff, var(--ode25d-fx-color, #f4bd58) 48%, transparent 72%);
  box-shadow: 0 0 12px var(--ode25d-fx-color, #f4bd58);
}

#battlePanel[data-ode25d="1"] .ode25d-impact-ring,
#battlePanel[data-ode25d="1"] .ode25d-heal-ring,
#battlePanel[data-ode25d="1"] .ode25d-shield-ring,
#battlePanel[data-ode25d="1"] .ode25d-death-ring {
  position: absolute;
  z-index: 4;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid var(--ode25d-fx-color, #f1d08b);
  border-radius: 50%;
  box-shadow: 0 0 16px var(--ode25d-fx-color, #f1d08b), inset 0 0 10px var(--ode25d-fx-color, #f1d08b);
  animation: ode25dImpactRing 520ms ease-out both;
}

#battlePanel[data-ode25d="1"] .ode25d-heal-ring {
  border-color: var(--ode25d-heal);
  box-shadow: 0 0 16px rgba(105, 230, 162, 0.68), inset 0 0 10px rgba(105, 230, 162, 0.42);
  animation-name: ode25dHealRing;
  animation-duration: 720ms;
}

#battlePanel[data-ode25d="1"] .ode25d-shield-ring {
  border-color: var(--ode25d-shield);
  box-shadow: 0 0 18px rgba(112, 207, 255, 0.72), inset 0 0 12px rgba(112, 207, 255, 0.46);
  animation-name: ode25dShieldRing;
}

#battlePanel[data-ode25d="1"] .ode25d-death-ring {
  border-color: #aa63d2;
  box-shadow: 0 0 22px rgba(170, 99, 210, 0.7), inset 0 0 14px rgba(170, 99, 210, 0.46);
  animation-name: ode25dDeathRing;
  animation-duration: 860ms;
}

#battlePanel[data-ode25d="1"] .ode25d-spark {
  position: absolute;
  z-index: 5;
  width: var(--ode25d-spark-size, 4px);
  height: var(--ode25d-spark-size, 4px);
  margin: -2px 0 0 -2px;
  border-radius: 50%;
  background: var(--ode25d-fx-color, #f1d08b);
  box-shadow: 0 0 8px var(--ode25d-fx-color, #f1d08b);
  animation: ode25dSpark 560ms cubic-bezier(0.1, 0.7, 0.2, 1) both;
}

#battlePanel[data-ode25d="1"] .ode25d-rune {
  position: absolute;
  z-index: 3;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border: 1px solid var(--ode25d-fx-color, #f1d08b);
  border-radius: 50%;
  opacity: 0;
  background:
    linear-gradient(90deg, transparent 48%, var(--ode25d-fx-color, #f1d08b) 49% 51%, transparent 52%),
    linear-gradient(0deg, transparent 48%, var(--ode25d-fx-color, #f1d08b) 49% 51%, transparent 52%);
  box-shadow: 0 0 18px color-mix(in srgb, var(--ode25d-fx-color, #f1d08b) 42%, transparent);
  animation: ode25dRune 820ms ease-out both;
}

#battlePanel[data-ode25d="1"] .float-text {
  z-index: 32 !important;
  padding: 2px 5px;
  border-radius: 5px;
  background: rgba(4, 2, 8, 0.48);
  backdrop-filter: blur(2px);
  font-size: clamp(0.69rem, 0.84vw, 0.94rem) !important;
  letter-spacing: 0.02em;
}

#battlePanel[data-ode25d="1"] .float-text.damage {
  color: #ff929c !important;
  text-shadow: 0 2px 5px #000, 0 0 12px rgba(255, 91, 107, 0.62) !important;
}

#battlePanel[data-ode25d="1"] .float-text.heal {
  color: #7cf0ae !important;
  text-shadow: 0 2px 5px #000, 0 0 12px rgba(90, 224, 151, 0.58) !important;
}

#battlePanel[data-ode25d="1"] .float-text-crit {
  color: #ffd67d !important;
  font-size: clamp(0.82rem, 1vw, 1.08rem) !important;
  transform-origin: center;
}

#battlePanel[data-ode25d="1"] .battlefield.ode25d-heavy-impact {
  animation: ode25dCameraImpact 310ms ease-out both;
}

#battlePanel[data-ode25d="1"] .battlefield.ode25d-phase-surge .ode25d-portal {
  animation: ode25dPortalSurge 1.05s ease-out both;
}

#battlePanel[data-ode25d="1"] .battlefield.ode25d-ultimate-focus .battle-background {
  filter: saturate(0.74) contrast(1.08) brightness(0.68) !important;
}

#battlePanel[data-ode25d="1"] .battlefield.ode25d-ultimate-focus .ode25d-vignette {
  background:
    radial-gradient(circle at 50% 46%, transparent 0 22%, rgba(3, 1, 7, 0.42) 60%, rgba(3, 1, 7, 0.76)),
    linear-gradient(90deg, rgba(3, 1, 7, 0.48), transparent 30%, transparent 70%, rgba(3, 1, 7, 0.48));
}

/* La UI permanece por encima del escenario y de los VFX. */
#battlePanel[data-ode25d="1"] .battle-boss-hud,
#battlePanel[data-ode25d="1"] .battle-side-rail,
#battlePanel[data-ode25d="1"] .battle-support-panel,
#battlePanel[data-ode25d="1"] .battle-ult-bar,
#battlePanel[data-ode25d="1"] .center-message,
#battlePanel[data-ode25d="1"] .battle-skill-banner {
  transform: translateZ(0);
}

@keyframes ode25dPortalBreath {
  0%, 100% { opacity: 0.68; filter: brightness(0.9) saturate(0.9); }
  50% { opacity: 0.88; filter: brightness(1.12) saturate(1.08); }
}

@keyframes ode25dPortalSurge {
  0% { transform: translate3d(-50%, -50%, -12px) scale(1); filter: brightness(1); }
  32% { transform: translate3d(-50%, -50%, -12px) scale(1.16); filter: brightness(1.72); }
  100% { transform: translate3d(-50%, -50%, -12px) scale(1); filter: brightness(1); }
}

@keyframes ode25dFogDrift {
  from { transform: translate3d(-2.5%, 0, 0) scaleX(0.96); }
  to { transform: translate3d(2.5%, -5px, 0) scaleX(1.04); }
}

@keyframes ode25dEmbersRise {
  from { background-position: 0 80px, 0 120px, 0 60px, 0 150px, 0 90px, 0 180px; }
  to { background-position: 24px -180px, -16px -140px, 18px -170px, -22px -130px, 13px -160px, -12px -100px; }
}

@keyframes ode25dActorIdle {
  0%, 100% { transform: translate3d(0, 0, var(--ode25d-depth-z, 0px)); }
  50% { transform: translate3d(0, -3px, var(--ode25d-depth-z, 0px)); }
}

@keyframes ode25dRangedAttackAnchor {
  0%, 100% {
    translate: 0 0;
    scale: 1;
    filter: brightness(1);
  }
  42% {
    translate: 0 -2px;
    scale: 1.018;
    filter: brightness(1.16) saturate(1.06);
  }
}

@keyframes ode25dHitDepth {
  0% { transform: translate3d(0, 0, var(--ode25d-depth-z, 0px)); filter: brightness(1); }
  28% { transform: translate3d(var(--ode25d-hit-x, -7px), 2px, calc(var(--ode25d-depth-z, 0px) - 12px)); filter: brightness(1.85) saturate(0.68); }
  100% { transform: translate3d(0, 0, var(--ode25d-depth-z, 0px)); filter: brightness(1); }
}

@keyframes ode25dCastAura {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(-18deg) scale(0.52); }
  38% { opacity: 0.72; }
  100% { opacity: 0; transform: translate(-50%, -50%) rotate(42deg) scale(1.12); }
}

@keyframes ode25dDeathSettle {
  0% { transform: translate3d(0, 0, var(--ode25d-depth-z, 0px)) rotate(0); filter: brightness(1); opacity: 1; }
  50% { filter: brightness(1.45) saturate(0.38); }
  100% { transform: translate3d(0, 9px, calc(var(--ode25d-depth-z, 0px) - 18px)) rotate(-2deg); filter: grayscale(0.75) brightness(0.58); opacity: 0.32; }
}

@keyframes ode25dShieldPulse {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
  36% { opacity: 0.92; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.12); }
}

@keyframes ode25dMeleeLunge {
  0%, 100% {
    transform: translate3d(0, 0, var(--ode25d-depth-z, 0px));
  }
  34% {
    transform: translate3d(
      var(--ode25d-melee-x, 18px),
      var(--ode25d-melee-y, 0px),
      calc(var(--ode25d-depth-z, 0px) + 14px)
    ) scale(1.035);
    filter: brightness(1.28) saturate(1.08);
  }
  64% {
    transform: translate3d(
      var(--ode25d-melee-x-return, 6px),
      var(--ode25d-melee-y-return, 0px),
      calc(var(--ode25d-depth-z, 0px) + 4px)
    );
  }
}

@keyframes ode25dMeleeSlash {
  0% { opacity: 0; transform: rotate(var(--ode25d-slash-angle, 0rad)) scale(0.4); }
  24% { opacity: 1; }
  100% { opacity: 0; transform: rotate(calc(var(--ode25d-slash-angle, 0rad) + 34deg)) scale(1.45); }
}

@keyframes ode25dMagicSigil {
  0% { opacity: 0; transform: scale(0.42) rotate(-34deg); }
  34% { opacity: 0.92; }
  100% { opacity: 0; transform: scale(1.65) rotate(52deg); }
}

@keyframes ode25dMagicArc {
  0% {
    opacity: 0;
    clip-path: inset(0 100% 0 0);
    filter: brightness(1.55) drop-shadow(0 0 5px var(--ode25d-fx-color));
  }
  20% { opacity: 1; }
  72% {
    opacity: 1;
    clip-path: inset(0 0 0 0);
  }
  100% {
    opacity: 0;
    clip-path: inset(0 0 0 88%);
    filter: brightness(0.95) drop-shadow(0 0 10px var(--ode25d-fx-color));
  }
}

@keyframes ode25dProjectile {
  0% { opacity: 0; clip-path: inset(0 100% 0 0); filter: brightness(1.6) drop-shadow(0 0 5px var(--ode25d-fx-color)); }
  18% { opacity: 1; }
  68% { opacity: 1; clip-path: inset(0 0 0 0); }
  100% { opacity: 0; clip-path: inset(0 0 0 82%); filter: brightness(0.9) drop-shadow(0 0 9px var(--ode25d-fx-color)); }
}

@keyframes ode25dImpactRing {
  0% { opacity: 0; transform: scale(0.34); }
  28% { opacity: 1; }
  100% { opacity: 0; transform: scale(3.4); }
}

@keyframes ode25dHealRing {
  0% { opacity: 0; transform: translateY(14px) scale(0.55) rotateX(68deg); }
  28% { opacity: 0.92; }
  100% { opacity: 0; transform: translateY(-28px) scale(3.6) rotateX(68deg); }
}

@keyframes ode25dShieldRing {
  0% { opacity: 0; transform: scale(0.68); }
  40% { opacity: 0.9; }
  100% { opacity: 0; transform: scale(3); }
}

@keyframes ode25dDeathRing {
  0% { opacity: 0; transform: scale(0.4) rotate(0); }
  34% { opacity: 1; }
  100% { opacity: 0; transform: scale(4.6) rotate(58deg); }
}

@keyframes ode25dSpark {
  0% { opacity: 0; transform: translate3d(0, 0, 0) scale(0.4); }
  22% { opacity: 1; }
  100% { opacity: 0; transform: translate3d(var(--ode25d-dx, 0), var(--ode25d-dy, -34px), 0) scale(0.1); }
}

@keyframes ode25dRune {
  0% { opacity: 0; transform: scale(0.42) rotate(-20deg); }
  35% { opacity: 0.72; }
  100% { opacity: 0; transform: scale(2.45) rotate(42deg); }
}

@keyframes ode25dScreenFlash {
  0% { opacity: 0; }
  22% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes ode25dCameraImpact {
  0%, 100% { transform: translate3d(0, 0, 0); }
  24% { transform: translate3d(-3px, 2px, 0); }
  48% { transform: translate3d(3px, -1px, 0); }
  72% { transform: translate3d(-1px, 1px, 0); }
}

/* Calidad reducida: conserva legibilidad y escala, reduce coste visual. */
#battlePanel[data-ode25d-quality="reduced"] .ode25d-embers,
#battlePanel[data-ode25d-quality="reduced"] .ode25d-fog--far {
  display: none;
}

#battlePanel[data-ode25d-quality="reduced"] .ode25d-portal,
#battlePanel[data-ode25d-quality="reduced"] .battle-unit .unit-visual {
  animation: none;
}

@media (max-width: 980px) {
  html body #battlePanel[data-ode25d="1"] {
    --ode25d-base-art: clamp(78px, 10.7vw, 108px);
    --ode25d-miniboss-art: clamp(101.4px, 13.91vw, 140.4px);
    --ode25d-boss-art: clamp(117px, 16.05vw, 162px);
    --ode25d-base-card: clamp(102px, 13vw, 126px);
    --ode25d-miniboss-card: clamp(132.6px, 16.9vw, 163.8px);
    --ode25d-boss-card: clamp(153px, 19.5vw, 189px);
  }

  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-afk-polish="1"] .ally-line,
  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-afk-polish="1"] .battlefield:not(.boss-battle) .enemy-line {
    min-height: 310px !important;
    grid-template-rows: repeat(3, minmax(102px, 1fr)) !important;
  }

  #battlePanel[data-ode25d="1"] .ode25d-engine-badge {
    display: none;
  }
}

@media (orientation: landscape) and (max-height: 650px) {
  html body #battlePanel[data-ode25d="1"] {
    --ode25d-base-art: clamp(72px, 8.5vw, 98px);
    --ode25d-miniboss-art: clamp(93.6px, 11.05vw, 127.4px);
    --ode25d-boss-art: clamp(108px, 12.75vw, 147px);
    --ode25d-base-card: clamp(94px, 10.6vw, 116px);
    --ode25d-miniboss-card: clamp(122.2px, 13.78vw, 150.8px);
    --ode25d-boss-card: clamp(141px, 15.9vw, 174px);
  }

  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-afk-polish="1"] .ally-line,
  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-afk-polish="1"] .battlefield:not(.boss-battle) .enemy-line {
    bottom: 88px !important;
    height: calc(100% - 108px) !important;
    min-height: 270px !important;
    grid-template-rows: repeat(3, minmax(88px, 1fr)) !important;
  }

  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-afk-polish="1"] .battlefield {
    min-height: 500px !important;
  }
}

@media (max-width: 760px) and (orientation: portrait) {
  html body #battlePanel[data-ode25d="1"] {
    --ode25d-base-art: clamp(72px, 20vw, 96px);
    --ode25d-miniboss-art: clamp(93.6px, 26vw, 124.8px);
    --ode25d-boss-art: clamp(108px, 30vw, 144px);
    --ode25d-base-card: clamp(94px, 25vw, 118px);
    --ode25d-miniboss-card: clamp(122.2px, 32.5vw, 153.4px);
    --ode25d-boss-card: clamp(141px, 37.5vw, 177px);
  }

  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-ode25d-formation="compact-2-2-1"][data-afk-polish="1"] .ally-line,
  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-ode25d-formation="compact-2-2-1"][data-afk-polish="1"] .battlefield:not(.boss-battle) .enemy-line {
    bottom: 206px !important;
    height: 460px !important;
    min-height: 460px !important;
    max-height: 460px !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-template-rows: repeat(3, minmax(148px, 1fr)) !important;
    column-gap: 4px !important;
  }

  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-ode25d-formation="compact-2-2-1"][data-afk-polish="1"] .ally-line {
    left: 0.5% !important;
    width: 48.5% !important;
  }

  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-ode25d-formation="compact-2-2-1"][data-afk-polish="1"] .battlefield:not(.boss-battle) .enemy-line {
    right: 0.5% !important;
    width: 48.5% !important;
  }

  #battlePanel[data-ode25d="1"] .ode25d-world::before {
    bottom: 190px;
  }

  /* En vertical, el encuentro con jefe usa una secuencia legible:
     HUD/controles, refuerzos, jefe, formación y banda de definitivas. */
  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-afk-polish="1"] .battlefield.boss-battle {
    min-height: 1390px !important;
    height: auto !important;
    max-height: none !important;
    overflow: hidden !important;
  }

  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-afk-polish="1"] .battlefield.boss-battle:has(.enemy-support-zone--no-summons) {
    min-height: 1230px !important;
  }

  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-afk-polish="1"] .battle-boss-hud {
    left: 8px !important;
    right: 8px !important;
    top: 8px !important;
    width: auto !important;
    max-width: none !important;
  }

  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-afk-polish="1"] .battle-side-rail {
    left: 8px !important;
    right: 8px !important;
    top: 96px !important;
    width: auto !important;
    max-width: none !important;
  }

  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-afk-polish="1"] .battle-side-rail .battle-controls {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 4px !important;
  }

  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-afk-polish="1"] .battle-side-rail .timer,
  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-afk-polish="1"] .battle-side-rail .btn.small {
    width: auto !important;
    min-width: 0 !important;
    min-height: 34px !important;
    padding: 0 4px !important;
    font-size: 0.48rem !important;
  }

  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-afk-polish="1"] .boss-battle .enemy-line {
    position: absolute !important;
    z-index: 8 !important;
    left: 0 !important;
    right: 0 !important;
    top: 205px !important;
    bottom: auto !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    display: flex !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 8px !important;
  }

  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-afk-polish="1"] .boss-battle .enemy-support-zone,
  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-afk-polish="1"] .boss-battle .enemy-support-zone--full,
  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-afk-polish="1"] .boss-battle .enemy-support-zone--no-summons {
    position: relative !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 8px !important;
    overflow: visible !important;
  }

  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-afk-polish="1"] .boss-battle .enemy-regular-row,
  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-afk-polish="1"] .boss-battle .enemy-summon-row,
  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-afk-polish="1"] .boss-battle .enemy-support-zone--no-summons .enemy-regular-row {
    position: relative !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    bottom: auto !important;
    width: min(320px, calc(100% - 20px)) !important;
    min-height: 160px !important;
    display: grid !important;
    grid-template-columns: repeat(3, minmax(88px, 100px)) !important;
    grid-template-rows: 160px !important;
    justify-content: space-between !important;
    justify-items: center !important;
    align-items: end !important;
    gap: 0 6px !important;
    overflow: visible !important;
  }

  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-afk-polish="1"] .boss-battle .enemy-boss-slot {
    position: relative !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 170px !important;
    min-height: 170px !important;
    display: flex !important;
    align-items: flex-end !important;
    justify-content: center !important;
    overflow: visible !important;
  }

  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-afk-polish="1"] .boss-battle .enemy-boss-slot .battle-unit.boss-unit {
    align-self: flex-end !important;
    justify-self: center !important;
  }

  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-ode25d-formation="compact-2-2-1"][data-afk-polish="1"] .boss-battle .ally-line {
    position: absolute !important;
    left: 0 !important;
    right: 0 !important;
    top: 720px !important;
    bottom: auto !important;
    width: 100% !important;
    height: 460px !important;
    min-height: 460px !important;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-template-rows: repeat(3, 150px) !important;
    column-gap: 6px !important;
    row-gap: 5px !important;
    align-content: start !important;
    justify-items: center !important;
  }

  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-ode25d-formation="compact-2-2-1"][data-afk-polish="1"] .battlefield.boss-battle:has(.enemy-support-zone--no-summons) .ally-line {
    top: 550px !important;
  }

  /* En retrato se repliega a dos columnas para conservar el tamaño de arte. */
  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-ode25d-formation="compact-2-2-1"][data-afk-polish="1"] .ally-line .battle-unit[data-formation-pos="0"] {
    grid-column: 2 !important;
    grid-row: 1 !important;
  }

  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-ode25d-formation="compact-2-2-1"][data-afk-polish="1"] .ally-line .battle-unit[data-formation-pos="1"] {
    grid-column: 2 !important;
    grid-row: 3 !important;
  }

  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-ode25d-formation="compact-2-2-1"][data-afk-polish="1"] .ally-line .battle-unit[data-formation-pos="2"] {
    grid-column: 1 !important;
    grid-row: 1 !important;
  }

  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-ode25d-formation="compact-2-2-1"][data-afk-polish="1"] .ally-line .battle-unit[data-formation-pos="3"] {
    grid-column: 1 !important;
    grid-row: 2 !important;
  }

  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-ode25d-formation="compact-2-2-1"][data-afk-polish="1"] .ally-line .battle-unit[data-formation-pos="4"] {
    grid-column: 1 !important;
    grid-row: 3 !important;
  }

  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-ode25d-formation="compact-2-2-1"][data-afk-polish="1"] .battlefield:not(.boss-battle) .enemy-line .battle-unit[data-formation-pos="0"] {
    grid-column: 1 !important;
    grid-row: 1 !important;
  }

  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-ode25d-formation="compact-2-2-1"][data-afk-polish="1"] .battlefield:not(.boss-battle) .enemy-line .battle-unit[data-formation-pos="1"] {
    grid-column: 1 !important;
    grid-row: 3 !important;
  }

  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-ode25d-formation="compact-2-2-1"][data-afk-polish="1"] .battlefield:not(.boss-battle) .enemy-line .battle-unit[data-formation-pos="2"] {
    grid-column: 2 !important;
    grid-row: 1 !important;
  }

  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-ode25d-formation="compact-2-2-1"][data-afk-polish="1"] .battlefield:not(.boss-battle) .enemy-line .battle-unit[data-formation-pos="3"] {
    grid-column: 2 !important;
    grid-row: 2 !important;
  }

  html body #battlePanel[data-ode25d="1"][data-ode25d="1"][data-ode25d="1"][data-ode25d-formation="compact-2-2-1"][data-afk-polish="1"] .battlefield:not(.boss-battle) .enemy-line .battle-unit[data-formation-pos="4"] {
    grid-column: 2 !important;
    grid-row: 3 !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  #battlePanel[data-ode25d="1"] .ode25d-portal,
  #battlePanel[data-ode25d="1"] .ode25d-fog,
  #battlePanel[data-ode25d="1"] .ode25d-embers,
  #battlePanel[data-ode25d="1"] .battle-unit .unit-visual {
    animation: none !important;
  }

  #battlePanel[data-ode25d="1"] .battle-background {
    transition: none !important;
  }

  #battlePanel[data-ode25d="1"] .ode25d-melee-slash,
  #battlePanel[data-ode25d="1"] .ode25d-magic-sigil,
  #battlePanel[data-ode25d="1"] .ode25d-magic-arc,
  #battlePanel[data-ode25d="1"] .ode25d-projectile {
    display: none !important;
  }
}

/*
 * COMBAT-2.5D-A35-A1.3 — BATTLEFIELD ENVIRONMENT POLISH
 * Los 15 backdrops existentes son la autoridad visual. Estas reglas solo
 * aportan transición/haze y conservan el fallback 2D sin alterar gameplay.
 */
html body #battlePanel[data-ode25d="1"][data-ode25d-environment] {
  --ode25d-env-backdrop-scale: 1.02;
  --ode25d-env-backdrop-brightness: 0.95;
  --ode25d-env-backdrop-contrast: 1.03;
  --ode25d-env-backdrop-saturation: 0.98;
  --ode25d-env-horizon-y: 46%;
  --ode25d-env-haze-rgb: 64, 39, 76;
  --ode25d-env-far-haze-opacity: 0.18;
  --ode25d-env-near-haze-opacity: 0.10;
  --ode25d-env-particle-opacity: 0.16;
  --ode25d-env-ground-join-y: 55%;
  --ode25d-env-ground-blend-opacity: 0.21;
}

#battlePanel[data-ode25d="1"][data-ode25d-environment] .battle-background {
  transform:
    translate3d(
      var(--ode25d-bg-x),
      var(--ode25d-bg-y),
      -24px
    )
    scale(var(--ode25d-env-backdrop-scale)) !important;
  filter:
    saturate(var(--ode25d-env-backdrop-saturation))
    contrast(var(--ode25d-env-backdrop-contrast))
    brightness(var(--ode25d-env-backdrop-brightness)) !important;
  background-size: cover !important;
  background-repeat: no-repeat !important;
  transform-origin: center center !important;
}

/* Sustituye la cuadrícula genérica por una unión atmosférica sin líneas. */
#battlePanel[data-ode25d="1"][data-ode25d-environment] .ode25d-world::before {
  left: -5%;
  right: -5%;
  top: var(--ode25d-env-ground-join-y);
  bottom: -4%;
  height: auto;
  transform: none;
  border: 0;
  background:
    linear-gradient(
      180deg,
      rgba(var(--ode25d-env-haze-rgb), 0) 0%,
      rgba(var(--ode25d-env-haze-rgb), 0.065) 18%,
      rgba(6, 4, 8, 0.15) 52%,
      rgba(4, 3, 6, 0.31) 100%
    ),
    radial-gradient(
      ellipse at 50% 20%,
      rgba(var(--ode25d-env-haze-rgb), 0.08),
      transparent 68%
    );
  opacity: 1;
  mask-image: none;
}



/* R7: battle-plane join. Screen-space only, below WebGL actors. It makes the
 * painted floor and the projected y=0 plane read as one continuous surface. */
#battlePanel[data-ode25d="1"][data-ode25d-environment] .ode25d-world::after {
  content: "";
  position: absolute;
  z-index: 1;
  left: 2%;
  right: 2%;
  top: calc(var(--ode25d-env-ground-join-y) - 2%);
  bottom: -6%;
  pointer-events: none;
  opacity: var(--ode25d-env-ground-blend-opacity);
  background:
    radial-gradient(
      ellipse at 50% 4%,
      rgba(var(--ode25d-env-haze-rgb), 0.22) 0%,
      rgba(8, 5, 10, 0.16) 38%,
      rgba(3, 2, 5, 0.38) 78%,
      rgba(2, 1, 4, 0.52) 100%
    );
  filter: blur(4px);
}

#battlePanel[data-ode25d="1"][data-ode25d-environment] .ode25d-fog--far {
  top: calc(var(--ode25d-env-ground-join-y) - 10%);
  opacity: var(--ode25d-env-far-haze-opacity);
  background:
    radial-gradient(ellipse at 22% 50%, rgba(var(--ode25d-env-haze-rgb), 0.36), transparent 42%),
    radial-gradient(ellipse at 74% 50%, rgba(var(--ode25d-env-haze-rgb), 0.30), transparent 46%);
  filter: blur(18px);
}

#battlePanel[data-ode25d="1"][data-ode25d-environment] .ode25d-fog--near {
  bottom: 4%;
  opacity: var(--ode25d-env-near-haze-opacity);
  background:
    radial-gradient(ellipse at 28% 50%, rgba(var(--ode25d-env-haze-rgb), 0.28), transparent 46%),
    radial-gradient(ellipse at 72% 50%, rgba(var(--ode25d-env-haze-rgb), 0.24), transparent 48%);
  filter: blur(22px);
}

#battlePanel[data-ode25d="1"][data-ode25d-environment] .ode25d-embers {
  opacity: var(--ode25d-env-particle-opacity);
}

#battlePanel[data-ode25d="1"][data-ode25d-environment] .ode25d-vignette {
  background:
    linear-gradient(90deg, rgba(4, 2, 8, 0.28), transparent 12%, transparent 88%, rgba(4, 2, 8, 0.28)),
    linear-gradient(180deg, rgba(4, 2, 8, 0.12), transparent 30%, transparent 74%, rgba(4, 2, 8, 0.32));
  box-shadow: inset 0 0 66px rgba(0, 0, 0, 0.32);
}
