* {
  box-sizing: border-box;
}

:root {
  --purple: #68449d;
  --purple-dark: #47306f;

  --nav: #634799;
  --nav-dark: #432e70;

  --cream: #f1e2c8;
  --cream-light: #fff9ef;

  --yellow: #f2cf72;
  --yellow-dark: #c49b3f;

  --blue: #28388e;
  --blue-dark: #171f5b;

  --red: #c94e4e;
  --red-dark: #913535;

  --text: #20162d;
  --shadow: rgba(24, 17, 48, 0.25);
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background:
    radial-gradient(
      circle at top right,
      rgba(242, 207, 114, 0.22) 0,
      transparent 30%
    ),
    radial-gradient(
      circle at bottom left,
      rgba(104, 68, 157, 0.35) 0,
      transparent 34%
    ),
    linear-gradient(
      135deg,
      #081b3a,
      #171630
    );
}

body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 10px;
}

.book-shell {
  width: min(1280px, 100%);
  height: min(720px, calc(100vh - 20px));
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr) 64px;
  gap: 10px;
  padding: 14px;
  border: 4px solid rgba(255, 255, 255, 0.94);
  border-radius: 30px;
  background: rgba(241, 226, 200, 0.96);
  box-shadow: 0 24px 60px var(--shadow);
}

.book-topbar {
  display: grid;
  grid-template-columns: 150px 1fr 150px;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 22px;
  background: var(--cream);
}

.top-btn,
.logo-pill,
.nav-btn,
.sound-btn {
  border: none;
  outline: none;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 900;
  cursor: pointer;
  text-decoration: none;
  transition:
    transform 0.14s ease,
    filter 0.14s ease,
    box-shadow 0.14s ease;
}

.top-btn,
.logo-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border-radius: 999px;
  color: #ffffff;
  background: var(--nav);
  box-shadow: 0 5px 0 var(--nav-dark);
  font-size: 15px;
  text-align: center;
}

.page-status {
  display: grid;
  justify-items: center;
  gap: 7px;
  font-size: 17px;
}

.progress-track {
  width: min(420px, 100%);
  height: 13px;
  overflow: hidden;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: #d9cbed;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(
    90deg,
    var(--purple),
    var(--yellow)
  );
}

.pag1-progress {
  width: 4.1667%;
}

.pag2-progress {
  width: 8.3333%;
}

.pag3-progress {
  width: 12.5%;
}

.pag4-progress {
  width: 16.6667%;
}

.pag5-progress {
  width: 20.8333%;
}

.pag6-progress {
  width: 25%;
}

.pag7-progress {
  width: 29.1667%;
}

.pag8-progress {
  width: 33.3333%;
}

.pag9-progress {
  width: 37.5%;
}

.pag10-progress {
  width: 41.6667%;
}

.pag11-progress {
  width: 45.8333%;
}

.pag12-progress {
  width: 50%;
}

.pag13-progress {
  width: 54.1667%;
}

.pag14-progress {
  width: 58.3333%;
}

.pag15-progress {
  width: 62.5%;
}

.pag16-progress {
  width: 66.6667%;
}

.pag17-progress {
  width: 70.8333%;
}

.pag18-progress {
  width: 75%;
}

.pag19-progress {
  width: 79.1667%;
}

.pag20-progress {
  width: 83.3333%;
}

.pag21-progress {
  width: 87.5%;
}

.pag22-progress {
  width: 91.6667%;
}

.pag23-progress {
  width: 95.8333%;
}

.pag24-progress {
  width: 100%;
}

.book-main {
  display: grid;
  grid-template-columns: 65% 35%;
  gap: 14px;
  min-height: 0;
}

.stage-area,
.text-panel {
  min-height: 0;
  overflow: hidden;
  border: 5px solid #ffffff;
  border-radius: 28px;
  box-shadow: 0 14px 35px rgba(25, 19, 52, 0.2);
}

.stage-area {
  position: relative;
  display: grid;
  place-items: center;
  background: var(--cream);
}

.scene-box {
  position: relative;
  height: 100%;
  max-width: 100%;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  border-radius: 18px;
  background: var(--cream);
}

.stage-bg {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.personagem {
  position: absolute;
  height: auto;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.roman-pag1 {
  left: 20%;
  bottom: 4%;
  z-index: 10;
  width: 27%;
  transform-origin: bottom center;
}

.domenic-pag1 {
  left: 47%;
  bottom: 4%;
  z-index: 11;
  width: 28%;
  transform-origin: bottom center;
}

.text-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 18px;
  background: linear-gradient(
    180deg,
    var(--cream-light),
    #f1e2c8
  );
}

.story-card {
  display: grid;
  align-content: center;
  gap: 18px;
  min-height: 0;
  padding: 22px;
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.68);
}

.story-card p {
  margin: 0;
  font-family: "Nunito", Arial, Helvetica, sans-serif;
  font-size: clamp(20px, 2vw, 30px);
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.sound-buttons {
  display: grid;
  gap: 10px;
}

.sound-btn {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 17px;
  color: #ffffff;
  font-size: 16px;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.2);
}

.story-btn {
  background: var(--red);
  box-shadow: 0 5px 0 var(--red-dark);
}

.play-btn {
  background: var(--purple);
  box-shadow: 0 5px 0 var(--purple-dark);
}

.book-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 12px;
  border-radius: 22px;
  background: var(--cream);
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 220px;
  min-height: 46px;
  padding: 10px 18px;
  border-radius: 18px;
  color: #ffffff;
  background: var(--nav);
  box-shadow: 0 5px 0 var(--nav-dark);
  font-size: 16px;
}

.sound-btn:hover,
.nav-btn:hover,
.top-btn:hover,
.logo-pill:hover {
  transform: translateY(-3px) scale(1.03);
  filter: brightness(1.07);
}

.sound-btn:active,
.nav-btn:active,
.top-btn:active,
.logo-pill:active {
  transform: translateY(4px) scale(0.96);
  filter: brightness(0.95);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18);
}

.sound-btn.is-playing {
  animation: botaoTocando 0.9s ease-in-out infinite;
}

.roman-pag1.brincando {
  animation: romanBrinca 0.9s ease-in-out;
}

.domenic-pag1.brincando {
  animation: domenicBrinca 0.9s ease-in-out;
}

@keyframes botaoTocando {
  0%,
  100% {
    transform: scale(1);
    filter: brightness(1);
  }

  50% {
    transform: scale(1.04);
    filter: brightness(1.12);
  }
}

@keyframes romanBrinca {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }

  35% {
    transform: translateY(-12px) rotate(-3deg);
  }

  70% {
    transform: translateY(0) rotate(2deg);
  }
}

@keyframes domenicBrinca {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }

  35% {
    transform: translateY(-10px) rotate(3deg);
  }

  70% {
    transform: translateY(0) rotate(-2deg);
  }
}

@media (max-width: 900px) {
  body {
    padding: 10px;
  }

  .book-shell {
    height: auto;
    min-height: 0;
    grid-template-rows: auto auto auto;
    padding: 12px;
    border-radius: 24px;
  }

  .book-topbar {
    grid-template-columns: 1fr;
  }

  .book-main {
    grid-template-columns: 1fr;
  }

  .stage-area {
    aspect-ratio: 1 / 1;
  }

  .scene-box {
    width: 100%;
    height: auto;
  }

  .text-panel {
    min-height: 320px;
  }

  .book-footer {
    flex-direction: column;
  }

  .nav-btn {
    width: 100%;
  }
}