@font-face {
  font-family: Fraunces;
  src: url("fonts/fraunces.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --ink: #1c1210;
  --ink-soft: #2a1c16;
  --cream: #f6efe4;
  --cream-dim: #e7d7c6;
  --gold: #f0c27a;
  --gold-deep: #e0a85a;
  --berry: #a84356;
  --paper: #f4eadc;
  --danger: #ffb4a8;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  min-height: 100dvh;
  background: var(--ink);
  color: var(--cream);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 1.05rem;
  line-height: 1.5;
  overflow-x: hidden;
}

.room,
#confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.room { z-index: 0; }

#confetti { z-index: 4; width: 100%; height: 100%; }

.glow {
  position: absolute;
  inset: 0;
  transition: opacity 2.6s ease;
}

.glow-warm {
  opacity: 1;
  background:
    radial-gradient(ellipse 88% 58% at 50% 22%, rgba(255, 168, 64, 0.92), transparent 70%),
    linear-gradient(180deg, #3a2012 0%, #1c1210 76%);
}

.glow-cool {
  opacity: 0;
  background:
    radial-gradient(ellipse 88% 58% at 50% 22%, rgba(198, 46, 34, 0.9), transparent 70%),
    linear-gradient(180deg, #3a1414 0%, #140c0c 76%);
}

body[data-scene="lit"] .glow-warm { opacity: 1; animation: breathe 3.4s ease-in-out infinite; }
body[data-scene="blowing"] .glow-warm { opacity: 0.42; animation: none; }
body[data-scene="blowing"] .glow-cool { opacity: 0.7; }
body[data-scene="dark"] .glow-warm { opacity: 0; animation: none; }
body[data-scene="dark"] .glow-cool { opacity: 1; }

.grain {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.18;
  mix-blend-mode: overlay;
}

main {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 0.35rem;
  padding: 2.25rem 1.25rem 2.75rem;
  text-align: center;
}

body[data-scene="dark"] main {
  align-content: start;
  padding-top: 2.4rem;
}

.eyebrow {
  margin: 0 0 1.25rem;
  width: 100%;
  font-size: clamp(1rem, 2.4vw, 1.35rem);
  letter-spacing: 0.22em;
  text-align: center;
  text-transform: uppercase;
  color: #f0d7a8;
}

h1 {
  margin: 0;
  max-width: 16ch;
  font-family: Fraunces, Palatino, Georgia, serif;
  font-weight: 560;
  font-size: clamp(3.15rem, 12vw, 5.5rem);
  font-variation-settings: "opsz" 144, "SOFT" 40, "WONK" 1;
  letter-spacing: -0.035em;
  line-height: 0.92;
  text-wrap: balance;
}

h1.is-long { font-size: clamp(2.15rem, 8vw, 3.5rem); }

h1 .name { color: var(--gold); }

.lead,
.wish-label {
  margin: 0.85rem 0 0;
  color: var(--cream-dim);
}

.slip,
.actions {
  width: min(100%, 28rem);
}

.aging {
  display: none;
  max-width: 22rem;
  margin: 0.2rem 0 0;
  text-align: center;
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(1.35rem, 4vw, 1.85rem);
  font-weight: 560;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: #f3d2ce;
}

body[data-scene="dark"] .aging { display: block; }

.spot {
  width: min(100%, 28rem);
  margin: 0.35rem 0 0.8rem;
}

.spot iframe {
  width: 100%;
  height: 190px;
  border: 0;
  border-radius: 16px;
  background: #241814;
}

#reveal {
  display: grid;
  justify-items: center;
  width: min(100%, 28rem);
}



#party {
  display: grid;
  grid-template-areas:
    "cake"
    "aging"
    "actions"
    "dread";
  justify-items: center;
  width: min(100%, 32rem);
  gap: 0.85rem;
}

.stage-cake { grid-area: cake; }
.aging { grid-area: aging; }
#lit-actions { grid-area: actions; }
#reveal { grid-area: dread; }

#name-form,
.actions,
.slip {
  display: grid;
  justify-items: center;
  gap: 0.85rem;
}

.name-input,
textarea,
button {
  font: inherit;
}

.name-input {
  width: min(100%, 16rem);
  margin-top: 0.15rem;
  padding: 0.15rem 0.2rem 0.4rem;
  border: 0;
  border-bottom: 2px solid rgba(246, 239, 228, 0.45);
  border-radius: 0;
  background: transparent;
  color: var(--cream);
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(1.7rem, 5vw, 2.15rem);
  font-weight: 520;
  line-height: 1.15;
  text-align: center;
}

.name-input::placeholder {
  color: #cbbba6;
}

.name-input:focus { outline: none; }
.name-input:focus-visible { border-bottom-color: var(--gold); }

.error {
  margin: 0;
  color: var(--danger);
  font-size: 0.95rem;
}

.btn {
  appearance: none;
  min-height: 48px;
  padding: 0.8rem 1.35rem;
  border: 0;
  border-radius: 999px;
  background: var(--cream);
  color: var(--ink-soft);
  cursor: pointer;
}

.btn:hover { background: #fff8ef; }

.btn:disabled {
  cursor: progress;
  opacity: 0.7;
}

.btn.ghost {
  background: transparent;
  color: var(--cream);
  box-shadow: inset 0 0 0 1px rgba(246, 239, 228, 0.42);
}

.btn.ghost:hover { background: rgba(246, 239, 228, 0.08); }

.row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem;
}

.cake {
  position: relative;
  width: 236px;
  margin: 0.4rem auto 0.2rem;
  filter: drop-shadow(0 22px 16px rgba(0, 0, 0, 0.38));
}

.wind {
  position: absolute;
  left: -70px;
  right: -24px;
  top: 4px;
  height: 86px;
  z-index: 5;
  pointer-events: none;
}

.wind span {
  position: absolute;
  left: 0;
  height: 4px;
  width: 92px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(255, 244, 230, 0.95), transparent);
  opacity: 0;
  filter: blur(0.3px);
}

