:root {
  --red: #b91435;
  --deep-red: #77091f;
  --pink: #ff6f9f;
  --soft-pink: #ffd6e6;
  --cream: #fff7f9;
  --ink: #3b0714;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 214, 230, 0.95), transparent 28rem),
    radial-gradient(circle at 82% 16%, rgba(255, 111, 159, 0.55), transparent 24rem),
    linear-gradient(135deg, #8f0d28 0%, #e93668 48%, #ff9fbc 100%);
}

.page-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-view,
.letter-view,
.loading-view,
.paper-view,
.moments-loading-view,
.slideshow-view,
.final-paper-view {
  width: min(100%, 460px);
}

.login-panel {
  padding: clamp(28px, 7vw, 44px);
  background: rgba(255, 247, 249, 0.93);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(59, 7, 20, 0.32);
}

h1 {
  margin: 0 0 28px;
  font-size: clamp(2rem, 8vw, 3.25rem);
  line-height: 1;
}

.login-form {
  display: grid;
  gap: 12px;
}

label {
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 2px solid #f6abc4;
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  font-family: "Segoe UI", Arial, sans-serif;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 4px rgba(255, 111, 159, 0.22);
}

button {
  min-height: 50px;
  margin-top: 8px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--deep-red), var(--red) 55%, var(--pink));
  font-family: "Segoe UI", Arial, sans-serif;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 14px 30px rgba(185, 20, 53, 0.28);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

button:hover,
button:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 18px 34px rgba(185, 20, 53, 0.34);
}

.error-message {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-weight: 700;
}

.letter-view {
  display: grid;
  place-items: center;
}

.letter-scene {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 26px;
  animation: riseIn 680ms ease both;
}

.click-cue {
  position: absolute;
  top: -74px;
  right: -8px;
  color: #fff7f9;
  font-size: clamp(1.15rem, 4vw, 1.55rem);
  font-weight: 800;
  text-shadow: 0 2px 12px rgba(59, 7, 20, 0.34);
  transform: rotate(-8deg);
  transition: opacity 220ms ease;
}

.click-cue::before {
  position: absolute;
  content: "";
  width: 74px;
  height: 38px;
  right: 16px;
  top: 24px;
  border-right: 3px solid #fff7f9;
  border-bottom: 3px solid #fff7f9;
  border-radius: 0 0 28px 0;
  transform: rotate(24deg);
}

.click-cue::after {
  position: absolute;
  content: "";
  width: 12px;
  height: 12px;
  right: 82px;
  top: 63px;
  border-left: 3px solid #fff7f9;
  border-bottom: 3px solid #fff7f9;
  transform: rotate(10deg);
}

.sealed-letter {
  position: relative;
  width: min(76vw, 360px);
  aspect-ratio: 1.5;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  outline: none;
  overflow: hidden;
  filter: drop-shadow(0 28px 34px rgba(59, 7, 20, 0.28));
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.9);
}

.sealed-letter:focus-visible {
  box-shadow:
    0 0 0 5px rgba(255, 247, 249, 0.42),
    inset 0 0 0 2px rgba(255, 255, 255, 0.9);
}

