* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Segoe UI', sans-serif;
}

html,
body {
  overscroll-behavior: none;
}

body {
  background: #f8f1f7;
  color: #333;
  padding: 2rem;
  overflow-x: hidden;
  overflow-y: auto;
}

.container {
  max-width: 600px;
  margin: auto;
  margin-bottom: 1.5rem;
  background: #fff;
  padding: 2rem;
  border-radius: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

h1,
h2 {
  text-align: center;
  color: crimson;
}

h1 {
  font-size: 2rem;
  margin-bottom: 1rem;
}

h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: #dd84d6;
}

#timer {
  font-size: 1.4rem;
  color: #555;
  font-family: monospace;
  text-align: center;
  margin: 1rem auto;
  width: 100%;
}

.countdown-message {
  text-align: center;
  font-size: 1.2rem;
  font-weight: bold;
  color: #d23669;
  margin-top: 0.5rem;
}

#heart-rain {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 9999;
}

.heart {
  position: absolute;
  font-size: 24px;
  animation: fall linear forwards;
}

@keyframes fall {
  0% {
    transform: translateY(-10vh);
    opacity: 1;
  }
  100% {
    transform: translateY(110vh);
    opacity: 0;
  }
}

/* ================= LOCK SCREEN ================= */

#lock-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #ffe3f3, #ffd1ea);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 99999;
}

.lock-box {
  background: white;
  padding: 40px;
  border-radius: 20px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.lock-box input {
  padding: 10px;
  margin: 10px;
  border-radius: 8px;
  border: 1px solid #ccc;
}

.lock-box button {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  background: #dd84d6;
  color: white;
  cursor: pointer;
}

#errorMsg {
  color: crimson;
  margin-top: 8px;
}

button,
img,
div {
  touch-action: manipulation;
}

/* ================= GENERAL IMAGE SAFETY ================= */

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ================= ROSE ================= */

.rose-animation {
  width: 300px;
  max-width: 100%;
  margin: 1rem auto;
  position: relative;
}

.rose-image {
  width: 100%;
  display: block;
  border-radius: 12px;
  transition: opacity 0.8s ease;
  position: relative;
}

.glow {
  text-shadow: 0 0 3px #f8d8e9, 0 0 8px #d8bdcc;
}

/* ================= ENVELOPE SECTION ================= */

.envelope-subtext {
  text-align: center;
  color: #b55c9a;
  margin-top: -0.25rem;
  margin-bottom: 1.25rem;
  font-weight: 600;
}

.envelope-section {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.5rem 0 0.25rem;
}

.envelope-button {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
}

.envelope {
  position: relative;
  width: 220px;
  height: 150px;
  transition: transform 0.25s ease;
}

.envelope-button:hover .envelope {
  transform: translateY(-4px) scale(1.02);
}

.envelope-front {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #ffb7dc, #ff8fc8);
  border-radius: 0 0 16px 16px;
  clip-path: polygon(0 26%, 50% 68%, 100% 26%, 100% 100%, 0 100%);
  box-shadow: 0 12px 26px rgba(221, 132, 214, 0.28);
  z-index: 3;
}

.envelope-back {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #ffd3e9, #ffb7dc);
  border-radius: 0 0 16px 16px;
  z-index: 1;
}

.envelope-flap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 90px;
  background: linear-gradient(180deg, #ffc7e5, #ff9dd0);
  clip-path: polygon(0 0, 50% 100%, 100% 0);
  transform-origin: top center;
  transition: transform 0.6s ease;
  z-index: 4;
  border-radius: 12px 12px 0 0;
}

.envelope-letter-peek {
  position: absolute;
  left: 50%;
  bottom: 18px;
  width: 128px;
  height: 88px;
  background: #fffdfd;
  transform: translateX(-50%);
  border-radius: 10px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
  transition: transform 0.6s ease;
  z-index: 2;
}

.envelope-heart {
  position: absolute;
  left: 50%;
  top: 72px;
  transform: translateX(-50%);
  z-index: 4;
  font-size: 1.8rem;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.12));
}

.envelope.open-preview .envelope-flap {
  transform: rotateX(180deg);
}

.envelope.open-preview .envelope-letter-peek {
  transform: translateX(-50%) translateY(-12px);
}

/* ================= LETTER MODAL ================= */

.letter-modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 100000;
}

.letter-modal.show {
  display: block;
}

.letter-overlay {
  position: absolute;
  inset: 0;
  background: rgba(45, 17, 39, 0.45);
  backdrop-filter: blur(4px);
}

