.halloween-ghost {
  position: fixed;
  top: 0;
  left: 0;
  width: 60px;
  height: 60px;
  pointer-events: auto;
  /* Permite hacer clic */
  cursor: pointer;
  z-index: 99999;
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.6)) drop-shadow(0 0 20px rgba(186, 104, 200, 0.5));
  will-change: transform, opacity;
  opacity: 0.88;
  user-select: none;
  -webkit-user-select: none;
  transition: opacity 0.4s ease-in-out, filter 0.3s ease-out;
}

/* Modo translúcido cuando el usuario escribe en inputs/formularios */
.halloween-ghost.ghost-typing-mode {
  opacity: 0.18 !important;
  pointer-events: none !important;
  /* No bloquea clics ni selección */
  filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.3)) !important;
}

.halloween-ghost:hover {
  filter: drop-shadow(0 0 15px rgba(255, 165, 0, 0.9)) drop-shadow(0 0 25px rgba(255, 215, 0, 0.7));
}

.halloween-ghost svg {
  width: 100%;
  height: 100%;
  display: block;
}

.halloween-ghost .ghost-body {
  animation: ghost-bob 3s ease-in-out infinite alternate;
}

/* Efecto de explosión/desvanecimiento al hacer clic */
.halloween-ghost.ghost-popped {
  pointer-events: none !important;
  animation: ghost-vanish 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards !important;
}

@keyframes ghost-vanish {
  0% {
    transform: scale(1);
    opacity: 1;
    filter: drop-shadow(0 0 25px #ff5722) brightness(1.5);
  }

  50% {
    transform: scale(1.6) rotate(15deg);
    opacity: 0.8;
  }

  100% {
    transform: scale(2.2) rotate(-20deg);
    opacity: 0;
    filter: drop-shadow(0 0 40px #ffeb3b) brightness(2);
  }
}

/* Texto flotante "¡BOO!", "¡🎃!", etc. al hacer clic */
.halloween-ghost-pop-text {
  position: fixed;
  pointer-events: none;
  z-index: 100000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: #ff9800;
  background: rgba(20, 16, 28, 0.85);
  border: 1px solid rgba(255, 152, 0, 0.5);
  border-radius: 12px;
  padding: 3px 9px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4), 0 0 8px rgba(255, 87, 34, 0.4);
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
  animation: text-float-up 0.8s ease-out forwards;
  text-align: center;
}

/* Chispitas / confeti de Halloween */
.halloween-sparkle {
  position: fixed;
  pointer-events: none;
  z-index: 99999;
  font-size: 14px;
  animation: sparkle-burst 0.8s ease-out forwards;
}

@keyframes text-float-up {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.6);
  }

  25% {
    opacity: 1;
    transform: translate(-50%, -70%) scale(1.0);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -120%) scale(0.9);
  }
}

@keyframes sparkle-burst {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1) rotate(0deg);
  }

  100% {
    opacity: 0;
    transform: translate(var(--tx), var(--ty)) scale(0.2) rotate(360deg);
  }
}

@keyframes ghost-bob {
  0% {
    transform: translateY(0px) rotate(0deg);
  }

  50% {
    transform: translateY(-8px) rotate(3deg);
  }

  100% {
    transform: translateY(5px) rotate(-3deg);
  }
}

/* Barra/Insignia inferior para el contador de fantasmas cazados (oculta por defecto, aparece solo al hacer clic) */
#halloween-ghost-counter {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 99990;
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(26, 21, 38, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  border: 1px solid rgba(255, 152, 0, 0.6);
  border-radius: 25px;
  padding: 6px 12px 6px 10px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4), 0 0 15px rgba(255, 152, 0, 0.4);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 13px;
  font-weight: 600;
  user-select: none;
  cursor: default;
  pointer-events: none;
  opacity: 0;
  transform: translateY(20px) scale(0.9);
  transition: opacity 0.4s ease-out, transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#halloween-ghost-counter.counter-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

#halloween-ghost-counter .counter-icon {
  font-size: 18px;
  display: inline-block;
  cursor: pointer;
  animation: ghost-bob 2.5s ease-in-out infinite alternate;
}

#halloween-ghost-counter .counter-num {
  background: linear-gradient(135deg, #ff9800, #ff5722);
  color: #ffffff;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: bold;
  font-size: 13px;
  box-shadow: 0 0 8px rgba(255, 87, 34, 0.5);
}

