/* === SHADOW REALMS — Dark Fractured Aesthetic === */

:root {
  --void: #0a0012;
  --deep-purple: #1a0033;
  --mid-purple: #2d1b69;
  --neon-purple: #9d4edd;
  --neon-pink: #e040fb;
  --neon-cyan: #00e5ff;
  --gold: #ffd700;
  --void-glow: #c026d3;
  --text: #e0d4f7;
  --text-dim: #8b7fb0;
  --card-bg: #12001f;
  --border: #3d1a6e;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--void);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Background atmosphere */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 20% 10%, rgba(157,78,221,0.15) 0%, transparent 60%),
    radial-gradient(ellipse 50% 50% at 80% 80%, rgba(224,64,251,0.1) 0%, transparent 50%),
    radial-gradient(ellipse 40% 60% at 50% 50%, rgba(45,27,105,0.2) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

#app { position: relative; z-index: 1; }

/* Typography */
h1, h2, h3 { font-weight: 700; letter-spacing: 0.02em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.4rem; margin-bottom: 1rem; }

/* Header */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  background: rgba(26,0,51,0.8);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-size: 1.4rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--neon-purple), var(--neon-pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 0.05em;
}

.currency-bar {
  display: flex;
  gap: 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.currency-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--gold);
}

.currency-item .label { color: var(--text-dim); font-weight: 400; }

/* Nav tabs */
.nav-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem 2rem;
  border-bottom: 1px solid var(--border);
  background: rgba(10,0,18,0.6);
  overflow-x: auto;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab-btn:hover { color: var(--text); background: rgba(157,78,221,0.15); }
.tab-btn.active {
  color: var(--neon-purple);
  background: rgba(157,78,221,0.2);
  box-shadow: 0 0 12px rgba(157,78,221,0.3);
}

/* Main content */
main { padding: 2rem; max-width: 1200px; margin: 0 auto; }
.section { display: none; }
.section.active { display: block; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-primary {
  background: linear-gradient(135deg, var(--neon-purple), var(--mid-purple));
  color: white;
  box-shadow: 0 0 20px rgba(157,78,221,0.4);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 0 30px rgba(157,78,221,0.6); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-gold {
  background: linear-gradient(135deg, var(--gold), #b8860b);
  color: #1a0010;
}
.btn-gold:hover { box-shadow: 0 0 20px rgba(255,215,0,0.5); }

.btn-outline {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--neon-purple); color: var(--neon-purple); }

/* Grid layouts */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.card-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
}

/* === CARD STYLES === */
.card {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.5); }

/* Rarity borders */
.card.common { border-color: #5a5a6e; }
.card.common:hover { box-shadow: 0 0 15px rgba(90,90,110,0.4); }
.card.common::before { background: radial-gradient(ellipse at top, rgba(90,90,110,0.2), transparent 60%); }

.card.rare { border-color: #1e88e5; }
.card.rare:hover { box-shadow: 0 0 15px rgba(30,136,229,0.4); }
.card.rare::before { background: radial-gradient(ellipse at top, rgba(30,136,229,0.15), transparent 60%); }

.card.ultra-rare { border-color: var(--neon-pink); }
.card.ultra-rare:hover { box-shadow: 0 0 20px rgba(224,64,251,0.5); }
.card.ultra-rare::before { background: radial-gradient(ellipse at top, rgba(224,64,251,0.15), transparent 60%); }

.card.void { border-color: var(--void-glow); }
.card.void:hover { box-shadow: 0 0 25px rgba(192,38,211,0.6); }
.card.void::before { background: radial-gradient(ellipse at top, rgba(192,38,211,0.2), transparent 60%); }

.card:hover::before { opacity: 1; }

/* Shard overlay for void cards */
.card.void::after {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: conic-gradient(from 0deg, transparent, rgba(192,38,211,0.1), transparent, rgba(192,38,211,0.1), transparent);
  animation: shard-rotate 8s linear infinite;
  pointer-events: none;
}

@keyframes shard-rotate { to { transform: rotate(360deg); } }

.card-art {
  width: 100%;
  aspect-ratio: 3/4;
  border-radius: 4px;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--deep-purple), var(--void));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  overflow: hidden;
  position: relative;
}

.card-art-icon { font-size: 3rem; filter: drop-shadow(0 0 8px currentColor); }

.card-name {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  line-height: 1.2;
}

