:root {
  --night-0:  #04060e;
  --night-1:  #090c1a;
  --violet:   #17123a;
  --plum:     #2a1230;
  --gold:     #ffd7a0;
  --gold-dim: rgba(255, 215, 160, .62);
  --ink:      #f4efe7;
  --muted:    rgba(244, 239, 231, .52);
  --faint:    rgba(244, 239, 231, .26);

  --serif: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --sans:  "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --ease: cubic-bezier(.22, .61, .28, 1);
  --pad:  max(22px, env(safe-area-inset-left));
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: var(--night-0);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  touch-action: manipulation;   /* kills the 300ms tap delay, keeps nested scrolling alive */
}

/* ---------- sky ---------- */

.nebula, .vignette, #sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

.nebula {
  background:
    radial-gradient(120% 80% at 18% 12%,  rgba(58, 42, 120, .40), transparent 62%),
    radial-gradient(100% 70% at 88% 78%,  rgba(72, 26, 66, .34),  transparent 58%),
    radial-gradient(80%  60% at 50% 100%, rgba(28, 46, 92, .30),  transparent 60%),
    linear-gradient(180deg, var(--night-0) 0%, var(--night-1) 48%, #0b0716 100%);
}

/* the sky swallows drag gestures; everything else scrolls normally */
#sky { z-index: 1; touch-action: none; }

.vignette {
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% 45%, transparent 42%, rgba(2, 3, 8, .72) 100%);
}

/* ---------- shared bits ---------- */

.eyebrow {
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 400;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--gold-dim);
}

.rule {
  width: 34px;
  height: 1px;
  margin: 22px auto;
  background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
}

.btn {
  appearance: none;
  border: 1px solid rgba(255, 215, 160, .34);
  background: rgba(255, 215, 160, .05);
  color: var(--gold);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: .2em;
  text-transform: uppercase;
  padding: 15px 34px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .5s var(--ease), border-color .5s var(--ease), transform .3s var(--ease);
  box-shadow: 0 0 34px -12px rgba(255, 215, 160, .5);
}
.btn:active { transform: scale(.97); }
@media (hover: hover) {
  .btn:hover { background: rgba(255, 215, 160, .12); border-color: rgba(255, 215, 160, .55); }
}
.btn--ghost { border-color: rgba(244, 239, 231, .18); color: var(--muted); box-shadow: none; }

.is-hidden {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* ---------- intro ---------- */

.intro {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: var(--pad);
  background: radial-gradient(90% 70% at 50% 50%, rgba(4, 6, 14, .72), rgba(4, 6, 14, .94));
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  transition: opacity 1.1s var(--ease), visibility 1.1s;
}

.intro__inner {
  text-align: center;
  max-width: 30rem;
  animation: rise 1.6s var(--ease) both;
}

.intro__name {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(3.4rem, 17vw, 6rem);
  line-height: .95;
  letter-spacing: -.01em;
  margin-top: 20px;
  background: linear-gradient(175deg, #fffaf2 12%, var(--gold) 62%, #d8a877 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.intro__line {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.05rem, 4.6vw, 1.3rem);
  line-height: 1.6;
  color: rgba(244, 239, 231, .82);
  margin-bottom: 40px;
  text-wrap: balance;
}

.intro__hint {
  margin-top: 26px;
  font-size: 11.5px;
  line-height: 1.7;
  letter-spacing: .04em;
  color: var(--faint);
  text-wrap: balance;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(18px); filter: blur(6px); }
  to   { opacity: 1; transform: none; filter: none; }
}

/* ---------- tilt nudge ---------- */

.nudge {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: calc(38px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--faint);
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  text-align: center;
  transition: opacity 1.2s var(--ease), visibility 1.2s;
}
.nudge svg { width: 44px; animation: rock 3.6s var(--ease) infinite; }

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

/* ---------- counter ---------- */

.counter {
  position: fixed;
  z-index: 20;
  top: calc(var(--pad) + env(safe-area-inset-top));
  right: var(--pad);
  font-size: 11px;
  letter-spacing: .16em;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  transition: opacity 1s var(--ease), visibility 1s;
}
.counter__sep { margin: 0 4px; opacity: .5; }
#counter-found { color: var(--gold-dim); }

/* ---------- sound ---------- */

.sound {
  position: fixed;
  z-index: 20;
  top: calc(var(--pad) + env(safe-area-inset-top) - 8px);
  left: calc(var(--pad) - 8px);
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  background: none;
  color: var(--faint);
  cursor: pointer;
  transition: opacity 1s var(--ease), visibility 1s, color .4s;
}
.sound svg { width: 17px; }
.sound .sound__mute { opacity: 0; }
.sound.is-muted .sound__wave { opacity: 0; }
.sound.is-muted .sound__mute { opacity: 1; }

/* ---------- memory sheet ---------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-left))
           max(20px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-right));
  transition: opacity .5s var(--ease), visibility .5s;
}

.sheet__scrim {
  position: absolute;
  inset: 0;
  background: rgba(3, 4, 10, .58);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
}

.sheet__card {
  position: relative;
  width: 100%;
  max-width: 32rem;
  max-height: 84dvh;
  border-radius: 24px;
  border: 1px solid rgba(255, 215, 160, .14);
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(255, 215, 160, .08), transparent 64%),
    linear-gradient(180deg, rgba(21, 19, 42, .97), rgba(9, 9, 20, .985));
  box-shadow:
    0 40px 110px -34px rgba(0, 0, 0, .95),
    0 0 60px -20px rgba(255, 200, 140, .12);
  transform: translateY(10px) scale(.94);
  opacity: 0;
  transition: transform .55s var(--ease), opacity .4s var(--ease);
}
.sheet:not(.is-hidden) .sheet__card { transform: none; opacity: 1; }

.sheet__scroll {
  max-height: 84dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;   /* body is touch-action:none for the sky — opt this back in */
  padding: 38px 26px 34px;
}

