:root {
  --ink: #14080e;
  --wine: #4a1528;
  --rose: #c23a54;
  --blush: #e8b4b8;
  --petal: #f6d5d8;
  --gold: #d4af77;
  --gold-soft: #e8d5b0;
  --ivory: #f6efe6;
  --mist: rgba(246, 239, 230, 0.72);
  --glass: rgba(18, 8, 12, 0.55);
  --line: rgba(212, 175, 119, 0.35);
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  --serif: "Cormorant Garamond", "Times New Roman", serif;
  --display: "Cinzel", serif;
  --script: "Great Vibes", cursive;
  --urdu: "Noto Nastaliq Urdu", "Cormorant Garamond", serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --app-height: 100dvh;
  --hud-space: 0px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: auto;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  color-scheme: dark;
}

html,
body {
  min-height: 100%;
  min-height: var(--app-height);
  background: var(--ink);
  color: var(--ivory);
  font-family: var(--serif);
  overflow-x: hidden;
  overscroll-behavior-x: none;
}

html.sealed,
body.sealed {
  overflow: hidden;
  height: 100%;
  height: var(--app-height);
}

body {
  cursor: none;
}

body.is-touch {
  cursor: auto;
}

body.sealed {
  overflow: hidden;
}

::selection {
  background: rgba(194, 58, 84, 0.45);
  color: #fff;
}

#garden {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  height: var(--app-height);
}

.vignette,
.grain,
.cursor,
.progress {
  pointer-events: none;
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 2;
  background:
    radial-gradient(ellipse at center, transparent 40%, rgba(8, 3, 6, 0.72) 100%),
    linear-gradient(180deg, rgba(8, 3, 6, 0.35), transparent 18%, transparent 82%, rgba(8, 3, 6, 0.55));
}

.grain {
  position: fixed;
  inset: -20%;
  z-index: 3;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 8s steps(6) infinite;
}

@keyframes grain {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-2%, 1%); }
  40% { transform: translate(1%, -2%); }
  60% { transform: translate(-1%, 2%); }
  80% { transform: translate(2%, -1%); }
}

.cursor {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 80;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 1px solid var(--gold);
  border-radius: 50%;
  mix-blend-mode: difference;
  transition: transform 0.25s ease, width 0.25s, height 0.25s, margin 0.25s;
}

.cursor.hot {
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
}

.cursor::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: var(--gold);
  opacity: 0.35;
}

.progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 40;
  height: 2px;
  width: 0;
  background: linear-gradient(90deg, #7a1f36, var(--gold), var(--blush));
  box-shadow: 0 0 16px var(--gold);
}

.hud {
  position: fixed;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--display);
  font-size: 10px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--gold-soft);
}

.hud-left {
  top: 28px;
  left: 28px;
}

.hud-right {
  top: 28px;
  right: 28px;
}

button,
input,
.rose-key {
  -webkit-tap-highlight-color: rgba(212, 175, 119, 0.22);
  touch-action: manipulation;
}

.hud button,
.seal-btn,
.play-btn,
.unlock-btn,
.reply-btn {
  font: inherit;
  color: inherit;
  background: transparent;
  border: 1px solid var(--line);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  cursor: none;
  transition: 0.35s ease;
}

.label-short {
  display: none;
}

body.is-touch .hud button,
body.is-touch .seal-btn,
body.is-touch .play-btn,
body.is-touch .unlock-btn,
body.is-touch .reply-btn {
  cursor: pointer;
}

.hud button {
  padding: 8px 14px;
  border-radius: 999px;
}

.hud button:hover,
.play-btn:hover,
.unlock-btn:hover,
.reply-btn:hover {
  background: rgba(212, 175, 119, 0.12);
  color: #fff;
}

.chapter-mark {
  opacity: 0.7;
}

.story {
  position: relative;
  z-index: 10;
}

img {
  max-width: 100%;
}

.gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background:
    linear-gradient(180deg, rgba(8, 3, 6, 0.35), rgba(8, 3, 6, 0.72)),
    url("../assets/letter.jpg") center/cover;
  transition: opacity 1.4s ease, visibility 1.4s;
}

