:root {
  --ink: #211d1a;
  --paper: #fff7e8;
  --mint: #45c7a5;
  --coral: #f06b57;
  --lemon: #ffd54d;
  --sky: #83c7ee;
  --violet: #7058c8;
}

* {
  box-sizing: border-box;
}

body {
  align-items: center;
  background: #050505;
  color: #fff7e8;
  display: flex;
  font-family: Arial, Helvetica, sans-serif;
  justify-content: center;
  margin: 0;
  min-height: 100vh;
  padding: 28px;
}

.stage {
  width: min(1040px, 100%);
}

.book-wrap {
  perspective: 1800px;
}

.book {
  aspect-ratio: 16 / 10;
  margin: 0 auto;
  max-height: 720px;
  position: relative;
  transform-style: preserve-3d;
  width: min(940px, 100%);
}

.page {
  backface-visibility: hidden;
  background: #fff;
  border: 4px solid var(--ink);
  box-shadow: 10px 10px 0 var(--ink);
  display: grid;
  grid-template-rows: auto auto 1fr;
  inset: 0;
  overflow: hidden;
  padding: clamp(22px, 4vw, 52px);
  position: absolute;
  transform: rotateY(0deg);
  transform-origin: left center;
  transition: transform .78s cubic-bezier(.2, .7, .2, 1), filter .78s ease;
}

.page::after {
  background: linear-gradient(90deg, rgba(0,0,0,.16), transparent 22%, transparent);
  bottom: 0;
  content: "";
  left: 0;
  opacity: .35;
  pointer-events: none;
  position: absolute;
  top: 0;
  width: 100%;
}

.page.turned {
  filter: brightness(.9);
  transform: rotateY(-178deg);
}

.page.cover {
  background: #000;
  color: #fff;
}

.page.sky {
  background: var(--sky);
}

.page.night {
  background: #263252;
  color: #fff7e8;
}

.page.yellow {
  background: #f7d35a;
}

.page.split {
  background: linear-gradient(135deg, var(--mint) 0 50%, var(--coral) 50% 100%);
}

.page.violet {
  background: var(--violet);
  color: #fff7e8;
}

.kicker,
.page-no {
  font-size: .82rem;
  font-weight: 900;
  margin: 0 0 12px;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  line-height: .86;
  margin-bottom: 18px;
}

.book-logo {
  display: block;
  height: auto;
  max-width: 100%;
  width: min(720px, 92%);
}

h2 {
  font-size: clamp(2.2rem, 7vw, 5.4rem);
  line-height: .9;
  max-width: 760px;
}

.bubble {
  align-self: end;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 0 18px 18px 18px;
  color: var(--ink);
  font-size: clamp(1rem, 2vw, 1.35rem);
  font-weight: 900;
  line-height: 1.25;
  max-width: 520px;
  padding: 16px;
  z-index: 2;
}

.cover-crew,
.scene,
.choice-map {
  bottom: 42px;
  position: absolute;
  right: 52px;
}

.treet {
  background: var(--mint);
  border: 4px solid var(--ink);
  border-radius: 50% 45% 52% 48%;
  display: inline-block;
  height: 118px;
  position: relative;
  width: 118px;
}

.treet::before,
.treet::after {
  background: var(--ink);
  border-radius: 50%;
  content: "";
  height: 12px;
  position: absolute;
  top: 38px;
  width: 12px;
}

.treet::before {
  left: 34px;
}

.treet::after {
  right: 34px;
}

.coral {
  background: var(--coral);
}

.lemon {
  background: var(--lemon);
}

.cover-crew .treet {
  margin-left: -22px;
}

.shop,
.glass {
  border: 4px solid var(--ink);
  display: block;
}

.shop {
  background: repeating-linear-gradient(90deg, #fff 0 32px, var(--coral) 32px 64px);
  height: 160px;
  width: 260px;
}

.walker {
  bottom: -32px;
  left: -90px;
  position: absolute;
}

.glass {
  background: linear-gradient(135deg, rgba(255,255,255,.86), rgba(255,255,255,.12));
  height: 230px;
  transform: skew(-6deg);
  width: 330px;
}

.spark {
  background: var(--lemon);
  clip-path: polygon(50% 0, 62% 35%, 100% 50%, 62% 65%, 50% 100%, 38% 65%, 0 50%, 38% 35%);
  display: block;
  height: 82px;
  position: absolute;
  right: -28px;
  top: -34px;
  width: 82px;
}

.hero {
  height: 220px;
  width: 220px;
}

.choice-map {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, 150px);
}

.choice-map span {
  background: #fff;
  border: 4px solid var(--ink);
  box-shadow: 5px 5px 0 var(--ink);
  font-size: 1.2rem;
  font-weight: 900;
  padding: 18px;
  text-align: center;
}

.finale {
  display: flex;
  gap: 12px;
}

.controls {
  align-items: center;
  display: flex;
  gap: 18px;
  justify-content: center;
  margin-top: 28px;
}

button {
  background: var(--lemon);
  border: 3px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 900;
  padding: 12px 16px;
}

button:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.hint {
  font-weight: 800;
  margin: 18px 0 0;
  text-align: center;
}

@media (max-width: 680px) {
  body {
    padding: 16px;
  }

  .book {
    aspect-ratio: 3 / 4;
  }

  .page {
    padding: 22px;
  }

  .cover-crew,
  .scene,
  .choice-map {
    bottom: 22px;
    right: 22px;
    transform: scale(.72);
    transform-origin: bottom right;
  }

  .controls {
    align-items: stretch;
    flex-direction: column;
  }
}