.wind span:nth-child(1) { top: 10px; width: 110px; }
.wind span:nth-child(2) { top: 24px; width: 74px; }
.wind span:nth-child(3) { top: 38px; width: 128px; height: 5px; }
.wind span:nth-child(4) { top: 52px; width: 86px; }
.wind span:nth-child(5) { top: 66px; width: 104px; }
.wind span:nth-child(6) { top: 30px; width: 64px; height: 3px; }

.cake.is-blowing .wind span { animation: gust 1.2s ease-in infinite; }
.cake.is-blowing .wind span:nth-child(2) { animation-delay: 0.2s; animation-duration: 1.35s; }
.cake.is-blowing .wind span:nth-child(3) { animation-delay: 0.4s; animation-duration: 1.5s; }
.cake.is-blowing .wind span:nth-child(4) { animation-delay: 0.1s; animation-duration: 1.15s; }
.cake.is-blowing .wind span:nth-child(5) { animation-delay: 0.55s; animation-duration: 1.4s; }
.cake.is-blowing .wind span:nth-child(6) { animation-delay: 0.3s; animation-duration: 1.25s; }

.cake.is-blowing .candles { animation: sway 0.55s ease-in-out infinite alternate; }

.candles {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 78px;
  margin-bottom: -14px;
  gap: 12px;
}

.candle {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 14px;
}

