:root {
  color-scheme: light;
  --sand: #FFFFFF;
  --oat: #FFFFFF;
  --sage: #8B9D83;
  --red: #A91F3D;
  --rose: #D9415D;
  --blush: #F2CDD2;
  --soft-pink: #E9A0AA;
  --moss: #606C38;
  --ink: #472633;
  --line: rgba(71, 38, 51, 0.14);
  --sans: "Poppins", Arial, sans-serif;
  --serif: "Poppins", Arial, sans-serif;
  --handwriting: "Caveat", "Comic Sans MS", cursive;
}

* {
  box-sizing: border-box;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--oat);
}

body {
  position: relative;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  color: var(--ink);
  background: var(--oat);
  font-family: var(--sans);
}

body::before {
  position: fixed;
  z-index: 10;
  inset: 0;
  pointer-events: none;
  content: "";
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.35'/%3E%3C/svg%3E");
}

button,
a {
  color: inherit;
  font: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--rose);
  outline-offset: 4px;
}

.album {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(100%, 560px);
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  overflow: hidden;
  background:
    radial-gradient(ellipse 112% 38% at 50% 24%, rgba(242, 205, 210, 0.18), transparent 74%),
    var(--sand);
}

.album-header,
.album-footer {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px clamp(18px, 5vw, 28px);
  font-size: 13px;
}

.album-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  min-height: 72px;
  border-bottom: 1px solid var(--line);
}

.album-mark {
  grid-column: 2;
  justify-self: center;
  padding-bottom: 3px;
  border-bottom: 1px solid var(--red);
  font-family: var(--serif);
  font-size: 16px;
  font-style: italic;
  text-decoration: none;
}

.album-progress {
  grid-column: 3;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-track {
  display: block;
  width: 56px;
  height: 4px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(71, 38, 51, 0.12);
}

.progress-track > span {
  display: block;
  width: 20%;
  height: 100%;
  border-radius: inherit;
  background: var(--rose);
  transition: width 350ms ease;
}

.pages {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  flex: 1;
  min-height: 0;
}

.page {
  position: relative;
  grid-area: 1 / 1;
  display: none;
  flex-direction: column;
  align-items: center;
  min-height: 540px;
  padding: 34px 36px 26px;
  text-align: center;
  animation: page-in 380ms ease-out both;
}

.page.is-active {
  display: flex;
  overflow-y: auto;
  overscroll-behavior-y: contain;
}

.page.is-active:not(.memory-page) {
  scrollbar-width: none;
}

.page.is-active:not(.memory-page)::-webkit-scrollbar {
  display: none;
}

.page-copy {
  position: relative;
  z-index: 1;
  width: 100%;
  margin-block: auto;
  padding-block: 34px;
}

.page-copy h1,
.page-copy h2 {
  max-width: 13ch;
  margin: 0 0 20px;
  margin-inline: auto;
  font-family: var(--serif);
  font-size: clamp(42px, 11vw, 66px);
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -0.04em;
}

.page-copy h2 {
  max-width: 14ch;
  font-size: clamp(36px, 9vw, 54px);
}

.page-copy.page-copy-long h2 {
  max-width: 24ch;
  font-size: clamp(25px, 5.4vw, 35px);
  line-height: 1.12;
}

.page-copy.page-copy-long p {
  max-width: 42ch;
  font-size: 16px;
  line-height: 1.75;
}

.page-copy.page-copy-long p + p {
  margin-top: 12px;
}

.page-copy.page-copy-long .page-two-teaser {
  margin-top: 18px;
  color: var(--red);
  font-weight: 500;
}

.page-copy p {
  max-width: 34ch;
  margin: 0 auto;
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.7;
  text-align: center;
}

.page-copy.welcome-copy h1 {
  max-width: 18ch;
  margin-bottom: 0;
  font-size: clamp(32px, 8vw, 54px);
  font-weight: 500;
  line-height: 1.1;
}

.heart-stage {
  position: relative;
  align-self: center;
  flex: 0 0 auto;
  display: grid;
  width: min(100%, 390px);
  aspect-ratio: 1 / 0.92;
  margin: 0 auto 10px;
  place-items: center;
}

.heart-launch {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  display: grid;
  width: 82%;
  aspect-ratio: 160 / 150;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 32%;
  background: transparent;
  cursor: pointer;
  transform: translate(-50%, -50%);
  transition: transform 220ms ease;
  touch-action: manipulation;
}

.heart-launch:hover {
  transform: translate(-50%, -50%) scale(1.05);
}

.heart-launch:active {
  transform: translate(-50%, -50%) scale(0.96);
}

.heart-launch:focus-visible {
  outline: 3px solid var(--rose);
  outline-offset: 7px;
}

.heart-halo {
  position: absolute;
  width: 84%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(217, 65, 93, 0.2) 0%, rgba(217, 65, 93, 0.08) 48%, transparent 72%);
  filter: blur(5px);
  animation: halo-breathe 4.2s ease-in-out infinite;
  pointer-events: none;
}

