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

:root {
  --pink: #f8dce8;
  --deep-pink: #bd6489;
  --dark-pink: #8f4568;
  --pale: #fff8fb;
  --shadow: 0 24px 70px rgba(116, 54, 83, .20);
}
* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; color: var(--dark-pink);
  background: radial-gradient(circle at 20% 20%, #fff7fa, transparent 34%),
              radial-gradient(circle at 85% 80%, #f6d4e2, transparent 38%), #fceaf1;
  font-family: 'DM Sans', sans-serif;
}
.scene { min-height: 100vh; display: grid; place-items: center; padding: 28px 16px; }
.book-wrap { width: min(92vw, 680px); }
.book {
  position: relative; width: 100%; aspect-ratio: 1 / 1.12;
  min-height: 490px; max-height: 760px; border-radius: 10px 22px 22px 10px;
  filter: drop-shadow(0 20px 28px rgba(121, 57, 87, .14));
}
.page {
  position: absolute; inset: 0; overflow: hidden; border-radius: 10px 22px 22px 10px;
  background: var(--pale); border: 1px solid #e9b9cd;
  box-shadow: inset 10px 0 18px rgba(153, 79, 111, .06);
}
.page[hidden] { display: none; }
.cover {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 42px 28px;
  background: radial-gradient(ellipse at center, rgba(255,255,255,.68), transparent 58%),
              linear-gradient(145deg, #fce8f0, #f4cddd 62%, #f9e6ee);
  border: 9px double #e7a9c3;
}
.cover:before, .cover:after {
  content: "✧"; position: absolute; color: #d98eae; font-size: 25px; opacity: .8;
}
.cover:before { top: 24px; left: 27px; }
.cover:after { bottom: 24px; right: 27px; }
.cover-copy { width: 100%; position: relative; z-index: 2; }
.lily { position: absolute; width: clamp(92px, 19%, 145px); height: auto; z-index: 1; opacity: .96; filter: drop-shadow(0 5px 5px rgba(155, 76, 111, .10)); }
.lily-left { left: 1.5%; bottom: 3%; transform: rotate(-8deg); }
.lily-right { right: 1.5%; top: 3%; transform: rotate(8deg) scaleX(-1); }
.title-divider { display: flex; align-items: center; justify-content: center; gap: 10px; color: #c47b9b; margin: 2px 0 18px; }
.title-divider i { display: block; width: 62px; height: 1px; background: #d89ab4; }
.title-divider span { font-size: 13px; }
.eyebrow { text-transform: uppercase; letter-spacing: 3px; font-size: 10px; color: #b36c8d; }
h1, h2, .georgian { font-family: 'Playfair Display', Georgia, serif; }
.cover h1 { font-size: clamp(35px, 7.5vw, 59px); line-height: 1.08; margin: 18px 0 12px; color: #a94f78; letter-spacing: -.8px; text-shadow: 0 2px 0 rgba(255,255,255,.55); }
.georgian { font-size: clamp(18px, 4.2vw, 28px); font-style: italic; margin: 0; color: #b85e86; text-shadow: 0 1px 0 #fff; }
.cover h2 { font-size: clamp(39px, 7.8vw, 58px); font-style: italic; margin: 10px 0; color: #99466e; text-shadow: 0 2px 0 rgba(255,255,255,.65); }
.heart { font-size: 35px; color: #c66f96; margin-top: 20px; }
.next-arrow, .back-arrow {
  border: 0; background: #e9b2c9; color: #783d5a; width: 48px; height: 44px;
  border-radius: 24px; font-size: 25px; cursor: pointer; transition: transform .2s, background .2s;
}
.next-arrow:hover, .back-arrow:hover { transform: translateX(3px); background: #e39dbb; }
.cover-arrow { position: absolute; right: 24px; bottom: 22px; }
.photo-page { padding: clamp(18px, 4vw, 34px); display: flex; flex-direction: column; }
.page-heading { text-align: center; display: flex; justify-content: center; align-items: center; gap: 13px; font-family: 'Playfair Display', Georgia, serif; font-style: italic; font-size: clamp(18px, 3.5vw, 25px); color: #a74f78; margin-bottom: 18px; }
.tiny-heart { color: #d68cac; font-size: 19px; }
.photo-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: clamp(10px, 2.5vw, 18px); }
.photo-frame { min-height: 0; padding: 7px; background: #f4cddd; border: 1px solid #e4a9c1; border-radius: 12px; box-shadow: 0 4px 12px rgba(145, 69, 102, .10); }
.photo-frame img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 7px; background: #f8e4ed; }
.page-footer { display: flex; align-items: center; justify-content: space-between; padding-top: 14px; color: #b36c8d; font-size: 12px; }
.final-page { display: grid; place-items: center; padding: clamp(22px, 5vw, 48px); background: linear-gradient(150deg, #fff9fc, #fbe5ee); }
.final-inner { width: 100%; max-width: 520px; text-align: center; }
.final-hearts { color: #cf83a4; font-size: 25px; letter-spacing: 8px; }
.final-inner h2 { font-size: clamp(27px, 5vw, 39px); color: #a34e77; margin: 16px 0 8px; }
.edit-hint { color: #b27691; font-size: 13px; }
#loveMessage {
  display: block; width: 100%; min-height: 150px; resize: vertical; padding: 20px;
  border: 2px solid #edc0d2; border-radius: 14px; background: #fffafd; color: #874765;
  font: italic 18px/1.65 'Playfair Display', Georgia, serif; text-align: center; outline: none;
}
#loveMessage:focus { border-color: #cc83a2; box-shadow: 0 0 0 3px rgba(204, 131, 162, .12); }
.saved-note { min-height: 18px; color: #b27691; font-size: 11px; }
.final-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 22px; color: #b27691; font-size: 11px; }
.back-arrow { width: 40px; height: 38px; font-size: 22px; }
.restart { border: 0; background: transparent; color: #a34e77; text-decoration: underline; cursor: pointer; font: inherit; }
.instruction { text-align: center; color: #ad718d; font-size: 12px; margin: 18px 0 0; }
.empty-message { display: grid; place-items: center; text-align: center; border: 2px dashed #e6b5c9; border-radius: 12px; padding: 20px; color: #a96b88; grid-column: 1 / -1; }
@media (max-width: 520px) {
  .book { min-height: 460px; aspect-ratio: .82 / 1; }
  .cover { padding: 30px 18px; }
  .cover-flourish { top: 40px; }
  .photo-page { padding: 17px; }
  .photo-grid { gap: 9px; }
  .photo-frame { padding: 5px; }
  .final-page { padding: 20px; }
  #loveMessage { min-height: 145px; font-size: 16px; }
}

@media (max-width: 520px) {
  .lily { width: 22%; }
  .lily-left { left: -1%; bottom: 2%; }
  .lily-right { right: -1%; top: 2%; }
  .cover h1 { margin-top: 10px; }
}


/* Opening gift intro */
.gift-intro {
  position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column;
  align-items: center; justify-content: center; overflow: hidden; padding: 24px;
  text-align: center; background:
    radial-gradient(circle at 50% 43%, rgba(255,255,255,.96), transparent 34%),
    radial-gradient(circle at 15% 15%, #fff8fc, transparent 35%),
    linear-gradient(145deg, #fceaf2, #f7d4e3 58%, #fcebf3);
  transition: opacity .75s ease, visibility .75s ease;
}
.gift-intro::before, .gift-intro::after {
  content: "♡"; position: absolute; color: rgba(196, 111, 151, .22);
  font-family: Georgia, serif; pointer-events: none;
}
.gift-intro::before { font-size: 170px; top: 7%; left: 8%; transform: rotate(-18deg); }
.gift-intro::after { font-size: 220px; right: 6%; bottom: 3%; transform: rotate(16deg); }
.gift-intro.is-done { opacity: 0; visibility: hidden; pointer-events: none; }
.gift-glow {
  position: absolute; width: min(76vw, 430px); aspect-ratio: 1; border-radius: 50%;
  background: rgba(255,255,255,.62); filter: blur(32px); pointer-events: none;
}
.gift-kicker {
  position: relative; z-index: 1; margin: 0 0 22px; color: #a84f78;
  text-transform: uppercase; letter-spacing: 4px; font-size: 11px; font-weight: 600;
}
.gift-button {
  position: relative; z-index: 2; width: 220px; height: 205px; border: 0;
  background: transparent; cursor: pointer; filter: drop-shadow(0 20px 18px rgba(151, 64, 105, .2));
  transition: transform .25s ease; -webkit-tap-highlight-color: transparent;
}
.gift-button:hover { transform: translateY(-7px) scale(1.035); }
.gift-button:focus-visible { outline: 3px solid #bd6489; outline-offset: 12px; border-radius: 18px; }
.gift-box {
  position: absolute; left: 22px; right: 22px; bottom: 8px; height: 128px;
  border-radius: 12px 12px 18px 18px;
  background: linear-gradient(105deg, #e978a8 0%, #f59ac0 48%, #d95f96 100%);
  box-shadow: inset 8px 0 12px rgba(255,255,255,.22), inset -8px 0 12px rgba(139,43,88,.12);
}
.gift-box-ribbon {
  position: absolute; top: 0; bottom: 0; left: 50%; width: 34px; transform: translateX(-50%);
  background: linear-gradient(90deg, #fff0f6, #fff 48%, #f9d9e7);
  box-shadow: 0 0 10px rgba(255,255,255,.25);
}
.gift-lid {
  position: absolute; z-index: 3; left: 12px; right: 12px; top: 48px; height: 42px;
  border-radius: 10px; transform-origin: 12% 85%;
  background: linear-gradient(100deg, #f48bb7, #ffb5d0 50%, #e66c9f);
  box-shadow: inset 0 5px 8px rgba(255,255,255,.25), 0 7px 8px rgba(146,49,93,.12);
}
.gift-lid-ribbon {
  position: absolute; left: 50%; top: 0; bottom: 0; width: 34px; transform: translateX(-50%);
  background: linear-gradient(90deg, #fff0f6, #fff 48%, #f9d9e7);
}
.gift-bow {
  position: absolute; z-index: 4; top: 10px; width: 58px; height: 48px;
  border: 12px solid #fff0f6; border-radius: 55% 55% 12% 55%;
  filter: drop-shadow(0 3px 2px rgba(145,54,94,.12));
}
.bow-left { left: 56px; transform: rotate(24deg); }
.bow-right { right: 56px; transform: scaleX(-1) rotate(24deg); }
.gift-heart {
  position: absolute; left: 50%; top: 48%; transform: translate(-50%,-50%);
  color: rgba(255,255,255,.88); font-size: 31px; text-shadow: 0 2px 4px rgba(151,53,96,.2);
}
.gift-shine {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 50% 58%, rgba(255,255,255,.5), transparent 43%);
}
.gift-prompt { position: relative; z-index: 1; margin: 23px 0 7px; color: #934568; font: italic 24px 'Playfair Display', Georgia, serif; }
.gift-subtitle { position: relative; z-index: 1; margin: 0; color: #b27691; font-size: 12px; letter-spacing: 1px; }
.gift-sparkles { position: absolute; top: 17%; color: #d88bab; font-size: 23px; letter-spacing: 8px; animation: sparkleFloat 3s ease-in-out infinite; }
@keyframes sparkleFloat { 0%,100% { transform: translateY(0); opacity: .65; } 50% { transform: translateY(-10px); opacity: 1; } }
.gift-button.opening { pointer-events: none; animation: giftBounce .45s ease-in-out 2; }
.gift-button.opening .gift-lid { animation: lidFly .85s cubic-bezier(.2,.8,.2,1) .55s forwards; }
.gift-button.opening .gift-box { animation: boxPop .55s ease .45s; }
@keyframes giftBounce { 0%,100% { transform: translateY(0) rotate(0); } 35% { transform: translateY(-10px) rotate(-3deg); } 70% { transform: translateY(0) rotate(3deg); } }
@keyframes lidFly { to { transform: translate(-32px,-100px) rotate(-32deg); opacity: 0; } }
@keyframes boxPop { 50% { transform: scale(1.07); filter: brightness(1.12); } }
.confetti-layer { position: fixed; inset: 0; z-index: 30; overflow: hidden; pointer-events: none; }
.confetti-piece { position: absolute; top: -20px; width: 9px; height: 14px; opacity: 0; border-radius: 2px; animation: confettiFall var(--fall-time, 2.4s) ease-in var(--delay, 0s) forwards; }
@keyframes confettiFall { 0% { transform: translate3d(0,-20px,0) rotate(0); opacity: 1; } 85% { opacity: 1; } 100% { transform: translate3d(var(--drift, 30px),110vh,0) rotate(780deg); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .gift-sparkles, .gift-button.opening, .gift-button.opening .gift-lid, .gift-button.opening .gift-box, .confetti-piece { animation-duration: .01ms !important; }
}
#ambient {position:fixed;inset:0;overflow:hidden;pointer-events:none;}
#ambient span {position:absolute;bottom:-40px;color:#d18aaa;opacity:.5;animation:floatMemory linear infinite;}
@keyframes floatMemory {0%{transform:translateY(0) rotate(-15deg);opacity:0} 20%{opacity:.6} 80%{opacity:.6} 100%{transform:translate(30px,-115vh) rotate(25deg);opacity:0}}
.scene{position:relative;}
.photo-frame{position:relative;display:flex;flex-direction:column;min-width:0;background:#fffdfd;border-radius:3px;padding:6px 6px 24px;cursor:zoom-in;transition:transform .2s;transform:rotate(-1deg);}
.photo-frame:nth-child(even){transform:rotate(1deg)}
.photo-frame:hover,.photo-frame:focus-visible{transform:scale(1.035);z-index:2;}
.photo-frame img{min-height:0;flex:1;border-radius:2px;}
.photo-frame:before{content:'';position:absolute;top:-5px;left:calc(50% - 20px);width:40px;height:11px;background:#efb5cba8;transform:rotate(-5deg);}
.memory-caption{position:absolute;bottom:5px;left:0;right:0;font:italic 10px Georgia,serif;color:#a65a7c;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
dialog{color:#8f4568;border:1px solid #e8b4ca;border-radius:14px;background:#fff8fb;padding:40px 16px 16px;max-width:92vw;max-height:90vh;box-shadow:0 20px 80px #54263d55;}
dialog::backdrop{background:#492338a8;backdrop-filter:blur(5px);}
.close-modal{position:absolute;right:10px;top:6px;border:0;background:none;color:#a34e77;font-size:28px;cursor:pointer;}
.memory-dialog img{display:block;max-width:min(76vw,650px);max-height:68vh;object-fit:contain;margin:auto;}
.viewer-nav{display:flex;align-items:center;justify-content:space-between;gap:12px;padding-top:12px;font-size:13px;}
.viewer-nav button{border:0;border-radius:20px;padding:8px 14px;background:#f4cddd;color:#8f4568;cursor:pointer;}.viewer-nav button:disabled{opacity:.35;}
.envelope{display:inline-flex;align-items:center;gap:10px;border:1px solid #e5a6c1;background:#fff6fa;border-radius:30px;padding:9px 15px;color:#a34e77;cursor:pointer;font:italic 13px Georgia,serif;}
.envelope-art{display:grid;place-items:center;width:34px;height:23px;border:1px solid #d18aaa;border-radius:3px;background:linear-gradient(145deg,transparent 49%,#e5a1bf 50%,transparent 52%),linear-gradient(215deg,#f6c4d8 49%,#e5a1bf 50%,#f9dce8 52%);color:#b85e86;}
.letter-paper{max-width:420px;padding:15px 24px 25px;border:4px double #e7a9c3;text-align:center;font:16px/1.7 Georgia,serif;animation:letterReveal .5s ease both;}
@keyframes letterReveal{from{transform:translateY(18px);opacity:0}to{transform:translateY(0);opacity:1}}
.final-page{background:radial-gradient(circle at 15% 10%,white,transparent 30%),radial-gradient(circle at 90% 90%,#f2bfd6,transparent 40%),#fff0f6;overflow:auto;}
.final-stars{color:#d18aaa;letter-spacing:8px;animation:sparkleFloat 3s ease-in-out infinite;}
.final-inner h2{margin:8px 0;font-size:clamp(24px,5vw,36px)}
.final-inner .saved-note{margin:3px 0;}.final-bottom{margin-top:12px;}
@media(max-width:520px){.final-page{padding:15px}.final-inner #loveMessage{min-height:135px;padding:12px}.final-hearts{font-size:20px}.memory-caption{font-size:9px}}
@media(prefers-reduced-motion:reduce){#ambient span,.final-stars,.letter-paper{animation:none!important}#ambient{display:none}}

.music-toggle {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 40; min-width: 64px; height: 44px; padding: 0 20px; border: 1px solid #e5a6c1;
  border-radius: 24px; background: rgba(255, 248, 251, .92); color: #a34e77; font-size: 16px;
  cursor: pointer; box-shadow: 0 8px 22px rgba(116, 54, 83, .22); backdrop-filter: blur(6px);
  -webkit-tap-highlight-color: transparent; transition: background .2s;
}
.music-toggle:hover { background: #f4cddd; }
.music-toggle[hidden] { display: none; }

.special-photo-frame {
  padding: 10px;
  margin: 20px auto;
  background: #fff;
  border: 2px solid #e8a5c0;
  border-radius: 12px;
  box-shadow: 0 5px 20px rgba(200, 100, 150, 0.2);
  max-width: 100%;
  box-sizing: border-box;
}

.special-photo-frame img {
  display: block;
  width: 100%;
  max-height: 55vh;
  object-fit: contain;
  border-radius: 6px;
}

/* Pink love envelope */

.love-envelope-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  margin: 25px auto;
  padding: 20px;
  border: none;
  background: transparent;
  cursor: pointer;
}

.love-envelope {
  position: relative;
  display: block;
  width: 220px;
  height: 145px;
  background: #efafca;
  border-radius: 8px;
  perspective: 800px;
  box-shadow: 0 10px 30px #d889ac55;
  transition: transform .3s ease;
}

.love-envelope-button:hover .love-envelope {
  transform: translateY(-5px);
}

.love-envelope-paper {
  position: absolute;
  left: 10%;
  top: 10px;
  width: 80%;
  height: 115px;
  padding-top: 15px;
  box-sizing: border-box;
  background: #fffafc;
  border: 1px solid #edc1d4;
  border-radius: 5px;
  color: #bd648c;
  font-family: Georgia, serif;
  font-style: italic;
  transition: transform .7s ease;
  z-index: 1;
}

.love-envelope-front {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    145deg,
    #f9c6dc,
    #eca3c3
  );
  clip-path: polygon(
    0 0, 50% 55%, 100% 0,
    100% 100%, 0 100%
  );
  border-radius: 8px;
  z-index: 2;
}

.love-envelope-flap {
  position: absolute;
  inset: 0;
  background: #f6bfd7;
  clip-path: polygon(0 0, 100% 0, 50% 65%);
  transform-origin: top;
  transition: transform .6s ease;
  z-index: 3;
}

.love-envelope-seal {
  position: absolute;
  top: 65px;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #ce648f;
  color: #fff0f6;
  font-size: 23px;
  box-shadow: 0 3px 8px #a8467355;
  z-index: 4;
  transition: opacity .3s ease;
}

.love-envelope-label {
  color: #b66b8c;
  font-family: Georgia, serif;
  font-size: 14px;
  font-style: italic;
}

/* Envelope opening animation */

.love-envelope-button.opening .love-envelope-seal {
  opacity: 0;
}

.love-envelope-button.opening .love-envelope-flap {
  transform: rotateX(180deg);
  z-index: 0;
}

.love-envelope-button.opening .love-envelope-paper {
  transform: translateY(-65px);
  transition-delay: .35s;
}

/* Decorative handwritten letter */

.love-note-dialog {
  width: min(90vw, 480px);
  max-height: 85vh;
  box-sizing: border-box;
  background: #fff7fa;
  border: 2px solid #e5a2bf;
  border-radius: 15px;
  padding: 25px;
  box-shadow: 0 20px 60px #71334f55;
}

.love-note-dialog[open] {
  animation: revealLoveNote .6s ease both;
}

.love-note-dialog::backdrop {
  background: rgba(70, 30, 50, .45);
  backdrop-filter: blur(5px);
}

.love-note-paper {
  padding: 25px 20px;
  border: 4px double #e8afc7;
  border-radius: 5px;
  background: #fffdf8;
  text-align: center;
}

.love-note-decoration {
  color: #d580a6;
  font-size: 25px;
  letter-spacing: 6px;
}

.love-note-heading {
  color: #a9567c;
  font-family: Georgia, serif;
  font-size: 23px;
  font-style: italic;
  margin: 20px 0;
}

.love-note-paper #loveMessage {
  display: block;
  width: 100%;
  min-height: 240px;
  padding: 0 8px;
  box-sizing: border-box;
  border: none;
  border-radius: 0;
  outline: none;
  box-shadow: none;
  resize: none;
  cursor: default;
  background: repeating-linear-gradient(
    transparent,
    transparent 31px,
    #efd8e2 31px,
    #efd8e2 32px
  );
  color: #80536a;
  font-family: "Segoe Print", "Bradley Hand", cursive;
  font-size: 17px;
  line-height: 32px;
  text-align: left;
}

.love-note-signature {
  margin-top: 25px;
  color: #b9638b;
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 20px;
}

@keyframes revealLoveNote {
  from {
    opacity: 0;
    transform: translateY(30px) scale(.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .love-note-dialog[open] {
    animation: none;
  }

  .love-envelope *,
  .love-envelope {
    transition: none;
  }
}