/* Savaş alanı (deneme) — kahraman savaşçı + yaratık sahnesi. Kapatınca eski HUD kartları. */
.dzb.has-bf .dzb-battle-col { flex: 0 0 auto; padding-top: 0; gap: 8px; }
.dzb.has-bf.bf-off .dzb-battle-col { flex: 1 1 auto; gap: 12px; padding-top: 8px; }

.bf {
  position: relative;
  z-index: 4;
  flex: 1 1 0;
  min-height: 168px;
  width: 100%;
  margin: 0 auto;
  pointer-events: none;
}
.dzb.bf-off .bf { display: none; }

.bf-fig { position: absolute; bottom: 2%; }
.bf-fig.is-hero { left: 1%; height: 62%; max-height: 210px; aspect-ratio: 240 / 300; }
.bf-fig.is-foe { right: 3%; width: 50%; height: 68%; max-height: 230px; }
.bf-fig.is-foe.is-boss { width: 56%; height: 82%; max-height: 270px; right: 3%; }

.bf-shadow {
  position: absolute;
  left: 4%; right: 4%; bottom: -2%;
  height: 9%;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 50%, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0) 70%);
}
.bf-fig.is-hero .bf-shadow { left: 12%; right: 0; }

.bf-body, .bf-hit, .bf-idle { position: absolute; inset: 0; transform-origin: 50% 96%; }
.bf-idle img, .bf-svg {
  display: block;
  width: 100%;
  height: 100%;
}
.bf-idle img {
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.55));
  -webkit-user-drag: none;
}
.bf-svg { overflow: visible; filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.5)); }

/* rölanti: yalnız uniform hareket (şekil bozulmaz) */
@keyframes bfFoeIdle {
  0%, 100% { transform: translateY(0) scale(1) rotate(0); }
  50% { transform: translateY(-4px) scale(1.012) rotate(0.5deg); }
}
.bf-fig.is-foe .bf-idle { animation: bfFoeIdle 2.4s ease-in-out infinite; transform-origin: 50% 100%; }
.bf-fig.is-foe.is-boss .bf-idle { animation-duration: 3.1s; }