.letter-popup {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(92vw, 560px);
  transform: translate(-50%, -46%);
  opacity: 0;
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.letter-popup.show {
  opacity: 1;
  transform: translate(-50%, -50%);
}

.close-letter-btn {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: #ff69b4;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  z-index: 3;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.letter-paper {
  background: linear-gradient(180deg, #fffefe, #fff6fb);
  border-radius: 20px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  transform-origin: top center;
  transform: scaleY(0.05);
  opacity: 0;
  transition: transform 0.45s ease, opacity 0.35s ease;
}

.letter-paper.open {
  transform: scaleY(1);
  opacity: 1;
}

.letter-content {
  padding: 2rem 1.5rem 1.6rem;
  text-align: center;
}

.letter-content h2 {
  margin-bottom: 1rem;
}

.letter-content p {
  font-size: 1.05rem;
  line-height: 1.7;
  color: #6d3c61;
  margin-bottom: 1rem;
}

.letter-image {
  display: block;
  width: min(100%, 280px);
  margin: 1rem auto 1.25rem;
  border-radius: 16px;
  box-shadow: 0 10px 24px rgba(221, 132, 214, 0.18);
}

.letter-signoff {
  font-weight: 700;
  color: #c94e98;
}

/* ================= PHOTO GALLERY - DESKTOP ================= */

.gallery-subtext {
  text-align: center;
  color: #b55c9a;
  margin-top: -0.25rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

.gallery-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.gallery-viewport {
  position: relative;
  width: 100%;
  max-width: 420px;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border-radius: 20px;
  background: #f9e9f4;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  touch-action: pan-y;
}

.gallery-track {
  display: flex;
  width: 100%;
  height: 100%;
  transition: transform 0.45s ease;
}

.gallery-slide {
  min-width: 100%;
  width: 100%;
  height: 100%;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f9e9f4;
}

.gallery-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.gallery-btn {
  border: none;
  background: #ff8fc8;
  color: white;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(221, 132, 214, 0.22);
  transition: transform 0.2s ease, background 0.2s ease;
  flex-shrink: 0;
}

.gallery-btn:hover {
  transform: scale(1.08);
  background: #ff6bb7;
}

.gallery-counter {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.45);
  color: white;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
  z-index: 2;
}

.gallery-label {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  background: rgba(255, 255, 255, 0.85);
  color: #8d3b71;
  padding: 0.7rem 0.9rem;
  border-radius: 14px;
  text-align: center;
  font-weight: 700;
  font-size: 0.98rem;
  backdrop-filter: blur(4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 2;
}

.gallery-label.is-changing {
  opacity: 0.65;
  transform: translateY(4px);
}

.gallery-dots {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 1rem;
}

.gallery-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e4bfd8;
  border: none;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.gallery-dot.active {
  background: #dd84d6;
  transform: scale(1.2);
}

/* ================= CUTE GIF / BACK TO TOP - DESKTOP ================= */

.back-top-subtext {
  text-align: center;
  color: #b55c9a;
  margin-top: -0.25rem;
  margin-bottom: 1.1rem;
  font-weight: 600;
}

.container > img {
  width: min(100%, 280px);
  height: auto;
  margin: 0 auto 1rem;
  border-radius: 16px;
}

.back-top-section {
  display: flex;
  justify-content: center;
  align-items: center;
  padding-top: 0.25rem;
}

.back-top-btn {
  border: none;
  background: linear-gradient(180deg, #ffb7dc, #ff8fc8);
  color: white;
  padding: 0.95rem 1.4rem;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(221, 132, 214, 0.22);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.back-top-btn:hover {
  transform: translateY(-2px) scale(1.03);
  background: linear-gradient(180deg, #ff9fd0, #ff74bb);
  box-shadow: 0 10px 24px rgba(221, 132, 214, 0.28);
}

/* ================= TABLET + MOBILE ================= */

@media (max-width: 640px) {
  body {
    padding: 1rem;
  }

  .container {
    padding: 1.25rem;
    border-radius: 18px;
  }

  h1 {
    font-size: 1.7rem;
  }

  h2 {
    font-size: 1.3rem;
  }

  #timer {
    font-size: 1.15rem;
  }

  .countdown-message {
    font-size: 1rem;
    line-height: 1.5;
  }

  .rose-animation {
    width: 220px;
  }

  .letter-content {
    padding: 1.35rem 1rem 1.2rem;
  }

  .letter-content p {
    font-size: 0.98rem;
    line-height: 1.6;
  }

  .close-letter-btn {
    top: -10px;
    right: -6px;
    width: 38px;
    height: 38px;
    font-size: 1.35rem;
  }

  /* gallery on mobile */
  .gallery-wrapper {
    gap: 0.5rem;
  }

  .gallery-viewport {
    max-width: 100%;
    aspect-ratio: 3 / 4;
    border-radius: 16px;
  }

  .gallery-track {
    height: 100%;
  }

  .gallery-slide {
    border-radius: 16px;
  }

  .gallery-slide img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center center;
    background: #f9e9f4;
  }

  .gallery-btn {
    width: 40px;
    height: 40px;
    font-size: 1.7rem;
  }

  .gallery-counter {
    top: 10px;
    right: 10px;
    font-size: 0.82rem;
    padding: 0.3rem 0.55rem;
  }

  .gallery-label {
    left: 10px;
    right: 10px;
    bottom: 10px;
    font-size: 0.9rem;
    padding: 0.65rem 0.75rem;
  }

  .gallery-dots {
    gap: 0.4rem;
    margin-top: 0.85rem;
  }

  .gallery-dot {
    width: 9px;
    height: 9px;
  }

  /* bear gif on mobile */
  .container > img {
    width: min(100%, 220px);
    max-width: 100%;
    height: auto;
    margin: 0 auto 0.9rem;
    border-radius: 14px;
  }

  .back-top-subtext {
    font-size: 0.95rem;
    line-height: 1.5;
  }

  .back-top-btn {
    width: 100%;
    max-width: 260px;
    padding: 0.9rem 1.2rem;
    font-size: 0.98rem;
  }
}