.hero-heart-main {
  position: relative;
  display: block;
  width: 100%;
  overflow: visible;
  filter: drop-shadow(0 10px 14px rgba(169, 31, 61, 0.2));
  animation: heart-beat 3.8s ease-in-out infinite;
}

.mini-heart {
  position: absolute;
  z-index: 3;
  width: 23%;
  overflow: visible;
  filter: drop-shadow(0 5px 7px rgba(169, 31, 61, 0.13));
  animation: heart-drift 4.4s ease-in-out infinite;
  pointer-events: none;
}

.mini-heart-left {
  top: 25%;
  left: 5%;
  animation-delay: -1.1s;
}

.mini-heart-right {
  top: 18%;
  right: 3%;
  width: 17%;
  animation-delay: -2.3s;
}

.heart-sparkle {
  position: absolute;
  z-index: 3;
  width: 11%;
  opacity: 0.8;
  animation: sparkle 2.8s ease-in-out infinite;
  pointer-events: none;
}

.sparkle-one {
  top: 13%;
  left: 28%;
}

.sparkle-two {
  right: 19%;
  bottom: 22%;
  width: 8%;
  animation-delay: -1.2s;
}

.page-heart-float {
  position: absolute;
  top: 40px;
  right: 38px;
  width: 42px;
  transform: rotate(8deg);
  filter: drop-shadow(0 5px 7px rgba(169, 31, 61, 0.18));
  animation: heart-drift 3.7s ease-in-out infinite;
}

.page-heart-float svg {
  display: block;
  width: 100%;
}

.letter-page .page-heart-float {
  position: relative;
  top: auto;
  right: auto;
  align-self: center;
  flex: 0 0 auto;
  width: 34px;
}

.letter-page .page-copy-long {
  margin-top: 0;
  padding-top: 14px;
}

.welcome-copy {
  margin: 0;
  padding-block: 16px 8px;
}

.next-button,
.restart-button,
.back-button {
  position: relative;
  z-index: 2;
  min-height: 48px;
  border: 1px solid rgba(217, 65, 93, 0.28);
  border-radius: 999px;
  background: #fff;
  color: var(--red);
  font-family: var(--sans);
  font-size: 15px;
  cursor: pointer;
  transition: transform 350ms ease, background-color 350ms ease, box-shadow 350ms ease;
}

.next-button,
.restart-button {
  align-self: center;
  min-width: 152px;
  padding: 12px 18px;
  box-shadow: 0 6px 18px rgba(169, 31, 61, 0.1);
}

.next-button:hover,
.restart-button:hover,
.back-button:hover:not(:disabled) {
  border-color: var(--soft-pink);
  background: #fff4f6;
  box-shadow: 0 9px 22px rgba(169, 31, 61, 0.14);
  transform: translateY(-2px);
}