@keyframes bfBreath { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2.4px); } }
@keyframes bfSway { 0% { transform: rotate(-2.2deg); } 100% { transform: rotate(3deg); } }
@keyframes bfPlume { 0% { transform: rotate(-3deg); } 100% { transform: rotate(4deg); } }
@keyframes bfEye { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
.bf-breath { animation: bfBreath 2s ease-in-out infinite; }
.bf-sway { animation: bfSway 2.6s ease-in-out infinite alternate; }
.bf-plume { animation: bfPlume 1.7s ease-in-out infinite alternate; }
.bf-eye { animation: bfEye 2.4s ease-in-out infinite; }

/* Sahne aç / kapa */
.bf-switch {
  position: absolute;
  right: 10px;
  top: calc(12px + env(safe-area-inset-top, 0px));
  z-index: 12;
  min-width: 52px;
  height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(8, 14, 26, 0.72);
  color: rgba(232, 238, 248, 0.78);
  font: 800 11px/1 var(--font, system-ui);
  letter-spacing: 0.04em;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}
.bf-switch.is-on {
  color: #1b1405;
  background: linear-gradient(180deg, #ffe08a, #f0b93a);
  border-color: rgba(255, 236, 170, 0.9);
}
.dzb.is-result .bf-switch { display: none; }

/* İsim plakaları — sahne açıkken alanın üstünde yan yana: solda kahraman, sağda yaratık (kendi tarafı).
   Sahne kapalıyken eski yerleşim. */
.dzb.has-bf:not(.bf-off) .dzb-hcard {
  position: absolute;
  z-index: 7;
  top: calc(136px + env(safe-area-inset-top, 0px));
  width: calc(50% - 14px);
  max-width: 230px;
  margin: 0;
  display: block;
  padding: 6px 9px 6px;
  border-radius: 10px;
  pointer-events: none;
}
.dzb.has-bf:not(.bf-off) .dzb-hcard.is-hero { left: 10px; right: auto; border-left: 3px solid #5fa8ff; }
.dzb.has-bf:not(.bf-off) .dzb-hcard.is-enemy { right: 10px; left: auto; border-left: 0; border-right: 3px solid #ff6a58; }
.dzb.has-bf:not(.bf-off) .dzb-hcard-av { display: none; }
/* Skill vuruşu sahadaki figürde (hitFx). İsim plakasında eski kart efekti açılmasın. */
.dzb.has-bf:not(.bf-off) .dzb-hcard > .dzb-fx { display: none; }
/* Boss vuruşu kolonu değil sahneyi sarsın; plakalar yerinde kalsın */
.dzb.has-bf:not(.bf-off).is-boss-slam .dzb-battle-col,
.dzb.has-bf:not(.bf-off).is-boss-slam-ult .dzb-battle-col { animation: none; }
.dzb.has-bf:not(.bf-off).is-boss-slam .bf { animation: dzbBossSlam 0.5s ease-out; }
.dzb.has-bf:not(.bf-off).is-boss-slam-ult .bf { animation: dzbBossSlamUlt 0.8s ease-out; }
.dzb.has-bf:not(.bf-off) .dzb-hcard-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto auto;
  gap: 3px 6px;
  align-items: center;
}
.dzb.has-bf:not(.bf-off) .dzb-hcard-top {
  grid-column: 1 / -1;
  grid-row: 1;
  min-height: 0;
  min-width: 0;
  align-items: center;
}
.dzb.has-bf:not(.bf-off) .dzb-hcard-id {
  flex-direction: row;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}
.dzb.has-bf:not(.bf-off) .dzb-hcard-id strong {
  font-size: 13px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dzb.has-bf:not(.bf-off) .dzb-hcard-id em { font-size: 10px; flex: none; }
.dzb.has-bf:not(.bf-off) .dzb-hcard-bar { display: contents; }
.dzb.has-bf:not(.bf-off) .dzb-hcard .dzb-hp-track { grid-column: 1 / -1; grid-row: 2; height: 7px; }
.dzb.has-bf:not(.bf-off) .dzb-hcard-hp {
  grid-column: 1;
  grid-row: 3;
  font-size: 10px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}
.dzb.has-bf:not(.bf-off) .dzb-hcard-stats {
  grid-column: 2;
  grid-row: 3;
  flex-wrap: nowrap;
  gap: 0;
}
.dzb.has-bf:not(.bf-off) .dzb-hstat.is-hp,
.dzb.has-bf:not(.bf-off) .dzb-hstat.is-def { display: none; }
.dzb.has-bf:not(.bf-off) .dzb-hstat { font-size: 10px; gap: 2px; }
.dzb.has-bf:not(.bf-off) .dzb-hstat svg { width: 11px; height: 11px; }

/* 3D şövalye — canvas figür kutusundan taşar (kılıç/kol alanı) */
.bf-gl {
  position: absolute;
  left: -50%;
  bottom: -19%;
  width: 200%;
  height: 166%;
  display: block;
  pointer-events: none;
}
.bf-fig.is-hero .bf-svg { filter: none; }

/* Yaratık ışığı: blur filtresi yerine ucuz radial katman */
.bf-aura {
  position: absolute;
  left: -14%; right: -14%; top: -8%; bottom: -4%;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  will-change: opacity, transform;
}

/* Zemin teması: figürlerin ayağına yumuşak temas gölgesi */
.bf-shadow { filter: none; }
.bf-fig.is-foe .bf-idle img { filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.5)) saturate(1.04) contrast(1.03); }

/* Savaş günlüğü — koyu cam, HUD şeritleriyle aynı dil */
.dzb.has-bf:not(.bf-off) .dzb-log {
  min-height: 38px;
  padding: 7px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-left: 3px solid #f0b93a;
  border-radius: 10px;
  background: linear-gradient(90deg, rgba(10, 18, 32, 0.82), rgba(10, 18, 32, 0.6));
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  color: #f3efe4;
  font-size: 13px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
.dzb.has-bf:not(.bf-off) .dzb-log.is-hero-act { border-left-color: #5fa8ff; background: linear-gradient(90deg, rgba(18, 36, 66, 0.88), rgba(10, 18, 32, 0.6)); }
.dzb.has-bf:not(.bf-off) .dzb-log.is-enemy-act { border-left-color: #ff6a58; background: linear-gradient(90deg, rgba(64, 22, 20, 0.88), rgba(10, 18, 32, 0.6)); }
.dzb.has-bf:not(.bf-off) .dzb-log.is-skill-act .dzb-log-txt { color: #ffe6a0; }
.dzb.has-bf:not(.bf-off) .dzb-log-who { font-size: 10px; padding: 2px 7px; border-radius: 6px; }
.dzb.has-bf:not(.bf-off) .dzb-battle-col { gap: 8px; }

/* Hasar sayısı — karakterin / yaratığın üstünde yüzer (kartta değil) */
.bf-fig .dzb-dmg { top: 2%; }
.bf-fig.is-foe .dzb-dmg { top: 10%; }
.bf-fig.is-foe.is-boss .dzb-dmg { top: 6%; }

/* Knight 3 (sprite atlası) — çerçeve 860:745, ayak çizgisi karenin %79.5'inde */
.bf-fig.is-hero.is-spr {
  width: min(70%, 290px);
  height: auto;
  max-height: none;
  aspect-ratio: 860 / 745;
  left: calc(-0.27 * min(70%, 290px) + 12px);
  transform: translateY(20.5%);
}
.bf-fig.is-spr .bf-body, .bf-fig.is-spr .bf-hit, .bf-fig.is-spr .bf-idle { transform-origin: 49% 80%; }
.bf-fig.is-spr .bf-shadow { left: 30%; right: 26%; bottom: 17.5%; height: 6%; }
.bf-fig.is-spr .bf-aura { left: 24%; right: 6%; top: 20%; bottom: 14%; }
.bf-aim { position: absolute; left: 30%; width: 56%; top: 28%; height: 50%; pointer-events: none; visibility: hidden; }
.bf-spr { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.bf-spr .bf-spr-img {
  position: absolute;
  left: 0; top: 0;
  width: 1000%; height: 500%;
  max-width: none; max-height: none;
  object-fit: fill;
  filter: none;
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
}
.bf-fig.is-spr .dzb-dmg { top: 16%; left: 56%; }

/* Slash efekt sprite'ları (vuruş anı) */
.bf-fxl { position: absolute; inset: 0; z-index: 6; pointer-events: none; }
.bf-fx { position: absolute; overflow: hidden; pointer-events: none; }
.bf-fx[hidden] { display: none; }
.bf-fx img { position: absolute; left: 0; top: 0; width: 1000%; height: 1000%; max-width: none; will-change: transform; -webkit-user-drag: none; }

/* Yaratık iskeleti: canvas figür kutusunun %25 taşar; hazır olunca düz PNG gizlenir */
.bf-rig {
  position: absolute;
  left: -25%; top: -25%;
  width: 150%; height: 150%;
  display: none;
  pointer-events: none;
}
.bf-fig.is-rig .bf-rig { display: block; }
.bf-fig.is-rig .bf-idle img { visibility: hidden; }

/* Yaratık sprite atlası (10×4): kutu = tüm animasyon karelerinin birleşimi; rölanti ayağı kutu tabanına, ortası figür ortasına hizalı.
   Yaratıklar sağa bakar → scaleX(-1) ile kahramana döner (ixf zaten aynalı). */
.bf-fig.is-foe { container-type: size; }
.bf-fig.is-fspr .bf-idle { animation: none; }
.bf-fspr {
  /* Taşma yok: ölçek ne olursa olsun rölanti boyu kutudan (yükseklik ≤ %106, genişlik ≤ %100) büyük olamaz */
  --h: min(calc(100cqh * var(--dm, 1)), 106cqh, calc(92cqw / var(--iwr)));
  --bh: calc(var(--h) * var(--k));
  position: absolute;
  height: var(--bh);
  width: calc(var(--bh) * var(--ar));
  left: calc(50% - var(--bh) * var(--ar) * var(--ixf));
  bottom: calc(var(--bh) * var(--bf) * -1);
  overflow: hidden;
  transform: scaleX(-1);
  pointer-events: none;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.5));
}
.bf-fig.is-foe .bf-fspr .bf-spr-img {
  position: absolute; left: 0; top: 0;
  width: 500%; height: 800%;
  max-width: none; max-height: none;
  object-fit: fill;
  filter: none;
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
}
.bf-fig.is-fspr .dzb-dmg { top: 4%; }
