* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

html {
  background: #12102b;
}

body {
  margin: 0;
  position: fixed;
  inset: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  color: #f3eefc;
  background: linear-gradient(180deg, #151033 0%, #241a4d 45%, #3a2166 100%);
  -webkit-font-smoothing: antialiased;
}

/* ---------- background layers ---------- */

.sky {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.star {
  position: absolute;
  width: 2px;
  height: 2px;
  background: #fff;
  border-radius: 50%;
  opacity: 0.6;
  animation: twinkle 3s ease-in-out infinite;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.15; transform: scale(1); }
  50% { opacity: 0.9; transform: scale(1.6); }
}

.hearts-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.shooting-star {
  position: absolute;
  width: 140px;
  height: 2px;
  background: linear-gradient(90deg, rgba(255,255,255,0.95), rgba(255,255,255,0));
  transform: rotate(-18deg);
  border-radius: 2px;
  opacity: 0;
  animation: shootAcross 1.4s ease-in forwards;
  will-change: transform, opacity;
}

@keyframes shootAcross {
  0% { opacity: 0; transform: translate(0, 0) rotate(-18deg); }
  8% { opacity: 1; }
  85% { opacity: 0.9; }
  100% { opacity: 0; transform: translate(-260px, 220px) rotate(-18deg); }
}

.moon-small {
  display: inline-block;
  font-size: clamp(1.6rem, 6vw, 2.1rem);
  margin-bottom: 0.4rem;
  filter: drop-shadow(0 0 12px rgba(255, 244, 200, 0.55));
  animation: moonFloat 5s ease-in-out infinite;
}

@keyframes moonFloat {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-8px) rotate(4deg); }
}

.paw-trail {
  display: flex;
  gap: 0.6rem;
  margin-top: 1.2rem;
  font-size: 1.3rem;
}

.paw-trail span {
  opacity: 0;
  transform: translateY(6px) scale(0.7);
  animation: pawStep 2.4s ease-in-out infinite;
  filter: drop-shadow(0 0 1px rgba(255, 255, 255, 0.9)) drop-shadow(0 1px 1px rgba(0, 0, 0, 0.6));
}

.paw-trail span:nth-child(1) { animation-delay: 0s; }
.paw-trail span:nth-child(2) { animation-delay: 0.25s; }
.paw-trail span:nth-child(3) { animation-delay: 0.5s; }
.paw-trail span:nth-child(4) { animation-delay: 0.75s; }
.paw-trail span:nth-child(5) { animation-delay: 1s; }

@keyframes pawStep {
  0% { opacity: 0; transform: translateY(6px) scale(0.7) rotate(-8deg); }
  20% { opacity: 1; transform: translateY(0) scale(1) rotate(4deg); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-4px) scale(0.8) rotate(4deg); }
}

.paw-glow {
  filter: drop-shadow(0 0 1px rgba(255, 255, 255, 0.9));
}

.floating-heart {
  position: absolute;
  bottom: -10dvh;
  font-size: 1.2rem;
  opacity: 0.8;
  animation-name: floatUp;
  animation-timing-function: ease-in;
  animation-fill-mode: forwards;
  will-change: transform, opacity;
}

@keyframes floatUp {
  0% { transform: translateY(0) translateX(0) rotate(0deg); opacity: 0; }
  10% { opacity: 0.85; }
  100% { transform: translateY(-110dvh) translateX(var(--drift, 20px)) rotate(20deg); opacity: 0; }
}

.heart-burst {
  position: fixed;
  font-size: 1.3rem;
  opacity: 1;
  animation: burstOut 1s cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
  will-change: transform, opacity;
}

@keyframes burstOut {
  0% { transform: translate(0, 0) scale(0.6); opacity: 1; }
  100% { transform: translate(var(--bx, 0px), var(--by, -120px)) scale(1); opacity: 0; }
}

/* ---------- layout ---------- */

main {
  position: relative;
  z-index: 2;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
}

.scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(env(safe-area-inset-top), 28px) 24px max(env(safe-area-inset-bottom), 28px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(100%);
  transition: transform 0.65s cubic-bezier(0.22, 0.61, 0.36, 1), opacity 0.5s ease, visibility 0s linear 0.65s;
}

.scene-inner {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin: auto 0;
}

.scene.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
  transition: transform 0.65s cubic-bezier(0.22, 0.61, 0.36, 1), opacity 0.5s ease;
  z-index: 2;
}

.scene.prev {
  transform: translateY(-100%);
}

