:root {
  color-scheme: light;
  --ink: #171717;
  --paper: #fffefa;
  --panel: #f4f0e6;
  --line: #26221e;
  --accent: #c53b2d;
  --accent-2: #26736c;
  --accent-3: #e2a92f;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: linear-gradient(180deg, #f7f3ea 0%, #e8f2ef 48%, #fbf7ee 100%);
  color: var(--ink);
  font-family: "Comic Sans MS", "Trebuchet MS", Arial, sans-serif;
}

.comic {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 20px 14px 42px;
}

.comic-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 2px 4px 16px;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  color: #6b4530;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 7vw, 4.6rem);
  line-height: .95;
  letter-spacing: 0;
}

.page-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  max-width: 44%;
}

.page-nav a {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: #fff;
  font-weight: 900;
  text-decoration: none;
  box-shadow: 0 3px 0 rgba(0,0,0,.14);
}

.page {
  margin: 0 0 32px;
}

.page-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 1241 / 1754;
  overflow: hidden;
  isolation: isolate;
  background: white;
  border: 2px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 16px 34px rgba(29, 23, 18, .13);
}

.page-art {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.cutout,
.effect,
.voice-bubble {
  position: absolute;
}

.cutout {
  z-index: 3;
  height: auto;
  pointer-events: none;
  transform-origin: 50% 55%;
  filter: drop-shadow(0 4px 0 rgba(0,0,0,.045));
}

.effect {
  z-index: 4;
  fill: none;
  stroke: var(--accent);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .74;
  pointer-events: none;
}

.effect circle {
  fill: #54a7cf;
  stroke: none;
}

.alarm {
  left: 71%;
  top: 7%;
  width: 18%;
  height: 9%;
  animation: blink 1.1s steps(2, jump-none) infinite;
}

.blast {
  left: 6%;
  top: 2%;
  width: 25%;
  height: 14%;
  stroke: var(--accent);
  animation: pulse 1.8s ease-in-out infinite;
}

.rope-lines {
  left: 60%;
  top: 70%;
  width: 20%;
  height: 11%;
  stroke: var(--accent-2);
  animation: shimmer 2.8s ease-in-out infinite;
}

.fire-puffs {
  left: 9%;
  top: 55%;
  width: 23%;
  height: 11%;
  stroke: var(--accent);
  animation: pulse 1.8s ease-in-out infinite;
}

.voice-bubble {
  z-index: 7;
  width: clamp(28px, 5.5vw, 50px);
  aspect-ratio: 1;
  border: 2px solid #191615;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 34%, #fff 0 28%, #ffe29f 29% 56%, #d85635 57% 100%);
  box-shadow: 0 5px 0 rgba(0,0,0,.18);
  cursor: grab;
  touch-action: none;
}

.voice-bubble::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-28%, -50%);
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 12px solid #171312;
}

.voice-bubble::after {
  content: "";
  position: absolute;
  right: -7px;
  bottom: 2px;
  width: 12px;
  height: 10px;
  border-right: 2px solid #171312;
  border-bottom: 2px solid #171312;
  transform: rotate(-18deg);
  background: #ffe29f;
}

