/* ═══════════════════════════════════════════════════════════
   Boss Battle — Reusable Game Engine Styles
   /games/boss-battle.css
═══════════════════════════════════════════════════════════ */

.bb-wrap {
  font-family: var(--font-display, 'Outfit', 'DM Sans', sans-serif);
  max-width: 640px;
  margin: 0 auto 32px;
}

/* ── Arena shell ─────────────────────────────── */
.bb-arena {
  background: linear-gradient(160deg, #0c1222 0%, #162032 100%);
  border-radius: 20px;
  padding: 24px 24px 28px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.06);
  position: relative;
  overflow: hidden;
  min-height: 480px;
}

/* Atmospheric glow */
.bb-arena::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 20% 30%, rgba(99,102,241,0.08) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 70%, rgba(239,68,68,0.06) 0%, transparent 60%);
  pointer-events: none;
}

/* ── HUD ─────────────────────────────────────── */
.bb-hud {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 4px;
  position: relative;
  z-index: 2;
}

.bb-hp-block { flex: 1; }

.bb-hp-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 5px;
}

.bb-hp-name {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #64748b;
}

.bb-hp-val {
  font-size: 12px;
  font-weight: 700;
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
}

.bb-hp-track {
  height: 10px;
  background: rgba(255,255,255,0.07);
  border-radius: 5px;
  overflow: hidden;
}