.letter-back {
  position: absolute;
  inset: 0;
  background: linear-gradient(145deg, #ffffff, #fff7fa);
  border: 2px solid #fff;
  border-radius: inherit;
  overflow: hidden;
  z-index: 2;
}

.letter-front {
  position: absolute;
  inset: auto 0 0 0;
  height: 50%;
  background: linear-gradient(180deg, #fff8fb, #ffffff);
  border-top: 2px solid rgba(185, 20, 53, 0.12);
  border-radius: 0 0 8px 8px;
  z-index: 4;
}

.letter-front::before,
.letter-front::after {
  position: absolute;
  bottom: 0;
  content: "";
  width: 51%;
  height: 100%;
  background: #fff;
}

.letter-front::before {
  left: 0;
  clip-path: polygon(0 0, 100% 100%, 0 100%);
}

.letter-front::after {
  right: 0;
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
}

.letter-flap {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #ffffff, #fff3f7);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  filter: drop-shadow(0 2px 1px rgba(185, 20, 53, 0.08));
  transition: clip-path 760ms cubic-bezier(0.2, 0.82, 0.22, 1), opacity 260ms ease;
  z-index: 5;
}

.letter-seal {
  position: absolute;
  left: 50%;
  top: 50%;
  width: clamp(34px, 10vw, 48px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff8aaa, #b91435 62%, #77091f);
  border: 3px solid rgba(255, 242, 246, 0.88);
  transform: translate(-50%, -50%);
  box-shadow: 0 9px 18px rgba(119, 9, 31, 0.28);
  transition: opacity 220ms ease, transform 500ms ease;
  z-index: 6;
}

.letter-seal::before {
  position: absolute;
  content: "";
  width: 34%;
  height: 18%;
  left: 24%;
  top: 20%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.45);
  transform: rotate(-22deg);
}

.sealed-letter.open .letter-flap {
  clip-path: polygon(0 0, 100% 0, 50% 0);
}

.sealed-letter.open .letter-seal {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.7);
}

.letter-scene.letter-open .click-cue {
  opacity: 0;
  pointer-events: none;
}

.letter-caption {
  margin: 0;
  color: #fff7f9;
  font-size: clamp(1.2rem, 4vw, 1.7rem);
  font-weight: 800;
  text-align: center;
  text-shadow: 0 2px 14px rgba(59, 7, 20, 0.38);
}

.loading-view,
.paper-view,
.final-paper-view {
  display: grid;
  place-items: center;
}

.loading-scene {
  display: grid;
  justify-items: center;
  gap: 28px;
  color: #fff7f9;
  animation: riseIn 420ms ease both;
}

.loading-message {
  margin: 0;
  font-size: clamp(1.4rem, 5vw, 2rem);
  font-weight: 800;
  text-align: center;
  text-shadow: 0 2px 14px rgba(59, 7, 20, 0.34);
  transition: opacity 260ms ease, transform 260ms ease;
}

.loading-message.changing {
  opacity: 0;
  transform: translateY(10px);
}

.loading-message.got-it {
  animation: gotItArrive 380ms ease both;
}

.stickman-wrap {
  position: relative;
  width: min(72vw, 320px);
  height: 220px;
}

.tiny-envelope {
  position: absolute;
  left: 50%;
  bottom: 50px;
  width: 136px;
  height: 86px;
  border: 3px solid #fff;
  border-radius: 8px;
  background:
    linear-gradient(30deg, transparent 49%, rgba(185, 20, 53, 0.16) 50%, transparent 51%),
    linear-gradient(150deg, transparent 49%, rgba(185, 20, 53, 0.16) 50%, transparent 51%),
    #fff9fb;
  transform: translateX(-50%);
  box-shadow: 0 18px 36px rgba(59, 7, 20, 0.2);
  overflow: visible;
  z-index: 3;
}

.tiny-flap {
  position: absolute;
  inset: 0;
  background: #fff;
  clip-path: polygon(0 0, 100% 0, 50% 80%);
  animation: tinyFlap 3.1s ease-in-out forwards;
  z-index: 2;
}

.tear {
  position: absolute;
  top: 0;
  width: 51%;
  height: 100%;
  background: #fff9fb;
  border: 2px solid rgba(185, 20, 53, 0.1);
  z-index: 4;
  opacity: 0;
  animation-duration: 3.1s;
  animation-fill-mode: forwards;
  animation-timing-function: cubic-bezier(0.2, 0.82, 0.22, 1);
}

.tear-left {
  left: -1px;
  clip-path: polygon(0 0, 100% 0, 72% 100%, 0 100%);
  transform-origin: left center;
  animation-name: ripLeft;
}

.tear-right {
  right: -1px;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 28% 100%);
  transform-origin: right center;
  animation-name: ripRight;
}

.stickman {
  position: absolute;
  left: 50%;
  bottom: 104px;
  width: 92px;
  height: 118px;
  transform: translateX(-50%);
  z-index: 5;
}

.stickman div {
  position: absolute;
  background: #fff7f9;
  box-shadow: 0 2px 10px rgba(59, 7, 20, 0.22);
}

.stickman .head {
  left: 32px;
  top: 0;
  width: 30px;
  height: 30px;
  border: 3px solid #fff7f9;
  border-radius: 50%;
  background: transparent;
}

.stickman .body {
  left: 45px;
  top: 34px;
  width: 4px;
  height: 44px;
  border-radius: 999px;
}

.arm,
.leg {
  width: 4px;
  height: 40px;
  border-radius: 999px;
  transform-origin: top center;
}

.arm::after {
  position: absolute;
  left: 50%;
  bottom: -5px;
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff7f9;
  transform: translateX(-50%);
}

.arm-left {
  left: 43px;
  top: 43px;
  height: 58px;
  transform: rotate(64deg);
  animation: pullLeft 3.1s cubic-bezier(0.2, 0.82, 0.22, 1) forwards;
}

