:root {
  --paper: #eee8da;
  --ink: #111111;
  --charcoal: #1a1a1a;
  --red: #c8102e;

  --font-comic: "Bangers", "Impact", sans-serif;
  --font-hand: "Kalam", "Comic Sans MS", cursive;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  background: var(--charcoal);
}

body {
  background: var(--charcoal);
  color: var(--paper);
  font-family: var(--font-hand);
  overflow-x: hidden;
}


.layer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.backdrop {
  z-index: 0;
  background-color: #151515;
  background-image:
    repeating-linear-gradient(45deg, rgba(128, 128, 128, 0.06) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(-45deg, rgba(128, 128, 128, 0.04) 0 1px, transparent 1px 9px);
  transition: background-color 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

body[data-scene="mutation"] .backdrop {
  background-color: #0d0f18;
}

body[data-scene="awakening"] .backdrop,
body[data-scene="ending"] .backdrop {
  background-color: #ece5d6;
}

body[data-scene="transformation"] .backdrop {
  background-color: #111111;
}

#stage {
  z-index: 1;
  display: block;
  opacity: 0;
  transition: opacity 1.2s ease;
}

#stage.ready {
  opacity: 1;
}

.halftone {
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  background-image: radial-gradient(circle, rgba(0, 0, 0, 0.9) 1.2px, transparent 1.6px);
  background-size: 6px 6px;
  mix-blend-mode: multiply;
}

.grain {
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  z-index: 4;
  pointer-events: none;
  opacity: 0.22;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain-shift 0.6s steps(3) infinite;
}

@keyframes grain-shift {
  0%   { transform: translate(0, 0); }
  33%  { transform: translate(-3%, 2%); }
  66%  { transform: translate(2%, -3%); }
  100% { transform: translate(0, 0); }
}

.vignette {
  z-index: 4;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, 0.65) 100%);
}

.flash {
  z-index: 6;
  pointer-events: none;
  opacity: 0;
  background: var(--red);
  mix-blend-mode: multiply;
}

.flash.replaying {
  background: #111;
  mix-blend-mode: normal;
}


main {
  position: relative;
  z-index: 2;
}

.scene {
  position: relative;
}

#encounter      { height: 600vh; }
#mutation       { height: 450vh; }
#awakening      { height: 700vh; }
#transformation { height: 600vh; }
#ending         { height: 400vh; }

.frame {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  pointer-events: none;
}

.scene.light .frame {
  color: var(--ink);
}


.intro {
  position: absolute;
  top: 12vh;
  left: 8vw;
  max-width: 80vw;
}

#encounter .intro {
  top: auto;
  bottom: 12vh;
}

.chapter {
  font-family: var(--font-hand);
  font-size: clamp(14px, 1.3vw, 18px);
  letter-spacing: 0.25em;
  text-transform: uppercase;
  opacity: 0.75;
  margin-bottom: 10px;
}

.title {
  font-family: var(--font-comic);
  font-weight: 400;
  font-size: clamp(44px, 8vw, 128px);
  line-height: 0.92;
  letter-spacing: 0.02em;
}

.title .word {
  display: inline-block;
}

.ink-underline {
  display: block;
  width: min(520px, 70vw);
  height: 28px;
  margin-top: 10px;
}

.ink-underline path {
  fill: none;
  stroke: var(--red);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}


.caption {
  position: absolute;
  left: 8vw;
  bottom: 12vh;
  max-width: min(460px, 84vw);
  padding: 14px 22px;
  background: var(--paper);
  color: var(--ink);
  border: 3px solid var(--ink);
  box-shadow: 7px 7px 0 var(--ink);
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: clamp(18px, 2vw, 28px);
  line-height: 1.3;
}

.caption.red-shadow {
  box-shadow: 7px 7px 0 var(--red);
}

.caption.right {
  left: auto;
  right: 8vw;
}


.sfx {
  position: absolute;
  font-family: var(--font-comic);
  font-size: clamp(60px, 11vw, 170px);
  line-height: 1;
  color: var(--red);
  -webkit-text-stroke: 3px var(--ink);
  text-shadow: 6px 6px 0 var(--ink);
}

.sfx-crack  { top: 20vh; right: 10vw; }
.sfx-whoosh { top: 48vh; left: 6vw; color: var(--paper); }


.big-line {
  position: absolute;
  left: 0;
  width: 100%;
  top: 50%;
  margin-top: -0.6em;
  padding: 0 6vw;
  text-align: center;
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: clamp(28px, 4.6vw, 72px);
  line-height: 1.15;
}

.big-line.quote {
  color: var(--paper);
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.9);
}

.big-line.second {
  margin-top: 0.9em;
  font-family: var(--font-comic);
  font-weight: 400;
  color: var(--red);
  font-size: clamp(40px, 7vw, 110px);
}

.scene.light .big-line.second {
  -webkit-text-stroke: 2px var(--ink);
}


.replay {
  position: absolute;
  left: 50%;
  bottom: 9vh;
  transform: translateX(-50%);
  pointer-events: auto;
  cursor: pointer;
  padding: 10px 22px;
  background: transparent;
  color: inherit;
  border: 2px solid currentColor;
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.08em;
}

.replay:hover,
.replay:focus-visible {
  background: var(--red);
  border-color: var(--red);
  color: var(--paper);
  outline: none;
}


.scroll-hint {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 5;
  transform: translateX(-50%);
  font-family: var(--font-hand);
  font-size: 14px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--paper);
  opacity: 0.7;
  transition: opacity 0.5s;
  pointer-events: none;
}

.scroll-hint::after {
  content: "";
  display: block;
  width: 1px;
  height: 40px;
  margin: 10px auto 0;
  background: var(--paper);
  animation: hint-drop 1.6s ease-in-out infinite;
  transform-origin: top;
}

.scroll-hint.hidden {
  opacity: 0;
}

@keyframes hint-drop {
  0%   { transform: scaleY(0); }
  50%  { transform: scaleY(1); }
  100% { transform: scaleY(0); transform-origin: bottom; }
}
