* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a0a0a 0%, #2d0a0a 30%, #1a0505 100%);
  overflow: hidden;
  font-family: 'Cormorant Garamond', Georgia, serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(139,26,26,0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(100,20,20,0.06) 0%, transparent 40%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.5) 100%);
  pointer-events: none;
  z-index: 0;
}

/* ========== PHASE 1: ENVELOPE ========== */

.envelope-wrapper {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 20;
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.envelope-wrapper.hiding {
  opacity: 0;
  transform: scale(0.7) translateY(-40px);
  pointer-events: none;
}

.envelope {
  --ew: min(80vw, 300px);
  --eh: min(56vw, 210px);
  --half: calc(var(--ew) / 2);
  --flap-h: calc(var(--eh) * 0.5);
  --env-color: #e8d5b7;
  --env-color-dark: #dcc9a3;
  position: relative;
  width: var(--ew);
  height: var(--eh);
  perspective: 1000px;
  cursor: pointer;
  transition: transform 0.3s ease;
}

.envelope:active {
  transform: scale(0.97);
}

.envelope-back {
  position: absolute;
  inset: 0;
  background: linear-gradient(170deg, var(--env-color) 0%, var(--env-color-dark) 100%);
  border-radius: 6px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.3);
}

/* Front pocket (inverted triangle) */
.envelope-front {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  overflow: hidden;
  z-index: 2;
}

.envelope-pocket {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  border-left: var(--half) solid transparent;
  border-right: var(--half) solid transparent;
  border-top: calc(var(--eh) * 0.5) solid var(--env-color-dark);
  filter: brightness(0.96);
  z-index: -5;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.envelope.open .envelope-pocket {
  opacity: 0;
}

.envelope-cover {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--env-color-dark);
  z-index: 2;
  opacity: 0;
  transition: opacity 0.5s ease;
  clip-path: polygon(50% 50%, 100% 0, 100% 100%, 0 100%, 0 0);
}

.envelope.open .envelope-cover {
  opacity: 1;
}

/* Flap - CSS border triangle */
.envelope-flap {
  position: absolute;
  left: 0;
  top: 5px;
  width: 0;
  height: 0;
  border-left: var(--half) solid transparent;
  border-right: var(--half) solid transparent;
  border-top: var(--flap-h) solid var(--env-color);
  transform-origin: top center;
  transform: rotateX(0deg);
  transition: transform 0.9s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 3;
}

.envelope.open .envelope-flap {
  transform: rotateX(180deg);
  border-top-color: var(--env-color-dark);
}

.envelope.flap-back .envelope-flap {
  z-index: -1;
}

/* Letter behind envelope - slides up when opened */
.envelope-letter {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 0;
  height: 78%;
  background: linear-gradient(180deg, #fffef8 0%, #faf5eb 100%);
  border-radius: 3px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  z-index: -1;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateY(0);
  transition: transform 0.75s ease-in-out, z-index 0s;
}

.envelope.letter-up .envelope-letter {
  transform: translateY(-100px);
  z-index: 1;
}

.envelope-letter-lines {
  width: 70%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
}

.el-line {
  height: 4px;
  background: #e0d5c5;
  border-radius: 2px;
  width: 100%;
}

.el-short { width: 45%; }

/* Seal */
.seal {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  width: clamp(52px, 15vw, 68px);
  height: clamp(52px, 15vw, 68px);
  z-index: 5;
  cursor: pointer;
  transition: transform 0.3s ease;
}

.seal:active {
  transform: translate(-50%, -50%) scale(0.9);
}

.seal-body {
  width: 100%;
  height: 100%;
  position: relative;
}

.seal-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #e84040 0%, #c62828 40%, #8b1a1a 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5), inset 0 2px 4px rgba(255,255,255,0.2), inset 0 -2px 4px rgba(0,0,0,0.3), 0 0 20px rgba(139,26,26,0.4);
  position: relative;
  overflow: hidden;
  transition: transform 0.5s ease;
}

.seal-inner::before {
  content: '';
  position: absolute;
  top: 8%;
  left: 15%;
  width: 35%;
  height: 20%;
  background: radial-gradient(ellipse, rgba(255,255,255,0.35) 0%, transparent 70%);
  border-radius: 50%;
  transform: rotate(-20deg);
}

.seal-inner::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,200,200,0.25);
}

.seal-heart {
  font-size: clamp(1rem, 4vw, 1.3rem);
  color: #ffcccc;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  line-height: 1;
}

.seal-text {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(0.35rem, 1.2vw, 0.5rem);
  font-weight: 600;
  color: rgba(255,200,200,0.7);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 1px;
}

.seal-glow {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(200,40,40,0.3) 0%, transparent 70%);
  animation: pulse-glow 2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}

.seal-crack {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}

.seal-crack::before, .seal-crack::after {
  content: '';
  position: absolute;
  background: rgba(0,0,0,0.6);
}