.arm-right {
  left: 47px;
  top: 43px;
  height: 58px;
  transform: rotate(-64deg);
  animation: pullRight 3.1s cubic-bezier(0.2, 0.82, 0.22, 1) forwards;
}

.leg-left {
  left: 45px;
  top: 76px;
  transform: rotate(28deg);
}

.leg-right {
  left: 47px;
  top: 76px;
  transform: rotate(-28deg);
}

.paper-page {
  position: relative;
  width: min(88vw, 520px);
  min-height: min(70vh, 620px);
  padding: clamp(30px, 8vw, 54px);
  background:
    repeating-linear-gradient(180deg, transparent 0 31px, rgba(185, 20, 53, 0.08) 32px),
    linear-gradient(180deg, #ffffff, #fff9fb);
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(59, 7, 20, 0.28);
  animation: paperArrive 660ms cubic-bezier(0.2, 0.82, 0.22, 1) both;
}

.paper-page h2 {
  margin: 0 0 22px;
  color: var(--red);
  font-size: clamp(2rem, 8vw, 3.2rem);
  line-height: 1;
}

.typed-message p {
  margin: 0 0 18px;
  font-size: clamp(1.05rem, 3.6vw, 1.25rem);
  line-height: 1.55;
}

.typed-message p:last-child::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 3px;
  background: var(--red);
  vertical-align: -0.12em;
  animation: cursorBlink 780ms steps(1) infinite;
}

.typed-message.typing-done p:last-child::after,
.moments-intro-text.typing-done::after,
.month-text.typing-done::after {
  display: none;
}

.month-text span.typing-done::after {
  display: none;
}

.typed-message .letter-spacer {
  min-height: 14px;
  margin-bottom: 8px;
}

.play-button {
  position: relative;
  width: 58px;
  min-height: 58px;
  margin: 22px 0 0 auto;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--deep-red), var(--red) 62%, var(--pink));
  box-shadow: 0 14px 28px rgba(185, 20, 53, 0.32);
}

.play-button span {
  width: 0;
  height: 0;
  margin-left: 5px;
  border-top: 13px solid transparent;
  border-bottom: 13px solid transparent;
  border-left: 19px solid #fff7f9;
}

.play-button:hover,
.play-button:focus-visible {
  transform: translateY(-2px) scale(1.03);
}

.moments-loading-view {
  display: grid;
  place-items: center;
}

.moments-loading-card {
  width: min(88vw, 560px);
  display: grid;
  justify-items: center;
  gap: 22px;
  color: #fff7f9;
  text-align: center;
  animation: riseIn 520ms ease both;
}

.moments-intro-text {
  min-height: 7.6rem;
  margin: 0;
  font-size: clamp(1.35rem, 5vw, 2.2rem);
  font-weight: 800;
  line-height: 1.25;
  text-shadow: 0 2px 14px rgba(59, 7, 20, 0.36);
}

.moments-intro-text::after,
.month-text::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 4px;
  background: currentColor;
  vertical-align: -0.12em;
  animation: cursorBlink 780ms steps(1) infinite;
}

.heart-start-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-height: 116px;
  animation: paperArrive 420ms ease both;
}

.heart-button {
  width: 74px;
  min-height: 66px;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: linear-gradient(135deg, var(--deep-red), var(--red) 58%, var(--pink));
  clip-path: polygon(50% 90%, 9% 49%, 9% 24%, 25% 8%, 50% 23%, 75% 8%, 91% 24%, 91% 49%);
  box-shadow: none;
  filter: drop-shadow(0 16px 20px rgba(119, 9, 31, 0.28));
}

.heart-click-text {
  color: #fff7f9;
  font-size: clamp(1.1rem, 4vw, 1.45rem);
  font-weight: 800;
  text-shadow: 0 2px 12px rgba(59, 7, 20, 0.34);
}

.slideshow-view {
  width: min(100%, 1180px);
  display: grid;
  place-items: center;
}

.slideshow-frame {
  width: min(94vw, 1120px);
  min-height: min(76vh, 680px);
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(280px, 0.95fr);
  align-items: center;
  gap: clamp(26px, 5vw, 70px);
  animation: riseIn 640ms ease both;
}

.media-stage {
  width: 100%;
  min-height: min(72vh, 640px);
  display: grid;
  place-items: center;
  overflow: visible;
}

.memory-media {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(72vh, 640px);
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 26px 70px rgba(59, 7, 20, 0.3);
  animation: mediaArrive 700ms ease both;
}

video.memory-media {
  background: #000;
}

