@font-face {
  font-family: "Cormorant Garamond";
  src: url("cormorant-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Cormorant Garamond";
  src: url("cormorant-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Cormorant Garamond";
  src: url("cormorant-500i.woff2") format("woff2");
  font-weight: 500;
  font-style: italic;
  font-display: swap;
}

:root {
  --lit: 0;
  --cream: #fbf6ee;
  --gold: #f0d7a4;
  --gold-deep: #e4c07a;
  --muted: #ead9c8;
  --ink: #2a0c14;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  color: var(--cream);
  font-family: "Cormorant Garamond", "Iowan Old Style", Palatino, "Liberation Serif", Georgia, serif;
  background-color: #21080e;
  background-image:
    radial-gradient(ellipse 90% 50% at 50% -10%, rgba(156, 52, 38, 0.55), transparent 58%),
    radial-gradient(ellipse 55% 42% at 110% 86%, rgba(92, 32, 16, 0.4), transparent 55%),
    radial-gradient(ellipse 48% 40% at -12% 74%, rgba(84, 20, 34, 0.48), transparent 52%),
    linear-gradient(#3c1422, #21080e 42%, #14060a);
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}

::selection {
  background: rgba(224, 164, 72, 0.35);
  color: #fff8ee;
}

.ambient,
.embers {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.ambient {
  z-index: 0;
  opacity: var(--lit);
  background:
    radial-gradient(ellipse 110% 48% at 50% 112%, rgba(255, 132, 42, 0.55), transparent 56%),
    radial-gradient(ellipse 70% 36% at 50% 18%, rgba(255, 206, 140, 0.2), transparent 70%);
  transition: opacity 420ms linear;
}

.embers {
  z-index: 0;
  overflow: hidden;
  opacity: 0;
}

body.complete .embers { opacity: 1; }

.embers i {
  position: absolute;
  bottom: -8px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #ffd089;
  box-shadow: 0 0 8px 2px rgba(255, 170, 70, 0.65);
  opacity: 0;
  animation: rise 9s linear infinite;
}

.embers i:nth-child(1) { left: 14%; animation-duration: 8.5s; }
.embers i:nth-child(2) { left: 32%; animation-duration: 10s; animation-delay: -3s; }
.embers i:nth-child(3) { left: 51%; animation-duration: 7.8s; animation-delay: -1.4s; }
.embers i:nth-child(4) { left: 68%; animation-duration: 9.4s; animation-delay: -5s; }
.embers i:nth-child(5) { left: 84%; animation-duration: 11s; animation-delay: -2.2s; }

@keyframes rise {
  0% { transform: translateY(0) scale(1); opacity: 0; }
  10% { opacity: 0.75; }
  100% { transform: translateY(-105vh) scale(0.6); opacity: 0; }
}

.page {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: min(640px, calc(100% - 28px));
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 0 calc(32px + env(safe-area-inset-bottom));
}

.copy { display: contents; }

.intro { order: 1; text-align: center; }
.photo { order: 2; margin: 0; }
.from { order: 3; }
.light { order: 4; }
.hearth { order: 5; }

.rule {
  display: flex;
  justify-content: center;
  margin: 0 0 8px;
}

.rule span {
  position: relative;
  width: 92px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-deep), transparent);
}

.rule span::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  background: var(--gold);
  transform: translate(-50%, -50%) rotate(45deg);
}

h1 {
  margin: 0;
  font-weight: 600;
  font-size: clamp(3rem, 12vw, 4.6rem);
  line-height: 0.88;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.saal {
  margin: 8px 0 0;
  color: var(--gold);
  font-size: clamp(1.25rem, 4.6vw, 1.65rem);
  font-weight: 500;
  letter-spacing: 0.14em;
}

.frame {
  padding: 3px;
  border-radius: 12px;
  background: linear-gradient(145deg, #f8e7c3, #b8883e 42%, #f4d7a4 68%, #8a5e2a);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.38);
  transition: box-shadow 420ms ease;
}

.frame img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 9px;
  background: #1a070c;
}

body.complete .frame {
  box-shadow:
    0 0 0 1px rgba(246, 220, 170, 0.35),
    0 18px 50px rgba(255, 140, 48, 0.28);
}

.from {
  margin: 2px 0 0;
  text-align: center;
  font-style: italic;
  font-weight: 500;
  font-size: clamp(1.28rem, 5.2vw, 1.7rem);
  line-height: 1.25;
  color: #f7ecdf;
  text-wrap: balance;
}

.light { text-align: center; }

.invite {
  margin: 0;
  font-size: clamp(1.7rem, 6vw, 2.15rem);
  font-weight: 600;
  line-height: 1.05;
  color: var(--cream);
}

.hint {
  margin: 6px 0 0;
  min-height: 1.35em;
  font-family: Inter, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 0.94rem;
  line-height: 1.35;
  letter-spacing: 0.01em;
  color: var(--muted);
}

body.complete .invite { color: var(--gold); }

.hearth {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  width: min(100%, 460px);
  margin: 2px auto 0;
  align-self: center;
}

.hearth::before {
  content: "";
  position: absolute;
  left: 4%;
  right: 4%;
  bottom: 4px;
  height: 18px;
  background: radial-gradient(ellipse at center, rgba(255, 150, 60, calc(0.12 + var(--lit) * 0.55)), transparent 72%);
  pointer-events: none;
}

.diya {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 96px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.art {
  position: relative;
  display: block;
  width: 100%;
  max-width: 86px;
}

.diya:nth-child(1) .art { transform: rotate(-8deg); }
.diya:nth-child(2) .art { transform: rotate(-3deg); }
.diya:nth-child(4) .art { transform: rotate(3.5deg); }
.diya:nth-child(5) .art { transform: rotate(7deg); }

.diya:nth-child(2) .lamp { filter: saturate(1.08) brightness(1.04); }
.diya:nth-child(4) .lamp { filter: hue-rotate(8deg) saturate(0.95); }
.diya:nth-child(5) .lamp { filter: brightness(0.96); }

.lamp {
  display: block;
  width: 100%;
  height: auto;
}

.diya[aria-pressed="true"] .lamp {
  filter: drop-shadow(0 0 8px rgba(255, 164, 58, 0.85)) brightness(1.08);
}

.fire {
  position: absolute;
  left: 50%;
  bottom: 62%;
  width: 28px;
  height: 40px;
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms linear;
}

.diya[aria-pressed="true"] .fire { opacity: 1; }

.halo,
.tongue {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  transform-origin: center bottom;
}

.halo {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 186, 80, 0.9) 0%, rgba(255, 120, 30, 0.28) 46%, transparent 70%);
  filter: blur(1px);
}

.t1 {
  width: 16px;
  height: 30px;
  border-radius: 50% 50% 46% 46% / 62% 62% 38% 38%;
  background: radial-gradient(ellipse at 50% 78%, #ffe7a8 0%, #ff9a32 36%, #ff5c12 64%, rgba(255, 70, 0, 0) 76%);
  animation: flick 780ms ease-in-out infinite;
}

.t2 {
  width: 9px;
  height: 18px;
  bottom: 2px;
  border-radius: 50% 50% 46% 46% / 60% 60% 40% 40%;
  background: radial-gradient(ellipse at 50% 80%, #fffef8 0%, #ffe08a 42%, rgba(255, 176, 40, 0) 74%);
  animation: flick 560ms ease-in-out infinite reverse;
}

.t3 {
  width: 4px;
  height: 9px;
  bottom: 4px;
  border-radius: 50%;
  background: #fffaf2;
  filter: blur(0.4px);
}

.diya:nth-child(2) .t1 { animation-duration: 640ms; }
.diya:nth-child(3) .t1 { animation-duration: 860ms; }
.diya:nth-child(4) .t1 { animation-duration: 700ms; }
.diya:nth-child(5) .t1 { animation-duration: 920ms; }
.diya:nth-child(2) .t2 { animation-duration: 480ms; }
.diya:nth-child(3) .t2 { animation-duration: 620ms; }
.diya:nth-child(5) .t2 { animation-duration: 700ms; }

@keyframes flick {
  0%, 100% { transform: translateX(-50%) scale(1, 1) rotate(-2.5deg); }
  45% { transform: translateX(-50%) scale(0.84, 1.1) rotate(3deg); }
  72% { transform: translateX(-50%) scale(1.05, 0.94) rotate(-1deg); }
}

.diya:focus { outline: none; }

.diya:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  border-radius: 14px;
}

@media (hover: hover) and (pointer: fine) {
  .diya:hover .art { translate: 0 -2px; }
}

.diya:active .art { translate: 0 1px; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 900px) {
  .page {
    display: grid;
    grid-template-columns: minmax(0, 1.12fr) minmax(280px, 0.88fr);
    column-gap: 56px;
    row-gap: 0;
    align-items: center;
    width: min(1080px, calc(100% - 72px));
    min-height: calc(100dvh - 48px);
    padding-top: 28px;
  }

  .copy {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    min-width: 0;
  }

  .intro,
  .from,
  .light { text-align: left; }

  .photo { margin: 0; }

  .rule { justify-content: flex-start; }

  h1 { font-size: clamp(3.4rem, 5vw, 5.15rem); }

  .hearth {
    width: min(100%, 440px);
    margin: 6px 0 0;
    align-self: stretch;
  }

  .diya { height: 112px; }

  .frame img {
    width: auto;
    max-width: 100%;
    max-height: calc(100dvh - 64px);
    margin-inline: auto;
  }
}

@media (max-height: 740px) and (max-width: 899px) {
  .page { gap: 10px; padding-top: 12px; }
  h1 { font-size: clamp(2.5rem, 10vw, 3.2rem); }
  .frame img { max-height: 38dvh; width: auto; max-width: 100%; margin-inline: auto; }
  .diya { height: 84px; }
}

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

  .embers { display: none; }

  .t1,
  .t2,
  .t3,
  .halo { transform: translateX(-50%); }
}
