:root {
  --bg: #0c0a0d;
  --ink: #f2e9e5;
  --muted: #a99da4;
  --pink: #d36c91;
  --pink-light: #f2a8c1;
  --line: #2b232b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: Georgia, 'Times New Roman', serif;
  scrollbar-color: #9e5872 #120e12;
  scrollbar-width: thin;
}

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: #120e12; }
::-webkit-scrollbar-thumb {
  min-height: 44px;
  background: linear-gradient(180deg, #7e4059, #b76583);
  border: 2px solid #120e12;
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover { background: linear-gradient(180deg, #a95574, #dc7da0); }
::-webkit-scrollbar-corner { background: #120e12; }

body {
  overflow-x: hidden;
  background: radial-gradient(circle at 50% -10%, #2a1723 0, transparent 35%), var(--bg);
}

.sky { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.stars { position: absolute; inset: 0; }
.stars-small { opacity: .58; }
.stars-medium { opacity: .76; }
.stars-large { opacity: .92; }
.star-particle {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: #fffafc;
  box-shadow: 0 0 calc(var(--size) * 2.2) #fff9, 0 0 calc(var(--size) * 4) #d998b855;
  animation: natural-twinkle var(--twinkle-time) ease-in-out var(--twinkle-delay) infinite alternate;
}
.star-particle.warm { background: #f3cfda; }
.star-particle.bright::before,
.star-particle.bright::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  border-radius: 50%;
  background: linear-gradient(90deg, transparent, #fff9, transparent);
  transform: translate(-50%, -50%);
}
.star-particle.bright::before { width: calc(var(--size) * 5); height: .5px; }
.star-particle.bright::after { width: .5px; height: calc(var(--size) * 5); background: linear-gradient(180deg, transparent, #fff9, transparent); }
.aurora { position: absolute; width: 70vw; height: 45vh; left: 15vw; top: -28vh; border-radius: 50%; background: #7e345b; filter: blur(90px); opacity: .13; animation: aurora-breathe 8s ease-in-out infinite alternate; }
.shooting-star { position: absolute; width: 140px; height: 1.5px; top: 8%; left: -160px; opacity: 0; transform-origin: right center; transform: rotate(19deg); background: linear-gradient(90deg, transparent 0%, #f7dce633 18%, #f7dce6bb 72%, #fff 100%); filter: drop-shadow(0 0 2px #f8dce6); }
.shooting-star::after { content: ''; position: absolute; right: -1px; top: -1.25px; width: 4px; height: 4px; border-radius: 50%; background: #fff; box-shadow: 0 0 4px #fff, 0 0 8px #e9afc5; }
.shooting-star-one { animation: shoot 10s 2.5s linear infinite; }
.shooting-star-two { top: 34%; width: 95px; animation: shoot 14s 8s linear infinite; }

.app { position: relative; z-index: 1; max-width: 520px; min-height: 100vh; margin: auto; padding: 42px 20px 110px; }
.screen { display: none; }
.screen.active, .screen.leaving { display: block; }
.screen.entering { animation: screen-in .48s cubic-bezier(.2,.8,.2,1) both; }
.screen.leaving { position: absolute; inset: 42px 20px auto; width: calc(100% - 40px); pointer-events: none; animation: screen-out .22s ease both; }

.eyebrow { color: #e596b2; text-align: center; letter-spacing: .12em; font-size: 14px; margin: 12px 0; }
h1, h2 { font-weight: 400; text-align: center; margin: 10px 0 14px; }
h1 { font-size: 38px; line-height: 1.08; }
h1 em { color: var(--pink); font-style: normal; text-shadow: 0 0 30px #d36c9166; }
h2 { font-size: 30px; }
.sub { color: var(--muted); text-align: center; line-height: 1.55; margin: 0 auto 28px; max-width: 430px; }

.mood-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mood-grid button, .letter-list button { position: relative; overflow: hidden; background: linear-gradient(145deg, #1d171ee8, #121014e8); border: 1px solid var(--line); color: var(--ink); border-radius: 16px; padding: 18px 12px; min-height: 92px; box-shadow: 0 10px 30px #0004; font: inherit; transition: transform .25s ease, border-color .25s ease, box-shadow .25s ease; }
.mood-grid button::after, .letter-list button::after { content: ''; position: absolute; inset: 0; opacity: 0; background: radial-gradient(circle at 50% 0, #d36c9126, transparent 65%); transition: opacity .25s ease; }
.mood-grid button:hover, .letter-list button:hover { transform: translateY(-3px); border-color: #694153; box-shadow: 0 14px 34px #0007, 0 0 25px #d36c9112; }
.mood-grid button:hover::after, .letter-list button:hover::after { opacity: 1; }
.mood-grid button span { display: block; color: var(--pink); font-size: 28px; margin-bottom: 8px; transition: transform .35s ease; }
.mood-grid button:hover span { transform: scale(1.18) rotate(6deg); }

.daily { margin-top: 22px; border: 1px solid #3a2932; border-radius: 18px; padding: 20px; background: #171116d9; backdrop-filter: blur(8px); }
.reveal-card { animation: card-rise .65s .18s cubic-bezier(.2,.8,.2,1) both; }
.daily small, .message-wrap small, .paper small { color: #d887a5; letter-spacing: .13em; }
.daily p { font-size: 20px; line-height: 1.5; }
.pill { border: 1px solid #4a3440; background: #0c0a0d55; color: #e7c9d4; border-radius: 999px; padding: 10px 16px; font: inherit; transition: transform .2s ease, background .2s ease, border-color .2s ease, box-shadow .2s ease; }
.pill:hover { background: #d36c9114; border-color: #9b5872; box-shadow: 0 0 18px #d36c911f; }
.back { margin-bottom: 30px; }
.message-wrap { text-align: center; padding-top: 8vh; }
.sigil { font-size: 58px; color: var(--pink); margin-bottom: 20px; filter: drop-shadow(0 0 14px #d36c9166); animation: heartbeat 2.4s ease-in-out infinite; }
.message-wrap blockquote { font-size: 28px; line-height: 1.45; margin: 24px 0 34px; }
.message-content-out { animation: message-out .16s ease both; }
.message-content-in { animation: message-in .42s cubic-bezier(.2,.8,.2,1) both; }
.actions { display: flex; justify-content: center; gap: 10px; }
.letter-sigil { width: 94px; margin: 0 auto 10px; color: var(--pink); filter: drop-shadow(0 12px 18px #0008) drop-shadow(0 0 14px #d36c913d); animation: letter-float 3.6s ease-in-out infinite; }
.letter-sigil svg { display: block; width: 100%; overflow: visible; }
.letter-envelope { fill: #171116; stroke: #c96f90; stroke-width: 2; }
.letter-fold { fill: none; stroke: #d887a5; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.letter-fold-bottom { opacity: .52; }
.letter-seal { fill: #7d334e; stroke: #edacc3; stroke-width: 1.5; }
.letter-heart { fill: #f3c6d6; transform-origin: 56px 52px; animation: seal-heartbeat 2.8s ease-in-out infinite; }
.letter-list { display: grid; gap: 10px; margin-top: 28px; }
.letter-list button { text-align: left; min-height: auto; padding: 18px 52px 18px 18px; }
.letter-list button::before { content: '♡'; position: absolute; z-index: 1; top: 50%; right: 19px; color: #c96f90; font-size: 23px; line-height: 1; transform: translateY(-50%); text-shadow: 0 0 14px #d36c9155; transition: color .25s ease, transform .25s ease; }
.letter-list button:hover::before { color: #f1b7cc; transform: translateY(-50%) scale(1.14) rotate(7deg); }
.letter-list strong { position: relative; z-index: 1; display: block; color: #e9c5d2; font-size: 17px; margin-bottom: 5px; }
.letter-list span { color: var(--muted); font-size: 14px; }
.paper { background: #bda08d; color: #251c20; border-radius: 3px; padding: 30px 25px; box-shadow: 0 20px 60px #0008; background-image: repeating-linear-gradient(0deg, #00000008 0 1px, transparent 1px 4px); transform-origin: top center; animation: unfold .6s cubic-bezier(.2,.8,.2,1) both; }
.paper small { color: #6d2e47; }
.paper p { font-size: 18px; line-height: 1.7; }
.signoff { text-align: right; margin-top: 30px; font-style: italic; color: #6d2e47; }

.page-sigil { margin: 32px auto 12px; color: var(--pink); text-align: center; font-size: 48px; line-height: 1; filter: drop-shadow(0 0 16px #d36c9166); animation: heartbeat 2.8s ease-in-out infinite; }
.moon-sigil { font-size: 58px; animation: natural-twinkle 3.5s ease-in-out infinite alternate; }
.memory-notes { margin-top: 28px; padding: 24px 20px; color: var(--muted); text-align: center; background: #171116d9; border: 1px solid #3a2932; border-radius: 18px; box-shadow: 0 18px 45px #0005; backdrop-filter: blur(8px); }
.memory-notes blockquote { color: var(--ink); font-size: 20px; line-height: 1.5; }
.prompt-pop { animation: message-in .4s cubic-bezier(.2,.8,.2,1) both; }
.favorite-list { display: grid; gap: 10px; margin-top: 25px; }
.fav { background: #171217d9; border: 1px solid var(--line); padding: 16px; border-radius: 14px; display: flex; gap: 12px; justify-content: space-between; align-items: center; animation: card-rise .4s both; }
.fav button { background: none; border: 0; color: #d67a9b; font-size: 20px; }
.portrait-copy { max-width: 430px; margin: 28px auto; padding: 24px; text-align: center; font-size: 20px; line-height: 1.6; color: #d7c8ce; background: #171116d9; border: 1px solid #3a2932; border-radius: 18px; box-shadow: 0 18px 45px #0005; }

nav { position: fixed; bottom: 0; left: 50%; z-index: 10; width: min(520px, 100%); display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 9px 8px max(9px, env(safe-area-inset-bottom)); transform: translateX(-50%); background: #0e0b0fe8; backdrop-filter: blur(15px); border-top: 1px solid #2d242c; }
nav button { position: relative; border: 0; background: none; color: #857981; font-size: 19px; transition: color .25s ease, transform .25s ease; }
nav button.active { color: var(--pink); transform: translateY(-2px); text-shadow: 0 0 15px #d36c9188; }
nav button.active::before { content: ''; position: absolute; top: -9px; left: 38%; width: 24%; height: 2px; border-radius: 2px; background: var(--pink); box-shadow: 0 0 9px var(--pink); }
nav small { display: block; font-family: system-ui; font-size: 10px; margin-top: 4px; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:active { transform: scale(.96); }

#celebrations { position: fixed; inset: 0; z-index: 30; pointer-events: none; overflow: hidden; }
.floating-heart { position: absolute; color: var(--pink-light); font-size: 18px; text-shadow: 0 0 10px #d36c91; animation: float-heart 1.15s ease-out forwards; }
.save-button.saved { animation: saved-pulse .45s ease; }

@keyframes screen-in { from { opacity: 0; transform: translateY(18px) scale(.99); filter: blur(3px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes screen-out { to { opacity: 0; transform: translateY(-8px) scale(.99); filter: blur(2px); } }
@keyframes message-out { to { opacity: 0; transform: translateY(-8px); } }
@keyframes message-in { from { opacity: 0; transform: translateY(12px); filter: blur(2px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes card-rise { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: none; } }
@keyframes heartbeat { 0%, 100% { transform: scale(1); } 8% { transform: scale(1.12); } 16% { transform: scale(1); } 24% { transform: scale(1.08); } 36% { transform: scale(1); } }
@keyframes unfold { from { opacity: 0; transform: perspective(900px) rotateX(-9deg) translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes natural-twinkle { from { opacity: .28; transform: scale(.72); } to { opacity: 1; transform: scale(1.12); } }
@keyframes aurora-breathe { to { opacity: .22; transform: scale(1.16) translateX(4%); } }
@keyframes shoot {
  0%, 78% { opacity: 0; transform: translate(-15vw, -5vw) rotate(19deg); }
  79% { opacity: 1; }
  89% { opacity: 1; transform: translate(140vw, 48vw) rotate(19deg); }
  90%, 100% { opacity: 0; transform: translate(140vw, 48vw) rotate(19deg); }
}
@keyframes float-heart { 0% { opacity: 0; transform: translate(-50%, 0) scale(.5) rotate(0); } 18% { opacity: 1; } 100% { opacity: 0; transform: translate(calc(-50% + var(--drift)), -115px) scale(1.25) rotate(var(--spin)); } }
@keyframes saved-pulse { 50% { color: #fff; border-color: var(--pink); background: #d36c912a; transform: scale(1.06); } }
@keyframes letter-float { 0%, 100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-5px) rotate(1deg); } }
@keyframes seal-heartbeat { 0%, 76%, 100% { transform: scale(1); } 82% { transform: scale(1.18); } 88% { transform: scale(1); } 93% { transform: scale(1.1); } }

@media (max-width: 370px) {
  .app { padding-inline: 14px; }
  h1 { font-size: 34px; }
  .message-wrap blockquote { font-size: 24px; }
}

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