.seal-crack::before {
  top: 20%;
  left: 48%;
  width: 4%;
  height: 60%;
  transform: rotate(15deg);
  border-radius: 2px;
}

.seal-crack::after {
  top: 35%;
  left: 30%;
  width: 40%;
  height: 3%;
  transform: rotate(-8deg);
  border-radius: 2px;
}

.seal.breaking .seal-crack {
  opacity: 1;
  transition: opacity 0.2s ease;
}

.seal.breaking .seal-inner {
  animation: seal-shatter 0.6s ease forwards;
}

@keyframes seal-shatter {
  0% { transform: scale(1); opacity: 1; }
  30% { transform: scale(1.1); }
  100% { transform: scale(0.2) rotate(45deg); opacity: 0; }
}

.seal.breaking .seal-glow {
  animation: glow-burst 0.5s ease forwards;
}

@keyframes glow-burst {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(3); opacity: 0; }
}

.seal-piece {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #e84040, #8b1a1a);
  pointer-events: none;
}

.instruction {
  margin-top: 28px;
  font-family: 'Dancing Script', cursive;
  font-size: clamp(1.1rem, 4.5vw, 1.6rem);
  color: rgba(255,200,200,0.6);
  text-align: center;
  animation: float-text 3s ease-in-out infinite;
  white-space: nowrap;
  transition: opacity 0.5s ease;
}

.instruction.hidden {
  opacity: 0;
  pointer-events: none;
}

.envelope-title {
  font-family: 'Dancing Script', cursive;
  font-size: clamp(1.6rem, 6vw, 2.4rem);
  color: rgba(255,200,200,0.85);
  text-align: center;
  margin-bottom: 24px;
  opacity: 1;
  animation: float-text 3s ease-in-out infinite;
  white-space: nowrap;
  transition: opacity 0.5s ease;
}

.envelope-title.hidden {
  opacity: 0;
  pointer-events: none;
}

.title-heart {
  color: #e84040;
  display: inline-block;
  animation: heartbeat 1.5s ease-in-out infinite;
}

@keyframes title-in {
  to { opacity: 1; transform: translateY(0); }
}

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

@keyframes float-text {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.ambient-particle {
  position: absolute;
  width: 3px;
  height: 3px;
  background: radial-gradient(circle, rgba(255,180,180,0.6), transparent);
  border-radius: 50%;
  animation: ambient-float 4s ease-in-out infinite;
}

@keyframes ambient-float {
  0%, 100% { transform: translateY(0) scale(1); opacity: 0.3; }
  50% { transform: translateY(-20px) scale(1.5); opacity: 0.7; }
}

/* ========== PHASE 2: PARCHMENT ========== */

.parchment-wrapper {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  opacity: 0;
  transform: scale(0.3);
  transition: opacity 1s ease 0.3s, transform 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s;
  pointer-events: none;
  padding: 16px;
}

.parchment-wrapper.visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.parchment-outer {
  position: relative;
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
}

.parchment-outer::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 10% 10%, rgba(160,100,40,0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 90% 90%, rgba(140,80,30,0.1) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, transparent 30%, rgba(0,0,0,0.06) 100%);
  pointer-events: none;
  z-index: 5;
  border-radius: 4px;
}

/* Scroll rods */
.parchment-scroll-top,
.parchment-scroll-bottom {
  position: relative;
  z-index: 3;
  display: flex;
  justify-content: center;
}

.scroll-rod {
  width: calc(100% + 16px);
  height: 14px;
  background: linear-gradient(180deg, #c4a06a 0%, #b08050 35%, #9a7040 65%, #c4a06a 100%);
  border-radius: 7px;
  box-shadow: 0 3px 8px rgba(0,0,0,0.35), inset 0 2px 3px rgba(255,255,255,0.25), inset 0 -1px 2px rgba(0,0,0,0.2);
}

.scroll-rod::before {
  content: '';
  position: absolute;
  left: 12px;
  right: 12px;
  top: 3px;
  height: 3px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  border-radius: 2px;
}

/* Scroll rod caps */
.scroll-rod::after {
  content: '';
  position: absolute;
  top: -2px;
  left: -6px;
  right: -6px;
  height: 18px;
  background: linear-gradient(180deg, #b8905a 0%, #a07838 50%, #b8905a 100%);
  border-radius: 9px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25), inset 0 1px 2px rgba(255,255,255,0.2);
  z-index: -1;
}

/* Parchment body */
.parchment {
  position: relative;
  width: 100%;
  max-height: 85vh;
  max-height: 85dvh;
  background: linear-gradient(180deg, #f5e6c8 0%, #f0dbb8 15%, #edd4a8 50%, #e8ca98 85%, #e0c090 100%);
  padding: clamp(24px, 6vw, 40px) clamp(18px, 5vw, 36px);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 12px 48px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.3), inset 0 0 60px rgba(139,90,43,0.12);
}

.parchment::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 28px, rgba(139,90,43,0.04) 28px, rgba(139,90,43,0.04) 29px);
  pointer-events: none;
}

