@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,500;0,600;1,500&family=Nunito:wght@400;600;700&display=swap');

:root {
  color-scheme: dark;
  font-family: "Nunito", sans-serif;
  --cream: #fff6ec;
  --ink: #3f2730;
  --rose: #d8879e;
  --rose-dark: #a85672;
  --night: #080b1b;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--night);
}

button { font: inherit; }

#experience {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  isolation: isolate;
  background: radial-gradient(circle at 50% 42%, #202445 0%, #080b1b 68%);
}

#scene {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

#scene:active { cursor: grabbing; }

body.gate-locked #experience {
  visibility: hidden;
  pointer-events: none;
}

.birthday-gate {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(22px, env(safe-area-inset-top)) 22px max(22px, env(safe-area-inset-bottom));
  overflow: auto;
  background:
    radial-gradient(circle at 50% 42%, rgba(80, 54, 91, .65) 0, rgba(15, 18, 42, .4) 38%, transparent 72%),
    radial-gradient(circle at 17% 20%, rgba(244, 202, 224, .5) 0 1px, transparent 3px),
    radial-gradient(circle at 82% 32%, rgba(244, 202, 224, .5) 0 1px, transparent 3px),
    radial-gradient(circle at 31% 82%, rgba(244, 202, 224, .4) 0 1px, transparent 3px),
    #080b1b;
  transition: opacity .65s ease, visibility .65s ease;
}

.birthday-gate.is-opening { opacity: 0; visibility: hidden; pointer-events: none; }
.birthday-gate[hidden] { display: none; }