/* Botón de historial (gráfico / lista) */
#halloween-ghost-counter .counter-history-btn {
  background: rgba(255, 255, 255, 0.12);
  color: #ffb74d;
  border: 1px solid rgba(255, 183, 77, 0.4);
  border-radius: 15px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 3px;
  margin-left: 4px;
}

#halloween-ghost-counter .counter-history-btn:hover {
  background: rgba(255, 152, 0, 0.25);
  color: #ffffff;
  border-color: #ff9800;
  transform: scale(1.05);
}

/* Animación de pulso cuando se incrementa el contador */
#halloween-ghost-counter.counter-bump {
  animation: counter-pulse 0.4s ease-out;
}

@keyframes counter-pulse {
  0% {
    transform: translateY(0) scale(1);
  }

  50% {
    transform: translateY(-3px) scale(1.18);
    border-color: #ffeb3b;
    box-shadow: 0 0 25px rgba(255, 235, 59, 0.8);
  }

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

/* Modal de Histórico de Fantasmas */
.halloween-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 8, 18, 0.75);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 100002;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.halloween-modal-backdrop.modal-open {
  opacity: 1;
  visibility: visible;
}

.halloween-modal-card {
  background: linear-gradient(145deg, #1f182c, #14101e);
  border: 1px solid rgba(255, 152, 0, 0.4);
  border-radius: 18px;
  width: 90%;
  max-width: 440px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.6), 0 0 25px rgba(255, 152, 0, 0.3);
  color: #f1f2f6;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  transform: scale(0.85);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  overflow: hidden;
}

.halloween-modal-backdrop.modal-open .halloween-modal-card {
  transform: scale(1);
}

.halloween-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 152, 0, 0.08);
}

.halloween-modal-title {
  margin: 0;
  font-size: 15px;
  font-weight: bold;
  color: #ffb74d;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.halloween-modal-close {
  background: none;
  border: none;
  color: #a4b0be;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  transition: color 0.2s ease;
}

.halloween-modal-close:hover {
  color: #ff5252;
}

.halloween-modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  max-height: calc(85vh - 120px);
}

.halloween-stats-summary {
  display: flex;
  justify-content: space-around;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 16px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.halloween-stat-box .stat-val {
  font-size: 20px;
  font-weight: bold;
  color: #ff9800;
}

.halloween-stat-box .stat-lbl {
  font-size: 11px;
  color: #a4b0be;
  text-transform: uppercase;
  margin-top: 2px;
}

.halloween-history-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.halloween-history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.03);
  margin-bottom: 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 13px;
  transition: background 0.2s ease;
}

.halloween-history-item:hover {
  background: rgba(255, 152, 0, 0.1);
  border-color: rgba(255, 152, 0, 0.3);
}

.halloween-history-item.is-today {
  border-color: rgba(255, 152, 0, 0.5);
  background: rgba(255, 152, 0, 0.08);
}

.halloween-history-item .history-date {
  color: #dfe4ea;
  display: flex;
  align-items: center;
  gap: 6px;
}

.halloween-history-item .history-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.halloween-history-item .history-count {
  font-weight: bold;
  color: #ff9800;
  background: rgba(255, 152, 0, 0.15);
  padding: 2px 10px;
  border-radius: 10px;
}

.halloween-reset-btn {
  background: rgba(231, 76, 60, 0.15);
  border: 1px solid rgba(231, 76, 60, 0.4);
  color: #ff6b6b;
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.halloween-reset-btn:hover {
  background: rgba(231, 76, 60, 0.35);
  color: #ffffff;
  border-color: #ff5252;
  transform: scale(1.04);
}

.halloween-domain-tag {
  color: #ff9800;
  background: rgba(255, 152, 0, 0.18);
  border: 1px solid rgba(255, 152, 0, 0.4);
  padding: 1px 7px;
  border-radius: 6px;
  font-size: 13px;
}

/* Opción discreta en el footer para activar/desactivar en este navegador */
.halloween-toggle-link {
  background: none;
  border: none;
  color: #747d8c;
  font-size: 11px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 2px 4px;
  transition: color 0.2s ease, opacity 0.2s ease;
  opacity: 0.8;
}

.halloween-toggle-link:hover {
  color: #ff9800;
  opacity: 1;
}

.halloween-modal-footer {
  padding: 10px 18px;
  background: rgba(0, 0, 0, 0.35);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 11px;
  color: #a4b0be;
}