body {
  margin: 0;
  background: #0A1432;
}

.advent-page {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  background: #0A1432;
}

/* =========================
   SCENE
   ========================= */

.scene {
  --ui: 1;               /* header / branches scale, set by script.js */
  --header-top: 14px;

  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  isolation: isolate;
  background: #0A1432;
}

/*
  Blurred copy of the art behind the canvas. It is only shown when the
  screen proportions force the scene to be letterboxed (very wide or
  very tall/short screens), so the empty space never looks like a bug.
*/
.scene-backdrop {
  position: absolute;
  inset: -40px;
  width: calc(100% + 80px);
  height: calc(100% + 80px);
  object-fit: cover;
  object-position: center bottom;
  filter: blur(18px) brightness(0.72) saturate(1.1);
  z-index: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.scene.is-letterboxed .scene-backdrop {
  opacity: 1;
  visibility: visible;
}

/*
  The design canvas has exactly the proportions of the scene art
  (1920 × 1080 desktop, 1170 × 2532 mobile). script.js sizes and places it;
  medallions and lanterns inside are positioned in % of it, so they always
  stay on the same windows / steps of the picture.
*/
.design-canvas {
  --cw: 1920px;          /* canvas width in px, set by script.js */

  position: absolute;
  left: 0;
  top: 0;
  width: 1920px;
  height: 1080px;
  z-index: 1;
}

.scene-art {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  z-index: 0;
  user-select: none;
  -webkit-user-drag: none;
}

/* Soft edges only when the art does not reach the edge of the screen */
.scene.is-letterboxed .scene-art {
  -webkit-mask-image:
    linear-gradient(to right, transparent 0, #000 var(--fade-x, 0px), #000 calc(100% - var(--fade-x, 0px)), transparent 100%),
    linear-gradient(to bottom, transparent 0, #000 var(--fade-top, 0px), #000 calc(100% - var(--fade-bottom, 0px)), transparent 100%);
  -webkit-mask-composite: source-in;
  mask-image:
    linear-gradient(to right, transparent 0, #000 var(--fade-x, 0px), #000 calc(100% - var(--fade-x, 0px)), transparent 100%),
    linear-gradient(to bottom, transparent 0, #000 var(--fade-top, 0px), #000 calc(100% - var(--fade-bottom, 0px)), transparent 100%);
  mask-composite: intersect;
}

.windows,
.lanterns {
  position: absolute;
  inset: 0;
}

.lanterns {
  z-index: 4;
  pointer-events: none;
}

.windows {
  z-index: 3;
}

/* =========================
   MEDALLIONS (WINDOWS)
   ========================= */

.advent-window {
  /* medallion artwork size: fraction of the canvas width (layout.json "med") */
  --w: calc(var(--med, 0.056) * var(--cw));
  --h: calc(var(--w) * 285 / 240);
  --cy: var(--circle-cy, 0.527);
  --n: var(--num, 0.279);

  position: absolute;
  left: var(--x);
  top: var(--y);

  /* (x, y) from layout.json = centre of the medallion circle.
     The button is never smaller than 44 × 44 px (tap target). */
  width: max(var(--w), 44px);
  height: max(var(--h), 44px);

  padding: 0;
  border: 0;
  background: transparent;

  transform: translate(-50%, -50%);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.advent-window.big-window {
  --w: calc(var(--med-big, 0.0625) * var(--cw));
  --h: calc(var(--w) * 404 / 340);
  --cy: var(--circle-cy-big, 0.512);
  --n: var(--num-big, 0.308);
}

.advent-window img {
  position: absolute;
  left: 50%;
  top: calc(50% - var(--cy) * var(--h));
  display: block;
  width: var(--w);
  height: var(--h);
  max-width: none;
  transform: translateX(-50%);
  pointer-events: none;
  user-select: none;
  transition: filter 0.15s ease;
}

.advent-window span {
  position: absolute;
  left: 50%;
  top: 50%;

  transform: translate(-50%, calc(-50% + 0.06em));

  color: #E6EEFFC7;
  font-family: "Cinzel", serif;
  font-weight: 900;
  font-size: calc(var(--w) * var(--n));
  line-height: 1;
  letter-spacing: -0.02em;
  white-space: nowrap;
  pointer-events: none;
}

.advent-window:focus-visible {
  outline: 2px solid #FFD978;
  outline-offset: 2px;
  border-radius: 50%;
}

.advent-window:disabled {
  cursor: default;
}

.advent-window.shake {
  animation: windowShake 0.4s ease-in-out;
}

@keyframes windowShake {
  0%, 100% {
    transform: translate(-50%, -50%) rotate(0deg);
  }

  15% {
    transform: translate(calc(-50% - 4px), -50%) rotate(-3deg);
  }

  30% {
    transform: translate(calc(-50% + 4px), -50%) rotate(3deg);
  }

  45% {
    transform: translate(calc(-50% - 3px), -50%) rotate(-2deg);
  }

  60% {
    transform: translate(calc(-50% + 3px), -50%) rotate(2deg);
  }

  75% {
    transform: translate(calc(-50% - 1px), -50%) rotate(-1deg);
  }
}

/* =========================
   MEDALLION STATES
   ========================= */

.advent-window.is-past span {
  color: #FFE7B0;
  text-shadow: 0 0.033em 0 #3C1400B2, 0 0 0.133em #00000080;
}

.advent-window.is-future span {
  color: #E6EEFFC7;
  text-shadow: 0 0.033em 0 #283C0ACC, 0 0 0.167em #FFDC78E5;
}

.advent-window.past-flash img {
  animation: pastMedallionFlash 0.5s ease;
}

@keyframes pastMedallionFlash {
  0%, 100% {
    filter: brightness(1);
  }

  50% {
    filter: brightness(1.3);
  }
}

.advent-window.future-shake {
  animation: futureWindowShake 0.38s ease;
}

@keyframes futureWindowShake {
  0%, 100% {
    translate: 0 0;
  }
  20% {
    translate: -3px 0;
  }
  40% {
    translate: 3px 0;
  }
  70% {
    translate: -2px 0;
  }
}

/* =========================
   TODAY MEDALLION
   ========================= */

.advent-window.is-today {
  z-index: 6;
}

.advent-window.is-today img {
  z-index: 1;
  animation: todayLight 2.4s ease-in-out infinite;
}

.advent-window.is-today span {
  z-index: 2;
  color: #fff;
  text-shadow:
    0 0.033em 0 #283C0ACC,
    0 0 0.167em #FFDC78E5;
  transform: translate(-50%, calc(-50% + 0.06em)) scale(1.12);
}

/* Glowing outline of today's window opening (Figma) */
.window-arch {
  display: none;
  position: absolute;
  left: 50%;
  top: calc(50% + var(--arch-dy, 0) * var(--cw));
  width: calc(var(--arch-w, 0.05) * var(--cw));
  height: calc(var(--arch-h, 0.0625) * var(--cw));
  z-index: 0;
  border: 2.5px solid #FFF1C4;
  border-radius: 999px 999px 4px 4px;
  box-shadow:
    0 0 4px 1px rgba(255, 228, 150, 0.95),
    0 0 14px 4px rgba(255, 170, 60, 0.7),
    inset 0 0 6px 1px rgba(255, 222, 135, 0.7);
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: archGlow 2.4s ease-in-out infinite;
}

.advent-window.big-window .window-arch {
  top: calc(50% + var(--arch-big-dy, 0) * var(--cw));
  width: calc(var(--arch-big-w, 0.066) * var(--cw));
  height: calc(var(--arch-big-h, 0.089) * var(--cw));
}

.advent-window.is-today .window-arch {
  display: block;
}

.advent-window.is-today.is-arriving .window-arch {
  animation:
    archArrival 1.1s ease-out,
    archGlow 2.4s ease-in-out 1.1s infinite;
}

@keyframes archGlow {
  0%, 100% {
    opacity: 0.85;
  }

  50% {
    opacity: 1;
  }
}

@keyframes archArrival {
  0% {
    opacity: 0;
  }

  100% {
    opacity: 0.85;
  }
}

.advent-window.is-today::before {
  content: "";
  position: absolute;
  width: 200%;
  height: 200%;
  left: 50%;
  top: 50%;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(
    70.71% 70.71% at 50% 50%,
    rgba(255, 214, 130, 0.5) 0%,
    rgba(255, 180, 80, 0.32) 22%,
    rgba(255, 150, 50, 0.12) 44%,
    rgba(255, 140, 40, 0) 64%
  );
  opacity: 0.8;
  transform: translate(-50%, -50%) scale(0.85);
  animation: haloBreath 1.8s ease-in-out infinite;
}

.advent-window.is-today::after {
  content: "";
  position: absolute;
  width: 115%;
  height: 115%;
  left: 50%;
  top: 50%;
  border: 2px solid rgba(255, 225, 150, 0.8);
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.5);
  opacity: 0;
  animation: beaconRing 2.2s ease-out infinite;
}

.advent-window.is-today.is-arriving::before {
  animation:
    haloArrival 1.1s ease-out forwards,
    haloBreath 1.8s ease-in-out 1.1s infinite;
}

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

  35% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.7);
  }

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

@keyframes haloBreath {
  0%, 100% {
    opacity: 0.8;
    transform: translate(-50%, -50%) scale(0.85);
  }

  50% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
  }
}

@keyframes beaconRing {
  0% {
    opacity: 0.8;
    transform: translate(-50%, -50%) scale(0.5);
  }

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

@keyframes todayLight {
  0%, 100% {
    filter: brightness(105%) drop-shadow(0 0 5px #FFDC78);
  }

  50% {
    filter: brightness(120%) drop-shadow(0 0 13px #FFDC78);
  }
}

/* =========================
   LANTERNS
   ========================= */

.advent-lantern {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: calc(var(--lantern-w, 0.026389) * var(--cw));

  /* (x, y) from layout.json = base of the lantern on the staircase */
  transform: translate(-50%, -100%);

  pointer-events: none;
}

.advent-lantern img {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
}

.advent-lantern .lantern-off {
  position: relative;
  opacity: 1;
  transition: opacity 0.35s ease;
}

.advent-lantern .lantern-on {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.advent-lantern.is-lit .lantern-off {
  opacity: 0;
}

.advent-lantern.is-lit .lantern-on {
  opacity: 1;
}

.advent-lantern::before {
  content: "";
  position: absolute;
  inset: -70%;
  z-index: -1;
  background: radial-gradient(
    circle,
    rgba(255, 205, 105, 0.65) 0%,
    rgba(255, 165, 65, 0.25) 40%,
    transparent 70%
  );
  opacity: 0;
  transition: opacity 0.5s ease;
}

.advent-lantern.is-lit::before {
  opacity: 1;
}

.advent-lantern.is-instant .lantern-off,
.advent-lantern.is-instant .lantern-on,
.advent-lantern.is-instant::before {
  transition: none;
}

/* =========================
   BRANCHES
   ========================= */

.branches {
  position: absolute;
  top: 0;
  z-index: 7;
  width: calc(var(--branch-w, 432px) * var(--ui));
  height: calc(var(--branch-h, 270px) * var(--ui));
  pointer-events: none;
  user-select: none;
  animation: branchGlow 3.6s ease-in-out infinite;
}

.branches-left {
  left: 0;
}

.branches-right {
  right: 0;
  transform: scaleX(-1);
  animation-delay: -1.8s;
}

@keyframes branchGlow {
  0% {
    filter: brightness(1);
  }

  50% {
    filter: brightness(1.18);
  }

  100% {
    filter: brightness(1);
  }
}

/* =========================
   HEADER
   ========================= */

.header {
  --hw: 820px;
  --hh: 282px;

  position: absolute;
  z-index: 8;
  top: calc(var(--header-top) * var(--ui));
  left: 50%;

  width: var(--hw);
  height: var(--hh);

  transform: translateX(-50%) scale(var(--ui));
  transform-origin: top center;
}

/*
  9-slice plate (source art 1200 × 675): corners and crown keep their
  proportions (scaled by the plate height), the edges stretch.
*/
.header-frame {
  position: absolute;
  inset: 0;

  display: grid;
  grid-template-columns:
    calc(var(--hh) * 170 / 675)
    1fr
    calc(var(--hh) * 400 / 675)
    1fr
    calc(var(--hh) * 170 / 675);
  grid-template-rows:
    calc(var(--hh) * 280 / 675)
    1fr
    calc(var(--hh) * 170 / 675);

  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.frame-piece {
  position: relative;
  display: block;
  width: calc(100% + 2px);
  height: calc(100% + 2px);
  min-width: 0;
  min-height: 0;
  object-fit: fill;
  user-select: none;
}

.top-left {
  grid-area: 1 / 1;
}

.top-edge-left {
  grid-area: 1 / 2;
}

.crown {
  grid-area: 1 / 3;
}

.top-edge-right {
  grid-area: 1 / 4;
}

.top-right {
  grid-area: 1 / 5;
}

.middle-left {
  grid-area: 2 / 1;
}

.middle-center {
  grid-area: 2 / 2 / 3 / 5;
}

.middle-right {
  grid-area: 2 / 5;
}

.bottom-left {
  grid-area: 3 / 1;
}

.bottom-center {
  grid-area: 3 / 2 / 4 / 5;
}

.bottom-right {
  grid-area: 3 / 5;
}

/* Small overlap so the 9-slice seams never show */
.top-left,
.top-edge-left,
.crown,
.top-edge-right,
.top-right,
.middle-left,
.middle-center,
.middle-right {
  margin-right: -1px;
  margin-bottom: -1px;
}

.bottom-left,
.bottom-center,
.bottom-right {
  margin-right: -1px;
}

.header-content {
  position: relative;
  z-index: 1;
}

h1 {
  font-family: "Cinzel", serif;
  font-weight: 900;
  font-size: 28px;
  line-height: 31px;
  letter-spacing: 0.28px;
  text-align: center;
  text-shadow: 0px 2px 0px #3C0A0ACC, 0px 0px 14px #FFC86459;
  color: #FFF3C9;
  margin: 103px auto 5px;
  max-width: 390px;
  position: relative;
}

h1 span {
  color: #F2C766;
}

.subtitle {
  font-weight: 400;
  font-size: 14px;
  line-height: 17px;
  text-align: center;
  color: #FFF6E4;
  position: relative;
  margin-bottom: 8px;
}

.subtitle span {
  color: #F2C766;
}

.button {
  position: relative;
  display: block;
  width: 305px;
  height: 52px;
  margin: 0 auto;
  background-color: transparent;
  border: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.button span {
  position: relative;
  z-index: 1;
  display: block;
  padding-top: 8px;
  font-family: "Cinzel", serif;
  font-weight: 800;
  font-size: 16px;
  line-height: 16px;
  letter-spacing: 0.96px;
  text-align: center;
  color: #FFF3C9;
}

.button img {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
}

.button:focus-visible {
  outline: none;
  outline-offset: 0px;
  border-radius: 0px;
}

#todayButton:disabled {
  filter: grayscale(60%) brightness(0.825);
  cursor: default;
}

/* =========================
   FOOTER
   ========================= */

.footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9;

  display: flex;
  align-items: flex-end;
  justify-content: center;

  min-height: 66px;
  padding: 0 16px calc(6px + env(safe-area-inset-bottom, 0px));

  background: linear-gradient(180deg, rgba(10, 20, 50, 0) 0%, rgba(10, 20, 50, 0.85) 45%);
}

.footer-text {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.footer-badge {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
}

.footer-text p {
  font-family: "Manrope", sans-serif;
  font-weight: 400;
  font-size: 12px;
  line-height: 16px;
  text-align: center;
  color: #E9DCC0;
  max-width: 336px;
}

/* =========================
   SOUND TOGGLE
   ========================= */

.sound-toggle {
  position: fixed;
  top: 10px;
  right: 10px;
  /* above the scene, below the modals (so it never covers a close button) */
  z-index: 900;

  width: 42px;
  height: 42px;

  padding: 0;
  border: 0;
  background: transparent;

  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.sound-toggle img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.sound-toggle:focus-visible {
  outline: 2px solid #ffd978;
  outline-offset: 4px;
  border-radius: 50%;
}

/* =========================
   SNOW
   ========================= */

.snow-layer {
  position: absolute;
  inset: 0;
  z-index: 10;
  overflow: hidden;
  pointer-events: none;
}

.snowflake {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform;
  animation: snowFall var(--fall-duration) linear infinite;
}

.snowflake-inner {
  display: block;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 1) 0%,
    rgba(230, 244, 255, .85) 45%,
    rgba(220, 240, 255, 0) 100%
  );
  will-change: transform;
  animation: snowSway var(--sway-duration) ease-in-out infinite;
}

@keyframes snowFall {
  from {
    transform: translate3d(0, -70px, 0);
  }
  to {
    transform: translate3d(0, var(--fall-distance), 0);
  }
}

@keyframes snowSway {
  0%, 100% {
    transform: translateX(calc(var(--sway) * -1));
  }
  50% {
    transform: translateX(var(--sway));
  }
}

/* =========================
   STARS
   ========================= */

.stars-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}

.star {
  position: absolute;
  display: block;

  color: #f4fbff;
  font-size: var(--star-size);
  line-height: 1;

  text-shadow:
    0 0 3px rgba(220, 245, 255, 1),
    0 0 7px rgba(130, 195, 255, 0.9),
    0 0 12px rgba(100, 170, 255, 0.45);

  opacity: 0.3;

  animation: starTwinkle var(--star-duration) ease-in-out infinite;
  animation-delay: var(--star-delay);

  will-change: opacity, filter;
}

@keyframes starTwinkle {
  0%, 100% {
    opacity: 0.3;
    filter: brightness(0.8);
  }

  50% {
    opacity: 1;
    filter: brightness(1.4);
  }
}

/* =========================
   EFFECTS LAYER (screen space)
   ========================= */

.effects-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 9;
}

/* =========================
   FLYING SPARKS
   ========================= */

.spark-flight {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    #fff 0%,
    #fff9d9 22%,
    #ffd66e 48%,
    rgba(255, 170, 55, 0) 75%
  );
  box-shadow:
    0 0 8px 3px rgba(255, 245, 190, 0.9),
    0 0 20px 7px rgba(255, 185, 70, 0.55);
  transform: translate(-50%, -50%);
  z-index: 2;
}

.spark-trail {
  position: absolute;
  border-radius: 50%;
  background: #ffe6a0;
  box-shadow: 0 0 7px 2px rgba(255, 194, 90, 0.8);
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: sparkTrailFade 0.45s ease-out forwards;
}

@keyframes sparkTrailFade {
  from {
    opacity: 0.9;
    transform: translate(-50%, -50%) scale(1);
  }

  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.1);
  }
}

/* =========================
   PARTICLE BURSTS
   ========================= */

.burst-particle {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, #ffd77a 55%, #ff9e36 100%);
  box-shadow: 0 0 7px 2px rgba(255, 205, 110, 0.8);
  transform: translate(-50%, -50%);
  animation: burstFly var(--duration) ease-out forwards;
}

@keyframes burstFly {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }

  55% {
    opacity: 0.9;
    transform: translate(
      calc(-50% + var(--dx) * 0.65),
      calc(-50% + var(--dy) * 0.55)
    ) scale(0.8);
  }

  100% {
    opacity: 0;
    transform: translate(
      calc(-50% + var(--dx)),
      calc(-50% + var(--dy))
    ) scale(0.15);
  }
}

