:root {
  --badge-bg: rgba(7, 10, 18, 0.72);
  --badge-card-bg: linear-gradient(
    180deg,
    rgba(25, 29, 45, 0.96),
    rgba(12, 15, 25, 0.96)
  );
  --badge-gold-1: #ffd76a;
  --badge-gold-2: #ffb800;
  --badge-text: #ffffff;
  --badge-muted: #d0d6e2;
  --badge-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  --badge-radius: 24px;
  --badge-z: 99999;
  --badge-font:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

.badge-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--badge-z);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--badge-bg);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
  overflow: hidden;
}

.badge-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.badge-ambient-glow {
  position: absolute;
  width: 560px;
  height: 560px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(255, 215, 106, 0.3) 0%,
    rgba(255, 184, 0, 0.15) 28%,
    rgba(255, 255, 255, 0.02) 55%,
    rgba(255, 255, 255, 0) 70%
  );
  filter: blur(12px);
  transform: scale(0.85);
  opacity: 0;
  animation: badgeGlowIn 700ms ease forwards;
}

.badge-card {
  position: relative;
  width: min(92vw, 540px);
  border-radius: var(--badge-radius);
  background: var(--badge-card-bg);
  box-shadow: var(--badge-shadow);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 28px 24px 24px;
  color: var(--badge-text);
  font-family: var(--badge-font);
  transform: translateY(18px) scale(0.88);
  opacity: 0;
  filter: blur(10px);
  overflow: hidden;
}

.badge-overlay.show .badge-card {
  animation: badgeCardIn 650ms cubic-bezier(0.2, 0.9, 0.2, 1) forwards;
}

.badge-card::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.28),
    rgba(255, 215, 106, 0.45),
    rgba(255, 255, 255, 0.1)
  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.badge-shine {
  position: absolute;
  top: -20%;
  left: -35%;
  width: 40%;
  height: 160%;
  transform: rotate(18deg);
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.22),
    transparent
  );
  filter: blur(5px);
  animation: badgeShine 1.6s ease 0.45s 1;
  pointer-events: none;
}

.badge-header {
  display: flex;
  align-items: center;
  gap: 18px;
  position: relative;
  z-index: 2;
}

.badge-icon-wrap {
  position: relative;
  flex: 0 0 96px;
  width: 96px;
  height: 96px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(
      circle at 30% 30%,
      rgba(255, 255, 255, 0.22),
      rgba(255, 255, 255, 0.05) 35%,
      rgba(255, 255, 255, 0.02) 60%
    ),
    linear-gradient(180deg, rgba(255, 215, 106, 0.18), rgba(255, 184, 0, 0.08));
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 0 0 8px rgba(255, 215, 106, 0.04),
    0 10px 30px rgba(0, 0, 0, 0.35);
  transform: scale(0.8);
  opacity: 0;
}

.badge-overlay.show .badge-icon-wrap {
  animation: badgeIconIn 580ms cubic-bezier(0.18, 0.89, 0.32, 1.28) 0.18s
    forwards;
}

.badge-icon-wrap::after {
  content: "";
  position: absolute;
  inset: -12px;
  border-radius: 28px;
  background: radial-gradient(
    circle,
    rgba(255, 215, 106, 0.22),
    rgba(255, 215, 106, 0)
  );
  opacity: 0.8;
  z-index: -1;
  animation: badgePulseGlow 2s ease-in-out infinite;
}

.badge-icon {
  width: 100px;
  height: 100px;
  object-fit: contain;
  filter: drop-shadow(0 8px 18px rgba(255, 184, 0, 0.18));
}

.badge-copy {
  min-width: 0;
}

.badge-kicker {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--badge-gold-1);
  font-weight: 800;
  margin-bottom: 8px;
  opacity: 0;
  transform: translateY(8px);
}

.badge-title {
  font-size: clamp(24px, 4vw, 34px);
  line-height: 1.04;
  font-weight: 900;
  margin: 0 0 8px;
  opacity: 0;
  transform: translateY(10px);
  text-wrap: balance;
}

.badge-description {
  font-size: 15px;
  line-height: 1.45;
  color: var(--badge-muted);
  margin: 0;
  opacity: 0;
  transform: translateY(10px);
}

.badge-overlay.show .badge-kicker {
  animation: badgeTextIn 420ms ease 0.3s forwards;
}

.badge-overlay.show .badge-title {
  animation: badgeTextIn 460ms ease 0.42s forwards;
}

