:root {
  --pink: #ff7eb9;
  --pink-hot: #ff4fa3;
  --lavender: #cbb7ff;
  --sky: #9ad8ff;
  --gold: #ffd76a;
  --door-w: min(56vw, 320px);
  --door-h: min(66vh, 520px);
  --wall: #2a1638;
}

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

html,
body {
  min-height: 100%;
  height: 100%;
  min-height: 100dvh;
  overflow: hidden;
  background: #1a1024;
  color: #5b2458;
  font-family: Quicksand, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32'%3E%3Ctext y='24' font-size='24'%3E🎀%3C/text%3E%3C/svg%3E") 4 4, auto;
}

@supports (-webkit-touch-callout: none) {
  html,
  body,
  .scene {
    min-height: -webkit-fill-available;
    height: -webkit-fill-available;
  }
}

button {
  font: inherit;
  -webkit-appearance: none;
  appearance: none;
}

.scene {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  -webkit-perspective: 1400px;
  perspective: 1400px;
}

.sparkle-layer,
.cursor-trail {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
}

.spark {
  position: absolute;
  font-size: 14px;
  animation: float-spark 2.8s ease-in forwards;
  filter: drop-shadow(0 0 6px #fff);
}

.trail-dot {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, #fff 0%, #ff9ad5 40%, transparent 70%);
  animation: fade-dot 0.7s ease-out forwards;
  pointer-events: none;
}

.universe {
  position: absolute;
  inset: 0;
  overflow: hidden;
  transform: scale(0.96);
  filter: blur(0.6px) brightness(0.72);
  transition: transform 1.8s ease, filter 1.8s ease;
}

.scene.opened .universe {
  filter: blur(0) brightness(1);
  transform: scale(1);
}

.sky {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, #fff6ff 0%, transparent 28%),
    radial-gradient(circle at 80% 10%, #ffe27a 0%, transparent 24%),
    linear-gradient(180deg, #9ad8ff 0%, #d7b6ff 32%, #ffb4e6 58%, #ffe6f7 100%);
}

.stars span {
  position: absolute;
  color: #fff;
  animation: twinkle 2s ease-in-out infinite;
  text-shadow: 0 0 8px #fff;
}

.rainbow {
  position: absolute;
  left: 50%;
  top: 8%;
  width: min(90vw, 920px);
  height: 420px;
  transform: translateX(-50%);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 115%,
      transparent 52%,
      #ff5d8f 52.5%, #ff5d8f 56%,
      #ffb347 56.5%, #ffb347 60%,
      #ffe566 60.5%, #ffe566 64%,
      #7dffb3 64.5%, #7dffb3 68%,
      #7ecbff 68.5%, #7ecbff 72%,
      #c9a7ff 72.5%, #c9a7ff 76%,
      transparent 76.5%);
  opacity: 0.9;
  filter: drop-shadow(0 10px 18px rgba(255, 255, 255, 0.35));
}

.cloud {
  position: absolute;
  background: #fff;
  border-radius: 999px;
  box-shadow:
    28px 8px 0 #fff,
    52px 4px 0 #fff,
    18px -14px 0 #fff,
    40px -10px 0 #fff;
  opacity: 0.92;
  animation: drift 18s linear infinite;
}

.cloud-a { width: 70px; height: 34px; top: 14%; left: 8%; animation-duration: 22s; }
.cloud-b { width: 90px; height: 38px; top: 22%; left: 62%; animation-duration: 26s; animation-delay: -8s; }
.cloud-c { width: 54px; height: 26px; top: 32%; left: 40%; animation-duration: 19s; animation-delay: -4s; }
.cloud-d { width: 80px; height: 32px; top: 10%; left: 78%; animation-duration: 24s; animation-delay: -12s; }

.hills {
  position: absolute;
  left: -10%;
  right: -10%;
  bottom: 0;
  height: 38%;
  background:
    radial-gradient(ellipse at 20% 120%, #b6f3c8 0 42%, transparent 43%),
    radial-gradient(ellipse at 55% 130%, #f7b6e8 0 48%, transparent 49%),
    radial-gradient(ellipse at 88% 120%, #c9b6ff 0 44%, transparent 45%),
    linear-gradient(#9af0c2, #7ed9a8);
  border-radius: 50% 50% 0 0 / 28% 28% 0 0;
}

.castle {
  position: absolute;
  left: 50%;
  bottom: 26%;
  width: 180px;
  height: 170px;
  transform: translateX(-50%);
  filter: drop-shadow(0 12px 0 rgba(255, 182, 230, 0.35));
}

.castle-keep {
  position: absolute;
  left: 40px;
  bottom: 0;
  width: 100px;
  height: 110px;
  background: linear-gradient(#ffe9fb, #ffc2ea);
  border: 4px solid #fff;
  border-radius: 8px 8px 0 0;
}

.castle-keep::after {
  content: "";
  position: absolute;
  inset: 14px 18px auto;
  height: 28px;
  background: #9ad8ff;
  border: 3px solid #fff;
  border-radius: 6px 6px 18px 18px;
}

.castle-tower {
  position: absolute;
  bottom: 0;
  width: 48px;
  height: 140px;
  background: linear-gradient(#fff0fb, #ffb7e4);
  border: 4px solid #fff;
  border-radius: 10px 10px 0 0;
}

.castle-tower::before {
  content: "";
  position: absolute;
  left: -10px;
  top: -28px;
  border-left: 34px solid transparent;
  border-right: 34px solid transparent;
  border-bottom: 32px solid #ff6fb2;
}

.castle-tower.left { left: 8px; }
.castle-tower.right { right: 8px; height: 150px; }

.castle-door {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 28px;
  height: 38px;
  transform: translateX(-50%);
  background: #c26bff;
  border: 3px solid #fff;
  border-radius: 14px 14px 0 0;
}

.castle-flag {
  position: absolute;
  left: 86px;
  top: -18px;
  width: 4px;
  height: 36px;
  background: #fff;
}

.castle-flag::after {
  content: "♥";
  position: absolute;
  left: 4px;
  top: 0;
  color: #ff4fa3;
  font-size: 22px;
}

.flowers span {
  position: absolute;
  bottom: 6%;
  font-size: 22px;
  animation: bob 3s ease-in-out infinite;
}

.pony {
  position: absolute;
  bottom: 8%;
  left: var(--x);
  width: min(30vw, 260px);
  animation: trot 2.4s ease-in-out infinite;
  animation-delay: var(--delay);
  z-index: 3;
  filter: drop-shadow(0 10px 0 rgba(255, 120, 190, 0.18));
}

.pony svg {
  width: 100%;
  overflow: visible;
}

.pony .body,
.pony .head,
.pony .neck,
.pony .snout,
.pony .leg {
  fill: var(--coat);
}

.pony .belly { fill: #fff; opacity: 0.35; }
.pony .hoof { fill: #f4c6de; }
.pony .tail,
.pony .mane,
.pony .ear {
  fill: var(--mane);
}

.pony .ear.inner { fill: #ffd0ea; }
.pony .eye-white { fill: #fff; }
.pony .eye { fill: #3b2458; }
.pony .shine { fill: #fff; }
.pony .lash,
.pony .smile {
  fill: none;
  stroke: #3b2458;
  stroke-width: 3;
  stroke-linecap: round;
}
.pony .nostril { fill: #d37aa8; }
.pony .cutie { fill: var(--mark); }
.pony .horn { fill: #ffe56a; stroke: #ffc44a; stroke-width: 2; }
.pony .wing { fill: #fff; opacity: 0.92; }
.pony .heart-mark { fill: #ff4fa3; font-size: 28px; font-family: Georgia, serif; }
.pony .star { fill: #ffe56a; }

.pony.pegasus { --coat: #ffd6f2; --mane: #ff5db1; --mark: #ff8ad4; }
.pony.unicorn { --coat: #ddd4ff; --mane: #8b6cff; --mark: #ffe56a; }
.pony.earth { --coat: #c4f3ff; --mane: #3fc4ff; --mark: #ff7eb9; }

.pony.pegasus .wing {
  animation: flap 1.2s ease-in-out infinite;
  transform-origin: 92px 118px;
}

.invite {
  position: absolute;
  left: 50%;
  top: 42%;
  z-index: 5;
  width: min(92vw, 640px);
  padding: 28px 24px 22px;
  transform: translate(-50%, -40%) scale(0.6);
  opacity: 0;
  text-align: center;
  background: linear-gradient(#fffafd, #ffe6f6);
  border: 6px solid #fff;
  border-radius: 28px;
  box-shadow:
    0 0 0 6px #ff8ac8,
    0 18px 40px rgba(255, 90, 170, 0.35),
    inset 0 0 40px rgba(255, 182, 230, 0.45);
  pointer-events: none;
}

.scene.entered .invite {
  animation: pop-invite 1s cubic-bezier(0.2, 1.4, 0.3, 1) forwards;
}

.invite-glitter {
  position: absolute;
  inset: 8px;
  border-radius: 20px;
  background-image: radial-gradient(#fff 1px, transparent 1px);
  background-size: 14px 14px;
  opacity: 0.35;
  pointer-events: none;
}

.invite-kicker {
  font-size: 0.95rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #ff4fa3;
  margin-bottom: 6px;
}

.invite h1 {
  font-family: "Cherry Bomb One", "Comic Sans MS", cursive;
  font-size: clamp(3.2rem, 10vw, 6rem);
  font-weight: 400;
  line-height: 1;
  background: linear-gradient(90deg, #ff4fa3, #c26bff, #62c2ff, #ff4fa3);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: shimmer 3s linear infinite;
}

.invite-line {
  font-family: Pacifico, cursive;
  font-size: clamp(1.25rem, 4vw, 2rem);
  margin: 8px 0 4px;
  color: #7a3a86;
}

.invite-date {
  font-family: "Cherry Bomb One", cursive;
  font-size: clamp(1.6rem, 5vw, 2.6rem);
  color: #ff4fa3;
  text-shadow: 0 0 12px #fff, 0 0 18px #ff9ad5;
}

.invite-spark {
  margin-top: 8px;
  font-size: 1.4rem;
  letter-spacing: 0.25em;
}

.hallway {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr var(--door-w) 1fr;
  grid-template-rows: 1fr var(--door-h) 1fr;
  -webkit-perspective: 1400px;
  perspective: 1400px;
  transition: opacity 1.15s ease 0.2s, transform 1.8s ease;
}

.scene.entered .hallway {
  opacity: 0;
  transform: scale(1.4);
  pointer-events: none;
}

.wall {
  background:
    repeating-linear-gradient(90deg, #2a1638 0 28px, #321c42 28px 56px);
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.28);
}

.wall::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(#ff8ac8 1.6px, transparent 1.7px);
  background-size: 48px 48px;
  opacity: 0.22;
  pointer-events: none;
}

.wall-top { grid-column: 1 / -1; grid-row: 1; position: relative; }
.wall-left { grid-column: 1; grid-row: 2; position: relative; }
.wall-right { grid-column: 3; grid-row: 2; position: relative; }
.wall-bottom { grid-column: 1 / -1; grid-row: 3; position: relative; }

.floor {
  grid-column: 1 / -1;
  grid-row: 3;
  position: relative;
  background: linear-gradient(#4a2a3a, #1a0e18);
  box-shadow: inset 0 30px 50px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 52%, transparent 18%, rgba(8, 0, 16, 0.66) 100%);
  -webkit-mask-image:
    linear-gradient(#000, #000),
    linear-gradient(#000, #000);
  -webkit-mask-size: 100% 100%, var(--door-w) var(--door-h);
  -webkit-mask-position: 0 0, center center;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-composite: xor;
  mask-image:
    linear-gradient(#000, #000),
    linear-gradient(#000, #000);
  mask-size: 100% 100%, var(--door-w) var(--door-h);
  mask-position: 0 0, center center;
  mask-repeat: no-repeat;
  mask-composite: exclude;
}

.hint {
  grid-column: 1 / -1;
  grid-row: 1;
  align-self: center;
  justify-self: center;
  z-index: 3;
  font-family: Pacifico, cursive;
  font-size: clamp(1.2rem, 3vw, 2rem);
  color: #ffe6f7;
  text-shadow: 0 0 16px #ff7eb9, 0 4px 0 #5b2458;
  animation: pulse 1.6s ease-in-out infinite;
  pointer-events: none;
}

.door-wrap {
  grid-column: 2;
  grid-row: 2;
  position: relative;
  width: 100%;
  height: 100%;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  overflow: visible;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  -webkit-transform-style: preserve-3d;
  transform-style: preserve-3d;
}

.door-wrap:focus-visible {
  outline: 4px dashed #ffd76a;
  outline-offset: 8px;
  border-radius: 12px;
}

.portal-glow {
  position: absolute;
  inset: 12px;
  border-radius: 8px;
  background: radial-gradient(circle, #fff6c2 0%, #ffc2ea 42%, transparent 70%);
  opacity: 0.35;
  filter: blur(8px);
  pointer-events: none;
}

.scene.opened .portal-glow {
  opacity: 1;
  animation: underglow 1.1s ease-in-out infinite;
}

.door-glow {
  position: absolute;
  left: 10%;
  right: 10%;
  bottom: -6px;
  height: 16px;
  border-radius: 50%;
  background: #ffe9a8;
  filter: blur(10px);
  box-shadow: 0 0 40px 16px rgba(255, 214, 120, 0.55);
  animation: underglow 1.4s ease-in-out infinite;
  pointer-events: none;
}

.door-frame {
  position: relative;
  width: 100%;
  height: 100%;
  border: 14px solid #e8c547;
  background: transparent;
  border-radius: 16px 16px 6px 6px;
  box-shadow:
    0 0 0 4px #7a4a10,
    0 20px 40px rgba(0, 0, 0, 0.45),
    inset 0 0 0 5px #9a6a12;
  -webkit-transform-style: preserve-3d;
  transform-style: preserve-3d;
  -webkit-perspective: 1400px;
  perspective: 1400px;
  -webkit-perspective-origin: 0% 50%;
  perspective-origin: 0% 50%;
}

.door {
  width: 100%;
  height: 100%;
  -webkit-transform-origin: left center;
  transform-origin: left center;
  -webkit-transform-style: preserve-3d;
  transform-style: preserve-3d;
  -webkit-transform: rotateY(0deg);
  transform: rotateY(0deg);
  -webkit-transition: -webkit-transform 2.2s cubic-bezier(0.15, 0.7, 0.2, 1);
  transition: transform 2.2s cubic-bezier(0.15, 0.7, 0.2, 1);
}

.scene.opened .door {
  -webkit-transform: rotateY(-105deg);
  transform: rotateY(-105deg);
}

.scene.opened .hint {
  opacity: 0;
  animation: none;
}

.door-face {
  position: relative;
  width: 100%;
  height: 100%;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.18), transparent 10%),
    linear-gradient(#ff8ac8, #ff5eac 55%, #ff4a9e);
  box-shadow: inset 0 0 0 5px #ffd1ea;
  overflow: hidden;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.door-wrap:hover .door-face {
  filter: brightness(1.08);
}

.door-panel {
  position: absolute;
  left: 12%;
  right: 12%;
  border: 4px solid rgba(255, 220, 240, 0.7);
  border-radius: 12px;
  box-shadow: inset 0 0 18px rgba(255, 255, 255, 0.25);
}

.door-panel.top { top: 10%; height: 28%; }
.door-panel.bottom { bottom: 10%; height: 34%; }

.door-window {
  position: absolute;
  top: 16%;
  left: 50%;
  width: 86px;
  height: 86px;
  transform: translateX(-50%) rotate(45deg);
  background: radial-gradient(circle, #fff6c2, #9ad8ff 60%, #c9a7ff);
  border: 5px solid #ffe9a8;
  box-shadow: 0 0 20px rgba(255, 255, 210, 0.8);
  display: grid;
  place-items: center;
}

.window-heart {
  transform: rotate(-45deg);
  color: #ff4fa3;
  font-size: 34px;
  text-shadow: 0 0 8px #fff;
}

.door-knob {
  position: absolute;
  right: 14px;
  top: 52%;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff6c2, #e0b000);
  box-shadow: 0 0 12px #ffe56a, 6px 2px 0 #b8860b;
}

.door-ornament {
  position: absolute;
  left: 50%;
  bottom: 16%;
  transform: translateX(-50%);
  color: #ffe9a8;
  font-size: 28px;
}

.door-ornament::before {
  content: "✦ ♥ ✦";
}

.mute {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 50;
  border: 3px solid #fff;
  background: #ff7eb9;
  color: #fff;
  padding: 10px 14px;
  border-radius: 999px;
  box-shadow: 0 6px 0 #c44583;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.mute[hidden] {
  display: none;
}

.mute:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 #c44583;
}

@keyframes drift {
  from { transform: translateX(0); }
  to { transform: translateX(-40px); }
}

@keyframes trot {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes flap {
  0%, 100% { transform: rotate(-8deg); }
  50% { transform: rotate(16deg); }
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes twinkle {
  0%, 100% { opacity: 0.2; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.06); opacity: 1; }
}

@keyframes underglow {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

@keyframes shimmer {
  from { background-position: 0% 50%; }
  to { background-position: 220% 50%; }
}

@keyframes pop-invite {
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes float-spark {
  0% { transform: translateY(0) scale(0.6) rotate(0deg); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translateY(-110px) scale(1.2) rotate(40deg); opacity: 0; }
}

@keyframes fade-dot {
  to { opacity: 0; transform: translate(-50%, -50%) scale(0.2); }
}

@media (max-width: 700px) {
  :root {
    --door-w: min(78vw, 280px);
    --door-h: min(62vh, 440px);
  }

  .pony {
    width: min(44vw, 190px);
    bottom: 7%;
  }

  .invite {
    top: 46%;
    padding: 22px 16px 16px;
  }

  .rainbow {
    height: 280px;
  }

  .door-window {
    width: 64px;
    height: 64px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