.flame {
  width: 12px;
  height: 18px;
  margin-bottom: 1px;
  border-radius: 50% 50% 42% 42%;
  background: radial-gradient(circle at 50% 72%, #fff6d4 0 16%, #ffd36a 32%, #ff8a2a 72%, #e25a1a 100%);
  transform-origin: 50% 100%;
  filter: drop-shadow(0 0 8px rgba(255, 150, 40, 0.95));
  animation: flicker 0.38s ease-in-out infinite alternate;
}

.candle:nth-child(2) .flame { animation-duration: 0.31s; }
.candle:nth-child(3) .flame { animation-duration: 0.46s; }
.candle:nth-child(4) .flame { animation-duration: 0.28s; }
.candle:nth-child(5) .flame { animation-duration: 0.42s; }
.candle:nth-child(6) .flame { animation-duration: 0.34s; }

.smoke {
  width: 8px;
  height: 8px;
  margin-bottom: -6px;
  border-radius: 50%;
  background: transparent;
}

.stick {
  width: 7px;
  height: var(--h);
  border-radius: 3px;
  background: linear-gradient(90deg, #f1dcb8, #fffaf2 46%, #e2c89f);
  box-shadow: inset -1px 0 0 rgba(90, 60, 30, 0.25);
}

.cake.is-blowing .flame { animation: thrash 0.42s ease-in-out infinite; }
.cake.is-blowing .candle:nth-child(2) .flame { animation-duration: 0.38s; }
.cake.is-blowing .candle:nth-child(3) .flame { animation-duration: 0.5s; }
.cake.is-blowing .candle:nth-child(4) .flame { animation-duration: 0.36s; }
.cake.is-blowing .candle:nth-child(5) .flame { animation-duration: 0.46s; }
.cake.is-blowing .candle:nth-child(6) .flame { animation-duration: 0.4s; }

.cake.is-out .flame {
  animation: die 0.5s ease-in forwards;
}

.cake.is-out .candle:nth-child(2) .flame { animation-delay: 0.06s; }
.cake.is-out .candle:nth-child(3) .flame { animation-delay: 0.12s; }
.cake.is-out .candle:nth-child(4) .flame { animation-delay: 0.04s; }
.cake.is-out .candle:nth-child(5) .flame { animation-delay: 0.16s; }
.cake.is-out .candle:nth-child(6) .flame { animation-delay: 0.1s; }

.cake.is-out .smoke { animation: rise 1.15s ease-out forwards; }

.tier {
  position: relative;
  margin-inline: auto;
}

.tier-top {
  z-index: 2;
  width: 168px;
  height: 52px;
  border-radius: 46px 46px 8px 8px / 18px 18px 8px 8px;
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.72) 0 18%, transparent 42%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.35), transparent 34%, rgba(90, 40, 28, 0.12)),
    linear-gradient(#fff9f4, #f0c3a8);
  box-shadow: inset 0 -7px 0 #e8b296, inset 0 8px 10px rgba(255, 255, 255, 0.45);
}

.tier-top::before {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  top: 6px;
  height: 10px;
  border-radius: 10px;
  background: linear-gradient(90deg, transparent, rgba(255, 248, 236, 0.85), transparent);
}

