@media only screen and (min-width: 700px){
  #envelope {
    border-radius: 0 0 4px 4px;
    width: 320px;
    height: 320px;
    min-height: 320px;
    margin: 20px auto;
  }
  #envelope::before {
    border-width: 296px 0 0 300px;
  }
  #envelope::after {
    border-width: 0 0 296px 300px;
  }
  #envelope .card {
    padding: 7.5px 15px;
  }
  #envelope .flap-inside {
    border-radius: 0 0 4px 4px;
  }
  #envelope .flap-inside .flap {
    border-radius: 40px 40px 80px 40px;
    border: 1px solid #e58477;
    margin-top: 20px;
  }
  #envelope .flap {
    border-radius: 40px;
    width: 305px;
    height: 305px;
    margin: -20px 0 0 -151px;
  }
  #envelope .flap .lining {
    border-radius: 0 0 30px 0;
  }
}

/*!!!!!!!!!!!             !!!!!!!!!!!!!!*/
/*!!!!!!!!!!!small screens!!!!!!!!!!!!!!*/
/*!!!!!!!!!!!             !!!!!!!!!!!!!!*/
@media only screen and (max-width: 700px){
  #envelope {
    border-radius: 0 0 3px 3px;
    width: 240px;
    height: 240px;
    min-height: 240px;
    margin: 15px auto;
  }
  #envelope::before {
    border-width: 222px 0 0 225px;
  }
  #envelope::after {
    border-width: 0 0 222px 225px;
  }
  #envelope .card {
    padding: 10px 20px;
  }
  #envelope .flap-inside {
    border-radius: 0 0 3px 3px;
  }
  #envelope .flap-inside .flap {
    border-radius: 30px 30px 30px;
    border: 1px solid #e58477;
    margin-top: 15px;
  }
  #envelope .flap {
    border-radius: 30px;
    width: 229px;
    height: 229px;
    margin: -15px 0 0 -113px;
  }
  #envelope .flap .lining {
    border-radius: 0 0 40px 0;
  }
}

#envelope-wrapper {
  color: #2f2f2f;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  height: 100%;
  perspective: 1000px;
  padding: 0;
}

#envelope {
  background: #e58477;
  position: relative;
  transition: all 0.3s cubic-bezier(0.42, 0, 0.58, 1);
  transform-origin: 50% 50%;
}
#envelope::before, #envelope::after {
  content: "";
  display: block;
  position: absolute;
  bottom: 0;
  z-index: 2;
}

#envelope::before {
  left: 0;
  width: 0;
  height: 0;
  border-style: solid;
  /* Dynamic value */
}
#envelope::after {
  right: 0;
  width: 0;
  height: 0;
  border-style: solid;
}

#envelope.open {
  transform: rotateZ(7deg) translateY(130px) rotateY(-9deg);
}
#envelope.open .flap-outside {
  top: -1px;
  animation: open-flap 0.6s ease-in-out forwards;
}
#envelope.open .flap-outside .flap {
  background: #e58477;
}
#envelope.open .card {
  transform: translateX(14%) translateY(-200px);
  transition-delay: 0.6s;
}
#envelope .card {
  background: #fff;
  background-size: cover;
  background-position: center;
  position: absolute;
  overflow: hidden;
  left: 0;
  bottom: 0;
  width: 80%;
  height: 85%;
  transform: translateX(14%);
  transition: all 0.3s cubic-bezier(0.42, 0, 0.58, 1) 0s;
  z-index: 1;
}
#envelope .flap-container {
  border-radius: 4px;
  overflow: hidden;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transition: all 0.4s cubic-bezier(0.18, 0.81, 0.76, 0.93) 0s;
  z-index: 3;
}
#envelope .flap-outside {
  overflow-y: auto;
  transform-origin: 50% 0;
  animation-delay: 0.6s;
  animation-fill-mode: backwards;
  z-index: 4;
}
#envelope .flap-outside .flap {
  background: #e9978c;
  backface-visibility: hidden;
}
#envelope .flap-outside .flap:after {
  /*background: #e58477;*/
  backface-visibility: hidden;
  content: "";
  display: block;
  position: absolute;
  transform: rotateX(180deg);
  height: 100%;
  width: 100%;
  left: 0;
  top: 0;
  z-index: 1;
}
#envelope .flap-inside {
  transform: rotateX(180deg);
  border-radius: 0 0 4px 4px;
  overflow: hidden;
}
#envelope .flap-inside .flap {
  border-radius: 40px 40px 80px 40px;
  border: 1px solid #e58477;
  margin-top: 20px;
}
#envelope .flap {
  background: #e9978c;
  border: 1px solid #e58477;
  overflow: hidden;
  position: absolute;
  top: -50%;
  left: 50%;
  transform: rotateZ(45deg);
  transform-style: preserve-3d;
  transition: all 0.8s ease 0s;
  z-index: 2;
}
#envelope .flap .lining {
  background: #a3cac0;
  backface-visibility: hidden;
  position: absolute;
  top: 0;
  left: 0;
  width: 92%;
  height: 92%;
  z-index: 3;
}
#envelope svg.string {
  position: relative;
  z-index: 10;
}

@keyframes open-flap {
  0%   {
    transform:rotateX(0deg);
    z-index:4;
  }
  50%  {
    transform:rotateX(90deg);
    z-index: 0;
  }
  100% {
    transform:rotateX(180deg);
    z-index: 0;
  }
}