.badge-overlay.show .badge-description {
  animation: badgeTextIn 460ms ease 0.54s forwards;
}

.badge-footer {
  position: relative;
  z-index: 2;
  margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transform: translateY(8px);
}

.badge-overlay.show .badge-footer {
  animation: badgeTextIn 420ms ease 0.66s forwards;
}

.badge-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.84);
}

.badge-chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff, var(--badge-gold-1));
  box-shadow: 0 0 12px rgba(255, 215, 106, 0.8);
}

.badge-particles {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.badge-particle {
  position: absolute;
  width: var(--size);
  height: var(--size);
  left: var(--x);
  top: var(--y);
  border-radius: 50%;
  background: radial-gradient(
    circle at 35% 35%,
    rgba(255, 255, 255, 0.95),
    rgba(255, 215, 106, 0.95) 45%,
    rgba(255, 184, 0, 0.65) 70%,
    rgba(255, 184, 0, 0) 100%
  );
  opacity: 0;
  filter: blur(0.3px);
  animation: particleBurst var(--dur) ease-out var(--delay) forwards;
}

.badge-exit {
  opacity: 0;
  transition: opacity 0.32s ease 0.12s;
}

@keyframes badgeGlowIn {
  from {
    opacity: 0;
    transform: scale(0.75);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes badgeCardIn {
  0% {
    opacity: 0;
    transform: translateY(18px) scale(0.88);
    filter: blur(10px);
  }

  70% {
    opacity: 1;
    transform: translateY(0) scale(1.02);
    filter: blur(0);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes badgeIconIn {
  0% {
    opacity: 0;
    transform: scale(0.45) rotate(-10deg);
  }

  70% {
    opacity: 1;
    transform: scale(1.08) rotate(2deg);
  }

  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

@keyframes badgeTextIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes badgeShine {
  0% {
    transform: translateX(0) rotate(18deg);
    opacity: 0;
  }

  20% {
    opacity: 1;
  }

  100% {
    transform: translateX(460px) rotate(18deg);
    opacity: 0;
  }
}

@keyframes badgePulseGlow {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.55;
  }

  50% {
    transform: scale(1.08);
    opacity: 0.9;
  }
}

@keyframes particleBurst {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.4);
  }

  10% {
    opacity: 1;
  }

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

@media (prefers-reduced-motion: reduce) {
  .badge-overlay,
  .badge-card,
  .badge-icon-wrap,
  .badge-kicker,
  .badge-title,
  .badge-description,
  .badge-footer,
  .badge-ambient-glow,
  .badge-particle,
  .badge-shine {
    animation: none !important;
    transition: none !important;
    filter: none !important;
  }

  .badge-overlay {
    opacity: 1;
  }

  .badge-card,
  .badge-icon-wrap,
  .badge-kicker,
  .badge-title,
  .badge-description,
  .badge-footer {
    opacity: 1 !important;
    transform: none !important;
  }
}

.badge-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  font-family: Inter, system-ui;
}

.badge-stage {
  width: 520px;
  background: #0f1320;
  border-radius: 20px;
  padding: 30px;
  text-align: center;
  color: white;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.badge-light {
  width: 220px;
  height: 220px;
  margin: auto;
  border-radius: 50%;
  background: radial-gradient(circle, #ffd76a, rgba(255, 184, 0, 0));
  filter: blur(10px);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(0.9);
    opacity: 0.6;
  }

  50% {
    transform: scale(1.1);
    opacity: 1;
  }

  100% {
    transform: scale(0.9);
    opacity: 0.6;
  }
}

.badge-title {
  font-size: 28px;
  font-weight: 800;
}

.badge-desc {
  opacity: 0.8;
  margin-top: 6px;
}

.badge-xp {
  margin-top: 18px;
  font-size: 18px;
  color: #ffd76a;
  font-weight: 700;
}

.badge-btn {
  margin-top: 24px;
  background: #ffd76a;
  color: black;
  border: none;
  padding: 12px 26px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  font-size: 16px;
}

.xp-toast {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 320px;
  background: var(--badge-card-bg);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 16px 20px;
  color: var(--badge-text);
  font-family: var(--badge-font);
  z-index: var(--badge-z);
  box-shadow: var(--badge-shadow);
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  /* No bloquea clics debajo de él */
}

.xp-toast.show {
  animation: toastIn 500ms cubic-bezier(0.2, 0.9, 0.2, 1) forwards;
}

@keyframes toastIn {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