.gate.is-gone {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.gate-inner {
  width: min(520px, 88vw);
  text-align: center;
  transform-style: preserve-3d;
  animation: floatCard 7s ease-in-out infinite;
}

@keyframes floatCard {
  0%, 100% { transform: translateY(0) rotateX(4deg); }
  50% { transform: translateY(-10px) rotateX(-2deg); }
}

.seal-wrap {
  width: 148px;
  height: 148px;
  margin: 0 auto 28px;
  filter: drop-shadow(0 16px 30px rgba(90, 12, 28, 0.55));
}

.seal-btn {
  width: 148px;
  height: 148px;
  padding: 0;
  border: 0;
  background: transparent;
  animation: pulseSeal 2.8s ease-in-out infinite;
}

@keyframes pulseSeal {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

.eyebrow {
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.46em;
  text-transform: uppercase;
  color: var(--gold);
}

.gate h1,
.hero-name {
  font-family: var(--script);
  font-size: clamp(64px, 12vw, 132px);
  font-weight: 400;
  line-height: 0.9;
  color: #fff;
  text-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}

.gate p,
.lede {
  margin: 18px auto 0;
  max-width: 36ch;
  font-size: 22px;
  font-style: italic;
  color: var(--mist);
}

.hint {
  margin-top: 28px;
  font-family: var(--display);
  font-size: 10px;
  letter-spacing: 0.38em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.8;
}

.scene {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 14vh 7vw;
}

.scene.tall {
  min-height: 160vh;
}

.scene.extra {
  min-height: 200vh;
}

.card,
.panel,
.letter-sheet {
  width: min(760px, 92vw);
  padding: 48px 48px 44px;
  background:
    linear-gradient(180deg, rgba(28, 12, 18, 0.72), rgba(12, 6, 10, 0.78));
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  transform: translateY(40px) rotateX(8deg);
  transform-style: preserve-3d;
  opacity: 0;
  transition: opacity 1s ease, transform 1.1s cubic-bezier(0.16, 1, 0.3, 1);
}

.scene.in .card,
.scene.in .panel,
.scene.in .letter-sheet,
.scene.in .reason,
.scene.in .promise,
.scene.in .memory {
  opacity: 1;
  transform: none;
}

.ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 22px;
  color: var(--gold);
}

.ornament svg {
  width: 120px;
  height: 18px;
}

.kicker {
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--gold);
}

h2 {
  margin: 10px 0 18px;
  font-family: var(--display);
  font-size: clamp(26px, 4vw, 48px);
  font-weight: 500;
  letter-spacing: 0.06em;
  overflow-wrap: break-word;
  text-wrap: balance;
}

h3 {
  font-family: var(--display);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--gold-soft);
}

.urdu {
  font-family: var(--urdu);
  font-size: clamp(22px, 4vw, 40px);
  line-height: 2.15;
  color: var(--petal);
  overflow-wrap: anywhere;
}

p {
  margin: 0 0 16px;
  font-size: clamp(18px, 2.1vw, 22px);
  line-height: 1.7;
  color: rgba(246, 239, 230, 0.88);
}

p.soft {
  color: rgba(232, 180, 184, 0.9);
  font-style: italic;
}

p:last-child {
  margin-bottom: 0;
}

.hero {
  min-height: 100vh;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 12vh 6vw 18vh;
}

.hero-copy {
  position: relative;
  z-index: 2;
}

.scroll-cue {
  position: absolute;
  bottom: 36px;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: 10px;
  font-family: var(--display);
  font-size: 10px;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--gold);
}

.scroll-cue i {
  width: 1px;
  height: 56px;
  background: linear-gradient(var(--gold), transparent);
  animation: drip 2s ease-in-out infinite;
}

@keyframes drip {
  0% { transform: scaleY(0); transform-origin: top; opacity: 0; }
  40% { opacity: 1; }
  100% { transform: scaleY(1); transform-origin: top; opacity: 0; }
}

.frame {
  width: min(980px, 92vw);
  aspect-ratio: 16 / 9;
  border-radius: 28px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  transform: perspective(1200px) rotateX(10deg) scale(0.96);
  transform-origin: center;
  opacity: 0;
  transition: 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.scene.in .frame {
  opacity: 1;
  transform: none;
}

.frame img,
.portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: saturate(0.92) contrast(1.05);
}

.split {
  width: min(1100px, 94vw);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 36px;
  align-items: center;
}