.next-button:active,
.restart-button:active,
.back-button:active:not(:disabled) {
  transform: translateY(0);
}

.letter-page .letter-next-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
}

.letter-next-button span[aria-hidden="true"] {
  color: var(--rose);
  font-size: 13px;
}

.scribble-frame {
  align-self: center;
  width: min(72%, 250px);
  margin: 7px 8px -14px 0;
  opacity: 0.86;
  transform: rotate(-2deg);
}

.scribble-frame svg {
  display: block;
  width: 100%;
}

.memory-page {
  isolation: isolate;
  min-height: 0;
  align-items: stretch;
  overflow-y: auto;
  padding: 18px 22px 24px;
  scrollbar-color: var(--rose) transparent;
  scrollbar-width: thin;
}

.memory-page::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  content: "";
  background:
    radial-gradient(ellipse at 12% 38%, rgba(242, 205, 210, 0.28), transparent 30%),
    radial-gradient(ellipse at 88% 72%, rgba(233, 160, 170, 0.18), transparent 28%);
}

.memory-heading {
  margin-block: 0;
  padding-block: 8px 16px;
  text-align: center;
}

.memory-heading h2 {
  max-width: 18ch;
  margin-inline: auto;
  margin-bottom: 0;
  font-size: clamp(30px, 7.2vw, 42px);
  line-height: 1.1;
}

.memory-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 26px 16px;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 4px 28px;
}

.polaroid {
  position: relative;
  width: 100%;
  margin: 0;
  padding: 0;
  filter: drop-shadow(0 12px 18px rgba(71, 38, 51, 0.16));
  transition: transform 350ms ease, filter 350ms ease;
}

.polaroid-one {
  --polaroid-tilt: -2.2deg;
  --reveal-delay: 0ms;
  --float-duration: 5.6s;
  --float-delay: 0ms;
  transform: rotate(var(--polaroid-tilt));
  animation: polaroid-float var(--float-duration) ease-in-out var(--float-delay) infinite;
}

.polaroid-two {
  --polaroid-tilt: 1.5deg;
  --reveal-delay: 140ms;
  --float-duration: 6.2s;
  --float-delay: -1.8s;
  transform: rotate(var(--polaroid-tilt));
  animation: polaroid-float var(--float-duration) ease-in-out var(--float-delay) infinite;
}

.polaroid-three {
  --polaroid-tilt: -1.7deg;
  --reveal-delay: 280ms;
  --float-duration: 5.9s;
  --float-delay: -3.1s;
  transform: rotate(var(--polaroid-tilt));
  animation: polaroid-float var(--float-duration) ease-in-out var(--float-delay) infinite;
}

.memory-gallery.is-revealing .polaroid {
  animation:
    polaroid-reveal 680ms cubic-bezier(0.2, 0.75, 0.25, 1) var(--reveal-delay, 0ms) both,
    polaroid-float var(--float-duration, 5.8s) ease-in-out var(--float-delay, 0ms) infinite;
}

.polaroid-photo {
  display: block;
  width: 100%;
  height: auto;
}

.polaroid-caption {
  position: absolute;
  right: 7%;
  bottom: 3.8%;
  left: 7%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  color: #171717;
  font-family: var(--handwriting);
  font-size: clamp(12px, 3.2vw, 18px);
  font-weight: 600;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
}

.caption-heart {
  color: #171717;
  font-family: Arial, sans-serif;
  font-size: 0.68em;
  line-height: 1;
}

.polaroid:nth-child(3) {
  grid-column: 1 / -1;
  width: min(82%, 320px);
  justify-self: center;
}

.memory-page > .next-button {
  align-self: center;
  margin: 0 auto 8px;
}

.ending-page {
  align-items: center;
  text-align: center;
}

.ending-stamp {
  width: 78px;
  margin: 18px 0 -8px;
  transform: rotate(4deg);
}