.parchment-content {
  position: relative;
  z-index: 1;
}

.p-line {
  font-size: clamp(1.15rem, 3.5vw, 1.25rem);
  line-height: 1.7;
  color: #3d2b1a;
  margin-bottom: 14px;
  text-align: justify;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.p-line.revealed {
  opacity: 1;
  transform: translateY(0);
}

.p-greeting {
  font-family: 'Dancing Script', cursive;
  font-size: clamp(2.1rem, 8vw, 2.8rem);
  color: #6b2020;
  text-align: left;
  margin-bottom: 4px;
  font-weight: 700;
}

.p-greeting-sub {
  font-family: 'Dancing Script', cursive;
  font-size: clamp(1.2rem, 4.8vw, 1.65rem);
  color: #8b3030;
  text-align: left;
  margin-bottom: 4px;
}

.p-name {
  font-family: 'Dancing Script', cursive;
  font-size: clamp(1.4rem, 5.5vw, 1.9rem);
  color: #c62828;
  text-align: left;
  font-weight: 700;
  margin-bottom: 18px;
}

.p-closing {
  font-family: 'Dancing Script', cursive;
  font-size: clamp(1.1rem, 4vw, 1.35rem);
  color: #5a3020;
  text-align: right;
  margin-top: 10px;
}

.p-love {
  font-family: 'Dancing Script', cursive;
  font-size: clamp(1.65rem, 6.5vw, 2.5rem);
  color: #c62828;
  text-align: right;
  font-weight: 700;
  margin-top: 4px;
  margin-bottom: 0;
}

.photo-gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid rgba(139,90,43,0.15);
}

.photo {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.photo.revealed {
  opacity: 1;
  transform: translateY(0);
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  cursor: pointer;
}

.lightbox.active {
  opacity: 1;
  visibility: visible;
}

.lightbox-img {
  max-width: 92vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  transform: scale(0.85);
  transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1);
}

.lightbox.active .lightbox-img {
  transform: scale(1);
}

.p-footer {
  text-align: center;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid rgba(139,90,43,0.15);
}

.footer-text {
  font-family: 'Dancing Script', cursive;
  font-size: clamp(1.6rem, 6vw, 2.3rem);
  color: #8b0000;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin: 0 0 6px;
}

.footer-heart {
  font-size: clamp(2rem, 8vw, 3.2rem);
  color: #8b0000;
  display: inline-block;
  animation: heartPulse 1.5s ease-in-out infinite;
}

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

.parchment::-webkit-scrollbar { width: 4px; }
.parchment::-webkit-scrollbar-track { background: transparent; }
.parchment::-webkit-scrollbar-thumb { background: rgba(139,90,43,0.3); border-radius: 2px; }

/* ========== ROSE PETALS ========== */

.petals-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 30;
  overflow: hidden;
}

.petal {
  position: absolute;
  top: -30px;
  opacity: 0;
}

.petal-shape {
  width: var(--petal-size, 14px);
  height: calc(var(--petal-size, 14px) * 1.2);
  background: linear-gradient(135deg, var(--petal-color-1, #ff6b8a) 0%, var(--petal-color-2, #ff3366) 100%);
  border-radius: 50% 0 50% 50%;
  transform: rotate(var(--petal-rotate, 45deg));
  box-shadow: inset 0 0 4px rgba(0,0,0,0.15);
  position: relative;
}

.petal-shape::after {
  content: '';
  position: absolute;
  top: 20%;
  left: 25%;
  width: 50%;
  height: 60%;
  background: linear-gradient(180deg, rgba(255,255,255,0.25) 0%, transparent 100%);
  border-radius: 50%;
  transform: rotate(-15deg);
}

@keyframes petal-fall {
  0% {
    opacity: 0;
    transform: translateY(0) translateX(0) rotate(0deg) scale(0.8);
  }
  10% { opacity: 0.9; }
  90% { opacity: 0.7; }
  100% {
    opacity: 0;
    transform: translateY(100vh) translateX(var(--petal-drift, 80px)) rotate(var(--petal-spin, 360deg)) scale(0.6);
  }
}

.petal.falling {
  animation: petal-fall var(--fall-duration, 6s) var(--fall-delay, 0s) ease-in forwards;
}

/* ========== RESPONSIVE ========== */

@media (max-width: 380px) {
  .envelope { --ew: 86vw; --eh: 60vw; }
  .parchment { padding: 22px 14px; }
  .p-line { font-size: 0.85rem; line-height: 1.5; }
}

@media (min-width: 768px) {
  .envelope { --ew: 340px; --eh: 240px; }
  .p-line { font-size: 1.2rem; }
}
