.celebration-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  overflow: hidden;
  opacity: 0;
  transition: opacity 260ms ease;
}

.celebration-overlay.is-active {
  opacity: 1;
}

.celebration-flag {
  position: absolute;
  top: var(--top, 120px);
  left: var(--left, 50%);
  width: var(--flag-width, 120px);
  height: var(--flag-height, 88px);
  opacity: 0.88;
  transform-origin: top center;
  animation: celebration-flag-sway var(--duration, 6.4s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
  will-change: transform;
}

.celebration-flag::before {
  content: "";
  position: absolute;
  left: 16px;
  top: -4px;
  width: 6px;
  height: calc(100% + 78px);
  border-radius: 999px;
  background: linear-gradient(180deg, #e7e0d3 0%, #c8bea9 100%);
  box-shadow: 0 4px 14px rgba(64, 48, 24, 0.16);
}

.celebration-flag::after {
  content: "";
  position: absolute;
  left: 11px;
  top: -10px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f7efe0 0%, #d8ccb3 70%, #b9ae95 100%);
  box-shadow: 0 4px 10px rgba(64, 48, 24, 0.12);
}

.celebration-flag-cloth {
  position: absolute;
  top: 6px;
  left: 22px;
  width: calc(100% - 30px);
  height: 58px;
  border-radius: 3px 12px 12px 3px;
  background:
    linear-gradient(90deg,
      #c61f2b 0 28%,
      #ffffff 28% 38%,
      #1a3977 38% 48%,
      #ffffff 48% 58%,
      #c61f2b 58% 100%
    );
  box-shadow: 0 12px 22px rgba(74, 55, 28, 0.14);
  overflow: hidden;
  transform-origin: left center;
  animation: celebration-flag-wave var(--wave-duration, 3.6s) ease-in-out infinite;
}

.celebration-flag-cloth::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg,
      rgba(255, 255, 255, 0.2) 0%,
      rgba(255, 255, 255, 0.04) 36%,
      rgba(18, 28, 56, 0.08) 72%,
      rgba(18, 28, 56, 0.18) 100%
    );
}

.celebration-flag-cloth::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.1) 0 9px,
    rgba(255, 255, 255, 0) 9px 18px
  );
  mix-blend-mode: soft-light;
}

.celebration-badge {
  position: fixed;
  top: 104px;
  right: 20px;
  z-index: 41;
  max-width: min(320px, calc(100% - 32px));
  padding: 12px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: #d9362b;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  font-weight: 800;
  letter-spacing: 0.01em;
  box-shadow: 0 14px 30px rgba(74, 55, 28, 0.16);
  border: 1px solid rgba(217, 54, 43, 0.14);
  transform: translateY(-8px);
  opacity: 0;
  transition: opacity 260ms ease, transform 260ms ease;
}

.celebration-badge.is-active {
  opacity: 1;
  transform: translateY(0);
}

@keyframes celebration-flag-sway {
  0% {
    transform: rotate(-2.5deg) translateY(0);
  }

  50% {
    transform: rotate(2.5deg) translateY(3px);
  }

  100% {
    transform: rotate(-2.5deg) translateY(0);
  }
}

@keyframes celebration-flag-wave {
  0% {
    transform: perspective(180px) rotateY(2deg) skewY(1.5deg);
    border-radius: 3px 14px 10px 3px;
  }

  50% {
    transform: perspective(180px) rotateY(-9deg) skewY(-2deg);
    border-radius: 3px 10px 16px 3px;
  }

  100% {
    transform: perspective(180px) rotateY(2deg) skewY(1.5deg);
    border-radius: 3px 14px 10px 3px;
  }
}

@media (max-width: 720px) {
  .celebration-badge {
    top: 150px;
    right: 16px;
    left: 16px;
    max-width: none;
    text-align: center;
  }

  .celebration-flag {
    width: var(--flag-width-mobile, 84px);
    height: 70px;
  }

  .celebration-flag-cloth {
    height: 42px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .celebration-overlay,
  .celebration-badge {
    display: none !important;
  }
}