h1.title {
  font-family: ui-rounded, -apple-system, BlinkMacSystemFont, "SF Pro Rounded", system-ui, "Segoe UI", Roboto, sans-serif;
  font-size: clamp(1.9rem, 7.5vw, 2.7rem);
  margin: 0.3em 0 0.2em;
  font-weight: 800;
  letter-spacing: -0.01em;
  background: linear-gradient(90deg, #ffd6e6, #c58bff, #ffd6e6);
  background-size: 220% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 4s linear infinite;
}

@keyframes shimmer {
  0% { background-position: 0% center; }
  100% { background-position: 220% center; }
}

h2 {
  font-family: ui-rounded, -apple-system, BlinkMacSystemFont, "SF Pro Rounded", system-ui, "Segoe UI", Roboto, sans-serif;
  font-size: clamp(1.4rem, 6vw, 1.9rem);
  margin: 0 0 0.6em;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.subtitle, .soft-text {
  font-size: clamp(1rem, 4vw, 1.15rem);
  line-height: 1.6;
  color: #e3d9fb;
  max-width: 34ch;
}

.pulse {
  display: inline-block;
  animation: pulse 1.6s ease-in-out infinite;
  -webkit-text-fill-color: initial;
  background: none;
  color: initial;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.btn-next {
  font-family: ui-rounded, -apple-system, BlinkMacSystemFont, "SF Pro Rounded", system-ui, "Segoe UI", Roboto, sans-serif;
  margin-top: 2.2rem;
  border: none;
  border-radius: 999px;
  padding: 0.9rem 1.8rem;
  font-size: 1rem;
  font-weight: 600;
  background: linear-gradient(135deg, #ff8fb1, #c58bff);
  color: #1c1435;
  min-height: 48px;
  min-width: 48px;
  box-shadow: 0 8px 24px rgba(197, 139, 255, 0.35);
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  animation: pulse 2.4s ease-in-out infinite;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-next:active {
  transform: scale(0.94);
  box-shadow: 0 4px 14px rgba(197, 139, 255, 0.3);
}

.btn-open {
  margin-top: 1.6rem;
}

/* ---------- cats ---------- */

.cat {
  font-size: clamp(2.8rem, 14vw, 4.2rem);
  display: inline-block;
  margin-bottom: 0.6rem;
  animation: catBob 2.6s ease-in-out infinite;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.cat-pair {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0.8rem;
  margin-bottom: 0.6rem;
}

.cat-pair .cat {
  font-size: clamp(2.4rem, 12vw, 3.6rem);
  margin-bottom: 0;
}

.cat-pair .cat:nth-child(1) {
  filter: grayscale(1) brightness(0.55) contrast(1.15);
}

.cat-pair .cat:nth-child(2) {
  animation-delay: 0.4s;
  filter: grayscale(1) brightness(1.35) contrast(0.9);
}

@keyframes catBob {
  0%, 100% { transform: rotate(-3deg) translateY(0); }
  50% { transform: rotate(3deg) translateY(-6px); }
}

.meow-bubble {
  position: absolute;
  font-size: 0.9rem;
  background: rgba(255,255,255,0.92);
  color: #3a2166;
  padding: 4px 10px;
  border-radius: 12px;
  font-weight: 600;
  pointer-events: none;
  animation: meowPop 1.1s ease-out forwards;
  white-space: nowrap;
}

@keyframes meowPop {
  0% { opacity: 0; transform: translate(-50%, 0) scale(0.7); }
  20% { opacity: 1; transform: translate(-50%, -18px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -46px) scale(1); }
}

/* ---------- typewriter lines ---------- */

.type-line {
  font-size: clamp(1rem, 4vw, 1.15rem);
  line-height: 1.6;
  color: #e3d9fb;
  max-width: 36ch;
  min-height: 1.6em;
  margin: 0.35em 0;
}

.type-line .cursor {
  display: inline-block;
  width: 1px;
  background: #e3d9fb;
  margin-left: 2px;
  animation: blink 0.9s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* ---------- missing list ---------- */

.missing-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  max-width: 36ch;
}

.missing-list li {
  font-size: clamp(1rem, 4vw, 1.1rem);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  padding: 0.7rem 1rem;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.missing-list li.shown {
  opacity: 1;
  transform: none;
}

.missing-list li.pressed {
  transform: scale(0.95) rotate(-1deg);
  background: rgba(255,255,255,0.14);
  border-color: rgba(255,255,255,0.28);
}

/* ---------- travel scene ---------- */

.travel-scene {
  position: relative;
  width: 100%;
  max-width: 320px;
  height: 90px;
  margin-bottom: 1rem;
}

.travel-scene .globe {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  font-size: 2.4rem;
  opacity: 0.85;
}

.travel-scene .plane {
  position: absolute;
  font-size: 1.8rem;
  animation: flyAcross 5s linear infinite;
}

@keyframes flyAcross {
  0% { left: -10%; top: 8%; opacity: 0; transform: scaleX(-1) rotate(-8deg); }
  10% { opacity: 1; }
  50% { top: 0%; }
  58% { left: 55%; opacity: 1; }
  68% { left: 63%; opacity: 0; }
  100% { left: 63%; top: 8%; opacity: 0; transform: scaleX(-1) rotate(-8deg); }
}

.travel-scene .cat-flight {
  position: absolute;
  right: 0;
  bottom: 10px;
  font-size: clamp(2.2rem, 10vw, 3rem);
  animation: catBob 2.6s ease-in-out infinite;
}

/* ---------- envelope / letter ---------- */

.envelope {
  position: relative;
  width: clamp(140px, 42vw, 190px);
  height: clamp(96px, 28vw, 128px);
  margin: 1rem auto 0.4rem;
  cursor: pointer;
}

.envelope-shadow {
  position: absolute;
  left: 50%;
  bottom: -16px;
  width: 76%;
  height: 20px;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0) 72%);
  transform: translateX(-50%);
  filter: blur(1px);
  z-index: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.envelope.open .envelope-shadow {
  opacity: 0.7;
  transform: translateX(-50%) scale(0.94);
}

.envelope-body {
  position: relative;
  width: 100%;
  height: 100%;
  background: linear-gradient(160deg, #ffe0ec 0%, #ffd8e6 45%, #ffdcc4 100%);
  border-radius: 10px;
  box-shadow:
    0 18px 30px rgba(10, 5, 25, 0.45),
    0 6px 10px rgba(10, 5, 25, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    inset 0 -10px 16px -10px rgba(120, 40, 70, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  z-index: 1;
}

.envelope-flap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 55%;
  background: linear-gradient(200deg, #ffcadf 0%, #ffb8d1 45%, #f0a2c2 85%, #e691b2 100%);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  transition: transform 0.5s ease;
  filter: drop-shadow(0 5px 7px rgba(70, 15, 40, 0.4));
  z-index: 2;
}

.envelope-flap::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(200deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0) 40%);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}

.wax-seal {
  position: absolute;
  top: 55%;
  left: 50%;
  width: clamp(36px, 11.5vw, 46px);
  height: clamp(36px, 11.5vw, 46px);
  border-radius: 50% 48% 51% 49% / 49% 51% 48% 52%;
  background: radial-gradient(circle at 34% 30%, #b8203f, #7d1029 65%, #5c0a1e 100%);
  box-shadow:
    0 3px 7px rgba(0, 0, 0, 0.5),
    inset 0 -3px 5px rgba(0, 0, 0, 0.5),
    inset 0 2px 3px rgba(255, 190, 200, 0.2);
  transform: translate(-50%, -50%) rotate(-6deg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  transition: transform 0.6s ease, opacity 0.6s ease;
}

.wax-seal::before {
  content: "❤";
  font-size: clamp(0.9rem, 4vw, 1.15rem);
  color: #922038;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.15),
    0 -1px 1px rgba(0, 0, 0, 0.55);
  line-height: 1;
}

.envelope.open .wax-seal {
  opacity: 0;
  transform: translate(-50%, -50%) rotate(30deg) scale(0.4);
}

.envelope-note {
  position: absolute;
  left: 50%;
  top: 4%;
  width: 58%;
  height: 56%;
  background: linear-gradient(160deg, #fffaf5 0%, #fff1e6 100%);
  border-radius: 3px 3px 2px 2px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transform: translate(-50%, 0) scale(0.92);
  opacity: 0;
  z-index: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 8%;
  pointer-events: none;
  transition: transform 0.6s cubic-bezier(0.32, 1.5, 0.4, 1) 0.15s, opacity 0.5s ease 0.15s;
}

.envelope-note::before {
  content: "❤";
  font-size: clamp(1rem, 4.4vw, 1.3rem);
  color: #d8285f;
}

.envelope.open .envelope-note {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1) rotate(-3deg);
}

.envelope.open .envelope-flap {
  transform: rotateX(180deg);
}

.envelope.open .envelope-body {
  transform: translateY(6px) scale(0.96);
}

.hint {
  font-size: 0.9rem;
  color: #cbb9f5;
  margin-top: 0.4rem;
  animation: pulse 2s ease-in-out infinite;
}

.hint.hidden {
  display: none;
}

.letter {
  max-width: 40ch;
  margin-top: 1.4rem;
  padding: 24px 1.4rem 22px;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(90, 55, 40, 0) 0,
      rgba(90, 55, 40, 0) 23px,
      rgba(90, 55, 40, 0.09) 23px,
      rgba(90, 55, 40, 0.09) 24px
    ),
    linear-gradient(175deg, #fdf9ef 0%, #f5ead6 100%);
  border-radius: 8px;
  box-shadow:
    0 18px 32px rgba(8, 4, 20, 0.5),
    0 5px 10px rgba(8, 4, 20, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Courier New", monospace;
  font-size: clamp(0.84rem, 3.6vw, 0.96rem);
  line-height: 24px;
  color: #3d2a1f;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transform: rotate(-1.1deg);
  transition: opacity 0.7s ease, max-height 0.9s ease, margin-top 0.7s ease, padding 0.7s ease, transform 0.7s ease;
}

.letter.open {
  opacity: 1;
  max-height: 900px;
  margin-top: 1.4rem;
  transform: rotate(-0.5deg);
}

.letter p {
  margin: 0 0 24px;
}

.signature {
  text-align: right;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Courier New", monospace;
  font-style: italic;
  font-weight: 600;
  color: #a3324f;
  margin-bottom: 0.25em !important;
}

.signature-note {
  text-align: right;
  font-size: 0.9em;
  color: #6b5847;
  margin-bottom: 0 !important;
}

/* small screens height safety */
@media (max-height: 700px) {
  .scene {
    padding-top: max(env(safe-area-inset-top), 40px);
    padding-bottom: max(env(safe-area-inset-bottom), 40px);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