.tier-top::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  top: 24px;
  height: 10px;
  background:
    radial-gradient(circle at 5px 5px, #c45d6a 3px, transparent 3.5px) 0 0 / 22px 10px repeat-x,
    radial-gradient(circle at 16px 5px, #e0a85a 2.6px, transparent 3.1px) 0 0 / 22px 10px repeat-x;
}

.tier-bottom {
  z-index: 1;
  width: 214px;
  height: 64px;
  margin-top: 8px;
  border-radius: 8px 8px 12px 12px;
  background:
    linear-gradient(115deg, rgba(255, 220, 214, 0.55) 0 16%, transparent 36%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.22), transparent 30%, rgba(0, 0, 0, 0.18)),
    linear-gradient(#e07b86, #c45d6a 46%, var(--berry));
  box-shadow: inset 0 -12px 14px rgba(70, 16, 28, 0.22), inset 0 6px 8px rgba(255, 236, 230, 0.28);
}

.tier-bottom::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -11px;
  height: 18px;
  background: radial-gradient(circle at 14px 0, #f8e7ea 13px, transparent 14px) left top / 28px 18px repeat-x;
}

.plate {
  width: 248px;
  height: 22px;
  margin: -12px auto 0.85rem;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, #f7efe4 0%, #e7d5c4 58%, #c9b5a2 74%, transparent 76%);
}

.slip {
  margin-top: 1rem;
  padding: 1.25rem 1.2rem 1.3rem;
  border-radius: 18px;
  background: var(--paper);
  color: var(--ink-soft);
  color-scheme: light;
  justify-items: stretch;
  text-align: left;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
}

.slip h2 {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.85rem;
  font-weight: 560;
  letter-spacing: -0.03em;
  line-height: 1.05;
  text-align: center;
}

.slip :focus-visible {
  outline-color: #6e2c3a;
}

.slip p {
  margin: 0.55rem 0 0;
  color: #4a342b;
}

.wish-label {
  justify-self: start;
  margin: 0;
  color: #2a1c16;
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 560;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.slip .error { color: #8a2d3a; }

textarea {
  width: 100%;
  min-height: 5.5rem;
  padding: 0.75rem 0.8rem;
  resize: vertical;
  border: 1px solid #e0d0be;
  border-radius: 12px;
  background: rgba(255, 252, 247, 0.72);
  color: var(--ink-soft);
  line-height: 1.45;
}

textarea:focus { outline: none; }
textarea:focus-visible {
  border-color: var(--berry);
  outline: 3px solid #6e2c3a;
  outline-offset: 2px;
}

.slip .row {
  flex-direction: column;
  width: 100%;
}

.slip .btn {
  width: 100%;
  background: var(--ink-soft);
  color: var(--cream);
}

.slip .btn:hover { background: #3a291f; }

.slip .btn.ghost {
  background: transparent;
  color: var(--ink-soft);
  box-shadow: inset 0 0 0 1px rgba(42, 28, 22, 0.35);
}

.slip .btn.ghost:hover { background: rgba(42, 28, 22, 0.06); }

.ip-result {
  display: grid;
  justify-items: center;
  gap: 0.75rem;
  width: min(100%, 24rem);
  margin: 0;
  text-align: center;
  color: var(--cream);
}

#reveal .where {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(1.45rem, 4vw, 1.85rem);
  font-weight: 560;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: #f3d2ce;
  animation: drip 1.1s steps(2, end) 1;
}

.ip-result .fact {
  margin: 0;
}

.ip-result .fact span {
  display: block;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #e7b2ad;
}

.ip-result .fact strong {
  display: block;
  margin-top: 0.15rem;
  font-weight: 600;
  color: #ffb4ae;
}

.ip-result .fact.mono strong {
  font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", monospace;
  font-size: 1.05rem;
  letter-spacing: 0;
}

.ip-result .ip-note {
  margin: 0;
  max-width: 34ch;
  color: var(--cream-dim);
  font-size: 0.92rem;
}

.ip-result.is-error {
  color: var(--danger);
}

@media (min-width: 960px) {
  main {
    width: min(1120px, calc(100% - 6rem));
    margin-inline: auto;
    padding: 3rem 0 4rem;
  }

  #party {
    width: min(720px, 100%);
    grid-template-columns: 1fr;
    grid-template-areas:
      "cake"
      "aging"
      "actions"
      "dread";
    row-gap: 1.25rem;
    justify-items: center;
    text-align: center;
  }

  .stage-cake {
    justify-self: center;
    width: auto;
    display: grid;
    place-items: start center;
    height: 330px;
  }

  .stage-cake .cake {
    transform: scale(1.4);
    transform-origin: top center;
  }

  #lit-actions,
  #reveal {
    width: min(100%, 28rem);
  }

  .actions { justify-items: center; }

  .row { justify-content: center; }

  .ip-result {
    justify-items: center;
    text-align: center;
  }

  .slip .row { justify-content: stretch; }
}

.noscript {
  position: relative;
  z-index: 1;
  margin: 0;
  padding: 0 1.25rem 2rem;
  text-align: center;
  color: var(--cream-dim);
}

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

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.name-input:focus-visible,
textarea:focus-visible { outline: none; }

::selection {
  background: var(--gold-deep);
  color: var(--ink);
}

@keyframes flicker {
  from { transform: scale(1, 1) rotate(-2deg); }
  to { transform: scale(0.92, 1.08) rotate(2deg); }
}

@keyframes thrash {
  0% { transform: scaleX(1.7) scaleY(0.48) translateX(16px) rotate(32deg); filter: blur(0.2px); }
  50% { transform: scaleX(2.15) scaleY(0.32) translateX(28px) rotate(48deg); }
  100% { transform: scaleX(1.35) scaleY(0.62) translateX(8px) rotate(18deg); }
}

@keyframes gust {
  0% { opacity: 0; transform: translateX(-50px) scaleX(0.45); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: translateX(230px) scaleX(1.35); }
}

@keyframes sway {
  from { transform: rotate(-1deg) translateX(-2px); }
  to { transform: rotate(3deg) translateX(7px); }
}

@keyframes die {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.25, 1.5) translateY(-8px); opacity: 0; }
}

@keyframes rise {
  0% { background: rgba(226, 226, 226, 0); transform: translateY(4px) scale(0.4); }
  25% { background: rgba(226, 226, 226, 0.65); }
  100% { background: rgba(226, 226, 226, 0); transform: translateY(-32px) scale(1.7); }
}

@keyframes breathe {
  from { opacity: 0.78; }
  to { opacity: 1; }
}

@keyframes drip {
  0% { opacity: 0.15; }
  35% { opacity: 1; }
  55% { opacity: 0.35; }
  100% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .flame,
  .cake.is-blowing .flame,
  .cake.is-blowing .wind span,
  .cake.is-blowing .candles,
  body[data-scene="lit"] .glow-warm,
  .cake.is-out .smoke,
  #reveal .where {
    animation: none;
  }

  .cake.is-out .flame { opacity: 0; }
  .glow { transition: none; }
}