.month-stage {
  position: relative;
  width: min(100%, 500px);
  min-height: 300px;
  padding: clamp(38px, 5.5vw, 58px);
  display: grid;
  align-content: center;
  justify-self: center;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.42), transparent 42%),
    #fff0a8;
  border-radius: 4px;
  box-shadow:
    0 26px 54px rgba(59, 7, 20, 0.25),
    inset 0 -14px 28px rgba(185, 20, 53, 0.06);
  transform: rotate(1.5deg);
}

.month-stage::before {
  position: absolute;
  left: 50%;
  top: -18px;
  content: "";
  width: 118px;
  height: 34px;
  border-radius: 3px;
  background: rgba(255, 247, 249, 0.58);
  box-shadow: 0 4px 12px rgba(59, 7, 20, 0.12);
  transform: translateX(-50%) rotate(-3deg);
}

.month-text {
  min-height: 1.2em;
  margin: 0;
  font-size: clamp(2.05rem, 5.2vw, 4.15rem);
  font-weight: 800;
  line-height: 1;
  text-shadow: none;
}

.month-text.ending-text {
  display: grid;
  gap: 18px;
  font-size: clamp(1.35rem, 3.2vw, 2.35rem);
  line-height: 1.12;
}

.month-text.ending-text::after {
  display: none;
}

.month-text.ending-text span {
  display: block;
}

.month-text.ending-text span::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 4px;
  background: currentColor;
  vertical-align: -0.12em;
  animation: cursorBlink 780ms steps(1) infinite;
}

.next-button {
  min-width: 118px;
  min-height: 48px;
  margin-top: 28px;
  padding: 0 22px;
  border-radius: 999px;
  background: #fff7f9;
  color: var(--red);
  box-shadow: 0 16px 34px rgba(59, 7, 20, 0.18);
  animation: paperArrive 420ms ease both;
  justify-self: start;
}

.final-paper-page {
  max-height: 86vh;
  overflow-y: auto;
}

.video-mode .slideshow-view {
  cursor: none;
  pointer-events: none;
}

.slideshow-view.ready-for-next {
  cursor: auto;
  pointer-events: auto;
}

.hidden {
  display: none;
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes tinyFlap {
  0%,
  28% {
    clip-path: polygon(0 0, 100% 0, 50% 80%);
  }

  58%,
  100% {
    clip-path: polygon(0 0, 100% 0, 50% 0);
  }
}

@keyframes pullLeft {
  0%,
  28% {
    transform: rotate(64deg);
  }

  58%,
  100% {
    transform: rotate(92deg) translateY(-8px);
  }
}

@keyframes pullRight {
  0%,
  28% {
    transform: rotate(-64deg);
  }

  58%,
  100% {
    transform: rotate(-92deg) translateY(-8px);
  }
}

@keyframes ripLeft {
  0%,
  27% {
    opacity: 0;
    transform: translateX(0) rotate(0);
  }

  28% {
    opacity: 1;
  }

  58%,
  100% {
    opacity: 1;
    transform: translateX(-26px) rotate(-14deg);
  }
}

@keyframes ripRight {
  0%,
  27% {
    opacity: 0;
    transform: translateX(0) rotate(0);
  }

  28% {
    opacity: 1;
  }

  58%,
  100% {
    opacity: 1;
    transform: translateX(26px) rotate(14deg);
  }
}

@keyframes paperArrive {
  from {
    opacity: 0;
    transform: translateY(22px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes gotItArrive {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes cursorBlink {
  0%,
  49% {
    opacity: 1;
  }

  50%,
  100% {
    opacity: 0;
  }
}

@keyframes pulsePlay {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.82;
  }

  50% {
    transform: scale(1.08);
    opacity: 1;
  }
}

@keyframes mediaArrive {
  from {
    opacity: 0;
    transform: scale(1.03);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (max-width: 420px) {
  .page-shell {
    padding: 16px;
  }

  .login-panel {
    padding: 26px 20px;
  }
}

@media (max-width: 760px) {
  .slideshow-frame {
    min-height: 82vh;
    grid-template-columns: 1fr;
    align-content: center;
    gap: 24px;
  }

  .media-stage {
    width: min(100%, 430px);
    justify-self: center;
    min-height: min(58vh, 520px);
  }

  .memory-media {
    max-height: min(58vh, 520px);
  }

  .month-stage {
    width: min(100%, 420px);
    min-height: 220px;
    padding: 32px;
    justify-self: center;
    text-align: center;
  }

  .month-text {
    font-size: clamp(1.85rem, 10vw, 3.2rem);
  }

  .month-text.ending-text {
    font-size: clamp(1.25rem, 6vw, 2rem);
  }

  .next-button {
    justify-self: center;
  }

}