/* =========================
   TODAY EMBERS
   ========================= */

.day-ember {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #ffe6a1;
  box-shadow: 0 0 8px 3px rgba(255, 190, 85, 0.8);
  animation: emberRise 1.4s ease-out forwards;
}

@keyframes emberRise {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.5);
  }

  20% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translate(var(--ember-x), var(--ember-y)) scale(0.1);
  }
}


/* =========================
   MODALS
   ========================= */

body.modal-open {
  overflow: hidden;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 20px;

  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);

  opacity: 0;
  visibility: hidden;
  pointer-events: none;

  transition:
    opacity 0.3s ease,
    visibility 0.3s ease;
}

.modal-overlay.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
#invitationModal.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.modal-card {
  position: relative;

  transform: translateY(12px) scale(0.86);
  opacity: 0;

  transition:
    transform 0.38s cubic-bezier(0.2, 1.3, 0.4, 1),
    opacity 0.3s ease;
}

.modal-overlay.is-open .modal-card {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.modal-close {
  position: absolute;
  z-index: 5;
  padding: 0;
  border: none;
  outline: none;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.modal-close img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.modal-close:focus-visible {
  outline: 2px solid #FFD978;
  outline-offset: 2px;
  border-radius: 50%;
}

/* =========================
   OFFER POPUP (9-slice frame)
   ========================= */

/*
  Top and bottom rows keep the artwork proportions (they scale with the
  width only); the middle row stretches to whatever height is left.
  Source pieces: top 254 px, middle 586 px, bottom 185 px at 820 px width.

  Corners and crown are scaled by --k (art px → screen px) and keep their
  proportions; the edges between them stretch. On desktop --k = 560 / 820,
  i.e. the whole frame is the artwork scaled to 560 px.

  Height: the popup is never shorter than the design height (700 px) and
  grows with its content up to the height of the screen. The text area only
  gets a scrollbar once the popup has reached that limit.
*/
.popup-frame {
  --pw: 560px;
  --k: 0.682927;
  --ph-min: min(700px, calc(100vh - 40px));
  --ph-max: calc(100vh - 40px);
  --top-h: calc(254px * var(--k));
  --bot-h: calc(185px * var(--k));
  --corner-w: calc(215px * var(--k));
  --crown-w: calc(254px * var(--k));
  --content-top: calc(var(--top-h) + 2px);
  --content-bottom: calc(var(--bot-h) + 3px);
  --content-side: 12%;

  position: relative;
  isolation: isolate;
  width: var(--pw);
  height: auto;
  min-height: var(--ph-min);
  max-height: var(--ph-max);
  flex-shrink: 0;

  display: flex;
  flex-direction: column;

  background: none;
  border: none;
  box-shadow: none;
  overflow: visible;
}

.popup-frame__row {
  position: absolute;
  left: 0;
  z-index: 1;
  width: 100%;
  display: flex;
  overflow: visible;
}

.popup-frame__row img {
  display: block;
  height: 100%;
  object-fit: fill;
  flex-shrink: 0;
  margin-right: -1px;   /* small overlap so the seams never show */
}

.popup-frame__row img:last-child {
  margin-right: 0;
}

.popup-frame__top {
  top: 0;
  height: var(--top-h);
}

/* corner | edge (stretch) | crown | edge (stretch) | corner */
.popup-frame__top img:nth-child(1),
.popup-frame__top img:nth-child(5) { width: var(--corner-w); }
.popup-frame__top img:nth-child(3) { width: var(--crown-w); }
.popup-frame__top img:nth-child(2),
.popup-frame__top img:nth-child(4) { flex: 1 0 0; width: auto; min-width: 0; }

.popup-frame__middle {
  top: calc(var(--top-h) - 1px);
  height: calc(100% - var(--top-h) - var(--bot-h) + 2px);
}

.popup-frame__middle img:nth-child(1),
.popup-frame__middle img:nth-child(3) { width: var(--corner-w); }
.popup-frame__middle img:nth-child(2) { flex: 1 0 0; width: auto; min-width: 0; }

.popup-frame__bottom {
  bottom: 0;
  height: var(--bot-h);
}

.popup-frame__bottom img:nth-child(1),
.popup-frame__bottom img:nth-child(3) { width: var(--corner-w); }
.popup-frame__bottom img:nth-child(2) { flex: 1 0 0; width: auto; min-width: 0; }

/* In normal flow: its height decides the height of the popup */
.popup-frame__content {
  position: relative;
  z-index: 2;

  flex: 1 1 auto;
  min-height: 0;
  margin:
    var(--content-top)
    var(--content-side)
    var(--content-bottom);

  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;

  padding: 10px;
  box-sizing: border-box;
}

.popup-frame__content::-webkit-scrollbar {
  width: 2px;
}

.popup-frame__content::-webkit-scrollbar-thumb {
  background: rgba(170, 49, 49, 0.45);
  border-radius: 10px;
}

.popup-frame .modal-close {
  top: 40px;
  right: 24px;
  width: 55px;
  height: 55px;
}

.modal-offer-number {
  font-family: "Cinzel", serif;
  font-weight: 800;
  font-size: 13px;
  line-height: 13px;
  letter-spacing: 2.34px;
  text-align: center;
  color: #9A1B22;
  margin-bottom: 6px;
}

.modal-title {
  font-family: "Cinzel", serif;
  font-weight: 900;
  font-size: 26px;
  line-height: 30px;
  letter-spacing: 0;
  text-align: center;
  color: #5A1A12;
  margin: 0;
}

.divider-box {
  margin: 10px auto;
  width: max-content;
}

.divider-box img {
  display: block;
  width: 152px;
  height: 8px;
}

.modal-content {
  overflow-wrap: anywhere;
}

.modal-content p {
  font-weight: 400;
  font-size: 14px;
  line-height: 21px;
  text-align: center;
  color: #86603E;
}

.modal-content p:not(:last-child) {
  margin-bottom: 10px;
}

.modal-content p span {
  font-weight: 400;
  font-size: 15px;
  line-height: 22px;
  text-align: center;
  color: #4A2A1A;
}

.modal-content p strong {
  font-weight: 700;
  font-size: 15px;
  line-height: 22px;
  text-align: center;
  color: #7A1418;
}

.modal-content p small {
  font-weight: 400;
  font-size: 13px;
  line-height: 19px;
  text-align: center;
  color: #86603E;
}

.modal-content p i {
  font-weight: 600;
  font-size: 15px;
  line-height: 22px;
  text-align: center;
  color: #86603E;
  font-style: normal;
}

.modal-content .offer-highlight {
  font-weight: 800;
  color: #ffd36a;
}

.modal-content small {
  font-size: 12px;
  opacity: 0.75;
}

.modal-content ul,
.modal-content ol {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0px;
  flex-direction: column;
  margin-bottom: 10px;
  list-style: none;
  padding: 0;
}

.modal-content ul li {
  font-weight: 400;
  font-size: 15px;
  line-height: 22px;
  text-align: center;
  color: #4A2A1A;
}

.modal-content ul li a {
  font-weight: 600;
  font-size: 15px;
  line-height: 22px;
  text-align: center;
  text-decoration: underline;
  color: #1D4F9A;
}

.modal-content ul li p {
  margin: 0;
}

.modal-content ul li p:not(:last-child) {
  margin-bottom: 0px;
}

.popup-frame__content ol {
  margin-bottom: 10px;
  list-style: none;
  counter-reset: offer-list;
  display: flex;
  align-items: center;
  justify-content: center;
}

.popup-frame__content ol li {
  counter-increment: offer-list;
  font-weight: 400;
  font-size: 15px;
  line-height: 22px;
  text-align: center;
  color: #4A2A1A;
  position: relative;
}

.popup-frame__content ol li::before {
  content: counter(offer-list) ".";
  font-weight: 400;
  font-size: 15px;
  line-height: 22px;
  color: #4A2A1A;
}

.modal-content .offer-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
}

.modal-content .offer-table th,
.modal-content .offer-table td {
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  text-align: left;
}

.modal-content a {
  color: #ffd36a;
  text-decoration: underline;
}

/* =========================
   DAY 25 POPUP EFFECTS
   ========================= */

.day25-effects {
  display: none;
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.popup-frame.is-day-25 .day25-effects {
  display: block;
}

/* Big radial glow (792 × 809 px on the 560 × 700 desktop popup) */
.day25-glow {
  position: absolute;

  width: 141.43%;
  height: 115.59%;

  top: 6.42%;
  left: -6.43%;

  background: radial-gradient(
    50% 50% at 50% 50%,
    rgba(255, 207, 90, 0.45) 0%,
    rgba(255, 207, 90, 0) 100%
  );

  pointer-events: none;
}

.day25-sparkle {
  position: absolute;
  display: block;
  object-fit: contain;

  filter: drop-shadow(0 0 10px #FFCF5A);
}

.sparkle-1 {
  width: 26px;
  height: 26px;
  top: 5%;
  left: -7%;
}

.sparkle-2 {
  width: 18px;
  height: 18px;
  top: 17%;
  right: -9%;
}

.sparkle-3 {
  width: 22px;
  height: 22px;
  top: 39%;
  left: -12%;
}

.sparkle-4 {
  width: 14px;
  height: 14px;
  top: 54%;
  right: -10%;
}

.sparkle-5 {
  width: 26px;
  height: 26px;
  bottom: 24%;
  left: -8%;
}

.sparkle-6 {
  width: 18px;
  height: 18px;
  bottom: 12%;
  right: -7%;
}

.sparkle-7 {
  width: 22px;
  height: 22px;
  bottom: -3%;
  left: 22%;
}

.sparkle-8 {
  width: 14px;
  height: 14px;
  bottom: -2%;
  right: 20%;
}

/* =========================
   INVITATION
   ========================= */

.invitation-card {
  --card-w: 460px;

  position: relative;
  z-index: 2;
  width: var(--card-w);
  height: calc(var(--card-w) * 1075 / 860);
  flex-shrink: 0;

  background: url("./assets/final_card.webp") center / 100% 100% no-repeat;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  box-sizing: border-box;
  /* 155 / 120 / 127 px on the 460 px card */
  padding:
    calc(var(--card-w) * 0.337)
    calc(var(--card-w) * 0.261)
    calc(var(--card-w) * 0.276);
  overflow: visible;

  border: none;
  box-shadow: none;
}

.invitation-card h2 {
  font-family: "Cinzel", serif;
  font-weight: 900;
  font-size: 24px;
  line-height: 28px;
  text-align: center;
  margin-bottom: 8px;
  color: #5A1A12;
}

.invitation-subtitle {
  font-family: "Cinzel", serif;
  font-weight: 800;
  font-size: 15px;
  line-height: 20px;
  text-align: center;
  color: #7A1A1A;
}

/* 35 / 55 / 60 px on the 460 px card */
.invitation-card .modal-close {
  top: calc(var(--card-w) * 0.076);
  right: calc(var(--card-w) * 0.12);
  width: calc(var(--card-w) * 0.13);
  height: calc(var(--card-w) * 0.13);
}

.final-fireworks {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}

.final-firework-spark {
  position: absolute;
  top: var(--start-y);
  left: var(--start-x);

  width: var(--size);
  height: var(--size);
  border-radius: 50%;

  background: var(--spark-color);
  box-shadow: 0 0 6px var(--spark-color);

  opacity: 1;
  transform: translate(-50%, -50%);

  animation: finalSparkFly 1.2s ease-out forwards;
}

@keyframes finalSparkFly {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }

  70% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform:
      translate(
        calc(-50% + var(--dx)),
        calc(-50% + var(--dy))
      )
      scale(0.2);
  }
}


/* ==========================================================
   MOBILE LAYOUT (portrait screens) — Figma "Mobile" frames,
   390 × 844 design. script.js sets data-layout="mobile".
   ========================================================== */

.scene[data-layout="mobile"] .header {
  --hw: 368px;
  --hh: 209px;
}

.scene[data-layout="mobile"] h1 {
  font-size: 20px;
  line-height: 22px;
  letter-spacing: 0.2px;
  max-width: 300px;
  margin: 65px auto 5px;
  text-shadow: 0px 1.5px 0px #3C0A0ACC, 0px 0px 10px #FFC86459;
}

.scene[data-layout="mobile"] .subtitle {
  font-size: 14px;
  line-height: 17px;
  margin-bottom: 10px;
}

.scene[data-layout="mobile"] .button {
  width: 277px;
  height: 47px;
}

.scene[data-layout="mobile"] .button span {
  padding-top: 4px;
  font-size: 14.5px;
  line-height: 15px;
  letter-spacing: 0.87px;
}

.scene[data-layout="mobile"] .footer {
  min-height: 84px;
  padding: 0 14px calc(8px + env(safe-area-inset-bottom, 0px));
}

.scene[data-layout="mobile"] .footer-text {
  gap: 14px;
}

.scene[data-layout="mobile"] .footer-text p {
  max-width: 300px;
}

/* Modals on phones / short screens (Figma: Mobile · 08 and · 10) */
@media (max-width: 600px), (max-height: 600px) {
  .modal-overlay {
    padding: 16px;
  }

  /*
    Phones (Figma: Mobile · 08): 350 × 596 px frame box — the visible frame
    is ~305 px wide — with smaller corners/crown (k = 0.386). Fixed height.
  */
  .popup-frame {
    --pw: min(350px, calc(100vw - 40px));
    --k: 0.386;
    --ph-min: min(596px, calc(100vh - 40px));
    --ph-max: min(596px, calc(100vh - 40px));
    /* ~256 px text column, never closer than 40 px to the frame edge */
    --content-side: max(40px, calc((var(--pw) - 264px) / 2));
    /* the parchment continues into the upper half of the bottom border */
    --content-bottom: calc(var(--bot-h) * 0.5);
  }

  .popup-frame__content {
    padding: 9px 4px 6px;
  }

  /* 44 px button sitting on the top-right corner of the frame (Figma) */
  .popup-frame .modal-close {
    top: 14px;
    right: 4px;
    width: 44px;
    height: 44px;
  }

  .modal-offer-number {
    font-size: 11px;
    line-height: 11px;
    letter-spacing: 1.98px;
    margin-bottom: 7px;
  }

  .modal-title {
    font-size: 21px;
    line-height: 25px;
  }

  .divider-box {
    margin: 8px auto;
  }

  .modal-content p {
    font-size: 13px;
    line-height: 19px;
  }

  .modal-content p:not(:last-child) {
    margin-bottom: 8px;
  }

  .modal-content p span,
  .modal-content p strong,
  .modal-content p i,
  .modal-content ul li,
  .modal-content ul li a,
  .popup-frame__content ol li,
  .popup-frame__content ol li::before {
    font-size: 14px;
    line-height: 20px;
  }

  .modal-content p small {
    font-size: 12px;
    line-height: 17px;
  }

  .modal-content ul,
  .modal-content ol {
    margin-bottom: 8px;
  }

  /* sparkles stay just outside the frame but inside the screen */
  .sparkle-1 { width: 18px; height: 18px; left: 0; }
  .sparkle-2 { width: 13px; height: 13px; right: 0; }
  .sparkle-3 { width: 16px; height: 16px; left: -2%; }
  .sparkle-4 { width: 10px; height: 10px; right: -1%; }
  .sparkle-5 { width: 18px; height: 18px; left: 0; }
  .sparkle-6 { width: 13px; height: 13px; right: 1%; }
  .sparkle-7 { width: 16px; height: 16px; }
  .sparkle-8 { width: 10px; height: 10px; }

  .invitation-card {
    --card-w: min(340px, calc(100vw - 32px), calc((100vh - 32px) * 860 / 1075));
  }

  .invitation-card h2 {
    font-size: 17px;
    line-height: 22px;
    margin-bottom: 6px;
  }

  .invitation-subtitle {
    font-size: 11px;
    line-height: 16px;
  }
}

/* Use the real visible height on mobile browsers (address bar aware) */
@supports (height: 100dvh) {
  .popup-frame {
    --ph-min: min(700px, calc(100dvh - 40px));
    --ph-max: calc(100dvh - 40px);
  }

  @media (max-width: 600px), (max-height: 600px) {
    .popup-frame {
      --ph-min: min(596px, calc(100dvh - 40px));
      --ph-max: min(596px, calc(100dvh - 40px));
    }

    .invitation-card {
      --card-w: min(340px, calc(100vw - 32px), calc((100dvh - 32px) * 860 / 1075));
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .branches,
  .star,
  .window-arch,
  .advent-window.is-today img,
  .advent-window.is-today::before,
  .advent-window.is-today::after {
    animation: none;
  }
}

/* Very narrow phones: keep the disclaimer to two lines */
@media (max-width: 359px) {
  .scene[data-layout="mobile"] .footer {
    padding-left: 10px;
    padding-right: 10px;
  }

  .scene[data-layout="mobile"] .footer-text {
    gap: 10px;
  }

  .scene[data-layout="mobile"] .footer-badge {
    width: 34px;
    height: 34px;
  }

  .footer-text p {
    font-size: 11px;
    line-height: 15px;
  }
}