.ending-stamp svg {
  display: block;
  width: 100%;
  filter: drop-shadow(0 8px 12px rgba(169, 31, 61, 0.2));
  animation: heart-beat 3.8s ease-in-out infinite;
}

.ending-copy {
  padding-block: 10px 14px;
}

.ending-copy h2 {
  max-width: 15ch;
  margin-inline: auto;
  margin-bottom: 22px;
  color: var(--red);
  font-size: clamp(34px, 8vw, 50px);
}

.ending-copy p {
  max-width: 38ch;
  margin-inline: auto;
  line-height: 1.8;
  text-align: center;
}

.ending-copy .love-line {
  margin-top: 24px;
  color: var(--red);
  font-family: var(--serif);
  font-size: 32px;
  font-style: italic;
  text-align: center;
}

.restart-button {
  align-self: center;
}

.album-footer {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  min-height: 66px;
  border-top: 1px solid var(--line);
}

.back-button {
  justify-self: start;
  padding: 10px 16px;
}

.back-button:hover:not(:disabled) {
  background: #fff4f6;
}

.back-button:disabled {
  opacity: 0.4;
  cursor: default;
}

.footer-mark {
  display: grid;
  width: 29px;
  height: 29px;
  place-items: center;
  border-radius: 50%;
  background: var(--blush);
  color: var(--red);
  font-family: var(--serif);
  font-size: 17px;
  font-style: italic;
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(9px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes heart-beat {
  0%, 100% { transform: scale(1); }
  45% { transform: scale(1.035); }
  52% { transform: scale(1.015); }
  60% { transform: scale(1.04); }
}

@keyframes heart-drift {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-10px) rotate(4deg); }
}

@keyframes polaroid-float {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -7px; }
}

@keyframes polaroid-reveal {
  from { opacity: 0; scale: 0.9; }
  to { opacity: 1; scale: 1; }
}

@keyframes halo-breathe {
  0%, 100% { opacity: 0.6; transform: scale(0.94); }
  50% { opacity: 1; transform: scale(1.05); }
}

@keyframes sparkle {
  0%, 100% { opacity: 0.35; transform: scale(0.78) rotate(0); }
  50% { opacity: 0.95; transform: scale(1.08) rotate(20deg); }
}

@media (min-width: 560px) {
  body {
    display: grid;
    place-items: center;
    padding: 24px 0;
  }

  .album {
    width: min(100%, 760px);
    min-height: min(840px, calc(100svh - 48px));
    border-radius: 28px;
    box-shadow: 0 20px 60px rgba(71, 38, 51, 0.12);
  }

  .page {
    padding-inline: 48px;
  }

  .memory-page {
    padding-inline: 32px;
  }

  .memory-gallery {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 24px 18px;
  }

  .polaroid:nth-child(3) {
    grid-column: auto;
    width: 100%;
  }
}

@media (max-width: 559px) {
  .album-header,
  .album-footer {
    padding-inline: clamp(16px, 5vw, 22px);
  }

  .album-header {
    min-height: 64px;
    padding-block: 12px;
  }

  .album-footer {
    min-height: 60px;
    padding-block: 10px;
  }

  .album-progress {
    gap: 7px;
  }

  .progress-track {
    width: 40px;
  }

  .page {
    padding: 26px clamp(20px, 7vw, 30px) 22px;
  }

  .page-copy h1 {
    font-size: clamp(36px, 10vw, 52px);
  }

  .page-copy.welcome-copy h1 {
    font-size: clamp(28px, 8vw, 36px);
  }

  .page-copy h2 {
    font-size: clamp(32px, 8.8vw, 46px);
  }

  .page-copy p {
    font-size: 16px;
    line-height: 1.65;
  }

  .page-copy.page-copy-long p {
    font-size: 15px;
    line-height: 1.7;
  }

  .heart-stage {
    width: min(82vw, 310px);
    margin-bottom: 4px;
  }

  .letter-page .page-heart-float {
    width: 30px;
  }

  .letter-page .page-copy-long {
    padding-top: 10px;
  }

  .memory-page {
    padding: 14px clamp(14px, 5vw, 22px) 18px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
  }

  .memory-gallery {
    gap: clamp(18px, 5vw, 26px) clamp(12px, 4vw, 16px);
    padding: 12px 2px 22px;
  }

  .polaroid:nth-child(3) {
    width: min(82%, 320px);
  }

  .memory-page > .next-button {
    min-height: 48px;
    margin-bottom: 6px;
  }
}

