:root {
  color-scheme: light;
  --ink: #15110f;
  --paper: #fffdf7;
  --panel: #f9efe1;
  --panel-border: #231f20;
  --accent: #d7482f;
  --accent-2: #16776a;
}

* {
  box-sizing: border-box;
}

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

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

.comic-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 0 4px 14px;
}

.comic-header h1 {
  margin: 0;
  font-size: clamp(1.35rem, 4vw, 2.6rem);
  letter-spacing: 0;
}

.comic-header p {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #5a4539;
}

.page {
  position: relative;
  width: 100%;
  aspect-ratio: 1241 / 1754;
  margin: 0 auto 28px;
  overflow: hidden;
  isolation: isolate;
  background: white;
  border: 2px solid #201d1c;
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(24, 20, 16, 0.14);
}

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

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

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

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

.effect circle {
  fill: #6bb9d7;
  stroke: none;
  opacity: 0.8;
}

.caption {
  z-index: 7;
  left: 4.6%;
  right: 4.6%;
  bottom: 3.8%;
  min-height: 6.4%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border: 2px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(249, 239, 225, 0.92);
  font-size: clamp(0.85rem, 2.5vw, 1.45rem);
  font-weight: 700;
  line-height: 1.18;
  text-align: center;
}

.voice-bubble {
  z-index: 8;
  width: clamp(28px, 5.6vw, 50px);
  aspect-ratio: 1;
  border: 2px solid #1c1715;
  border-radius: 50%;
  background:
    radial-gradient(circle at 42% 40%, #fff 0 30%, #ffe0a5 31% 56%, #ef6d3f 57% 100%);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.18);
  cursor: grab;
  touch-action: none;
}

.voice-bubble::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  transform: translate(-32%, -50%);
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 12px solid #1d1715;
}

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

