.event-popup-rail {
  position: fixed;
  z-index: 150;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  width: 320px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px - env(safe-area-inset-bottom));
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: 22px;
  color: #fff;
  background: #2a1020;
  box-shadow: 0 22px 64px rgba(24, 7, 17, .42), 0 6px 18px rgba(24, 7, 17, .28);
  scrollbar-width: thin;
}

.event-popup-rail[hidden] { display: none; }

.event-popup {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 28px 22px 22px;
  text-align: center;
  animation: event-popup-enter .28s ease-out both;
}

.event-popup--purchase { padding: 0; }

.event-popup__close {
  position: absolute;
  z-index: 2;
  top: 9px;
  right: 9px;
  display: grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: 50%;
  color: #fff;
  background: rgba(42, 16, 32, .9);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
  font: 700 25px/1 Arial, sans-serif;
  cursor: pointer;
}

.event-popup__close:hover { background: #76284d; }

.event-popup__close:focus-visible,
.event-popup__cta:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.event-popup__media {
  width: 100%;
  overflow: hidden;
  border-radius: 21px 21px 0 0;
  background: #f5ede2;
}

.event-popup__media img {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(260px, 38vh);
  max-height: min(260px, 38dvh);
  object-fit: contain;
}

.event-popup__content {
  display: grid;
  width: 100%;
  gap: 11px;
  padding: 18px 22px 22px;
  justify-items: center;
}

.event-popup__title {
  max-width: 250px;
  font: 800 1.25rem/1.18 var(--sans, Arial, sans-serif);
}

.event-popup__message {
  margin: 0;
  color: rgba(255, 255, 255, .84);
  font-size: .94rem;
  line-height: 1.45;
}

.event-popup__cta {
  display: flex;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: #2a1020;
  background: #f5ede2;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .24);
  font-size: .82rem;
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: .045em;
  text-decoration: none;
}

.event-popup__cta:hover { background: #fff; }

.event-popup__status-icon {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 50%;
  color: #2a1020;
  background: #f5ede2;
  font-size: 1.55rem;
  font-weight: 900;
}

.event-popup__platform {
  display: flex;
  min-height: 24px;
  align-items: center;
  gap: 7px;
  color: rgba(255, 255, 255, .8);
  font-size: .82rem;
  font-weight: 700;
}

.event-popup__platform-icon {
  width: 22px;
  height: 22px;
  fill: currentColor;
  object-fit: contain;
}

.event-popup--discord { background: linear-gradient(145deg, #2a1020 0%, #4b397e 100%); }
.event-popup--telegram { background: linear-gradient(145deg, #2a1020 0%, #17688d 100%); }

@keyframes event-popup-enter {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 760px) {
  .event-popup-rail {
    right: auto;
    bottom: calc(12px + env(safe-area-inset-bottom));
    left: 50%;
    width: 300px;
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px - env(safe-area-inset-bottom));
    transform: translateX(-50%);
  }

  .event-popup { gap: 10px; padding: 26px 18px 18px; }
  .event-popup--purchase { padding: 0; }
  .event-popup__content { padding: 16px 18px 18px; }
  .event-popup__media img { max-height: min(220px, 34vh); max-height: min(220px, 34dvh); }
  .event-popup__close { width: 44px; height: 44px; }
  .event-popup__cta { min-height: 50px; }
}

.event-popup-settings { margin-bottom: 24px; padding: 24px; border: 1px solid #d9c8cd; border-radius: 12px; }
.event-popup-settings form { display: grid; gap: 16px; align-items: start; max-width: 480px; }

@media (max-width: 480px) {
  .event-popup-settings { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .event-popup { animation: none; }
}