.portrait {
  aspect-ratio: 4 / 5;
  border-radius: 28px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  transform: rotateY(-14deg) rotateX(4deg);
  transform-origin: left center;
  opacity: 0;
  transition: 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.scene.in .portrait {
  opacity: 1;
  transform: none;
}

.meanings {
  display: grid;
  gap: 16px;
  margin-top: 8px;
}

.meanings li {
  list-style: none;
  padding: 14px 18px;
  border-left: 1px solid var(--gold);
  background: rgba(212, 175, 119, 0.05);
}

.reasons {
  width: min(1100px, 94vw);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.reason {
  min-height: 220px;
  padding: 26px 22px 22px;
  background: rgba(16, 7, 12, 0.7);
  border: 1px solid var(--line);
  border-radius: 22px;
  backdrop-filter: blur(12px);
  opacity: 0;
  transform: translateY(30px) rotateX(10deg);
  transition: 0.8s ease;
}

.reason:nth-child(2) { transition-delay: 0.08s; }
.reason:nth-child(3) { transition-delay: 0.16s; }
.reason:nth-child(4) { transition-delay: 0.04s; }
.reason:nth-child(5) { transition-delay: 0.12s; }
.reason:nth-child(6) { transition-delay: 0.2s; }
.reason:nth-child(7) { transition-delay: 0.06s; }
.reason:nth-child(8) { transition-delay: 0.14s; }
.reason:nth-child(9) { transition-delay: 0.22s; }
.reason:nth-child(10) { transition-delay: 0.1s; }
.reason:nth-child(11) { transition-delay: 0.18s; }
.reason:nth-child(12) { transition-delay: 0.26s; }

.reason:hover {
  transform: translateY(-8px) rotateX(0) rotateY(-4deg);
  border-color: rgba(212, 175, 119, 0.7);
}

.reason .num {
  font-family: var(--script);
  font-size: 36px;
  color: var(--gold);
  line-height: 1;
}

.reason h3 {
  margin: 8px 0 10px;
  font-size: 16px;
}

.reason p {
  font-size: 17px;
  margin: 0;
}

.memories,
.promises {
  width: min(860px, 92vw);
  display: grid;
  gap: 18px;
}

.memory,
.promise {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 18px;
  align-items: start;
  padding: 22px 24px;
  background: rgba(16, 7, 12, 0.66);
  border: 1px solid var(--line);
  border-radius: 20px;
  opacity: 0;
  transform: translateX(-24px);
  transition: 0.8s ease;
}

.scene.in .memory:nth-child(even),
.scene.in .promise:nth-child(even) {
  transition-delay: 0.1s;
}

.ico {
  width: 64px;
  height: 64px;
}

.mystery {
  width: min(640px, 92vw);
  text-align: center;
}

.lock-row {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin: 28px 0 10px;
}

.rose-key {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(18, 8, 12, 0.65);
  display: grid;
  place-items: center;
  transition: 0.35s ease;
}

.rose-key svg {
  width: 42px;
  height: 42px;
}

.rose-key.lit {
  border-color: var(--gold);
  box-shadow: 0 0 28px rgba(212, 175, 119, 0.45);
  transform: translateY(-4px);
}

.hidden-letter {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: 1s ease;
}

.hidden-letter.open {
  max-height: 900px;
  opacity: 1;
  margin-top: 24px;
}

.unlock-form {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 18px;
  flex-wrap: wrap;
}

.unlock-form input {
  width: min(280px, 70vw);
  padding: 12px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ivory);
  font-family: var(--serif);
  font-size: 18px;
  text-align: center;
}

.unlock-form input:focus {
  outline: 1px solid var(--gold);
}

.unlock-btn,
.reply-btn,
.play-btn {
  padding: 12px 22px;
  border-radius: 999px;
}

.finale {
  min-height: 120vh;
  text-align: center;
}

.finale .hero-name {
  display: block;
}

.big-sorry {
  font-family: var(--display);
  font-size: clamp(36px, 7vw, 84px);
  letter-spacing: 0.08em;
  margin: 10px 0 18px;
}

.reply {
  margin-top: 28px;
  display: grid;
  gap: 12px;
  justify-items: center;
}

.reply-note {
  min-height: 28px;
  font-style: italic;
  color: var(--blush);
}

.flower-rain {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
}

.credits {
  padding: 20vh 8vw 18vh;
  text-align: center;
}

.credits small {
  display: block;
  margin-top: 18px;
  font-family: var(--display);
  letter-spacing: 0.32em;
  text-transform: uppercase;
  font-size: 10px;
  color: var(--gold);
}

@media (max-width: 860px) {
  :root {
    --hud-space: calc(72px + var(--safe-bottom));
  }

  body,
  body.is-touch {
    cursor: auto;
  }

  .cursor,
  .grain {
    display: none;
  }

  .vignette {
    background:
      radial-gradient(ellipse at center, transparent 28%, rgba(8, 3, 6, 0.78) 100%),
      linear-gradient(180deg, rgba(8, 3, 6, 0.45), transparent 16%, transparent 78%, rgba(8, 3, 6, 0.7));
  }

  .hud-left {
    display: none;
  }

  .hud-right {
    top: auto;
    bottom: calc(10px + var(--safe-bottom));
    left: calc(10px + var(--safe-left));
    right: calc(10px + var(--safe-right));
    max-width: none;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 8px 8px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(12, 6, 10, 0.78);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  }

  .hud {
    font-size: 9px;
    letter-spacing: 0.16em;
  }

  .chapter-mark {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .hud button {
    flex: 0 0 auto;
    min-height: 40px;
    padding: 8px 12px;
  }

  .label-full {
    display: none;
  }

  .label-short {
    display: inline;
  }

  .gate {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: calc(20px + var(--safe-top)) 18px calc(24px + var(--safe-bottom));
    place-items: start center;
    background-position: 62% center;
  }

  .gate-inner {
    width: min(520px, 100%);
    animation: none;
    padding: 8px 0 16px;
  }

  .seal-wrap,
  .seal-btn {
    width: 128px;
    height: 128px;
  }

  .seal-btn svg {
    width: 128px;
    height: 128px;
  }

  .eyebrow,
  .kicker,
  .hint {
    letter-spacing: 0.22em;
    font-size: 10px;
  }

  .gate h1,
  .hero-name {
    font-size: clamp(56px, 22vw, 92px);
  }

  .gate p,
  .lede {
    font-size: 17px;
    max-width: 34ch;
    margin-top: 14px;
  }

  .story {
    padding-bottom: var(--hud-space);
  }

  .hero {
    min-height: var(--app-height);
    padding: calc(12vh + var(--safe-top)) 6vw calc(18vh + var(--hud-space));
  }

  .scroll-cue {
    bottom: calc(88px + var(--safe-bottom));
    letter-spacing: 0.22em;
  }

  .scroll-cue i {
    height: 36px;
  }

  .scene,
  .scene.tall,
  .scene.extra {
    min-height: 0;
    padding: 11vh 4.5vw 7vh;
  }

  .finale {
    min-height: var(--app-height);
    padding-bottom: calc(8vh + var(--hud-space));
  }

  .credits {
    padding: 16vh 6vw calc(14vh + var(--hud-space));
  }

  .split,
  .reasons {
    grid-template-columns: 1fr;
    width: min(1100px, 100%);
  }

  .split > *,
  .card,
  .panel,
  .letter-sheet,
  .reason,
  .memory,
  .promise {
    min-width: 0;
  }

  .card,
  .panel,
  .letter-sheet,
  .mystery,
  .memories,
  .promises {
    width: min(760px, 100%);
  }

  .card,
  .panel,
  .letter-sheet {
    padding: 28px 20px 24px;
    border-radius: 22px;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(16, 7, 12, 0.9);
    transform: translateY(28px);
  }

  .reason {
    min-height: 0;
    backdrop-filter: none;
    transform: translateY(20px);
  }

  .reason:hover {
    transform: none;
  }

  .portrait {
    transform: none;
    aspect-ratio: 5 / 4;
    max-height: 52vh;
  }

  .frame {
    width: min(980px, 100%);
    aspect-ratio: 4 / 3;
    border-radius: 18px;
    transform: none;
  }

  .memory,
  .promise {
    grid-template-columns: 52px 1fr;
    gap: 12px;
    padding: 16px;
    transform: translateY(16px);
  }

  .ico {
    width: 48px;
    height: 48px;
  }

  p {
    font-size: 17px;
    line-height: 1.65;
  }

  h2 {
    font-size: clamp(24px, 7vw, 34px);
    letter-spacing: 0.03em;
  }

  .big-sorry {
    font-size: clamp(32px, 12vw, 56px);
    letter-spacing: 0.04em;
  }

  .unlock-form {
    flex-direction: column;
    align-items: stretch;
  }

  .unlock-form input,
  .unlock-btn,
  .reply-btn {
    width: 100%;
    max-width: none;
    min-height: 48px;
    font-size: 16px;
    letter-spacing: 0.1em;
  }

  .reply {
    width: 100%;
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
    padding: 0 4px;
  }

  .lock-row {
    gap: 12px;
  }

  .rose-key {
    width: 64px;
    height: 64px;
  }

  .hidden-letter.open {
    max-height: none;
  }
}

@media (max-width: 480px) {
  .seal-wrap,
  .seal-btn,
  .seal-btn svg {
    width: 112px;
    height: 112px;
  }

  .gate h1,
  .hero-name {
    font-size: clamp(48px, 20vw, 72px);
  }

  .reasons {
    gap: 12px;
  }

  .reason {
    padding: 18px 16px;
  }

  .meanings li {
    padding: 12px 12px;
  }

  .hud-right {
    border-radius: 22px;
    padding: 8px;
  }

  .chapter-mark {
    display: none;
  }

  .hud-right {
    justify-content: center;
  }

  .hud button {
    flex: 1 1 auto;
  }
}

@media (max-width: 860px) and (orientation: landscape) {
  .gate {
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .seal-wrap {
    margin-bottom: 10px;
  }

  .hero {
    padding-top: 16px;
  }

  .scene,
  .scene.tall,
  .scene.extra {
    padding-top: 8vh;
    padding-bottom: 6vh;
  }

  .frame {
    aspect-ratio: 16 / 9;
    max-height: 70vh;
  }

  .portrait {
    max-height: 70vh;
  }
}

@media (hover: none) {
  .cursor {
    display: none;
  }

  .reason:hover,
  .card:hover,
  .panel:hover {
    transform: none;
  }
}

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

  .grain {
    display: none;
  }
}
