#envelope {
  position: relative;
  width: 280px;
  height: 180px;
  border-bottom-left-radius: 6px;
  border-bottom-right-radius: 6px;
  margin-left: auto;
  margin-right: auto;
  top: 150px;
  background-color: #d9534f; /* Warm romantic red */
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  transition: all 0.7s ease;
}

.front {
  position: absolute;
  width: 0;
  height: 0;
  z-index: 3;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.flap {
  border-left: 140px solid transparent;
  border-right: 140px solid transparent;
  border-bottom: 82px solid transparent;
  /* a little smaller */
  border-top: 98px solid #d9534f; /* Same romantic red */
  /* a little larger */
  transform-origin: top;
  pointer-events: none;
}

.pocket {
  border-left: 140px solid #f5a3a2; /* Soft pinkish red for the pocket */
  border-right: 140px solid #f5a3a2;
  border-bottom: 90px solid #ff6f61; /* Lighter romantic red */
  border-top: 90px solid transparent;
  border-bottom-left-radius: 6px;
  border-bottom-right-radius: 6px;
}

.letter {
  position: relative;
  background-color: #FCFEFC;
  border: 2px solid var(--dark-color);
  outline: 6px solid #FCFEFC;
  width: 90%;
  margin-left: auto;
  margin-right: auto;
  height: 80%;
  top: 5%;
  border-radius: 15px;
  box-shadow: 0 2px 26px rgba(0, 0, 0, 0.2);
  font-family: "Dancing Script", cursive;
  padding: 15px;
  transition: all 0.7s ease;
  overflow: hidden;
  line-height: 1.7;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.letter-side {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  padding: 20px;
  transition: opacity 1s ease;
}

.letter-side.file-side video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 300;
  border-radius: 10px;
}

.letter-side.file-side .letter-btn {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 301;
  margin-top: 0;
}

.letter .letter-side.file-side button {
  left: 0;
  translate: 0 0;
}

.letter-side:not(.active-side) {
  opacity: 0;
  pointer-events: none;
}

.letter-btn {
    position: relative;
    margin-top: 10px;
    width: 100%;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.letter button {
    position: absolute;
    top: 0;
    left: 50%;
    translate: -50% 0;
    background-color: var(--dark-color);
    color: white;
    padding: 8px 12px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    z-index: 300;
    transition: scale 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.letter button:active {
    scale: 0.92;
}

.envlope-wrapper.text-active .letter {
  top: 0;
  width: 100%;
  height: 100%;
  transform: translateY(0);
}

.envlope-wrapper.text-active .front {
  opacity: 0;
}

.envlope-wrapper.text-active #envelope {
  width: 100%;
  height: 100%;
  top: 0;
  background-color: transparent;
  box-shadow: none;
}

.envlope-wrapper.text-active {
  width: 700px !important;
  height: 800px !important;
}

.letter:after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
}
.open .flap {
  transform: rotateX(180deg);
  transition: transform 0.4s ease, z-index 0.6s;
  z-index: 1;
}

.close .flap {
  transform: rotateX(0deg);
  transition: transform 0.4s 0.6s ease, z-index 1s, opacity 0.4s 0.6s ease;
  z-index: 5;
}

.close .letter {
  transform: translateY(0px);
  transition: transform 0.4s 0.6s ease, z-index 1s, opacity 0.4s 0.6s ease;
  z-index: 1;
}

.open .letter {
  transform: translateY(-100px);
  transition: transform 0.4s 0.6s ease, z-index 0.6s;
  z-index: 2;
}

.hearts {
  position: absolute;
  top: 90px;
  left: 0;
  right: 0;
  z-index: 2;
}

.heart {
  position: absolute;
  bottom: 0;
  right: 10%;
  pointer-events: none;
}

.heart:before,
.heart:after {
  position: absolute;
  content: "";
  left: 50px;
  top: 0;
  width: 50px;
  height: 80px;
  background: #e60073; /* Deep romantic pink */
  border-radius: 50px 50px 0 0;
  transform: rotate(-45deg);
  transform-origin: 0 100%;
  pointer-events: none;
}

.heart:after {
  left: 0;
  transform: rotate(45deg);
  transform-origin: 100% 100%;
}

.close .heart {
  opacity: 0;
  -webkit-animation: none;
  animation: none;
}

.a1 {
  left: 20%;
  transform: scale(0.6);
  opacity: 1;
  -webkit-animation: slideUp 4s linear 1, sideSway 2s ease-in-out 4 alternate;
  -moz-animation: slideUp 4s linear 1, sideSway 2s ease-in-out 4 alternate;
  -webkit-animation-fill-mode: forwards;
  animation-fill-mode: forwards;
  -webkit-animation-delay: 0.7s;
  animation-delay: 0.7s;
}

.a2 {
  left: 55%;
  transform: scale(1);
  opacity: 1;
  -webkit-animation: slideUp 5s linear 1, sideSway 4s ease-in-out 2 alternate;
  -moz-animation: slideUp 5s linear 1, sideSway 4s ease-in-out 2 alternate;
  -webkit-animation-fill-mode: forwards;
  animation-fill-mode: forwards;
  -webkit-animation-delay: 0.7s;
  animation-delay: 0.7s;
}

.a3 {
  left: 10%;
  transform: scale(0.8);
  opacity: 1;
  -webkit-animation: slideUp 7s linear 1, sideSway 2s ease-in-out 6 alternate;
  -moz-animation: slideUp 7s linear 1, sideSway 2s ease-in-out 6 alternate;
  -webkit-animation-fill-mode: forwards;
  animation-fill-mode: forwards;
  -webkit-animation-delay: 0.7s;
  animation-delay: 0.7s;
}

@-webkit-keyframes slideUp {
  0% {
    top: 0;
  }
  100% {
    top: -600px;
  }
}
@keyframes slideUp {
  0% {
    top: 0;
  }
  100% {
    top: -600px;
  }
}
@-webkit-keyframes sideSway {
  0% {
    margin-left: 0px;
  }
  100% {
    margin-left: 50px;
  }
}
@keyframes sideSway {
  0% {
    margin-left: 0px;
  }
  100% {
    margin-left: 50px;
  }
}
body {
  background-color: #f0e6f6; /* Soft lavender for a romantic, dreamy feel */
}

.reset {
  text-align: center;
}

.reset button {
  font-weight: 800;
  font-style: normal;
  transition: all 0.1s linear;
  -webkit-appearance: none;
  background-color: transparent;
  border: solid 2px #d9534f;
  border-radius: 4px;
  color: #d9534f;
  display: inline-block;
  font-size: 14px;
  text-transform: uppercase;
  margin: 5px;
  padding: 10px;
  line-height: 1em;
  text-decoration: none;
  min-width: 120px;
  cursor: pointer;
}

.reset button:hover {
  background-color: #d9534f;
  color: #fff;
}

.letter-shadow {
  background-color: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(4px);
  position: fixed;
  top: 0;
  left: 0;
  width: 100svw;
  height: 100svh;
  z-index: 200;
  transition: opacity 0.4s ease;
}

.letter-shadow:not(.letter-active) {
  pointer-events: none;
  opacity: 0;
}

.letter-shadow:not(.letter-active) .letter-container {
  scale: 0.4;
  opacity: 0;
}

.letter-container {
  position: absolute;
  top: 50%;
  left: 50%;
  translate: -50% -50%;
  z-index: 201;
  transition: scale 0.4s ease, opacity 0.4s ease;
}

.letter-container .envlope-wrapper {
  zoom: 1.25;
  width: 280px;
  height: 380px;
  transition: 0.7s ease;
}

.letter-container.close {
  opacity: 0;
  pointer-events: none;
  transition: transform 0.4s 0.6s ease, z-index 1s, opacity 0.4s 0.6s ease;
}

.letter .letter-pic {
    height: 200px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}
.letter .letter-pic img {
    height: 100%;
    border-radius: 10px;
}
.letter .letter-pic::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-shadow: inset 0 0 20px 10px #FCFEFC;
    border-radius: 10px;
}