* {
  box-sizing: border-box;
}

body {
  height: 100vh;
}

.card {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  margin: auto;
  width: 500px;
  height: 35rem;
  perspective: 80rem;
  border-radius: 0 5px 5px 0;
}
@media only screen and (max-device-width: 667px) and (-webkit-min-device-pixel-ratio: 2) {
  .card {
    width: 50rem;
    height: 86rem;
  }
}

.cover, .page {
  transform-origin: 0 100%;
  box-shadow: inset 0px 0px 20px 3px rgba(0, 0, 0, 0.25);
  font-family: "Pacifico", serif;
  cursor: pointer;
  padding: 30px;
  background: #FC0E1B url("./book.gif") 50% 50% no-repeat;
}

.cover {
  position: absolute;
  background: #FC0E1B;
  color: #FFFFFF;
  font-size: 2rem;
  width: inherit;
  height: inherit;
  border-radius: inherit;
  background: #FC0E1B url(./book-bg.gif) 50% no-repeat;
  background-size: 350px 500px;
}
@media only screen and (max-device-width: 667px) and (-webkit-min-device-pixel-ratio: 2) {
  .cover {
    font-size: 6rem;
  }
}
.cover.front {
  -webkit-animation: coverClose 2s ease-in-out 0.5s both;
          animation: coverClose 2s ease-in-out 0.5s both;
  background: #FC0E1B url("./book.gif") 50% 50% no-repeat;
  background-size: cover;
}
.cover.open {
  -webkit-animation: coverOpen 2s ease-in-out both;
          animation: coverOpen 2s ease-in-out both;
}
.cover > .from {
  position: absolute;
  bottom: 30px;
  right: 30px;
  font-size: 20px;
  color: #FF0000;
}

.page {
  position: absolute;
  background: #E9E6C4;
  color: #000000;
  top: 0.25rem;
  left: 0;
  width: 495px;
  height: 34.5rem;
  font-size: 1.6rem;
  line-height: 2.2rem;
  border-radius: inherit;
  -webkit-animation: pageClose 2s ease-in-out both;
          animation: pageClose 2s ease-in-out both;
}
@media only screen and (max-device-width: 667px) and (-webkit-min-device-pixel-ratio: 2) {
  .page {
    width: 49.75rem;
    height: 85.5rem;
    font-size: 4.3rem;
    line-height: 4.4rem;
    padding: 50px;
  }
}
.page:nth-child(4) {
  -webkit-animation-delay: 0.2s;
          animation-delay: 0.2s;
}
.page:nth-child(3) {
  -webkit-animation-delay: 0.1s;
          animation-delay: 0.1s;
}
.page.open {
  -webkit-animation: pageOpen 2s ease-in-out both;
          animation: pageOpen 2s ease-in-out both;
}
.page.open:nth-child(4) {
  z-index: 0;
}
.page.open:nth-child(3) {
  z-index: 1;
}
.page.open:nth-child(2) {
  z-index: 2;
}

@-webkit-keyframes coverOpen {
  0% {
    z-index: 2;
  }
  100% {
    transform: rotateY(-100deg);
    z-index: -1;
  }
}

@keyframes coverOpen {
  0% {
    z-index: 2;
  }
  100% {
    transform: rotateY(-100deg);
    z-index: -1;
  }
}
@-webkit-keyframes pageOpen {
  64% {
    color: #000000;
  }
  65% {
    color: #E9E6C4;
  }
  100% {
    transform: rotateY(-100deg);
    color: #E9E6C4;
  }
}
@keyframes pageOpen {
  64% {
    color: #000000;
  }
  65% {
    color: #E9E6C4;
  }
  100% {
    transform: rotateY(-100deg);
    color: #E9E6C4;
  }
}
@-webkit-keyframes coverClose {
  0% {
    transform: rotateY(-100deg);
    z-index: -1;
  }
  50% {
    z-index: 2;
  }
  100% {
    transform: rotateY(0deg);
  }
}
@keyframes coverClose {
  0% {
    transform: rotateY(-100deg);
    z-index: -1;
  }
  50% {
    z-index: 2;
  }
  100% {
    transform: rotateY(0deg);
  }
}
@-webkit-keyframes pageClose {
  0% {
    transform: rotateY(-100deg);
    z-index: 0;
  }
  50% {
    z-index: 1;
  }
  100% {
    transform: rotateY(0deg);
  }
}
@keyframes pageClose {
  0% {
    transform: rotateY(-100deg);
    z-index: 0;
  }
  50% {
    z-index: 1;
  }
  100% {
    transform: rotateY(0deg);
  }
}