.card-rarity {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}
.card.common .card-rarity { color: #8a8a9e; }
.card.rare .card-rarity { color: #42a5f5; }
.card.ultra-rare .card-rarity { color: var(--neon-pink); }
.card.void .card-rarity { color: var(--void-glow); text-shadow: 0 0 8px var(--void-glow); }

.card-stats {
  display: flex;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
}

.card-stats span { padding: 0.15rem 0.4rem; border-radius: 3px; }
.atk { background: rgba(220,38,38,0.2); color: #ef5350; }
.def { background: rgba(30,136,229,0.2); color: #42a5f5; }
.hp { background: rgba(76,175,80,0.2); color: #66bb6a; }

.card-ability {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 0.35rem;
  font-style: italic;
}

/* Selected state */
.card.selected {
  box-shadow: 0 0 0 2px var(--neon-cyan), 0 0 20px rgba(0,229,255,0.3);
}

/* NEW badge on collection cards */
.card .new-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: linear-gradient(135deg, var(--gold), #ff9500);
  color: #1a0010;
  font-size: 0.55rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 5px;
  border-radius: 10px;
  box-shadow: 0 0 8px rgba(255,215,0,0.8);
  animation: newBadgePulse 2s ease-in-out infinite;
  z-index: 2;
}

@keyframes newBadgePulse {
  0%, 100% { box-shadow: 0 0 8px rgba(255,215,0,0.8); }
  50% { box-shadow: 0 0 16px rgba(255,215,0,1); }
}

/* === PACK OPENING === */
.pack-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  padding: 3rem 0;
}

.pack-btn {
  position: relative;
  width: 160px;
  height: 220px;
  background: linear-gradient(160deg, #2d1b69, #1a0033);
  border: 2px solid var(--neon-purple);
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.3s;
  box-shadow: 0 0 30px rgba(157,78,221,0.3);
  overflow: hidden;
}

.pack-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(157,78,221,0.2), rgba(224,64,251,0.1));
  opacity: 0;
  transition: opacity 0.3s;
}

.pack-btn:hover { transform: translateY(-4px) scale(1.02); box-shadow: 0 0 50px rgba(157,78,221,0.5); }
.pack-btn:hover::before { opacity: 1; }

.pack-btn .pack-icon { font-size: 3rem; }
.pack-btn .pack-label { font-weight: 800; font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.1em; }
.pack-btn .pack-desc { font-size: 0.7rem; color: var(--text-dim); }

.pack-options { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; }

/* Pack reveal overlay */
#pack-reveal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 200;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1.5rem;
}

#pack-reveal-overlay.show { display: flex; }

/* Screen flash on pack open */
#pack-flash {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 199;
  pointer-events: none;
  opacity: 0;
}
#pack-flash.flash-common  { background: rgba(90,90,110,0.7); display: block; animation: flashDim 0.3s ease-out forwards; }
#pack-flash.flash-rare    { background: rgba(30,136,229,0.8); display: block; animation: flashDim 0.3s ease-out forwards; }
#pack-flash.flash-ultra   { background: rgba(224,64,251,0.9); display: block; animation: flashDim 0.35s ease-out forwards; }
#pack-flash.flash-void    { background: rgba(192,38,211,0.9); display: block; animation: flashVoid 0.4s ease-out forwards; }

@keyframes flashDim {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes flashVoid {
  0%   { opacity: 1; }
  30%  { opacity: 0.6; background: rgba(255,215,0,0.9); }
  60%  { opacity: 0.8; background: rgba(192,38,211,0.9); }
  100% { opacity: 0; }
}

/* Pack reveal card — multi-phase animation */
.pack-reveal-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  border: 2px solid var(--border);
  min-width: 300px;
  position: relative;
  opacity: 0;
  transform: scale(0.5) rotateY(90deg);
  transition: none;
}

/* Phase 1: Card sweeps in and flips */
.pack-reveal-card.phase-card {
  animation: cardFlipIn 0.6s cubic-bezier(0.34, 1.3, 0.64, 1) forwards;
}

/* Phase 2: Rarity badge flashes in */
.pack-reveal-rarity {
  font-size: 1rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  margin-bottom: 0.5rem;
  opacity: 0;
  transform: translateY(-10px);
}

.pack-reveal-card.phase-text .pack-reveal-rarity {
  animation: textReveal 0.3s ease-out forwards;
}

/* Phase 3: Full glow pulse */
.pack-reveal-card.phase-glow {
  animation: glowPulse 0.4s ease-out forwards !important;
}

@keyframes cardFlipIn {
  0%   { opacity: 0; transform: scale(0.3) rotateY(90deg); }
  60%  { opacity: 1; transform: scale(1.1) rotateY(-5deg); }
  100% { opacity: 1; transform: scale(1) rotateY(0deg); }
}

@keyframes textReveal {
  0%   { opacity: 0; transform: translateY(-10px) scale(1.3); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes glowPulse {
  0%   { filter: brightness(1); }
  50%  { filter: brightness(1.6); }
  100% { filter: brightness(1); }
}

/* Rarity-specific reveal glow */
.pack-reveal-card.common { border-color: #5a5a6e; }
.pack-reveal-card.common.phase-glow { box-shadow: 0 0 50px rgba(90,90,110,0.7), inset 0 0 30px rgba(90,90,110,0.15); }

.pack-reveal-card.rare { border-color: #1e88e5; }
.pack-reveal-card.rare.phase-glow { box-shadow: 0 0 60px rgba(30,136,229,0.7), inset 0 0 30px rgba(30,136,229,0.15); }

.pack-reveal-card.ultra-rare { border-color: var(--neon-pink); }
.pack-reveal-card.ultra-rare.phase-glow { box-shadow: 0 0 80px rgba(224,64,251,0.8), inset 0 0 40px rgba(224,64,251,0.15); }

.pack-reveal-card.void {
  border-color: var(--void-glow);
}
.pack-reveal-card.void.phase-glow {
  box-shadow: 0 0 100px rgba(192,38,211,1), 0 0 200px rgba(255,215,0,0.5), inset 0 0 60px rgba(192,38,211,0.25);
  animation: voidPulse 1.2s ease-in-out infinite !important;
}

@keyframes voidPulse {
  0%, 100% { box-shadow: 0 0 100px rgba(192,38,211,1), 0 0 200px rgba(255,215,0,0.5), inset 0 0 60px rgba(192,38,211,0.25); }
  50% { box-shadow: 0 0 140px rgba(192,38,211,1), 0 0 280px rgba(255,215,0,0.8), inset 0 0 80px rgba(192,38,211,0.35); }
}

/* Void screen shake */
@keyframes voidShake {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  10% { transform: translate(-8px, -5px) rotate(-0.5deg); }
  20% { transform: translate(8px, 5px) rotate(0.5deg); }
  30% { transform: translate(-6px, 4px) rotate(-0.4deg); }
  40% { transform: translate(6px, -4px) rotate(0.4deg); }
  50% { transform: translate(-4px, 3px) rotate(-0.3deg); }
  60% { transform: translate(4px, -3px) rotate(0.3deg); }
  70% { transform: translate(-2px, 2px) rotate(-0.2deg); }
  80% { transform: translate(2px, -2px) rotate(0.2deg); }
  90% { transform: translate(-1px, 1px) rotate(-0.1deg); }
}

#pack-reveal-overlay.void-shake { animation: voidShake 0.8s ease-out; }

/* Void particle burst */
.pack-reveal-particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 201;
  overflow: hidden;
}

.particle {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: particleFly var(--duration, 1s) ease-out forwards;
}

@keyframes particleFly {
  0%   { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--tx, 0px), var(--ty, -100px)) scale(0); opacity: 0; }
}

/* Rarity text colors */
.pack-reveal-card.common .pack-reveal-rarity { color: #8a8a9e; }
.pack-reveal-card.rare .pack-reveal-rarity { color: #42a5f5; }
.pack-reveal-card.ultra-rare .pack-reveal-rarity { color: var(--neon-pink); }
.pack-reveal-card.void .pack-reveal-rarity {
  color: var(--void-glow);
  text-shadow: 0 0 10px var(--void-glow);
  animation: voidTextFlash 0.4s ease-out forwards;
}

@keyframes voidTextFlash {
  0%   { opacity: 0; transform: scale(1.8); color: #ffd700; text-shadow: 0 0 20px #ffd700; }
  100% { opacity: 1; transform: scale(1); color: var(--void-glow); text-shadow: 0 0 10px var(--void-glow); }
}

/* Icon and name reveal */
.pack-reveal-icon {
  font-size: 4rem;
  margin: 0.5rem 0;
  opacity: 0;
}
.pack-reveal-card.phase-card .pack-reveal-icon {
  animation: iconReveal 0.4s ease-out 0.2s forwards;
}
@keyframes iconReveal {
  0%   { opacity: 0; transform: scale(0.5); }
  100% { opacity: 1; transform: scale(1); }
}

.pack-reveal-name {
  font-size: 1.2rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  opacity: 0;
}
.pack-reveal-card.phase-card .pack-reveal-name {
  animation: nameReveal 0.3s ease-out 0.3s forwards;
}
@keyframes nameReveal {
  0%   { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}

.pack-reveal-stats { display: flex; gap: 1rem; justify-content: center; margin: 0.75rem 0; opacity: 0; }
.pack-reveal-card.phase-glow .pack-reveal-stats {
  animation: fadeIn 0.3s ease-out forwards;
}

.pack-reveal-ability { font-size: 0.85rem; color: var(--text-dim); font-style: italic; opacity: 0; }
.pack-reveal-card.phase-glow .pack-reveal-ability {
  animation: fadeIn 0.3s ease-out 0.1s forwards;
}

/* NEW badge */
.pack-reveal-new-badge {
  position: absolute;
  top: -10px;
  right: -10px;
  background: linear-gradient(135deg, var(--gold), #ff9500);
  color: #1a0010;
  font-size: 0.65rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 3px 8px;
  border-radius: 20px;
  box-shadow: 0 0 15px rgba(255,215,0,0.8);
  animation: newBadgePop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.8s forwards;
  opacity: 0;
  transform: scale(0) rotate(-15deg);
}

@keyframes newBadgePop {
  0%   { opacity: 0; transform: scale(0) rotate(-15deg); }
  70%  { opacity: 1; transform: scale(1.2) rotate(5deg); }
  100% { opacity: 1; transform: scale(1) rotate(-10deg); }
}

/* Rarity announcement text (full-screen) */
#pack-rarity-announcement {
  position: fixed;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2.5rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  z-index: 205;
  pointer-events: none;
  opacity: 0;
}

#pack-rarity-announcement.show-announce {
  animation: announceReveal 0.8s ease-out forwards;
}

@keyframes announceReveal {
  0%   { opacity: 0; transform: translateX(-50%) scale(2); }
  20%  { opacity: 1; transform: translateX(-50%) scale(0.9); }
  40%  { opacity: 1; transform: translateX(-50%) scale(1.05); }
  60%  { opacity: 1; transform: translateX(-50%) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) scale(0.8) translateY(-20px); }
}

#pack-rarity-announcement.common  { color: #8a8a9e; text-shadow: 0 0 20px rgba(90,90,110,0.8); }
#pack-rarity-announcement.rare    { color: #42a5f5; text-shadow: 0 0 30px rgba(30,136,229,0.9); }
#pack-rarity-announcement.ultra-rare {
  color: var(--neon-pink);
  text-shadow: 0 0 40px rgba(224,64,251,1), 0 0 80px rgba(224,64,251,0.5);
}
#pack-rarity-announcement.void {
  color: var(--gold);
  text-shadow: 0 0 60px rgba(255,215,0,1), 0 0 120px rgba(192,38,211,0.8);
}

/* === TEAM BUILDER === */
.team-builder { display: flex; flex-direction: column; gap: 1.5rem; }

.team-slots {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  min-height: 200px;
  padding: 1rem;
  background: rgba(26,0,51,0.4);
  border-radius: 8px;
  border: 1px dashed var(--border);
  align-items: flex-start;
  align-content: flex-start;
}

.team-slot {
  width: 120px;
  height: 160px;
  border: 2px dashed rgba(157,78,221,0.4);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--text-dim);
  background: rgba(10,0,18,0.4);
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.team-slot:hover { border-color: var(--neon-purple); color: var(--text); }
.team-slot.filled { border-style: solid; border-color: var(--neon-purple); background: var(--card-bg); }
.team-slot.filled:hover { box-shadow: 0 0 15px rgba(157,78,221,0.4); }

.slot-number { font-size: 1.2rem; font-weight: 900; color: rgba(157,78,221,0.3); }

.team-actions { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }

.team-info { font-size: 0.85rem; color: var(--text-dim); }
.team-info strong { color: var(--neon-cyan); }

/* === BATTLE ARENA === */
.battle-arena {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.battle-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: rgba(26,0,51,0.6);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.opponent-info, .player-info { text-align: center; }
.opponent-name, .player-name { font-weight: 700; margin-bottom: 0.5rem; }

.hp-bar-wrap { position: relative; height: 20px; background: rgba(0,0,0,0.5); border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.hp-bar { height: 100%; border-radius: 10px; transition: width 0.5s ease; }
.hp-bar.player { background: linear-gradient(90deg, #2e7d32, #66bb6a); }
.hp-bar.opponent { background: linear-gradient(90deg, #c62828, #ef5350); }
.hp-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 700; color: white; text-shadow: 0 1px 3px black; }

.battle-field {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  align-items: center;
}

.battle-team { display: flex; flex-direction: column; gap: 0.5rem; }

.battle-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: all 0.3s;
}

.battle-card.attacking { box-shadow: 0 0 20px rgba(220,38,38,0.6); border-color: #ef5350; transform: translateX(10px); }
.battle-card.defending { box-shadow: 0 0 20px rgba(30,136,229,0.6); border-color: #42a5f5; transform: translateX(-10px); }
.battle-card.dead { opacity: 0.35; text-decoration: line-through; filter: saturate(0.3); }
@keyframes damage-shake {
  0%   { transform: translateX(0); }
  20%  { transform: translateX(-8px) rotate(-2deg); filter: brightness(1.5) hue-rotate(-30deg); }
  40%  { transform: translateX(8px) rotate(2deg); }
  60%  { transform: translateX(-5px); }
  80%  { transform: translateX(5px); }
  100% { transform: translateX(0); filter: brightness(1); }
}
.battle-card.damage-shake { animation: damage-shake 0.5s ease-out; }

@keyframes knockout-collapse {
  0%   { transform: scale(1) rotate(0deg); opacity: 1; filter: brightness(1); }
  30%  { transform: scale(1.05) rotate(-3deg); filter: brightness(2) hue-rotate(60deg); opacity: 0.8; }
  60%  { transform: scale(0.9) rotate(5deg) translateY(4px); opacity: 0.5; filter: brightness(0.4) saturate(0.3); }
  100% { transform: scale(0.85) rotate(-2deg) translateY(6px); opacity: 0.25; filter: brightness(0.2) saturate(0); }
}
.battle-card.knocked-out {
  animation: knockout-collapse 0.7s ease-out forwards;
  border-color: #b71c1c !important;
  box-shadow: 0 0 16px rgba(183,28,28,0.5) !important;
}

/* Knockout screen flash */
@keyframes knockout-flash {
  0%   { opacity: 0; }
  15%  { opacity: 0.7; }
  100% { opacity: 0; }
}
#knockout-flash {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle, rgba(183,28,28,0.9) 0%, rgba(0,0,0,0) 70%);
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
}
#knockout-flash.active { animation: knockout-flash 0.6s ease-out forwards; }

/* Floating KO badge */
@keyframes ko-badge-rise {
  0%   { opacity: 0; transform: translateY(0) scale(0.5); }
  20%  { opacity: 1; transform: translateY(-10px) scale(1.3); }
  60%  { opacity: 1; transform: translateY(-30px) scale(1.1); }
  100% { opacity: 0; transform: translateY(-50px) scale(0.9); }
}
.ko-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.4rem;
  font-weight: 900;
  color: #ef5350;
  text-shadow: 0 0 12px rgba(239,83,80,0.9), 0 2px 4px rgba(0,0,0,0.8);
  pointer-events: none;
  z-index: 10;
  animation: ko-badge-rise 0.9s ease-out forwards;
}

/* Floating damage number animation */
@keyframes dmg-float {
  0%   { opacity: 0; transform: translateX(-50%) translateY(0) scale(0.6); }
  15%  { opacity: 1; transform: translateX(-50%) translateY(-5px) scale(1.2); }
  60%  { opacity: 1; transform: translateX(-50%) translateY(-20px) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-35px) scale(0.8); }
}

.battle-card-icon { font-size: 1.5rem; }
.battle-card-name { font-size: 0.8rem; font-weight: 700; flex: 1; }
.battle-card-stats { display: flex; gap: 0.25rem; font-size: 0.7rem; font-weight: 700; }
.battle-card-hp { color: #66bb6a; }
.battle-card-atk { color: #ef5350; }
.battle-card-def { color: #42a5f5; }

.vs-badge {
  font-size: 2rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--neon-purple), var(--neon-pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-align: center;
}

.battle-log {
  max-height: 300px;
  overflow-y: auto;
  background: rgba(10,0,18,0.6);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  line-height: 1.6;
}

.log-entry { margin-bottom: 0.25rem; }
.log-entry.round { color: var(--neon-cyan); font-weight: 700; border-bottom: 1px solid rgba(0,229,255,0.2); padding-bottom: 0.25rem; margin-bottom: 0.5rem; }
.log-entry.damage { color: #ef5350; }
.log-entry.heal { color: #66bb6a; }
.log-entry.knockout {
  color: #ef5350;
  font-weight: 700;
  text-shadow: 0 0 12px rgba(239,68,68,0.8);
  background: rgba(239,68,68,0.15);
  border-left: 3px solid #ef5350;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  animation: knockout-log-flash 0.8s ease-out forwards;
}
@keyframes knockout-log-flash {
  0%   { background: rgba(239,68,68,0.5); }
  100% { background: rgba(239,68,68,0.15); }
}
.log-entry.victory { color: var(--gold); font-weight: 700; font-size: 0.9rem; }
.log-entry.defeat { color: #ef5350; font-weight: 700; font-size: 0.9rem; }

.battle-controls { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

.battle-progress {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.battle-progress .round-num { color: var(--neon-cyan); font-weight: 700; }

/* === CAMPAIGN === */
.campaign-list { display: flex; flex-direction: column; gap: 1rem; }

.campaign-node {
  background: rgba(26,0,51,0.5);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  transition: all 0.2s;
}

.campaign-node:hover { border-color: var(--neon-purple); box-shadow: 0 0 20px rgba(157,78,221,0.2); }
.campaign-node.locked { opacity: 0.5; cursor: not-allowed; }
.campaign-node.completed { border-color: #2e7d32; }
.campaign-node.completed::after { content: '✓'; color: #66bb6a; font-size: 1.2rem; margin-left: auto; }

.node-icon { font-size: 2rem; }
.node-info { flex: 1; }
.node-name { font-weight: 700; margin-bottom: 0.25rem; }
.node-desc { font-size: 0.8rem; color: var(--text-dim); }
.node-hp { font-size: 0.75rem; color: #ef5350; }

.boss-badge {
  background: linear-gradient(135deg, #c62828, #ef5350);
  color: white;
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  letter-spacing: 0.1em;
}

/* === PVP === */
.pvp-section { text-align: center; padding: 2rem 0; }
.pvp-teams {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2rem;
  margin: 2rem 0;
}

.pvp-team { text-align: center; }
.pvp-label { font-size: 0.8rem; color: var(--text-dim); margin-bottom: 0.5rem; text-transform: uppercase; letter-spacing: 0.1em; }
.pvp-cards { display: flex; gap: 0.5rem; justify-content: center; }
.pvp-vs { font-size: 1.5rem; font-weight: 900; color: var(--neon-purple); }

/* === REWARDS === */
.rewards-banner {
  background: linear-gradient(135deg, rgba(157,78,221,0.2), rgba(224,64,251,0.1));
  border: 1px solid var(--neon-purple);
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
  margin-bottom: 1rem;
}

.rewards-banner h2 { color: var(--gold); }
.reward-items { display: flex; gap: 1.5rem; justify-content: center; margin: 1rem 0; font-size: 1.1rem; font-weight: 700; }
.reward-item { color: var(--gold); }

/* === STATS === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: rgba(26,0,51,0.5);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
}

.stat-value { font-size: 1.8rem; font-weight: 900; color: var(--neon-purple); }
.stat-label { font-size: 0.8rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 0.25rem; }

/* === EMPTY STATES === */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-dim);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.5; }
.empty-state p { margin-bottom: 1rem; }

/* === MODAL === */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  z-index: 150;
  align-items: center;
  justify-content: center;
}

.modal-overlay.show { display: flex; animation: fadeIn 0.2s; }

.modal {
  background: var(--deep-purple);
  border: 1px solid var(--neon-purple);
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 0 40px rgba(157,78,221,0.4);
}

.modal h3 { margin-bottom: 1rem; color: var(--neon-purple); }
.modal-actions { display: flex; gap: 0.75rem; margin-top: 1rem; justify-content: flex-end; }

/* === ANIMATIONS === */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

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

.floating { animation: float 3s ease-in-out infinite; }

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--void); }
::-webkit-scrollbar-thumb { background: var(--mid-purple); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--neon-purple); }

/* === RESPONSIVE === */
@media (max-width: 768px) {
  header { padding: 0.75rem 1rem; }
  .nav-tabs { padding: 0.5rem 1rem; }
  main { padding: 1rem; }
  .battle-field { grid-template-columns: 1fr; }
  .vs-badge { font-size: 1.5rem; }
}

/* === ABILITY TYPE BADGES === */
.ability-tag {
  display: inline-block;
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  margin-top: 4px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.ability-tag.lifesteal  { background: rgba(220,38,38,0.3); color: #ef5350; border: 1px solid #ef5350; }
.ability-tag.dodge     { background: rgba(0,229,255,0.2); color: #00e5ff; border: 1px solid #00e5ff; }
.ability-tag.thorns    { background: rgba(76,175,80,0.3); color: #66bb6a; border: 1px solid #66bb6a; }
.ability-tag.shield    { background: rgba(30,136,229,0.3); color: #42a5f5; border: 1px solid #42a5f5; }
.ability-tag.stun      { background: rgba(255,215,0,0.3); color: #ffd700; border: 1px solid #ffd700; }
.ability-tag.execute   { background: rgba(255,87,34,0.3); color: #ff7043; border: 1px solid #ff7043; }
.ability-tag.berserk   { background: rgba(244,67,54,0.3); color: #f44336; border: 1px solid #f44336; }
.ability-tag.fury      { background: rgba(255,152,0,0.3); color: #ffa726; border: 1px solid #ffa726; }
.ability-tag.silence    { background: rgba(156,39,176,0.3); color: #ce93d8; border: 1px solid #ce93d8; }
.ability-tag.instantKill { background: rgba(0,0,0,0.5); color: #fff; border: 1px solid #c026d3; }
.ability-tag.buff       { background: rgba(129,199,132,0.3); color: #a5d6a7; border: 1px solid #a5d6a7; }
.ability-tag.heal       { background: rgba(102,187,106,0.3); color: #81c784; border: 1px solid #81c784; }
.ability-tag.revival    { background: rgba(178,235,255,0.3); color: #b3e5fc; border: 1px solid #b3e5fc; }
.ability-tag.momentum   { background: rgba(255,224,130,0.3); color: #ffe082; border: 1px solid #ffe082; }
.ability-tag.vampiric   { background: rgba(171,71,188,0.3); color: #ba68c8; border: 1px solid #ba68c8; }
.ability-tag.retaliate  { background: rgba(239,83,80,0.3); color: #ef5350; border: 1px solid #ef5350; }
.ability-tag.sunder     { background: rgba(224,224,224,0.3); color: #e0e0e0; border: 1px solid #e0e0e0; }
.ability-tag.debuff     { background: rgba(158,158,158,0.3); color: #bdbdbd; border: 1px solid #bdbdbd; }
.ability-tag.siphon     { background: rgba(186,104,200,0.3); color: #ba68c8; border: 1px solid #ba68c8; }
.ability-tag.fortress   { background: rgba(21,101,192,0.3); color: #42a5f5; border: 1px solid #42a5f5; }
.ability-tag.taunt      { background: rgba(255,152,0,0.3); color: #ffb74d; border: 1px solid #ffb74d; }
.ability-tag.firstStrike { background: rgba(255,193,7,0.3); color: #ffd54f; border: 1px solid #ffd54f; }
.ability-tag.aoe         { background: rgba(0,150,136,0.3); color: #4db6ac; border: 1px solid #4db6ac; }
.ability-tag.entropy     { background: rgba(74,20,140,0.5); color: #e1bee7; border: 1px solid #7b1fa2; }
.ability-tag.annihilation { background: rgba(0,0,0,0.7); color: var(--neon-pink); border: 1px solid var(--neon-pink); }
.ability-tag.default    { background: rgba(157,78,221,0.3); color: var(--neon-purple); border: 1px solid var(--neon-purple); }

/* Battle log ability entries get glow */
.log-entry.ability {
  color: var(--neon-cyan);
  text-shadow: 0 0 8px rgba(0,229,255,0.5);
}

/* Battle card ability tag in card display */
.battle-card-ability {
  font-size: 0.6rem;
  color: var(--neon-cyan);
  opacity: 0.7;
  text-align: center;
  margin-top: 2px;
}

/* === ESSENCE SHOP === */
.btn-buy-essence {
  background: linear-gradient(135deg, #ffd700, #ff9500);
  color: #1a0010;
  border: none;
  border-radius: 6px;
  padding: 0.4rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 0 12px rgba(255,215,0,0.3);
  letter-spacing: 0.02em;
}
.btn-buy-essence:hover {
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(255,215,0,0.5);
}

.essence-packs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-top: 0.5rem;
}

.essence-pack {
  background: linear-gradient(145deg, #12001f, #1a0033);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem 1rem;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: all 0.25s;
}
.essence-pack:hover {
  border-color: var(--gold);
  box-shadow: 0 0 25px rgba(255,215,0,0.25);
  transform: translateY(-2px);
}

.essence-pack.best-value::before {
  content: '★ Best Value';
  position: absolute;
  top: 0.75rem;
  right: -1.5rem;
  background: var(--gold);
  color: #1a0010;
  font-size: 0.6rem;
  font-weight: 800;
  padding: 0.2rem 1.5rem;
  transform: rotate(45deg);
  letter-spacing: 0.05em;
}

.essence-pack-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  display: block;
  filter: drop-shadow(0 0 10px rgba(255,215,0,0.6));
}

.essence-pack-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.essence-amount {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 12px rgba(255,215,0,0.5);
  margin: 0.5rem 0;
}

.essence-amount-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.75rem;
}

.essence-pack .btn {
  width: 100%;
  margin-top: 0.5rem;
  font-weight: 700;
}

.btn-essence-buy {
  background: linear-gradient(135deg, #ffd700, #ff9500);
  color: #1a0010;
  border: none;
}
.btn-essence-buy:hover { filter: brightness(1.1); }

.essence-pack.loading { opacity: 0.6; pointer-events: none; }

#shop-status { text-align: center; }
#shop-status .success { color: #4caf50; font-weight: 700; }
#shop-status .error   { color: #ef5350; font-weight: 700; }
#shop-status .info    { color: var(--gold); font-weight: 700; }

/* === DAILY REWARD MODAL === */
.daily-reward-modal {
  background: linear-gradient(145deg, var(--deep-purple), #1a0033);
  border: 2px solid var(--neon-purple);
  border-radius: 16px;
  padding: 2rem;
  max-width: 380px;
  width: 90%;
  text-align: center;
  box-shadow: 0 0 60px rgba(157,78,221,0.5), 0 0 120px rgba(192,38,211,0.2);
  animation: dailyModalIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes dailyModalIn {
  0%   { opacity: 0; transform: scale(0.6) translateY(40px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.daily-reward-header { margin-bottom: 1.5rem; }

.daily-reward-header .fire-icon {
  font-size: 3rem;
  animation: firePulse 1.5s ease-in-out infinite;
  display: block;
  margin-bottom: 0.5rem;
}

@keyframes firePulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 8px #ff6b00); }
  50%       { transform: scale(1.1); filter: drop-shadow(0 0 16px #ff9500); }
}

.daily-reward-header h2 {
  color: var(--gold);
  text-shadow: 0 0 20px rgba(255,215,0,0.5);
  margin-bottom: 0.5rem;
  font-size: 1.5rem;
}

.streak-badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--neon-purple), var(--void-glow));
  color: white;
  font-size: 0.9rem;
  font-weight: 800;
  padding: 0.3rem 1rem;
  border-radius: 20px;
  letter-spacing: 0.1em;
  box-shadow: 0 0 15px rgba(157,78,221,0.5);
}

.streak-progress-wrap { margin: 1.25rem 0; }

.streak-progress-track {
  height: 10px;
  background: rgba(0,0,0,0.4);
  border-radius: 5px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.streak-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #ff6b00, #ffd700);
  border-radius: 5px;
  box-shadow: 0 0 10px rgba(255,107,0,0.6);
  transition: width 0.5s ease;
}

.daily-reward-rewards {
  background: rgba(10,0,18,0.5);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin: 1rem 0;
}

.reward-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0;
}

.reward-label { color: var(--text-dim); font-size: 0.9rem; }
.reward-value { font-size: 1.1rem; font-weight: 700; color: var(--gold); }

.btn-claim-daily {
  width: 100%;
  font-size: 1.1rem;
  padding: 0.9rem;
  background: linear-gradient(135deg, #ff6b00, #ff4500, #ffd700);
  color: #1a0010;
  border: none;
  border-radius: 10px;
  font-weight: 900;
  letter-spacing: 0.05em;
  box-shadow: 0 0 30px rgba(255,107,0,0.5);
  transition: all 0.2s;
}

.btn-claim-daily:hover {
  transform: scale(1.03);
  box-shadow: 0 0 50px rgba(255,107,0,0.8);
}

/* Streak display in header */
#streak-display {
  color: #ff6b00;
  font-weight: 700;
  padding: 0.3rem 0.6rem;
  background: rgba(255,107,0,0.1);
  border: 1px solid rgba(255,107,0,0.3);
  border-radius: 6px;
  font-size: 0.85rem;
}

/* Currency bump animation */
@keyframes currencyBump {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.4); color: var(--gold); }
  60%  { transform: scale(1.1); }
  100% { transform: scale(1); }
}

#shard-balance.currency-bump,
#essence-balance.currency-bump {
  animation: currencyBump 0.5s ease-out forwards;
}

/* === BOSS BATTLE DRAMA === */

/* Boss vignette effect */
body.boss-battle::before {
  background:
    radial-gradient(ellipse 80% 60% at 50% 50%, rgba(198,40,40,0.25) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 20% 10%, rgba(157,78,221,0.15) 0%, transparent 60%),
    radial-gradient(ellipse 50% 50% at 80% 80%, rgba(224,64,251,0.1) 0%, transparent 50%);
}
body.boss-battle::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  box-shadow: inset 0 0 120px rgba(198,40,40,0.4);
  animation: bossVignettePulse 2s ease-in-out infinite;
}
@keyframes bossVignettePulse {
  0%, 100% { box-shadow: inset 0 0 120px rgba(198,40,40,0.4); }
  50% { box-shadow: inset 0 0 180px rgba(198,40,40,0.6); }
}

/* ── Pre-boss warning screen ──────────────────────────────────── */
#boss-warning-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10,0,18,0.95);
  z-index: 200;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
#boss-warning-overlay.show { display: flex; }

.boss-warning-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.boss-warning-icon {
  font-size: 4rem;
  animation: warningPulse 0.5s ease-in-out infinite alternate;
}
@keyframes warningPulse {
  from { transform: scale(1); filter: drop-shadow(0 0 10px #ef5350); }
  to   { transform: scale(1.15); filter: drop-shadow(0 0 25px #ef5350); }
}

.boss-warning-text {
  font-size: 1.8rem;
  font-weight: 900;
  color: #ef5350;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  text-shadow: 0 0 30px rgba(239,83,80,0.8), 0 0 60px rgba(239,83,80,0.4);
  animation: warningTextFlash 0.4s ease-in-out infinite alternate;
}
@keyframes warningTextFlash {
  from { opacity: 0.7; }
  to   { opacity: 1; }
}

.boss-warning-name {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 0 15px rgba(255,215,0,0.5);
  opacity: 0;
  animation: bossNameReveal 0.6s ease-out forwards;
}
@keyframes bossNameReveal {
  from { opacity: 0; transform: scale(0.8); }
  to   { opacity: 1; transform: scale(1); }
}

.boss-warning-countdown {
  font-size: 4rem;
  font-weight: 900;
  color: var(--neon-cyan);
  text-shadow: 0 0 30px rgba(0,229,255,0.8), 0 0 60px rgba(0,229,255,0.4);
  opacity: 0;
  margin-top: 0.5rem;
}
@keyframes countdownSlam {
  0%   { opacity: 0; transform: scale(2); }
  40%  { opacity: 1; transform: scale(0.85); }
  70%  { transform: scale(1.1); }
  100% { opacity: 1; transform: scale(1); }
}

#boss-warning-icon.reveal {
  opacity: 0;
  animation: bossIconReveal 0.8s cubic-bezier(0.34,1.3,0.64,1) 0.2s forwards;
}
@keyframes bossIconReveal {
  0%   { opacity: 0; transform: scale(0.3) rotate(-10deg); }
  50%  { opacity: 1; transform: scale(1.3) rotate(5deg); }
  75%  { transform: scale(0.9) rotate(-2deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

/* ── Boss attack flash text ───────────────────────────────────── */
#boss-attack-flash {
  display: none;
  position: fixed;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  font-size: 2rem;
  font-weight: 900;
  color: #ef5350;
  text-shadow: 0 0 30px rgba(239,83,80,1), 0 0 60px rgba(239,83,80,0.5);
  letter-spacing: 0.15em;
  z-index: 180;
  pointer-events: none;
  white-space: nowrap;
}
#boss-attack-flash.show-flash {
  display: block;
  animation: bossFlashText 0.8s cubic-bezier(0.34,1.3,0.64,1) forwards;
}
@keyframes bossFlashText {
  0%   { transform: translate(-50%, -50%) scale(0) rotate(-5deg); opacity: 0; }
  15%  { transform: translate(-50%, -50%) scale(1.3) rotate(3deg); opacity: 1; }
  30%  { transform: translate(-50%, -50%) scale(0.95) rotate(-1deg); }
  50%  { transform: translate(-50%, -50%) scale(1.05); }
  80%  { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.2); opacity: 0; }
}

/* Boss card dramatic shake */
.battle-card.boss-attacking {
  box-shadow: 0 0 30px rgba(239,83,80,0.8), 0 0 60px rgba(239,83,80,0.4) !important;
  border-color: #ef5350 !important;
  animation: bossCardShake 0.4s ease-out;
}
@keyframes bossCardShake {
  0%   { transform: translateX(0); }
  20%  { transform: translateX(8px) rotate(1deg); }
  40%  { transform: translateX(-6px) rotate(-1deg); }
  60%  { transform: translateX(5px) rotate(0.5deg); }
  80%  { transform: translateX(-3px); }
  100% { transform: translateX(0); }
}

/* Boss HP bar upgrade */
#opponent-hp-bar-wrap .hp-bar-wrap {
  width: 220px;
  height: 24px;
  background: rgba(0,0,0,0.6);
  border: 2px solid #c62828;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 0 15px rgba(198,40,40,0.5);
}
#opponent-hp-bar-wrap .hp-bar-wrap .hp-bar {
  height: 100%;
  border-radius: 10px;
  transition: width 0.4s ease;
  background: linear-gradient(90deg, #b71c1c, #ef5350);
  box-shadow: inset 0 2px 4px rgba(255,255,255,0.2), 0 0 8px rgba(239,83,80,0.5);
}
#opponent-hp-bar-wrap.boss-hp-label::before {
  content: 'BOSS HP';
  position: absolute;
  top: -16px;
  left: 0;
  font-size: 0.6rem;
  font-weight: 800;
  color: #ef5350;
  letter-spacing: 0.15em;
  text-shadow: 0 0 8px rgba(239,83,80,0.8);
}

/* Boss name badge in battle header */
.boss-name-badge {
  display: inline-block;
  background: linear-gradient(135deg, #c62828, #ef5350);
  color: white;
  font-size: 0.6rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}

/* ── Boss victory sequence ─────────────────────────────────────── */
#boss-victory-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 190;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.75rem;
}
#boss-victory-overlay.show { display: flex; animation: fadeIn 0.3s; }

#boss-victory-slam {
  font-size: 4rem;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 40px rgba(255,215,0,1), 0 0 80px rgba(255,215,0,0.6), 0 4px 0 #b8860b;
  letter-spacing: 0.1em;
  opacity: 0;
  transform: translateY(-60px) scale(1.5);
  animation: victorySlam 0.5s cubic-bezier(0.34,1.3,0.64,1) 0.2s forwards;
}
@keyframes victorySlam {
  0%   { opacity: 0; transform: translateY(-60px) scale(1.5); }
  50%  { opacity: 1; transform: translateY(10px) scale(0.95); }
  70%  { transform: translateY(-5px) scale(1.05); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

#boss-victory-subtitle {
  font-size: 1.2rem;
  font-weight: 700;
  color: #ef5350;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  opacity: 0;
  animation: fadeIn 0.3s ease-out 0.6s forwards;
}

#boss-victory-reward {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.5rem;
  font-weight: 800;
  opacity: 0;
  animation: rewardReveal 0.5s ease-out 0.9s forwards;
  margin-top: 0.5rem;
}
@keyframes rewardReveal {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
#boss-reward-shards {
  color: var(--gold);
  text-shadow: 0 0 15px rgba(255,215,0,0.8);
  font-size: 2rem;
}

#boss-victory-flags {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.25rem;
  opacity: 0;
  animation: fadeIn 0.3s ease-out 1.1s forwards;
}

.flawless-badge {
  background: linear-gradient(135deg, #ffd700, #ff9500);
  color: #1a0010;
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 4px 12px;
  border-radius: 20px;
  box-shadow: 0 0 20px rgba(255,215,0,0.8);
  animation: flawlessPop 0.4s cubic-bezier(0.34,1.56,0.64,1) 1.2s forwards;
  opacity: 0;
  transform: scale(0);
}
@keyframes flawlessPop {
  from { opacity: 0; transform: scale(0) rotate(-10deg); }
  to   { opacity: 1; transform: scale(1) rotate(0); }
}

/* Shard fly animation */
.shard-fly {
  position: fixed;
  font-size: 1.5rem;
  pointer-events: none;
  z-index: 195;
  animation: shardFlyToCounter 1s ease-in-out forwards;
  filter: drop-shadow(0 0 8px rgba(255,215,0,0.8));
}
@keyframes shardFlyToCounter {
  0%   { transform: scale(1) translateY(0); opacity: 1; }
  60%  { transform: scale(1.3) translateY(-30px); opacity: 1; }
  100% { transform: scale(0.5) translateY(0); opacity: 0; }
}

@keyframes shardPulse {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.4); color: var(--gold); }
  60%  { transform: scale(1.1); }
  100% { transform: scale(1); }
}
.shard-pulse { animation: shardPulse 0.6s ease-out; }

/* Confetti */
.confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 191;
  overflow: hidden;
}
.confetti-piece {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  animation: confettiFall var(--fall-duration, 2s) ease-in forwards;
  animation-delay: var(--fall-delay, 0s);
}
@keyframes confettiFall {
  0%   { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(var(--fall-rotation, 720deg)); opacity: 0; }
}

/* ── Boss defeat overlay ──────────────────────────────────────── */
#boss-defeat-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,18,0.92);
  z-index: 190;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.75rem;
}
#boss-defeat-overlay.show { display: flex; }

#boss-defeat-text {
  font-size: 3.5rem;
  font-weight: 900;
  color: #ef5350;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  text-shadow: 0 0 40px rgba(239,83,80,0.6);
  opacity: 0;
  animation: defeatFade 0.6s ease-out forwards;
}
@keyframes defeatFade {
  from { opacity: 0; transform: scale(0.8); }
  to   { opacity: 1; transform: scale(1); }
}

#boss-defeat-subtitle {
  font-size: 1rem;
  color: var(--text-dim);
  opacity: 0;
  animation: fadeIn 0.4s ease-out 0.5s forwards;
}

#boss-defeat-encourage {
  font-size: 0.9rem;
  color: var(--gold);
  font-weight: 700;
  opacity: 0;
  animation: fadeIn 0.4s ease-out 0.7s forwards;
  min-height: 1.5rem;
}

#btn-boss-retry {
  font-size: 1.1rem;
  padding: 0.8rem 2rem;
  opacity: 0;
  animation: fadeIn 0.4s ease-out 0.9s forwards;
  margin-top: 0.5rem;
}

/* ── Campaign complete celebration ────────────────────────────── */
#campaign-complete-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse 80% 80% at 50% 40%, rgba(157,78,221,0.4) 0%, rgba(10,0,18,0.98) 60%);
  z-index: 200;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
}
#campaign-complete-overlay.show { display: flex; }

#campaign-complete-slam {
  font-size: 3rem;
  font-weight: 900;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  text-shadow: 0 0 50px rgba(255,215,0,1), 0 0 100px rgba(255,215,0,0.6), 0 4px 0 #b8860b;
  opacity: 0;
  animation: campaignSlam 0.7s cubic-bezier(0.34,1.3,0.64,1) 0.2s forwards;
}
@keyframes campaignSlam {
  0%   { opacity: 0; transform: translateY(-80px) scale(1.8) rotate(-3deg); }
  60%  { opacity: 1; transform: translateY(15px) scale(0.9) rotate(1deg); }
  80%  { transform: translateY(-5px) scale(1.05); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

#campaign-complete-sub {
  font-size: 1.2rem;
  color: var(--neon-cyan);
  font-weight: 700;
  text-shadow: 0 0 20px rgba(0,229,255,0.8);
  opacity: 0;
  animation: fadeIn 0.4s ease-out 0.7s forwards;
}

#campaign-complete-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.campaign-particle {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  animation: campaignParticleUp 2s ease-out forwards;
}
@keyframes campaignParticleUp {
  0%   { transform: translateY(100vh) scale(0); opacity: 0; }
  20%  { opacity: 1; transform: translateY(80vh) scale(1); }
  100% { transform: translateY(-20vh) scale(0.5); opacity: 0; }
}

/* Campaign node boss defeated state */
.campaign-node.boss-defeated::after {
  content: '💀 BOSS SLAYN';
  color: var(--gold);
  font-size: 0.7rem;
  font-weight: 800;
  background: rgba(255,215,0,0.15);
  border: 1px solid rgba(255,215,0,0.4);
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 0.5rem;
  letter-spacing: 0.1em;
}

/* === ACHIEVEMENTS === */
.achievements-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.achievement-counter {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--gold);
  background: rgba(255,215,0,0.1);
  border: 1px solid rgba(255,215,0,0.3);
  border-radius: 20px;
  padding: 0.4rem 1rem;
}
.achievements-categories { display: flex; flex-direction: column; gap: 1.5rem; }
.achievement-category h3 { font-size: 1rem; color: var(--neon-purple); margin-bottom: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; }
.achievement-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0.75rem; }
.achievement-card {
  background: rgba(26,0,51,0.5);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  transition: all 0.25s;
  position: relative;
  overflow: hidden;
}
.achievement-card.locked { opacity: 0.55; filter: grayscale(0.6); }
.achievement-card.unlocked {
  border-color: var(--gold);
  box-shadow: 0 0 20px rgba(255,215,0,0.2);
  background: rgba(255,215,0,0.05);
}
.achievement-card.unlocked::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,215,0,0.08), transparent);
  pointer-events: none;
}
.achievement-icon {
  font-size: 2rem;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(10,0,18,0.5);
  border: 2px solid var(--border);
}
.achievement-card.unlocked .achievement-icon {
  background: rgba(255,215,0,0.15);
  border-color: var(--gold);
  box-shadow: 0 0 12px rgba(255,215,0,0.4);
}
.achievement-card.locked .achievement-icon { filter: brightness(0.5); }
.achievement-info { flex: 1; min-width: 0; }
.achievement-name { font-size: 0.85rem; font-weight: 700; color: var(--text); margin-bottom: 0.2rem; }
.achievement-card.locked .achievement-name { color: var(--text-dim); }
.achievement-reward { font-size: 0.7rem; color: var(--gold); font-weight: 700; }
.achievement-card.locked .achievement-reward { color: var(--text-dim); }
.achievement-status { font-size: 0.65rem; color: var(--text-dim); margin-top: 0.2rem; }
.achievement-check { font-size: 1.2rem; color: var(--gold); flex-shrink: 0; }
.achievement-progress { height: 3px; background: rgba(255,255,255,0.1); border-radius: 2px; margin-top: 0.4rem; overflow: hidden; }
.achievement-progress-fill { height: 100%; background: linear-gradient(90deg, var(--neon-purple), var(--neon-cyan)); border-radius: 2px; transition: width 0.5s ease; }

/* Achievement Toast */
.achievement-toast {
  position: fixed;
  top: 80px;
  right: 2rem;
  background: linear-gradient(135deg, #1a0033, #2d1b69);
  border: 2px solid var(--gold);
  border-radius: 12px;
  padding: 1rem 1.5rem;
  z-index: 300;
  max-width: 340px;
  box-shadow: 0 0 40px rgba(255,215,0,0.4), 0 0 80px rgba(157,78,221,0.3);
}
.achievement-toast.show {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  animation: achievementSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes achievementSlideIn {
  0%   { opacity: 0; transform: translateX(100%) scale(0.8); }
  60%  { opacity: 1; transform: translateX(-5px) scale(1.02); }
  100% { opacity: 1; transform: translateX(0) scale(1); }
}
.achievement-toast-icon { font-size: 2rem; flex-shrink: 0; }
.achievement-toast-body { flex: 1; }
.achievement-toast-title { font-size: 0.65rem; color: var(--gold); font-weight: 800; text-transform: uppercase; letter-spacing: 0.15em; margin-bottom: 0.15rem; }
.achievement-toast-name { font-size: 0.95rem; font-weight: 700; color: var(--text); margin-bottom: 0.15rem; }
.achievement-toast-reward { font-size: 0.75rem; color: var(--gold); font-weight: 700; }

/* Achievement Panel */
.achievement-panel {
  background: var(--deep-purple);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 700px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 0 60px rgba(255,215,0,0.3);
}
.achievement-panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }
.achievement-panel-header h3 { color: var(--gold); margin-bottom: 0; }
.achievement-panel-categories { display: flex; flex-direction: column; gap: 1.25rem; margin-top: 0.5rem; }