/* ================================================================ Finale „Der Endgegner“ (Gaming, fin-boss-host.js / fin-boss-play.js)
   Bühne: links Frage + Antwortkacheln, rechts die Boss-Arena. Alles bemisst sich an der freien Bühne (--vq, Container-Einheiten
   der Arena-Mitte), nie am Fenster. Pixel-Optik: steps()-Animationen, harte Kanten, Pixel-Schrift (--font-pixel). */

/* ------------------------------------------------------------ Aufteilung */
.boss-wrap { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); gap: clamp(0.7rem, 1.4vw, 1.6rem); }
.boss-q { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: clamp(0.5rem, calc(var(--vq) * 1.6), 1.2rem); }
.boss-q .qcard { flex: none; font-size: clamp(1.15rem, calc(var(--vq) * 3.6), 2.8rem); padding: clamp(0.6rem, calc(var(--vq) * 2), 1.4rem) clamp(0.8rem, 1.6vw, 1.8rem); }
.boss-q.readying { justify-content: center; }
.boss-q.readying .qcard { font-size: clamp(1.5rem, calc(var(--vq) * 5), 3.8rem); }
.boss-q .opts { max-height: none; gap: clamp(0.4rem, calc(var(--vq) * 1.3), 1rem); }
.boss-q .opt { font-size: clamp(0.95rem, calc(var(--vq) * 2.8), 2.2rem); padding: 0.4rem 0.9rem; gap: 0.6rem; }
.boss-q .factcard { flex: none; font-size: clamp(0.8rem, calc(var(--vq) * 1.9), 1.3rem); padding: 0.4rem 0.8rem; }
.boss-q .ready-splash-bar { flex: none; }
.boss-wrap.rage .boss-q .qcard { box-shadow: 0 0 0 3px #ff2e5b, 0 0 26px rgba(255, 46, 91, 0.55), var(--shadow); }
/* Hochkant-Bildschirme: Arena unter die Frage */
@media (max-aspect-ratio: 5/4) {
  .boss-wrap { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1.15fr) minmax(0, 1fr); }
}