.sheet__close {
  position: absolute;
  top: 14px; right: 12px;
  z-index: 2;
  width: 40px; height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  background: none;
  color: var(--faint);
  cursor: pointer;
}
.sheet__close svg { width: 15px; }

.sheet__media {
  margin: 0 0 26px;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255, 255, 255, .03);
  box-shadow: 0 20px 50px -22px rgba(0, 0, 0, .9);
}
.sheet__media img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 40dvh;
  object-fit: cover;
}

#sheet-date {
  font-size: 22px;
  line-height: 1;
  letter-spacing: 0;
  text-transform: none;
  margin-bottom: 4px;
}

.sheet__title {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(1.7rem, 7vw, 2.3rem);
  line-height: 1.16;
  letter-spacing: -.005em;
  margin: 12px 0 20px;
  color: #fdf8f0;
  text-wrap: balance;
}

.sheet__text p {
  font-size: 15.5px;
  line-height: 1.78;
  color: rgba(244, 239, 231, .74);
  margin-bottom: 1.05em;
}
.sheet__text p:last-child { margin-bottom: 0; }

/* ---------- finale ---------- */

.finale {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: calc(var(--pad) + 8px);
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  background:
    radial-gradient(90% 60% at 50% 30%, rgba(40, 26, 76, .55), transparent 70%),
    rgba(4, 6, 14, .93);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: opacity 1.4s var(--ease), visibility 1.4s;
}

.finale__inner {
  text-align: center;
  max-width: 32rem;
  padding: 40px 0;
}
.finale:not(.is-hidden) .finale__inner { animation: rise 1.8s var(--ease) both; }

.finale__title {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(2rem, 9vw, 3rem);
  line-height: 1.14;
  margin-top: 18px;
  background: linear-gradient(175deg, #fffaf2 10%, var(--gold) 66%, #d09f6e 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-wrap: balance;
}

.finale__text p {
  font-family: var(--serif);
  font-size: clamp(1rem, 4.4vw, 1.18rem);
  line-height: 1.82;
  color: rgba(244, 239, 231, .78);
  margin-bottom: 1.15em;
  text-wrap: pretty;
}

.finale__title .plain {
  -webkit-text-fill-color: #ffe6bd;
  color: #ffe6bd;
  background: none;
}

.finale__sign {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--gold-dim);
  margin: 30px 0 34px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .18s !important;
  }
}
