#espuma-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  opacity: 1;
  transition: opacity .4s ease;
}
#espuma-overlay.espuma-hide {
  opacity: 0;
  pointer-events: none;
}

/* ── Fondo oscuro con blur ── */
#carnaval-dim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity .3s ease;
  z-index: 1;
  cursor: pointer;
}
#carnaval-dim.on { opacity: 1; }

/* ── Contenedor principal ── */
#carnaval-popup {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -48%) scale(.95);
  opacity: 0;
  transition: opacity .3s ease, transform .35s cubic-bezier(.34, 1.28, .64, 1);
  pointer-events: none;

  width: min(1024px, calc(100vw - 28px));
  height: min(686px, calc(100vh - 48px));

  border-radius: 18px;
  overflow: hidden;

  border: 1.5px solid rgba(255, 255, 255, .16);

  box-shadow:
    0 48px 120px rgba(0, 0, 0, .65),
    0 16px 40px rgba(0, 0, 0, .4),
    inset 0 1px 0 rgba(255, 255, 255, .1);

  background: #000;
  z-index: 2;
}

#carnaval-popup.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

/* ── Imagen ocupa todo el popup ── */
#carnaval-popup img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

/* ── Botón cerrar flotante ── */
#carnaval-popup .popup-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;

  box-sizing: border-box !important;
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  min-height: 36px !important;
  padding: 0 !important;
  margin: 0 !important;

  display: flex !important;
  align-items: center !important;
  justify-content: center !important;

  border-radius: 50% !important;
  border: 1.5px solid rgba(255, 255, 255, .25) !important;
  cursor: pointer;

  background: rgba(10, 10, 10, .72) !important;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);

  color: rgba(255, 255, 255, .9) !important;
  font-size: 16px !important;
  font-weight: 300 !important;
  line-height: 1 !important;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;

  transition: background .2s, border-color .2s, transform .15s, color .2s;
  outline: none !important;
  box-shadow: 0 2px 12px rgba(0,0,0,.45) !important;
}

#carnaval-popup .popup-close:hover {
  background: rgba(210, 40, 40, .85) !important;
  border-color: rgba(210, 40, 40, .6) !important;
  color: #fff !important;
  transform: scale(1.1) !important;
}

#carnaval-popup .popup-close:focus {
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .25) !important;
}

/* ── Responsive móvil ── */
@media (max-width: 768px) {
  #carnaval-popup {
    width: calc(100vw - 24px);
    height: auto;
    max-height: calc(100svh - 80px);
    border-radius: 14px;
    background: #fff;
    overflow: hidden;
  }

  /* La imagen sale de absoluto y dicta su propia altura */
  #carnaval-popup img {
    position: relative !important;
    inset: auto !important;
    width: 100% !important;
    height: auto !important;
    object-fit: unset !important;
    display: block !important;
    max-height: calc(100svh - 80px);
  }

  #carnaval-popup .popup-close {
    position: absolute !important;
    top: 8px !important;
    right: 8px !important;
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    font-size: 14px !important;
    /* fondo oscuro para contrastar con imagen clara */
    background: rgba(0, 0, 0, .55) !important;
    border-color: rgba(255, 255, 255, .3) !important;
  }
}