/* ------------------------------------------------------------ Arena */
.boss-arena {
  --glow: #a855f7;
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(0.25rem, calc(var(--vq) * 0.9), 0.7rem);
  padding: clamp(0.4rem, calc(var(--vq) * 1.3), 0.9rem);
  border: 3px solid #000;
  border-radius: 14px;
  background:
    radial-gradient(ellipse 60% 45% at 50% 46%, color-mix(in srgb, var(--glow) 30%, transparent), transparent 70%),
    linear-gradient(180deg, #130833 0%, #0b0522 62%, #1b0d3f 62.5%, #08041a 100%);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.12), var(--shadow);
  overflow: hidden;
  isolation: isolate;
}
/* Boden: Pixel-Gitter */
.boss-arena::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 62.5%;
  bottom: 0;
  z-index: -1;
  background-image: linear-gradient(rgba(34, 211, 238, 0.22) 2px, transparent 2px), linear-gradient(90deg, rgba(255, 46, 136, 0.18) 2px, transparent 2px);
  background-size: 28px 18px;
  -webkit-mask-image: linear-gradient(transparent, #000 40%);
  mask-image: linear-gradient(transparent, #000 40%);
}
.boss-arena.rage { background: radial-gradient(ellipse 65% 50% at 50% 46%, rgba(255, 30, 60, 0.42), transparent 72%), linear-gradient(180deg, #2a0616 0%, #170310 62%, #2d0a1c 62.5%, #12030b 100%); animation: bossRagePulse 1.1s steps(2) infinite; }
.boss-arena.ouch::after { content: ''; position: absolute; inset: 0; z-index: 4; background: rgba(255, 20, 50, 0.4); pointer-events: none; animation: bossOuch 0.55s steps(3) both; }

/* HP-Leiste */
.ba-bar { flex: none; display: flex; flex-direction: column; gap: 0.25rem; }
.ba-title { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; font-family: var(--font-pixel, monospace); font-size: clamp(0.62rem, calc(var(--vq) * 1.6), 1.05rem); color: #fff; text-shadow: 2px 2px 0 #000; line-height: 1.2; }
.ba-name { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ba-tag { flex: none; color: #ff3860; animation: bossBlink 1s steps(2) infinite; }
.ba-hp { --hp: 1; position: relative; height: clamp(1.1rem, calc(var(--vq) * 3.2), 2rem); border: 3px solid #000; background: #2a0d1a; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.55); }
.ba-fill, .ba-trail { position: absolute; inset: 0; transform-origin: left center; transform: scaleX(var(--hp)); }
.ba-trail { background: #ffe066; transition: transform 0.6s 0.45s ease-out; }
.ba-fill { background: linear-gradient(#ff8fab, #ff2e5b 45%, #a90f37); transition: transform 0.24s steps(5); }
.ba-hp.instant .ba-fill, .ba-hp.instant .ba-trail { transition: none; }
.ba-hp::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 3px), #000 calc(10% - 3px) 10%); pointer-events: none; }
.ba-hp.low .ba-fill { animation: bossBlink 0.5s steps(2) infinite; }
.ba-mark { position: absolute; left: calc(50% - 2px); top: -6px; bottom: -6px; width: 4px; z-index: 1; background: #fff; box-shadow: 0 0 0 1px #000, 0 0 8px #fff; }
.ba-num { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; font-family: var(--font-pixel, monospace); font-weight: 400; font-size: clamp(0.6rem, calc(var(--vq) * 1.35), 0.85rem); color: #fff; text-shadow: 2px 2px 0 #000, -1px -1px 0 #000; white-space: nowrap; }

/* Boss */
.ba-stage { position: relative; flex: 1; min-height: 2.5rem; container-type: size; display: grid; place-items: center; }
.ba-stage.shake { animation: bossShake 0.45s steps(6); }
.ba-boss { position: relative; width: min(86cqh, 72cqw); aspect-ratio: 1; animation: bossBob 1.3s steps(2) infinite; }
.boss-arena.rage .ba-boss { animation-duration: 0.6s; }
.ba-sprite { position: relative; z-index: 1; width: 100%; height: 100%; filter: drop-shadow(0 0 0.5rem var(--glow)) drop-shadow(0 0 1.6rem color-mix(in srgb, var(--glow) 60%, transparent)); }
.ba-sprite canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; }
.boss-arena.rage .ba-sprite { filter: sepia(1) saturate(6) hue-rotate(-45deg) brightness(0.95) drop-shadow(0 0 0.6rem #ff1e3c) drop-shadow(0 0 1.8rem rgba(255, 30, 60, 0.7)); }
.ba-shadow { position: absolute; left: 22%; right: 22%; bottom: 1%; height: 9%; border-radius: 50%; background: rgba(0, 0, 0, 0.55); }
/* Treffer: weiß aufblitzen und wackeln; Krit stärker */
.ba-boss.hurt .ba-sprite { animation: bossHurt 0.32s steps(4); }
.ba-boss.crit .ba-sprite { animation: bossCrit 0.52s steps(6); }
.ba-boss.lunge .ba-sprite { animation: bossLunge 0.7s steps(7); }
.ba-boss.appear .ba-sprite { animation: bossAppear 1.6s steps(10) both; }
.ba-boss.laugh .ba-sprite { animation: bossLaugh 0.45s steps(2) infinite; }
.ba-boss.dying { animation: none; }
.ba-boss.dying .ba-sprite { animation: bossDying 0.22s steps(2) infinite; }
.ba-boss.dead .ba-sprite, .ba-boss.dead .ba-shadow { visibility: hidden; }
/* Einblendungen (WARNING, Wutphase, K.O., GAME OVER) */
.ba-banner { position: absolute; left: -1rem; right: -1rem; top: 50%; z-index: 3; display: flex; flex-direction: column; align-items: center; gap: 0.2em; padding: 0.5em 0.4em; background: repeating-linear-gradient(-45deg, rgba(0, 0, 0, 0.88) 0 14px, rgba(60, 0, 12, 0.88) 14px 28px); border-block: 4px solid #ff2e5b; font-family: var(--font-pixel, monospace); color: #fff; text-align: center; transform: translateY(-50%) scaleY(0); transition: transform 0.25s steps(4); pointer-events: none; }
.ba-banner.show { transform: translateY(-50%) scaleY(1); }
.ba-banner b { font-weight: 400; font-size: clamp(0.9rem, 9cqw, 2.8rem); line-height: 1.1; color: #ff3860; text-shadow: 3px 3px 0 #000; }
.ba-banner small { font-size: clamp(0.45rem, 3.2cqw, 1rem); line-height: 1.3; opacity: 0.9; }
.ba-banner.warn b, .ba-banner.rage b { animation: bossBlink 0.5s steps(2) infinite; }
.ba-banner.win { border-color: var(--gold); background: rgba(0, 0, 0, 0.82); }
.ba-banner.win b { color: var(--gold); font-size: clamp(1.2rem, 13cqw, 4rem); }

/* Gruppe */
.ba-party { --bps: clamp(1.6rem, calc(var(--vq) * 6.2), 3.4rem); flex: none; max-height: 46%; display: flex; flex-wrap: wrap; justify-content: center; align-content: flex-end; gap: 0.2rem 0.45rem; }
.ba-party[data-n="l"] { --bps: clamp(1.4rem, calc(var(--vq) * 5), 2.7rem); }
.ba-party[data-n="xl"] { --bps: clamp(1.25rem, calc(var(--vq) * 4.1), 2.2rem); gap: 0.1rem 0.3rem; }
.bp { position: relative; display: flex; flex-direction: column; align-items: center; }
.bp-av { position: relative; }
.bp .avatar { --size: var(--bps) !important; transition: filter 0.4s, opacity 0.4s; }
.bp-hearts { display: flex; margin-top: 0.1rem; font-size: max(0.6rem, calc(var(--bps) * 0.3)); line-height: 1; white-space: nowrap; }
.bp-hearts i { font-style: normal; }
.bp-hearts i.lost { opacity: 0.35; filter: grayscale(1); }
.bp-combo { position: absolute; top: -0.25rem; right: -0.55rem; z-index: 1; padding: 0.15em 0.3em; border: 2px solid #000; background: var(--gold); color: #000; font-family: var(--font-pixel, monospace); font-weight: 400; font-size: calc(var(--bps) * 0.24); line-height: 1; transform: scale(0); transition: transform 0.3s var(--ease-back); }
.bp-combo.on { transform: scale(1); }
.bp-ghost { position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(var(--bps) * 0.72); opacity: 0; pointer-events: none; }
.bp.ghost .avatar { filter: grayscale(1) brightness(1.25); opacity: 0.4; }
.bp.ghost .bp-ghost { opacity: 0.95; animation: bossGhost 2.2s ease-in-out infinite; }
.bp.ghost .bp-hearts { opacity: 0.4; }
.bp.armed .bp-av::after { content: '⚔️'; position: absolute; left: -0.45rem; bottom: -0.15rem; font-size: calc(var(--bps) * 0.42); animation: pop 0.3s var(--ease-back) both; }
.bp.atk { animation: bossBpAtk 0.45s steps(3); }
.bp.hurt { animation: bossBpHurt 0.5s steps(4); }

/* Fliegende Schadenszahlen und Schilder */
.ba-fx { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.bfly { position: absolute; display: flex; flex-direction: column; align-items: center; font-family: var(--font-pixel, monospace); color: #fff; line-height: 1.15; white-space: nowrap; text-shadow: 2px 2px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000; }
.bfly b { font-weight: 400; font-size: clamp(0.75rem, calc(var(--vq) * 2.5), 1.6rem); }
.bfly small { font-size: clamp(0.4rem, calc(var(--vq) * 1.2), 0.75rem); color: var(--gold); }
.bfly.crit b { color: var(--gold); font-size: clamp(1rem, calc(var(--vq) * 3.8), 2.5rem); }
.bfly.crit small { color: #ff3860; font-size: clamp(0.5rem, calc(var(--vq) * 1.6), 1rem); }
.bfly.gh b { color: #c4b5fd; font-size: clamp(0.6rem, calc(var(--vq) * 1.8), 1.1rem); }
.btag { position: absolute; transform: translate(-50%, -110%); font-family: var(--font-pixel, monospace); font-size: clamp(0.62rem, calc(var(--vq) * 1.5), 0.95rem); color: #ff6b81; text-shadow: 2px 2px 0 #000; white-space: nowrap; animation: bossTag 1.4s ease-out both; }
.btag.ko { padding: 0.25em 0.4em; border: 2px solid #000; background: #ff1744; color: #fff; text-shadow: none; }

@keyframes bossBob { 0% { transform: translateY(0); } 100% { transform: translateY(-3%); } }
@keyframes bossBlink { 0% { opacity: 1; } 100% { opacity: 0.25; } }
@keyframes bossRagePulse { 0% { box-shadow: inset 0 0 0 2px rgba(255, 46, 91, 0.5), var(--shadow); } 100% { box-shadow: inset 0 0 0 4px rgba(255, 46, 91, 0.9), inset 0 0 40px rgba(255, 30, 60, 0.45), var(--shadow); } }
@keyframes bossOuch { 0% { opacity: 1; } 100% { opacity: 0; } }
@keyframes bossShake { 0%, 100% { transform: none; } 20% { transform: translate(-3%, 1%); } 40% { transform: translate(3%, -1%); } 60% { transform: translate(-2%, -1%); } 80% { transform: translate(2%, 1%); } }
@keyframes bossHurt { 0% { transform: translateX(0); filter: brightness(0) invert(1); } 50% { transform: translateX(4%); filter: brightness(0) invert(1); } 100% { transform: translateX(-2%); } }
@keyframes bossCrit { 0% { transform: scale(1); filter: brightness(0) invert(1); } 30% { transform: scale(0.88) translateX(6%); filter: brightness(0) invert(1); } 60% { transform: scale(1.06) translateX(-5%); filter: brightness(0) invert(0.6) sepia(1) saturate(8); } 100% { transform: none; } }
@keyframes bossLunge { 0% { transform: none; } 40% { transform: translateY(-6%) scale(0.95); } 60% { transform: translateY(14%) scale(1.25); } 100% { transform: none; } }
@keyframes bossAppear { 0% { transform: scale(0.15); filter: brightness(0); opacity: 0; } 60% { transform: scale(1.1); filter: brightness(0); opacity: 1; } 80% { filter: brightness(0) invert(1); } 100% { transform: none; } }
@keyframes bossLaugh { 0% { transform: translateY(0) rotate(-4deg); } 100% { transform: translateY(-6%) rotate(4deg); } }
@keyframes bossDying { 0% { opacity: 1; filter: brightness(0) invert(1); transform: translateX(-2%); } 100% { opacity: 0.3; transform: translateX(2%); } }
@keyframes bossGhost { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-14%); } }
@keyframes bossBpAtk { 0%, 100% { transform: none; } 50% { transform: translateY(-22%) scale(1.08); } }
@keyframes bossBpHurt { 0%, 100% { transform: none; filter: none; } 25% { transform: translateX(-12%); filter: sepia(1) saturate(6) hue-rotate(-50deg); } 75% { transform: translateX(12%); } }
@keyframes bossTag { 0% { opacity: 0; transform: translate(-50%, -60%) scale(0.6); } 20% { opacity: 1; transform: translate(-50%, -120%) scale(1.1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -200%); } }

/* ------------------------------------------------------------ Handy: eigener Stand */
.bossme { align-self: stretch; display: flex; flex-direction: column; gap: 0.35rem; padding: 0.45rem 0.7rem; border: 3px solid #000; border-radius: 12px; background: #120830; color: #fff; box-shadow: var(--shadow-sm); }
.bossme.small { align-self: center; width: 100%; max-width: 24rem; }
.bossme .bm-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; font-weight: 800; font-size: 0.9rem; line-height: 1.2; }
.bossme .bm-boss { flex: none; font-size: 1.3rem; line-height: 1; }
.bossme-hp { position: relative; flex: 1; min-width: 0; height: 1.3rem; border: 2px solid #000; background: #2a0d1a; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.4); }
.bossme-hp i { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(#ff8fab, #ff2e5b 45%, #a90f37); }
.bossme-hp span { position: relative; display: block; font-family: var(--font-pixel, monospace); font-size: 0.7rem; line-height: 1.25rem; text-align: center; text-shadow: 1px 1px 0 #000; white-space: nowrap; }
.bossme .bm-hearts { font-size: 1.05rem; letter-spacing: 0.05em; }
.bossme .bm-hearts i { font-style: normal; opacity: 0.35; filter: grayscale(1); }
.bossme .bm-combo { padding: 0.05rem 0.45rem; border: 2px solid #000; border-radius: 6px; background: var(--gold); color: #000; font-size: 0.8rem; white-space: nowrap; }
.bossme .bm-rage { flex: none; font-family: var(--font-pixel, monospace); font-size: 0.6rem; color: #ff3860; animation: bossBlink 0.6s steps(2) infinite; }
.bossme.rage { border-color: #ff2e5b; box-shadow: 0 0 14px rgba(255, 46, 91, 0.6), var(--shadow-sm); }
.bossme.ghost { background: #2b2440; }
.bossme .bm-end { font-family: var(--font-pixel, monospace); font-size: 0.8rem; text-align: center; }
.bossme .bm-end.win { color: var(--gold); }
.bossme .bm-end.lose { color: #ff3860; }