.voice-bubble:hover,
.voice-bubble:focus-visible,
.voice-bubble.is-playing {
  outline: none;
  background:
    radial-gradient(circle at 42% 40%, #fff 0 28%, #8cd6c9 29% 56%, #16776a 57% 100%);
}

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

.p1-trap-sign {
  left: 29.81%;
  top: 2.62%;
  width: 24.9%;
}

.p1-police {
  left: 24.17%;
  top: 26.8%;
  width: 25.79%;
}

.p1-hermione {
  left: 66.08%;
  top: 0.86%;
  width: 31.43%;
}

.p1-pizza {
  left: 45.93%;
  top: 66.13%;
  width: 18.94%;
}

.p1-spark {
  left: 50%;
  top: 46%;
  width: 15%;
  height: 8%;
}

.p1-voice-narration {
  left: 6%;
  top: 63%;
}

.p1-voice-hermione {
  left: 86%;
  top: 27%;
}

.p1-voice-police {
  left: 22%;
  top: 39%;
}

.p2-hermione {
  left: 73.73%;
  top: 3.14%;
  width: 24.17%;
}

.p2-police {
  left: 51.01%;
  top: 41.9%;
  width: 26.51%;
}

.p2-speed {
  left: 68%;
  top: 18%;
  width: 20%;
  height: 8%;
  stroke: var(--accent-2);
}

.p2-fall-marks {
  left: 47%;
  top: 73%;
  width: 20%;
  height: 13%;
}

.p2-voice-narration {
  left: 7%;
  top: 77%;
}

.p2-voice-hermione {
  left: 88%;
  top: 24%;
}

.p2-voice-police {
  left: 80%;
  top: 54%;
}

.p3-sleigh {
  left: 0.4%;
  top: 18.24%;
  width: 29.41%;
}

.p3-snow {
  left: 34%;
  top: 7%;
  width: 33%;
  height: 13%;
}

.p3-voice-narration {
  left: 8%;
  top: 64%;
}

.p3-voice-santa {
  left: 5%;
  top: 53%;
}

.p3-voice-reindeer {
  left: 72%;
  top: 32%;
}

.p4-imposter {
  left: 0.81%;
  top: 5.76%;
  width: 33.84%;
}

.p4-list {
  left: 30.22%;
  top: 16.25%;
  width: 40.69%;
}

.p4-danger {
  left: 13%;
  top: 7%;
  width: 16%;
  height: 10%;
}

.p4-voice-narration {
  left: 73%;
  top: 61%;
}

.p4-voice-imposter {
  left: 31%;
  top: 28%;
}

.p5-hermione {
  left: 31.43%;
  top: 32.5%;
  width: 19.34%;
}

.p5-santa-chase {
  left: 0;
  top: 38.77%;
  width: 26.59%;
}

.p5-confetti {
  left: 61%;
  top: 23%;
  width: 22%;
  height: 12%;
}

.p5-voice-narration {
  left: 84%;
  top: 34%;
}

.p5-voice-hermione {
  left: 74%;
  top: 31%;
}

.p5-voice-santa {
  left: 6%;
  top: 66%;
}

.p6-server {
  left: 0;
  top: 4.56%;
  width: 26.59%;
}

.p6-burger {
  left: 27.8%;
  top: 39.91%;
  width: 28.85%;
}

.p6-potion {
  left: 58%;
  top: 36%;
  width: 16%;
  height: 10%;
  stroke: var(--accent-2);
}

.p6-voice-narration {
  left: 68%;
  top: 64%;
}

.p6-voice-server {
  left: 21%;
  top: 46%;
}

.p7-left-cat {
  left: 7.33%;
  top: 63.85%;
  width: 12.41%;
}

.p7-right-cat {
  left: 66.88%;
  top: 60.43%;
  width: 9.67%;
}

.p7-voice-narration {
  left: 74%;
  top: 8%;
}

.p7-voice-cats {
  left: 80%;
  top: 63%;
}

.p15-caption,
.p17-caption,
.p18-caption {
  top: 4%;
  bottom: auto;
}

.p8-server {
  left: 2.42%;
  top: 34.78%;
  width: 37.47%;
}

.p8-table-cats {
  left: 37.87%;
  top: 52.28%;
  width: 61.64%;
}

.p8-cloche {
  left: 45.12%;
  top: 34.21%;
  width: 18.05%;
}

.p8-serving {
  left: 35%;
  top: 37%;
  width: 22%;
  height: 9%;
  stroke: var(--accent-2);
}

.p8-voice-narration {
  left: 72%;
  top: 70%;
}

.p8-voice-server {
  left: 33%;
  top: 44%;
}

.p11-idea {
  left: 63%;
  top: 38%;
  width: 14%;
  height: 8%;
  stroke: var(--accent);
  stroke-width: 6;
}

.p11-bob {
  left: 4.35%;
  top: 35.92%;
  width: 27.48%;
}

.p11-mary {
  left: 31.43%;
  top: 34.21%;
  width: 25.71%;
}

.p11-voice-narration {
  left: 72%;
  top: 61%;
}

.p11-voice-bob {
  left: 4%;
  top: 30%;
}

.p11-voice-mary {
  left: 72%;
  top: 36%;
}

.p12-master {
  left: 18.53%;
  top: 13.4%;
  width: 33.84%;
}

.p12-burgers {
  left: 55.6%;
  top: 1.14%;
  width: 31.27%;
}

.p12-potion {
  left: 12.09%;
  top: 43.9%;
  width: 20.55%;
}

.p12-antidote {
  left: 35%;
  top: 43%;
  width: 20%;
  height: 10%;
  stroke: var(--accent-2);
}

.p12-voice-narration {
  left: 70%;
  top: 63%;
}

.p12-voice-master {
  left: 43%;
  top: 23%;
}

.p13-hermione {
  left: 26.99%;
  top: 39.34%;
  width: 35.94%;
}

.p13-voice-narration {
  left: 65%;
  top: 59%;
}

.p13-voice-hermione {
  left: 58%;
  top: 41%;
}

.p14-mona {
  left: 29.01%;
  top: 23.09%;
  width: 47.14%;
}

.p14-glow {
  left: 41%;
  top: 26%;
  width: 17%;
  height: 10%;
}

.p14-voice-narration {
  left: 70%;
  top: 66%;
}

.p14-voice-mona {
  left: 66%;
  top: 31%;
}

.p15-pablo {
  left: 20.15%;
  top: 28.51%;
  width: 56%;
}

.p15-voice-narration {
  left: 70%;
  top: 12%;
}

.p15-voice-pablo {
  left: 71%;
  top: 36%;
}

.p17-bird {
  left: 65.27%;
  top: 43.61%;
  width: 19.26%;
}

.p17-voice-narration {
  left: 70%;
  top: 12%;
}

.p17-voice-bird {
  left: 84%;
  top: 40%;
}

.p18-sleeping-hermione {
  left: 0;
  top: 86.26%;
  width: 21.03%;
}

.p18-dream {
  left: 15%;
  top: 68%;
  width: 21%;
  height: 12%;
  stroke: var(--accent-2);
}

.p18-voice-narration {
  left: 70%;
  top: 12%;
}

.p18-voice-hermione {
  left: 22%;
  top: 84%;
}

@keyframes bob-soft {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(-0.35deg); }
  50% { transform: translate3d(0, -5px, 0) rotate(0.5deg); }
}

