* {
  box-sizing: border-box;
}

:root {
  --night: #24152f;
  --plum: #382044;
  --pink: #f5b9cf;
  --rose: #e88eae;
  --cream: #fff6ed;
  --ink: #38253d;
  --muted: #d9c5d9;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--cream);
  font-family: "DM Sans", sans-serif;
  background:
    radial-gradient(ellipse at 18% 20%, rgba(135, 76, 135, .28), transparent 35%),
    radial-gradient(ellipse at 82% 80%, rgba(196, 103, 142, .18), transparent 34%),
    var(--night);
  overflow-x: hidden;
}

body::before,
body::after {
  content: "✦   ·      ✧       ·   ✦       ·      ✧";
  position: fixed;
  z-index: 0;
  color: rgba(255, 230, 244, .22);
  letter-spacing: 2rem;
  font-size: 1rem;
  white-space: nowrap;
  pointer-events: none;
}

body::before { top: 12%; left: -2rem; }
body::after { bottom: 13%; right: -2rem; transform: rotate(180deg); }

main {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

.screen {
  min-height: 100vh;
  width: 100%;
  padding: 3rem 1.25rem;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  animation: appear .7s ease both;
}

.screen.active { display: flex; }

@keyframes appear {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

.intro-content { width: min(100%, 620px); }

.eyebrow {
  font-size: .68rem;
  letter-spacing: .28em;
  font-weight: 700;
  color: var(--pink);
}

h1, h2 {
  font-family: "Playfair Display", Georgia, serif;
  font-weight: 700;
}

.intro-screen h1 {
  margin: .6rem 0;
  font-size: clamp(3.8rem, 11vw, 7rem);
  line-height: 1;
  color: var(--cream);
}

.intro-screen h1 span {
  color: var(--pink);
  font-family: sans-serif;
  font-size: .42em;
  vertical-align: top;
  margin-left: .2em;
}

.intro-copy {
  color: var(--muted);
  font-size: clamp(.95rem, 2.5vw, 1.1rem);
}

.envelope-wrap {
  margin: 3rem auto 1.5rem;
  width: 170px;
  height: 125px;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 18px 24px rgba(0,0,0,.22));
}

.envelope {
  position: relative;
  width: 150px;
  height: 96px;
  border-radius: 8px;
  background: linear-gradient(145deg, #f4bfd0, #d985a9);
  overflow: visible;
}

.envelope::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(35deg, transparent 49%, rgba(255,255,255,.25) 50%, transparent 51%);
  border-radius: inherit;
}

.envelope-flap {
  position: absolute;
  z-index: 2;
  top: -1px;
  left: 0;
  width: 0;
  height: 0;
  border-left: 75px solid transparent;
  border-right: 75px solid transparent;
  border-top: 58px solid #f8d6df;
  transform-origin: top;
}

.envelope-heart {
  position: absolute;
  z-index: 3;
  top: 39px;
  left: 64px;
  color: #873d68;
  font-size: 1.8rem;
}

.open-card, .scroll-button, .replay-button {
  border: 0;
  border-radius: 999px;
  padding: .95rem 1.8rem;
  color: var(--night);
  background: var(--pink);
  font: 700 1rem "DM Sans", sans-serif;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(232, 142, 174, .2);
  transition: transform .2s ease, background .2s ease, box-shadow .2s ease;
}

.open-card:hover, .scroll-button:hover, .replay-button:hover {
  transform: translateY(-3px);
  background: #ffd2df;
  box-shadow: 0 12px 28px rgba(232, 142, 174, .3);
}

.open-card span { margin-left: .45rem; }
.tiny-note, .scroll-hint { color: #bda8c2; font-size: .75rem; margin-top: 1.25rem; }

.card-screen { gap: 1.5rem; }

.birthday-card {
  position: relative;
  width: min(100%, 510px);
  padding: 2rem 1.5rem 1.6rem;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 12%, rgba(255,255,255,.9), transparent 24%),
    linear-gradient(145deg, #fff9f1, #f8e5eb);
  border: 2px dashed #bd7796;
  outline: 7px solid rgba(255, 246, 237, .07);
  border-radius: 13px;
  box-shadow: 0 24px 70px rgba(0,0,0,.3);
  overflow: hidden;
}

.birthday-card::before {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1px dotted rgba(166, 91, 127, .45);
  border-radius: 7px;
  pointer-events: none;
}

.card-topline {
  color: #a45d7c;
  font-size: .58rem;
  letter-spacing: .25em;
  font-weight: 700;
}

.card-kicker {
  margin: 1.4rem 0 .3rem;
  color: #91657d;
  font-size: .8rem;
  letter-spacing: .08em;
}

.birthday-card h2 {
  margin: .2rem 0 0;
  font-size: clamp(2.7rem, 9vw, 4.2rem);
  line-height: .98;
  color: #56324e;
}

.birthday-card h2 em, .message-card h2 em {
  color: #c36d91;
  font-style: italic;
}

.name-script {
  margin: .65rem 0 .1rem;
  color: #9d5578;
  font-family: "Playfair Display", Georgia, serif;
  font-size: 1.55rem;
  font-style: italic;
}

.cake-scene {
  position: relative;
  height: 245px;
  width: min(100%, 340px);
  margin: .3rem auto .4rem;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.cake {
  position: relative;
  width: 245px;
  height: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.tier {
  position: relative;
  border: 2px solid rgba(151, 83, 111, .18);
  background: linear-gradient(90deg, #d98aa5, #f4c2ce 48%, #d98aa5);
  border-radius: 9px 9px 5px 5px;
  box-shadow: inset 0 -7px rgba(148, 73, 108, .1), 0 5px 8px rgba(83, 43, 68, .12);
}

.tier-top { width: 92px; height: 47px; z-index: 3; }
.tier-middle { width: 157px; height: 54px; margin-top: -2px; z-index: 2; }
.tier-bottom { width: 225px; height: 62px; margin-top: -2px; z-index: 1; }

.icing-drip {
  position: absolute;
  left: -2px;
  right: -2px;
  top: -5px;
  height: 14px;
  background: #fff0e9;
  border-radius: 9px 9px 5px 5px;
}

.icing-drip::after {
  content: "";
  position: absolute;
  left: 23%;
  top: 7px;
  width: 12px;
  height: 12px;
  background: #fff0e9;
  border-radius: 0 0 8px 8px;
  box-shadow: 37px 1px #fff0e9, 76px -1px #fff0e9;
}

.cake-plate {
  position: absolute;
  bottom: -7px;
  width: 250px;
  height: 11px;
  background: #b86d91;
  border-radius: 50%;
  box-shadow: 0 5px 0 rgba(120, 60, 91, .15);
}

.candles {
  position: absolute;
  z-index: 5;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 13px;
}

.candles i {
  position: relative;
  width: 7px;
  height: 34px;
  border-radius: 3px;
  background: repeating-linear-gradient(135deg, #fff1d9 0 5px, #b66a93 5px 9px);
}

.candles i::before {
  content: "";
  position: absolute;
  width: 10px;
  height: 14px;
  top: -15px;
  left: -1.5px;
  background: #ffbd61;
  border-radius: 60% 40% 60% 40%;
  transform: rotate(45deg);
  box-shadow: 0 0 13px rgba(255, 176, 76, .8);
  animation: flicker 1.1s infinite alternate;
}


#musicToggle {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 10;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  color: #ffffff;
  font-family: 'Baloo 2', sans-serif;
  background: radial-gradient(circle, rgba(255, 95, 168, 0.95), rgba(255, 95, 168, 0.55));
  box-shadow: 0 0 14px rgba(255, 95, 168, 0.7);
  transition: transform 0.2s ease;
}

#musicToggle:hover {
  transform: scale(1.08);
}

#musicToggle:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 3px;
}

#musicToggle.playing {
  animation: musicPulse 1.6s ease-in-out infinite;
}

@keyframes musicPulse {
  0%, 100% { box-shadow: 0 0 14px rgba(255, 95, 168, 0.7); }
  50%      { box-shadow: 0 0 26px rgba(255, 95, 168, 1); }
}


@keyframes flicker {
  from { transform: rotate(40deg) scale(.9); opacity: .8; }
  to { transform: rotate(50deg) scale(1.08); opacity: 1; }
}

.cake-star { position: absolute; color: #c4779a; font-size: 1.5rem; }
.star-one { left: 8%; top: 42%; }
.star-two { right: 8%; top: 28%; font-size: 2rem; }
.star-three { right: 17%; bottom: 9%; }

.card-footer {
  margin: .4rem 0 0;
  color: #91657d;
  font-family: "Playfair Display", Georgia, serif;
  font-style: italic;
  font-size: 1rem;
}

.dotted-corner {
  position: absolute;
  right: 18px;
  bottom: 12px;
  color: #c4779a;
  font-size: 1.3rem;
}

.scroll-button { background: #f4c0d0; }
.scroll-button span { margin-left: .5rem; font-size: 1.2rem; }
.scroll-hint { margin: -.7rem 0 0; }

.message-screen { padding-top: 4rem; padding-bottom: 4rem; }

.message-card {
  position: relative;
  width: min(100%, 590px);
  padding: clamp(1.7rem, 5vw, 3rem);
  text-align: left;
  color: var(--ink);
  background: #fff7f0;
  border-radius: 15px;
  box-shadow: 0 25px 75px rgba(0,0,0,.28);
}

.message-decoration {
  position: absolute;
  right: 25px;
  top: 18px;
  color: #d88aa8;
  font-size: 2rem;
}

.message-card .eyebrow { color: #a55e7e; }

.message-card h2 {
  margin: .8rem 0 1rem;
  color: #56324e;
  font-size: clamp(2rem, 7vw, 3.1rem);
  line-height: 1.08;
}

.divider-heart {
  color: #c36d91;
  text-align: center;
  font-size: 1.7rem;
  margin: 1rem 0;
}

.message-text {
  color: #6e586b;
  font-size: .98rem;
  line-height: 1.85;
}

.message-highlight {
  margin-top: 1.5rem;
  color: #a34f77;
  font-family: "Playfair Display", Georgia, serif;
  font-size: 1.25rem;
  font-style: italic;
}

.signature {
  color: #8f778b;
  font-size: .85rem;
  text-align: right;
  margin-top: 1.8rem;
}

.replay-button { margin-top: 1.8rem; }

@media (max-width: 480px) {
  .screen { padding: 2rem 1rem; }
  .birthday-card { padding: 1.6rem 1rem 1.4rem; }
  .cake-scene { transform: scale(.91); transform-origin: center bottom; margin-top: -.3rem; margin-bottom: -.4rem; }
  .message-card { padding: 1.6rem 1.25rem; }
  .message-text { font-size: .92rem; }
}

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