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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  background: radial-gradient(ellipse 120% 80% at 50% 40%, #2a2210 0%, #141008 55%, #0a0804 100%);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body.obs-mode {
  background: transparent;
}

.stage {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 32px;
}

.popup {
  order: 1;
  margin-bottom: 20px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(24px) scale(0.88);
  pointer-events: none;
}

.popup.is-visible {
  visibility: visible;
  animation: popupIn 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.popup.is-hiding {
  animation: popupOut 0.55s ease forwards;
}

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

@keyframes popupOut {
  to {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-16px) scale(0.92);
  }
}

.popup-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px 24px 18px;
  background: linear-gradient(
    160deg,
    rgba(212, 175, 55, 0.22) 0%,
    rgba(139, 105, 20, 0.14) 45%,
    rgba(30, 24, 10, 0.88) 100%
  );
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: 20px;
  backdrop-filter: blur(16px);
  box-shadow:
    0 16px 48px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(212, 175, 55, 0.25),
    0 0 40px rgba(212, 175, 55, 0.18);
}

.popup.is-visible .popup-card {
  animation: popupGlow 2.5s ease-in-out infinite;
}

@keyframes popupGlow {
  0%,
  100% {
    box-shadow:
      0 16px 48px rgba(0, 0, 0, 0.5),
      0 0 0 1px rgba(212, 175, 55, 0.3),
      0 0 32px rgba(212, 175, 55, 0.14);
  }
  50% {
    box-shadow:
      0 16px 48px rgba(0, 0, 0, 0.5),
      0 0 0 1px rgba(240, 216, 120, 0.55),
      0 0 56px rgba(212, 175, 55, 0.32);
  }
}

.popup-badge {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #f0d878;
  background: rgba(212, 175, 55, 0.22);
  border: 1px solid rgba(212, 175, 55, 0.35);
  padding: 4px 12px;
  border-radius: 999px;
}

.qr-wrap {
  padding: 10px;
  background: #fff;
  border-radius: 14px;
  line-height: 0;
}

.qr-wrap img {
  display: block;
  width: 200px;
  height: 200px;
  object-fit: contain;
  border-radius: 6px;
}

.popup-hint {
  font-size: 13px;
  font-weight: 600;
  color: rgba(240, 216, 120, 0.9);
  letter-spacing: 0.3px;
}

/* Headline — semua kata pakai aturan sama */
.headline {
  order: 2;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35em 0.5em;
  font-size: clamp(2rem, 6vw, 3.25rem);
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
  color: #fff8e7;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.5), 0 0 40px rgba(212, 175, 55, 0.12);
}

.word {
  display: inline-block;
  opacity: 0;
  transform: translateY(36px);
  filter: blur(5px);
  transition:
    opacity 0.55s ease,
    transform 0.55s ease,
    filter 0.55s ease,
    color 0.4s ease,
    text-shadow 0.4s ease;
}

.word.is-visible {
  opacity: 1;
  transform: translateY(0);
  filter: blur(0);
}

.word.accent.is-visible {
  color: #f0d878;
  text-shadow: 0 0 22px rgba(212, 175, 55, 0.65), 0 0 48px rgba(184, 134, 11, 0.35);
}

.qr-wrap img.is-placeholder {
  object-fit: contain;
  padding: 16px;
  background: #f5ecd4;
}

/* Efek petir saat fade out */
.lightning-fx {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}

.lightning-fx.is-active {
  visibility: visible;
  animation: lightningScreen 0.62s ease-out forwards;
}

.lightning-flash {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 90% 70% at 50% 38%, rgba(255, 252, 235, 0.92) 0%, transparent 55%),
    radial-gradient(ellipse 60% 50% at 30% 45%, rgba(240, 216, 120, 0.45) 0%, transparent 50%),
    radial-gradient(ellipse 50% 45% at 72% 42%, rgba(255, 255, 255, 0.35) 0%, transparent 45%);
}

.lightning-bolt {
  position: absolute;
  width: clamp(70px, 12vw, 110px);
  height: auto;
  opacity: 0;
  filter: drop-shadow(0 0 14px rgba(255, 255, 220, 0.95))
    drop-shadow(0 0 28px rgba(212, 175, 55, 0.75));
}

.lightning-bolt--left {
  left: 14%;
  top: 18%;
  transform: rotate(-14deg) scale(0.85);
}

.lightning-bolt--right {
  right: 12%;
  top: 22%;
  transform: rotate(10deg) scale(0.9);
}

.lightning-fx.is-active .lightning-bolt--left {
  animation: boltStrikeLeft 0.5s ease-out forwards;
}

.lightning-fx.is-active .lightning-bolt--right {
  animation: boltStrikeRight 0.52s ease-out 0.06s forwards;
}

body:has(.lightning-fx.is-active) .stage {
  animation: lightningShake 0.45s ease-out;
}

@keyframes lightningScreen {
  0% {
    opacity: 0;
  }
  6% {
    opacity: 1;
  }
  12% {
    opacity: 0.25;
  }
  18% {
    opacity: 1;
  }
  26% {
    opacity: 0.35;
  }
  34% {
    opacity: 0.85;
  }
  100% {
    opacity: 0;
  }
}

@keyframes boltStrikeLeft {
  0% {
    opacity: 0;
    transform: rotate(-14deg) scale(0.5) translateY(-20px);
  }
  12% {
    opacity: 1;
    transform: rotate(-14deg) scale(1.05) translateY(0);
  }
  45% {
    opacity: 1;
    transform: rotate(-14deg) scale(1);
  }
  100% {
    opacity: 0;
    transform: rotate(-14deg) scale(1.15) translateY(12px);
  }
}

@keyframes boltStrikeRight {
  0% {
    opacity: 0;
    transform: rotate(10deg) scale(0.5) translateY(-16px);
  }
  14% {
    opacity: 1;
    transform: rotate(10deg) scale(1.08) translateY(0);
  }
  48% {
    opacity: 1;
    transform: rotate(10deg) scale(1);
  }
  100% {
    opacity: 0;
    transform: rotate(10deg) scale(1.12) translateY(10px);
  }
}

@keyframes lightningShake {
  0%,
  100% {
    transform: translate(0, 0);
  }
  12% {
    transform: translate(-4px, 2px);
  }
  24% {
    transform: translate(5px, -2px);
  }
  36% {
    transform: translate(-3px, 1px);
  }
  48% {
    transform: translate(3px, -1px);
  }
}