@media (hover: hover) and (pointer: fine) {
  .polaroid:hover {
    z-index: 4;
    animation: none;
    filter: drop-shadow(0 18px 28px rgba(71, 38, 51, 0.22));
    transform: rotate(0deg) translateY(-5px) scale(1.025);
  }
}

@media (max-height: 700px) {
  .page {
    min-height: 0;
    padding-top: 16px;
    padding-bottom: 16px;
  }

  .heart-stage {
    width: min(86%, 300px);
    margin-top: 0;
  }

  .welcome-copy {
    padding-block: 9px 16px;
  }

  .page-copy {
    padding-block: 18px;
  }

}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
.heart-action-wrap {
  position: relative;
  z-index: 2;
  align-self: center;
  display: grid;
  justify-items: center;
  gap: 1px;
  margin: 4px auto 10px;
}
.heart-action-hint {
  margin: 0;
  color: var(--ink);
  font-family: var(--handwriting);
  font-size: 21px;
  line-height: 1.1;
  text-align: center;
}
.next-button.heart-button,
.restart-button.heart-button {
  display: grid;
  width: 58px;
  min-width: 58px;
  height: 54px;
  min-height: 54px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--rose);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.heart-button-icon {
  display: block;
  width: 48px;
  height: 46px;
  overflow: visible;
  color: var(--rose);
  filter: drop-shadow(0 5px 7px rgba(169, 31, 61, 0.2));
  animation: heart-beat 3.8s ease-in-out infinite;
  transition: filter 220ms ease, transform 220ms ease, color 220ms ease;
}
.heart-shape {
  fill: currentColor;
  stroke: #fff2f4;
  stroke-width: 7px;
  paint-order: stroke fill;
}
.next-button.heart-button:hover,
.restart-button.heart-button:hover,
.next-button.heart-button:active,
.restart-button.heart-button:active {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  transform: none;
}
.heart-glint {
  stroke: #FFE8EB;
  opacity: 0.95;
}
.heart-button:hover .heart-button-icon {
  color: var(--red);
  filter: drop-shadow(0 8px 10px rgba(169, 31, 61, 0.25));
  transform: scale(1.06);
}
.heart-button:active .heart-button-icon {
  transform: scale(0.94);
}
.heart-button:focus-visible {
  border-radius: 50%;
  outline: 3px solid var(--rose);
  outline-offset: 1px;
}
.memory-page > .heart-action-wrap {
  margin: 0 auto 8px;
}
.footer-mark {
  display: flex;
  width: auto;
  height: auto;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  color: var(--ink);
  font-family: var(--handwriting);
  font-size: 17px;
  font-style: normal;
  line-height: 1;
  white-space: nowrap;
}
.footer-mark svg {
  width: 10px;
  height: 10px;
  color: var(--red);
}
@media (max-width: 559px) {
  .heart-action-wrap {
    margin-block: 2px 8px;
  }
  .heart-action-hint {
    font-size: 20px;
  }
  .next-button.heart-button,
  .restart-button.heart-button {
    width: 58px;
    min-width: 58px;
    height: 54px;
    min-height: 54px;
  }
  .heart-button-icon {
    width: 44px;
    height: 42px;
  }
  .footer-mark {
    font-size: 16px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .heart-button-icon {
    animation: none;
    transition: none;
  }
}