@keyframes wobble-small {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(-0.5deg); }
  35% { transform: translate3d(2px, 2px, 0) rotate(0.8deg); }
  70% { transform: translate3d(-2px, -1px, 0) rotate(-0.4deg); }
}

@keyframes swim-arc {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(-0.6deg); }
  50% { transform: translate3d(5px, -6px, 0) rotate(0.8deg); }
}

@keyframes spin-soft {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(-4deg); }
  50% { transform: translate3d(5px, -6px, 0) rotate(5deg); }
}

@keyframes drop-machine {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg); }
  50% { transform: translate3d(0, 12px, 0) rotate(-0.7deg); }
}

@keyframes fall-loop {
  0%, 100% { transform: translate3d(0, -8px, 0) rotate(-1deg); }
  50% { transform: translate3d(0, 12px, 0) rotate(1deg); }
}

@keyframes sleigh-run {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg); }
  50% { transform: translate3d(12px, -7px, 0) rotate(-0.6deg); }
}

@keyframes tumble-soft {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(-2deg); }
  50% { transform: translate3d(7px, 9px, 0) rotate(4deg); }
}

@keyframes slow-lean {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(-0.5deg); }
  50% { transform: translate3d(5px, 0, 0) rotate(1deg); }
}

@keyframes list-wave {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(-0.3deg); }
  50% { transform: translate3d(7px, 5px, 0) rotate(1.1deg); }
}

@keyframes potion-shake {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(-1deg); }
  30% { transform: translate3d(4px, -2px, 0) rotate(1.4deg); }
  60% { transform: translate3d(-3px, 2px, 0) rotate(-1.2deg); }
}

@keyframes p11-bob-step {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(-0.3deg); }
  50% { transform: translate3d(3px, -4px, 0) rotate(0.5deg); }
}

@keyframes p11-mary-hover {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(0.3deg); }
  50% { transform: translate3d(-3px, -5px, 0) rotate(-0.5deg); }
}

.bob-soft { animation: bob-soft 3.8s ease-in-out infinite; }
.wobble-small { animation: wobble-small 2.9s ease-in-out infinite; }
.swim-arc { animation: swim-arc 3.4s ease-in-out infinite; }
.spin-soft { animation: spin-soft 3.1s ease-in-out infinite; }
.drop-machine { animation: drop-machine 2.5s ease-in-out infinite; }
.fall-loop { animation: fall-loop 2.2s ease-in-out infinite; }
.sleigh-run { animation: sleigh-run 3s ease-in-out infinite; }
.tumble-soft { animation: tumble-soft 2.6s ease-in-out infinite; }
.slow-lean { animation: slow-lean 4s ease-in-out infinite; }
.list-wave { animation: list-wave 3.6s ease-in-out infinite; }
.potion-shake { animation: potion-shake 2.4s ease-in-out infinite; }
.p11-bob-step { animation: p11-bob-step 3.6s ease-in-out infinite; }
.p11-mary-hover { animation: p11-mary-hover 3.2s ease-in-out infinite; }

.p1-spark path,
.p2-speed path,
.p2-fall-marks path,
.p4-danger path,
.p5-confetti path,
.p8-serving path,
.p11-idea path,
.p14-glow path {
  stroke-dasharray: 220;
  stroke-dashoffset: 220;
  animation: sketch 2s ease-in-out infinite;
}

.p3-snow circle,
.p5-confetti circle,
.p2-fall-marks circle,
.p6-potion circle,
.p12-antidote circle,
.p18-dream circle {
  animation: snow 3.5s ease-in-out infinite;
}

.p3-snow circle:nth-child(2),
.p3-snow circle:nth-child(5),
.p5-confetti circle:nth-child(3),
.p2-fall-marks circle:nth-child(5),
.p6-potion circle:nth-child(2),
.p12-antidote circle:nth-child(2),
.p18-dream circle:nth-child(3) {
  animation-delay: 0.7s;
}

@keyframes sketch {
  0% { stroke-dashoffset: 220; opacity: 0; }
  20%, 70% { opacity: 0.86; }
  100% { stroke-dashoffset: 0; opacity: 0; }
}

@keyframes snow {
  0%, 100% { transform: translateY(0); opacity: 0.2; }
  50% { transform: translateY(16px); opacity: 0.85; }
}

@media (max-width: 640px) {
  .comic {
    padding: 12px 8px 26px;
  }

  .comic-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .caption {
    left: 3.5%;
    right: 3.5%;
    padding: 8px 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