.gate-card {
  position: relative;
  width: min(100%, 480px);
  padding: clamp(30px, 6vw, 56px);
  text-align: center;
  color: var(--ink);
  border: 1px solid rgba(255, 227, 223, .9);
  border-radius: 24px;
  background: linear-gradient(150deg, #fff9f3, #f8e8e5 65%, #f4dbe1);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .48), inset 0 0 60px rgba(220, 156, 176, .18);
}

.gate-card::before,
.gate-card::after {
  content: "✦";
  position: absolute;
  color: #ca8ca6;
  font-size: 14px;
}

.gate-card::before { top: 19px; left: 22px; }
.gate-card::after { right: 22px; bottom: 19px; }

.gate-sparkle {
  display: block;
  margin-bottom: 12px;
  color: #b96a89;
  font-size: 29px;
  text-shadow: 0 0 17px rgba(211, 112, 151, .35);
}

.gate-eyebrow {
  margin: 0 0 9px;
  color: #9f5874;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .19em;
}

.gate-card h2 {
  max-width: 360px;
  margin: 0 auto 10px;
  color: #5b3446;
  font: italic 600 clamp(33px, 7vw, 47px)/.98 "Cormorant Garamond", serif;
}

.gate-intro {
  margin: 0 auto 28px;
  color: #8b6a76;
  font: 500 20px/1.3 "Cormorant Garamond", serif;
}

.gate-fields { display: grid; gap: 8px; text-align: left; }
.gate-fields label { margin-top: 9px; color: #795464; font-size: 12px; font-weight: 700; letter-spacing: .03em; }
.gate-fields input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid #d9b5bf;
  border-radius: 11px;
  outline: none;
  background: rgba(255, 255, 255, .78);
  color: #58394a;
  font: 600 16px "Nunito", sans-serif;
  letter-spacing: .07em;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.gate-fields input::placeholder { color: #b59aa4; font-weight: 400; }
.gate-fields input:focus { border-color: #ba7290; box-shadow: 0 0 0 3px rgba(202, 130, 159, .2); }

.gate-error { min-height: 20px; margin: 10px 0 5px; color: #9a3d5c; font-size: 12px; }

.gate-submit {
  width: 100%;
  padding: 15px 20px;
  border: 0;
  border-radius: 999px;
  color: #fff8f4;
  background: linear-gradient(135deg, #b56683, #a34f72);
  box-shadow: 0 11px 24px rgba(149, 69, 105, .23);
  cursor: pointer;
  font-weight: 700;
  transition: transform .2s ease, box-shadow .2s ease;
}

.gate-submit span { margin-left: 5px; color: #ffe1ec; }
.gate-submit:hover { transform: translateY(-2px); box-shadow: 0 14px 28px rgba(149, 69, 105, .3); }
.gate-submit:focus-visible { outline: 3px solid #704056; outline-offset: 3px; }

.vignette,
.grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.vignette {
  background:
    radial-gradient(circle at 50% 56%, transparent 35%, rgba(2, 3, 13, .22) 66%, rgba(1, 2, 8, .78) 115%),
    linear-gradient(to bottom, rgba(4, 6, 20, .32), transparent 32%, rgba(2, 3, 10, .2));
  z-index: 2;
}

.grain {
  z-index: 3;
  opacity: .055;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.6'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

.scene-title {
  position: absolute;
  z-index: 4;
  top: max(28px, env(safe-area-inset-top));
  left: clamp(24px, 6vw, 82px);
  color: var(--cream);
  pointer-events: none;
  text-shadow: 0 2px 20px rgba(0, 0, 0, .45);
  transition: opacity .5s ease, transform .5s ease;
}

.eyebrow {
  display: block;
  margin-bottom: 5px;
  color: #efbfd0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.scene-title h1 {
  margin: 0;
  font: italic 600 clamp(34px, 5vw, 68px)/.95 "Cormorant Garamond", serif;
  letter-spacing: -.03em;
}

.hint {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: 96px;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 9px 14px;
  transform: translateX(-50%);
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 999px;
  background: rgba(12, 14, 35, .48);
  backdrop-filter: blur(10px);
  color: rgba(255, 246, 236, .74);
  font-size: 12px;
  letter-spacing: .03em;
  pointer-events: none;
  animation: hint-in .8s 1.8s both;
  transition: opacity .35s ease;
}

.hint-star { color: #f4c4d2; }

.scene-actions {
  position: absolute;
  z-index: 5;
  right: clamp(18px, 4vw, 54px);
  bottom: max(28px, env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: calc(100vw - 36px);
}

.pill,
.reset {
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  color: var(--cream);
  background: rgba(11, 13, 32, .65);
  box-shadow: 0 12px 30px rgba(0,0,0,.24);
  backdrop-filter: blur(13px);
  cursor: pointer;
  transition: transform .2s ease, background .2s ease, border-color .2s ease;
}

.pill {
  padding: 12px 17px;
  font-size: 13px;
}

.pill span { margin-right: 5px; color: #ffd3df; }
.pill:hover { transform: translateY(-2px); border-color: rgba(255,255,255,.38); }
.pill.primary { background: rgba(159, 78, 107, .72); }
.pill.primary:hover { background: rgba(182, 91, 123, .88); }

.reset {
  position: absolute;
  z-index: 5;
  left: clamp(18px, 4vw, 54px);
  bottom: max(28px, env(safe-area-inset-bottom));
  padding: 10px 14px;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  font-size: 12px;
}

.reset.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }

.letter-backdrop {
  position: absolute;
  z-index: 8;
  inset: 0;
  background: rgba(4, 5, 15, .57);
  opacity: 0;
  pointer-events: none;
  backdrop-filter: blur(5px);
  transition: opacity .55s ease;
}

.letter-backdrop.open { opacity: 1; pointer-events: auto; }

.letter {
  position: absolute;
  z-index: 9;
  top: 50%;
  left: 50%;
  width: min(88vw, 550px);
  max-height: min(76vh, 690px);
  overflow: auto;
  padding: clamp(35px, 6vw, 68px);
  transform: translate(-50%, -45%) rotate(-1deg) scale(.82);
  opacity: 0;
  pointer-events: none;
  color: var(--ink);
  background:
    linear-gradient(rgba(255,250,242,.965), rgba(255,246,235,.975)),
    repeating-linear-gradient(0deg, transparent 0 29px, rgba(178,123,131,.08) 30px);
  border: 1px solid rgba(114, 70, 79, .22);
  border-radius: 3px;
  box-shadow: 0 35px 90px rgba(0,0,0,.52), inset 0 0 60px rgba(190,132,136,.08);
  transition: opacity .5s ease, transform .65s cubic-bezier(.2,.8,.2,1);
}

.letter::before,
.letter::after {
  content: "";
  position: absolute;
  width: 58px;
  height: 58px;
  border-color: rgba(171, 93, 117, .26);
}

.letter::before { top: 17px; left: 17px; border-top: 1px solid; border-left: 1px solid; }
.letter::after { right: 17px; bottom: 17px; border-right: 1px solid; border-bottom: 1px solid; }

.letter.open {
  transform: translate(-50%, -50%) rotate(-.25deg) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.letter-close {
  position: absolute;
  top: 14px;
  right: 17px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  color: #77515b;
  background: rgba(177, 111, 129, .1);
  font-size: 24px;
  cursor: pointer;
}

.letter-kicker {
  color: #a65c73;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .2em;
  text-align: center;
  text-transform: uppercase;
}

.letter h2 {
  margin: 9px 0 2px;
  font: 600 clamp(36px, 7vw, 58px)/1 "Cormorant Garamond", serif;
  text-align: center;
}

.letter-flourish { margin: 8px 0 25px; color: #c77a91; font-size: 24px; text-align: center; }
.letter p { margin: 0 0 18px; font: 500 clamp(18px, 3vw, 22px)/1.48 "Cormorant Garamond", serif; }
.letter .signature { margin-top: 28px; font-style: italic; }
.letter .signature span { color: #9f526a; font-size: 1.2em; }
.letter-note { margin-top: 28px; padding-top: 14px; border-top: 1px solid rgba(128,78,90,.15); color: #9a7a80; font-size: 10px; letter-spacing: .05em; text-align: center; }

.gift-backdrop {
  position: absolute;
  z-index: 10;
  inset: 0;
  background: rgba(4, 5, 15, .58);
  opacity: 0;
  pointer-events: none;
  backdrop-filter: blur(5px);
  transition: opacity .45s ease;
}

.gift-backdrop.open { opacity: 1; pointer-events: auto; }

.gift-card {
  position: absolute;
  z-index: 11;
  top: 50%;
  left: 50%;
  width: min(88vw, 480px);
  max-height: 82vh;
  overflow: auto;
  padding: 32px clamp(25px, 5vw, 46px) 38px;
  transform: translate(-50%, -44%) scale(.88);
  opacity: 0;
  pointer-events: none;
  text-align: center;
  color: var(--ink);
  background: linear-gradient(160deg, #fff9f2, #f9e6e4);
  border: 1px solid rgba(255, 222, 223, .9);
  border-radius: 18px;
  box-shadow: 0 34px 90px rgba(0, 0, 0, .52), inset 0 0 50px rgba(215, 151, 164, .13);
  transition: opacity .4s ease, transform .55s cubic-bezier(.2,.8,.2,1);
}

.gift-card.open { transform: translate(-50%, -50%) scale(1); opacity: 1; pointer-events: auto; }

.gift-close {
  position: absolute;
  top: 13px;
  right: 15px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  color: #77515b;
  background: rgba(177, 111, 129, .12);
  font-size: 24px;
  cursor: pointer;
}

.gift-card h2 {
  margin: 6px 0 21px;
  font: 600 clamp(31px, 6vw, 43px)/1 "Cormorant Garamond", serif;
}

.gift-image-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  height: min(42vh, 320px);
  margin: 0 auto 16px;
  border-radius: 13px;
  background: #fff;
  border: 1px solid rgba(202, 155, 164, .3);
  overflow: hidden;
}

.gift-image-frame img {
  display: block;
  width: auto;
  max-width: 100%;
  height: 100%;
  object-fit: contain;
}

.gift-message { max-width: 310px; margin: 0 auto; color: #765a62; font: 500 22px/1.35 "Cormorant Garamond", serif; }

.loading {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  background: #080b1b;
  color: rgba(255,246,236,.72);
  font: italic 500 19px "Cormorant Garamond", serif;
  letter-spacing: .03em;
  transition: opacity .8s ease, visibility .8s ease;
}

.loading.hidden { opacity: 0; visibility: hidden; }
.loading-moon { width: 44px; height: 44px; margin-bottom: 15px; border-radius: 50%; box-shadow: 12px 0 0 0 #ffe7cf; animation: float 1.8s ease-in-out infinite; }

@keyframes float { 50% { transform: translateY(-7px) rotate(4deg); } }
@keyframes hint-in { from { opacity: 0; transform: translate(-50%, 10px); } }

@media (max-width: 680px) {
  .scene-title { top: max(23px, env(safe-area-inset-top)); left: 22px; }
  .scene-title h1 { font-size: 39px; }
  .scene-actions { right: 14px; bottom: max(17px, env(safe-area-inset-bottom)); gap: 7px; }
  .pill { padding: 11px 13px; font-size: 11px; }
  .reset { left: 14px; bottom: max(17px, env(safe-area-inset-bottom)); }
  .hint { bottom: 113px; }
  .gift-image-frame { height: min(42vh, 300px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