.voice-bubble.narration-dot {
  background: radial-gradient(circle at 38% 34%, #fff 0 28%, #a7dfd8 29% 56%, var(--accent-2) 57% 100%);
}

.voice-bubble:hover,
.voice-bubble:focus-visible,
.voice-bubble.is-playing {
  outline: none;
  background: radial-gradient(circle at 38% 34%, #fff 0 26%, #f8d66a 27% 56%, var(--accent-3) 57% 100%);
}

.voice-bubble.is-dragging {
  cursor: grabbing;
  opacity: .78;
}

.story-box .voice-bubble {
  position: relative;
  left: auto !important;
  top: auto !important;
  flex: 0 0 auto;
  width: 38px;
  cursor: pointer;
}

.story-box {
  margin: 10px 0 0;
  padding: 13px 16px 14px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 246, .96);
  box-shadow: 0 8px 20px rgba(29, 23, 18, .08);
}

.story-heading {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 7px;
}

.story-heading span {
  display: inline-grid;
  place-items: center;
  min-width: 42px;
  height: 30px;
  padding: 0 9px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #f9d96a;
  font-weight: 900;
}

.story-heading strong {
  font-size: clamp(1.05rem, 3vw, 1.45rem);
}

.story-box p {
  margin: 0;
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: clamp(.95rem, 2.65vw, 1.15rem);
  line-height: 1.42;
}

.short-caption {
  margin-top: 8px;
  color: #5a4539;
  font-weight: 800;
}

.drift { animation: drift 3.5s ease-in-out infinite; }
.drift-alt { animation: driftAlt 3.9s ease-in-out infinite; }
.float { animation: float 3.4s ease-in-out infinite; }
.float-alt { animation: floatAlt 4.4s ease-in-out infinite; }
.monster-breathe { animation: monsterBreathe 2.8s ease-in-out infinite; }
.tail-wag { animation: tailWag 1.5s ease-in-out infinite; }
.spark-step { animation: sparkStep 2.2s ease-in-out infinite; }
.startle { animation: startle 1.6s ease-in-out infinite; }
.startle-alt { animation: startleAlt 1.7s ease-in-out infinite; }
.rope-swing { animation: ropeSwing 2.2s ease-in-out infinite; transform-origin: 50% 4%; }
.chew { animation: chew 1s ease-in-out infinite; }
.fire-breathe { animation: fireBreathe 1.8s ease-in-out infinite; transform-origin: 65% 50%; }
.aim { animation: aim 2.2s ease-in-out infinite; transform-origin: 60% 70%; }
.steady { animation: steady 2.4s ease-in-out infinite; }

@keyframes drift { 0%,100% { transform: translate(0,0) rotate(-1deg); } 50% { transform: translate(3px,-6px) rotate(1deg); } }
@keyframes driftAlt { 0%,100% { transform: translate(0,0) rotate(1deg); } 50% { transform: translate(-4px,-5px) rotate(-1deg); } }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes floatAlt { 0%,100% { transform: translate(0,0) rotate(0); } 50% { transform: translate(5px,-7px) rotate(2deg); } }
@keyframes monsterBreathe { 0%,100% { transform: scale(1) rotate(0); } 50% { transform: scale(1.015) rotate(-1deg); } }
@keyframes tailWag { 0%,100% { transform: rotate(-1deg); } 50% { transform: rotate(3deg); } }
@keyframes sparkStep { 0%,100% { transform: translateX(0) rotate(0); } 50% { transform: translateX(5px) rotate(-2deg); } }
@keyframes startle { 0%,100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-5px) rotate(-1.5deg); } }
@keyframes startleAlt { 0%,100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-4px) rotate(1.5deg); } }
@keyframes ropeSwing { 0%,100% { transform: rotate(-1.3deg); } 50% { transform: rotate(1.3deg); } }
@keyframes chew { 0%,100% { transform: translateX(0) rotate(-1deg); } 50% { transform: translateX(4px) rotate(2deg); } }
@keyframes fireBreathe { 0%,100% { transform: translateX(0) scale(1); } 50% { transform: translateX(5px) scale(1.018); } }
@keyframes aim { 0%,100% { transform: rotate(-1deg); } 50% { transform: rotate(1.5deg); } }
@keyframes steady { 0%,100% { transform: translateY(0); } 50% { transform: translateY(4px); } }
@keyframes blink { 0%,100% { opacity: .18; } 50% { opacity: .82; } }
@keyframes pulse { 0%,100% { opacity: .4; transform: scale(.98); } 50% { opacity: .92; transform: scale(1.03); } }
@keyframes shimmer { 0%,100% { opacity: .36; transform: translateX(0); } 50% { opacity: .8; transform: translateX(5px); } }

@media (max-width: 640px) {
  .comic { padding-inline: 8px; }
  .comic-header { align-items: start; flex-direction: column; }
  .page-nav { max-width: 100%; justify-content: flex-start; }
  .page-nav a { width: 30px; height: 30px; font-size: .88rem; }
  .story-box { padding: 11px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