.bb-hp-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.bb-hp-fill.player { background: linear-gradient(90deg, #10b981, #34d399); width: 100%; }
.bb-hp-fill.boss   { background: linear-gradient(90deg, #f97316, #ef4444); width: 100%; }

.bb-vs {
  font-size: 11px;
  font-weight: 900;
  color: #374151;
  letter-spacing: 1px;
  flex-shrink: 0;
}

/* ── Stage ───────────────────────────────────── */
.bb-stage {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 16px 20px 4px;
  position: relative;
  z-index: 2;
}

.bb-char {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.bb-char-emoji {
  font-size: 68px;
  line-height: 1;
  display: block;
}

.bb-player .bb-char-emoji {
  filter: drop-shadow(0 0 12px rgba(16,185,129,0.5));
  animation: bb-float 3s ease-in-out infinite;
}

.bb-boss .bb-char-emoji {
  font-size: 80px;
  filter: drop-shadow(0 0 20px rgba(239,68,68,0.5));
  animation: bb-float 3s ease-in-out infinite reverse;
}

.bb-char-name {
  font-size: 10px;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

@keyframes bb-float {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-10px); }
}

/* ── Hit animations ──────────────────────────── */
@keyframes bb-boss-hit {
  0%,100% { transform: translateX(0) rotate(0); }
  20%     { transform: translateX(-14px) rotate(-8deg); }
  50%     { transform: translateX(14px) rotate(8deg); }
  70%     { transform: translateX(-8px) rotate(-4deg); }
  90%     { transform: translateX(6px) rotate(2deg); }
}

@keyframes bb-player-hit {
  0%,100% { transform: translateX(0); }
  25%     { transform: translateX(14px); }
  55%     { transform: translateX(-12px); }
  80%     { transform: translateX(6px); }
}

@keyframes bb-boss-death {
  0%   { transform: scale(1) rotate(0deg); opacity: 1; }
  40%  { transform: scale(1.4) rotate(25deg); opacity: 0.8; }
  100% { transform: scale(0) rotate(200deg); opacity: 0; }
}

.bb-boss.hitting .bb-char-emoji   { animation: bb-boss-hit 0.45s ease-out forwards !important; }
.bb-player.hitting .bb-char-emoji  { animation: bb-player-hit 0.45s ease-out forwards !important; }
.bb-boss.dying .bb-char-emoji      { animation: bb-boss-death 0.7s ease-out forwards !important; }

/* ── Flash overlays ──────────────────────────── */
.bb-flash {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  pointer-events: none;
  opacity: 0;
  z-index: 5;
}

@keyframes bb-flash-anim {
  0%   { opacity: 0.7; }
  100% { opacity: 0; }
}

.bb-flash.active { animation: bb-flash-anim 0.4s ease-out forwards; }
.bb-flash.red    { background: rgba(239,68,68,0.2); }
.bb-flash.green  { background: rgba(16,185,129,0.14); }

/* ── Floating damage numbers ─────────────────── */
.bb-dmg-float {
  position: absolute;
  pointer-events: none;
  font-weight: 900;
  font-family: var(--font-display, 'Outfit', sans-serif);
  z-index: 10;
  animation: bb-dmg-rise 1.3s ease-out forwards;
  text-shadow: 0 2px 8px rgba(0,0,0,0.9);
  white-space: nowrap;
}

@keyframes bb-dmg-rise {
  0%   { opacity: 1; transform: translateY(0) scale(1.3); }
  30%  { opacity: 1; transform: translateY(-22px) scale(1); }
  100% { opacity: 0; transform: translateY(-72px) scale(0.8); }
}

/* ── Streak banner ───────────────────────────── */
.bb-streak-banner {
  text-align: center;
  min-height: 20px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #fbbf24;
  margin: 2px 0 4px;
  position: relative;
  z-index: 2;
}

/* ── Question panel ──────────────────────────── */
.bb-q-panel {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 18px 20px;
  margin-top: 4px;
  position: relative;
  z-index: 2;
}

.bb-q-meta {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #475569;
  margin-bottom: 10px;
}

.bb-q-text {
  font-size: 14.5px;
  font-weight: 600;
  color: #e2e8f0;
  line-height: 1.55;
  margin-bottom: 14px;
}

.bb-opts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.bb-opt {
  background: rgba(255,255,255,0.06);
  border: 1.5px solid rgba(255,255,255,0.09);
  border-radius: 9px;
  padding: 9px 13px;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  font-family: inherit;
  line-height: 1.4;
}

.bb-opt:hover:not(:disabled) {
  background: rgba(99,102,241,0.14);
  border-color: rgba(99,102,241,0.35);
  color: #e2e8f0;
}

.bb-opt.correct { background: rgba(16,185,129,0.18) !important; border-color: #10b981 !important; color: #6ee7b7 !important; }
.bb-opt.wrong   { background: rgba(239,68,68,0.14)  !important; border-color: #ef4444 !important; color: #fca5a5 !important; }
.bb-opt:disabled { cursor: default; }

/* ── Intro screen ────────────────────────────── */
.bb-intro {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 28px;
  z-index: 20;
  background: radial-gradient(circle at 50% 40%, rgba(99,102,241,0.15) 0%, rgba(12,18,34,0.97) 65%);
}

.bb-intro-boss {
  font-size: 96px;
  margin-bottom: 10px;
  animation: bb-float 3s ease-in-out infinite;
  filter: drop-shadow(0 0 28px rgba(239,68,68,0.6));
}

.bb-intro-tag {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 2.5px;
  color: #ef4444;
  margin-bottom: 8px;
}

.bb-intro-title {
  font-size: 24px;
  font-weight: 900;
  color: #f1f5f9;
  margin-bottom: 8px;
  letter-spacing: -0.3px;
}

.bb-intro-sub {
  font-size: 13px;
  color: #64748b;
  line-height: 1.6;
  max-width: 360px;
  margin-bottom: 20px;
}

.bb-intro-rules {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  padding: 12px 20px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 12px;
}

.bb-intro-rule {
  font-size: 12px;
  color: #64748b;
  text-align: center;
  line-height: 1.5;
}

.bb-intro-rule strong {
  display: block;
  color: #94a3b8;
  margin-bottom: 2px;
  font-size: 13px;
}

/* ── Overlay screens (victory / defeat) ──────── */
.bb-overlay {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 32px;
  z-index: 20;
  backdrop-filter: blur(2px);
}

.bb-overlay.victory {
  background: radial-gradient(circle at 50% 50%, rgba(16,185,129,0.25) 0%, rgba(12,18,34,0.95) 65%);
}

.bb-overlay.defeat {
  background: radial-gradient(circle at 50% 50%, rgba(239,68,68,0.2) 0%, rgba(12,18,34,0.95) 65%);
}

.bb-overlay-icon {
  font-size: 80px;
  margin-bottom: 14px;
  animation: bb-float 2.5s ease-in-out infinite;
}

.bb-overlay-title {
  font-size: 28px;
  font-weight: 900;
  margin-bottom: 8px;
  letter-spacing: -0.3px;
}

.bb-overlay.victory .bb-overlay-title { color: #6ee7b7; }
.bb-overlay.defeat  .bb-overlay-title { color: #fca5a5; }

.bb-overlay-sub {
  font-size: 14px;
  color: #64748b;
  line-height: 1.6;
  max-width: 340px;
  margin-bottom: 8px;
}

.bb-overlay-score {
  font-size: 13px;
  color: #475569;
  margin-bottom: 24px;
  font-weight: 600;
}

/* ── Shared buttons ──────────────────────────── */
.bb-btn {
  background: linear-gradient(135deg, #6366f1, #7c3aed);
  border: none;
  border-radius: 12px;
  padding: 13px 34px;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.3px;
  box-shadow: 0 6px 24px rgba(99,102,241,0.45);
  transition: filter 0.12s, transform 0.1s;
}

.bb-btn:hover  { filter: brightness(1.12); transform: translateY(-2px); }
.bb-btn:active { transform: translateY(0); }

.bb-btn.secondary {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.11);
  color: #94a3b8;
  box-shadow: none;
}

.bb-btn.secondary:hover { background: rgba(255,255,255,0.12); filter: none; }

.bb-btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ── Boss damaged states ─────────────────────── */
.bb-boss.hurt .bb-char-emoji {
  filter: drop-shadow(0 0 16px rgba(251,146,60,0.9)) saturate(0.7);
}
.bb-boss.critical .bb-char-emoji {
  filter: drop-shadow(0 0 20px rgba(239,68,68,1)) saturate(0.3) brightness(1.3);
  animation: bb-float 1.2s ease-in-out infinite !important;
}

/* ── Boss speech bubble ──────────────────────── */
.bb-speech {
  position: absolute;
  background: rgba(15,23,42,0.96);
  border: 1px solid rgba(239,68,68,0.35);
  border-radius: 10px 10px 2px 10px;
  padding: 7px 11px;
  font-size: 11.5px;
  font-weight: 600;
  color: #f1f5f9;
  max-width: 154px;
  text-align: center;
  pointer-events: none;
  z-index: 12;
  line-height: 1.45;
  white-space: pre-line;
  animation: bb-speech-pop 2.2s ease-out forwards;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

@keyframes bb-speech-pop {
  0%   { opacity: 0; transform: scale(0.8) translateY(4px); }
  12%  { opacity: 1; transform: scale(1.05) translateY(0); }
  20%  { transform: scale(1); }
  72%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(-12px); }
}

/* ── Particles ───────────────────────────────── */
.bb-particle {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 15;
  animation: bb-particle-fly 0.85s ease-out forwards;
  transform-origin: center;
}

@keyframes bb-particle-fly {
  0%   { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--rx), var(--ry)) scale(0.2); }
}

/* ── Stats grid (victory / defeat) ──────────── */
.bb-stats {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.bb-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.bb-stat-val {
  font-size: 16px;
  font-weight: 800;
  color: #e2e8f0;
  font-variant-numeric: tabular-nums;
}

.bb-stat-lbl {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #475569;
}

/* ── Stars ───────────────────────────────────── */
.bb-stars {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 4px;
}

.bb-star {
  font-size: 28px;
  color: #1e293b;
  transition: color 0.2s;
  text-shadow: 0 0 0 transparent;
}

.bb-star.filled {
  color: #fbbf24;
  text-shadow: 0 0 12px rgba(251,191,36,0.6);
}

.bb-rating-label {
  font-size: 13px;
  font-weight: 700;
  color: #64748b;
  margin-bottom: 18px;
  letter-spacing: 0.3px;
}

/* ── Timer ───────────────────────────────────── */
.bb-timer-wrap {
  height: 5px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
  position: relative;
  z-index: 2;
}

.bb-timer-bar {
  height: 100%;
  border-radius: 3px;
  width: 100%;
  background: #10b981;
  transition: width 0.1s linear, background 0.4s;
}

.bb-timer-bar.warn   { background: #f59e0b; }
.bb-timer-bar.danger { background: #ef4444; }

@keyframes bb-timer-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

.bb-timer-bar.danger { animation: bb-timer-pulse 0.45s ease-in-out infinite; }

.bb-timer-label {
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #475569;
  margin-bottom: 6px;
  position: relative;
  z-index: 2;
  transition: color 0.3s;
  font-variant-numeric: tabular-nums;
}

.bb-timer-label.warn   { color: #f59e0b; }
.bb-timer-label.danger { color: #ef4444; }

/* ── Responsive ──────────────────────────────── */
@media (max-width: 480px) {
  .bb-opts { grid-template-columns: 1fr; }
  .bb-arena { padding: 16px 16px 20px; }
  .bb-char-emoji { font-size: 52px !important; }
  .bb-boss .bb-char-emoji { font-size: 60px !important; }
  .bb-intro-rules { flex-direction: column; gap: 8px; }
  .bb-intro-boss { font-size: 72px; }
}
