:root {
  --ink: #0b0e0b;
  --bone: #e8e1c7;
  --leaf: #53f1d0;
  --leaf-dark: #147e72;
  --moss: #829044;
  --mud: #393526;
  --pointer-x: 0;
  --pointer-y: 0;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--ink); }
body { margin: 0; color: var(--bone); background: var(--ink); font-family: "Trebuchet MS", "Arial Narrow", Arial, sans-serif; }
button, a { font: inherit; }
a { color: inherit; }
button:focus-visible, a:focus-visible { outline: 3px dashed var(--leaf); outline-offset: 5px; }

.story { position: relative; min-height: 100vh; overflow: clip; background: var(--ink); }
.episode { position: relative; min-height: 100svh; isolation: isolate; display: flex; overflow: hidden; }
.scene-bg { position: absolute; inset: -4%; z-index: -5; background-repeat: no-repeat; background-size: cover; transform: scale(1.07) translate3d(calc(var(--pointer-x) * -13px), calc(var(--pointer-y) * -9px), 0); transition: transform .45s ease-out; will-change: transform; }
.film-grain { position: fixed; inset: -15%; z-index: 100; pointer-events: none; opacity: .14; background-image: repeating-radial-gradient(circle at 17% 28%, transparent 0 1px, rgba(255,244,198,.2) 1px 2px, transparent 2px 5px); background-size: 8px 11px; mix-blend-mode: soft-light; animation: grain .25s steps(2) infinite; }
.episode::before { content: ""; position: absolute; inset: 0; z-index: -3; pointer-events: none; box-shadow: inset 0 0 160px 20px rgba(2,4,2,.72); }

.hero { min-height: 100svh; align-items: center; padding: clamp(80px, 10vw, 142px) 7vw 120px; }
.hero-bg { background-image: url('episode-01.png'); background-position: center; animation: camera-drift 15s ease-in-out infinite alternate; }
.hero::after { content: ""; position: absolute; inset: 0 54% 0 0; z-index: -2; background: rgba(5,8,5,.62); border-right: 5px solid rgba(7,10,7,.08); transform: skewX(-4deg) translateX(-14%); box-shadow: 80px 0 90px rgba(5,8,5,.35); }
.hero-copy { width: min(650px, 84vw); position: relative; z-index: 8; text-shadow: 3px 4px 0 var(--ink); }
h1 { max-width: 7ch; margin: 0; color: #eee7cf; font-size: clamp(66px, 9.5vw, 150px); line-height: .75; letter-spacing: -.075em; text-transform: uppercase; -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; transform: rotate(-1.4deg); }
.ticker { width: fit-content; margin: 18px 0 0; padding: 4px 12px 5px; color: var(--ink); background: var(--leaf); border: 4px solid var(--ink); box-shadow: 5px 5px 0 #596433; transform: rotate(1.5deg); font: 900 clamp(22px, 3vw, 34px)/1 "Courier New", monospace; text-shadow: none; }
.tagline { max-width: 430px; margin: 20px 0 25px; font-size: clamp(18px, 2vw, 27px); font-weight: 900; line-height: 1.12; letter-spacing: -.025em; }
.terminal-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.toon-button { position: relative; display: inline-flex; align-items: center; justify-content: center; min-height: 52px; padding: 11px 18px; color: var(--bone); background: #30392c; border: 4px solid var(--ink); border-radius: 13px 9px 15px 10px; box-shadow: 5px 6px 0 #080a08, inset 0 -4px 0 #20261d; text-decoration: none; cursor: pointer; transform: rotate(.4deg); transition: transform .12s steps(2), filter .12s steps(2); font: 900 14px/1 "Courier New", monospace; letter-spacing: .035em; }
.toon-button.primary { color: #10130f; background: var(--leaf); box-shadow: 5px 6px 0 #080a08, inset 0 -4px 0 var(--leaf-dark); }
.toon-button:nth-child(2) { transform: rotate(-.7deg); }
.toon-button:hover { transform: translateY(-3px) rotate(-1deg) scale(1.02); filter: brightness(1.08); }
.toon-button:active { transform: translate(3px, 4px) scale(.97); box-shadow: 2px 2px 0 #080a08; }
.frequencies { display: flex; gap: 18px; margin-top: 18px; color: #c7d0ab; font: 800 13px/1 "Courier New", monospace; }
.frequencies a, .final-frequencies a { text-decoration-style: wavy; text-underline-offset: 4px; }
.frequencies a:hover, .final-frequencies a:hover { color: var(--leaf); }
.radar-cue { position: absolute; z-index: 8; right: 5vw; bottom: 7vh; display: flex; flex-direction: column; align-items: center; gap: 8px; color: #cbd0b8; text-decoration: none; font: 800 10px/1 "Courier New", monospace; letter-spacing: .12em; }
.radar-ring { width: 46px; height: 46px; border: 4px solid var(--leaf); border-radius: 54% 46% 51% 49%; box-shadow: 0 0 0 5px var(--ink), 0 0 18px var(--leaf); animation: radar 1.8s steps(5) infinite; }
.foreground-rocks { position: absolute; z-index: 10; inset: auto -7% -10% -7%; height: 22%; background: #090c09; border: 6px solid #050705; border-bottom: 0; border-radius: 51% 49% 0 0 / 32% 42% 0 0; transform: rotate(-1deg); pointer-events: none; }

.leaf-progress { position: fixed; z-index: 80; top: 20px; right: 22px; display: grid; grid-template-columns: auto auto; gap: 5px 9px; align-items: center; width: 152px; padding: 9px 11px; color: #afba92; background: #1c251a; border: 3px solid #070a07; border-radius: 12px 17px 11px 15px; box-shadow: 4px 5px 0 rgba(0,0,0,.65); transform: rotate(.6deg); font: 800 9px/1 "Courier New", monospace; }
.progress-label { letter-spacing: .08em; }
.leaf-progress b { grid-column: 2; grid-row: 1 / span 2; color: var(--leaf); font-size: 15px; }
.vein-track { display: flex; align-items: center; gap: 3px; }
.vein-track i { display: block; width: 25px; height: 4px; background: #4b5540; border-radius: 70% 30% 70% 30%; transform: rotate(-5deg); }
.vein-track i:nth-child(2) { transform: rotate(4deg); }
.vein-track i.awake { background: var(--leaf); box-shadow: 0 0 8px var(--leaf); animation: vein-pulse 1.4s steps(4) infinite; }

.forest { margin-top: -9vh; align-items: flex-end; padding: 14vh 6vw 12vh; clip-path: polygon(0 7%, 9% 4%, 21% 8%, 38% 3%, 56% 7%, 74% 2%, 91% 6%, 100% 3%, 100% 100%, 0 100%); }
.forest-bg { background-image: url('episode-02.png'); background-position: center; }
.forest::after { content: ""; position: absolute; inset: 0 60% 0 0; z-index: -2; background: rgba(4,8,5,.4); box-shadow: 70px 0 80px rgba(4,8,5,.32); }
.episode-caption { position: relative; z-index: 8; width: min(450px, 90vw); padding: 20px 23px 22px; color: var(--bone); background: #273025; border: 5px solid #0a0d0a; border-radius: 32px 18px 28px 15px; box-shadow: 8px 9px 0 rgba(4,6,4,.72), inset 0 -7px 0 #1a2119; transform: rotate(-1.2deg); }
.episode-no { margin: 0 0 8px; color: var(--leaf); font: 900 11px/1.2 "Courier New", monospace; letter-spacing: .11em; }
.episode-caption h2, .station-terminal h2, .finale-copy h2 { margin: 0; text-wrap: balance; color: #eee5c9; font-size: clamp(34px, 5vw, 70px); line-height: .92; letter-spacing: -.055em; -webkit-text-stroke: 2px #0c100c; paint-order: stroke fill; }
.episode-caption p:not(.episode-no), .finale-copy > p:not(.episode-no) { margin: 10px 0 0; font-size: clamp(14px, 1.35vw, 18px); font-weight: 700; line-height: 1.25; }
.spore-field { position: absolute; inset: 0; z-index: 3; pointer-events: none; overflow: hidden; }
.spore-field i { position: absolute; bottom: -5%; width: 6px; height: 6px; border: 2px solid #0a0d0a; border-radius: 50% 45% 55% 48%; background: var(--leaf); box-shadow: 0 0 7px var(--leaf); animation: float-spore 7s steps(9) infinite; }
.secret-hotspot { position: absolute; z-index: 9; left: 27%; top: 28%; display: flex; flex-direction: column; align-items: center; gap: 7px; color: #d5ddbb; background: transparent; border: 0; cursor: pointer; font: 900 10px/1 "Courier New", monospace; letter-spacing: .08em; text-shadow: 2px 2px 0 #0b0e0b; }
.secret-glyph { display: grid; place-items: center; width: 62px; height: 62px; color: var(--leaf); background: #253027; border: 4px solid #0a0d0a; border-radius: 47% 53% 43% 57%; box-shadow: 0 0 0 5px rgba(80,239,207,.25), 0 0 24px var(--leaf); transform: rotate(-8deg); font: 900 43px/1 serif; animation: glyph-wobble 1.8s steps(5) infinite; }
.secret-hotspot:hover .secret-glyph { filter: brightness(1.35); }
.secret-hotspot.solved .secret-glyph { background: var(--leaf); color: #14211b; animation: symbol-pop .35s steps(3); }
.forest.symbol-found .forest-bg { animation: forest-startle .45s steps(3); }
.vine-wipe { position: absolute; z-index: 12; right: -6%; bottom: -5%; width: 30%; height: 65%; background: #0b100c; border: 6px solid #040604; border-radius: 79% 21% 0 0 / 23% 76% 0 0; transform: rotate(10deg); pointer-events: none; }

.station { margin-top: -7vh; align-items: flex-end; justify-content: flex-end; padding: 14vh 7vw 10vh; clip-path: polygon(0 3%, 18% 7%, 33% 2%, 49% 7%, 67% 1%, 82% 5%, 100% 0, 100% 100%, 0 100%); }
.station-bg { background-image: url('episode-03.png'); background-position: center; }
.station-terminal { position: relative; z-index: 9; width: min(420px, 38vw); margin-right: 1vw; padding: 21px 23px 24px; color: #d8dfbd; background: #273228; border: 6px solid #090c09; border-radius: 23px 14px 28px 18px; box-shadow: 9px 10px 0 #090c09, inset 0 -8px 0 #182119; transform: rotate(.7deg); }
.station-terminal::before { content: ""; position: absolute; inset: 10px; border: 2px dashed #59634a; border-radius: 17px 9px 21px 13px; pointer-events: none; }
.station-terminal h2 { position: relative; font-size: clamp(32px, 3.6vw, 50px); }
.coordinate-readout, .survival-line { position: relative; display: flex; justify-content: space-between; gap: 16px; margin-top: 12px; padding: 10px 11px; background: #121a15; border: 3px solid #080b08; color: #8fa077; font: 800 10px/1.25 "Courier New", monospace; }
.coordinate-readout strong, .survival-line strong { color: var(--leaf); text-align: right; }
.token-readout { position: relative; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 8px 0; padding: 9px 11px; color: #82906d; border-left: 4px solid #596444; font: 800 10px/1.1 "Courier New", monospace; }
.token-readout strong { color: #d4dcc0; text-align: right; overflow-wrap: anywhere; }
.survival-line { color: #d5bd77; }
.survival-line strong { color: #ff8b79; font-size: 22px; }
.accept-switch { position: relative; width: 100%; min-height: 49px; margin-top: 9px; color: #101510; background: var(--leaf); border: 4px solid #080b08; border-radius: 10px 14px 9px 16px; box-shadow: 0 6px 0 #0a0e0a, inset 0 -4px 0 var(--leaf-dark); cursor: pointer; font: 900 14px/1 "Courier New", monospace; transition: transform .12s steps(2); }
.accept-switch:hover:not(:disabled) { transform: translateY(-2px) rotate(-.4deg); }
.accept-switch:active:not(:disabled) { transform: translateY(4px) scale(.98); box-shadow: 0 2px 0 #080b08; }
.accept-switch:disabled { color: #68725c; background: #30382d; cursor: not-allowed; }
.station.accepted .station-bg { animation: shrug .65s steps(4); }
.hard-flash { position: absolute; z-index: 7; inset: 0; background: #b9fbe8; opacity: 0; pointer-events: none; animation: flash-transition 1.8s steps(4) 1; }
.bulkhead-wipe { position: absolute; z-index: 12; inset: auto -5% -18% -5%; height: 28%; background: #101611; border: 7px solid #050705; border-radius: 51% 49% 0 0 / 42% 35% 0 0; transform: rotate(2deg); }

.ruins { margin-top: -8vh; align-items: center; padding: 15vh 7vw 10vh; clip-path: polygon(0 7%, 15% 3%, 31% 8%, 48% 2%, 63% 7%, 79% 3%, 100% 7%, 100% 100%, 0 100%); }
.ruins-bg { background-image: url('episode-04.png'); background-position: left center; filter: brightness(.67) saturate(.8); }
.ruins::after { content: ""; position: absolute; inset: 0 52% 0 0; z-index: -2; background: rgba(5,8,6,.46); box-shadow: 85px 0 90px rgba(5,8,6,.35); }
.ruins-caption { align-self: center; }
.glyph-button { display: flex; align-items: center; gap: 12px; width: 100%; margin-top: 16px; padding: 9px 12px; color: #0b100d; background: var(--leaf); border: 4px solid #080b08; border-radius: 18px 11px 15px 10px; box-shadow: 5px 6px 0 #0a0d0a, inset 0 -4px 0 var(--leaf-dark); cursor: pointer; font: 900 12px/1.1 "Courier New", monospace; }
.glyph-button:disabled { color: #7c836f; background: #3d4638; cursor: not-allowed; }
.glyph-orbit { font-size: 30px; animation: orbit-chop 2.4s steps(8) infinite; }
.root-light { position: absolute; z-index: 5; inset: 13% 6% 8% 35%; border: 5px dashed rgba(82,239,207,.08); border-radius: 62% 38% 55% 45%; opacity: 0; pointer-events: none; }
.ruin-awake .root-light { opacity: 1; box-shadow: inset 0 0 70px rgba(82,239,207,.14), 0 0 24px rgba(82,239,207,.35); animation: root-pulse 1.5s steps(6) infinite; }
.ruin-awake .ruins-bg { filter: brightness(.88) saturate(1); }

.finale { margin-top: -5vh; min-height: 92svh; align-items: flex-end; justify-content: center; padding: 16vh 6vw 8vh; }
.finale-bg { background-image: url('episode-04.png'); background-position: center; transform: scale(1.13) translate3d(calc(var(--pointer-x) * -18px), calc(var(--pointer-y) * -12px), 0); filter: brightness(.72) saturate(.72); }
.finale.complete .finale-bg { filter: brightness(.9) saturate(1.02); animation: cosmic-zoom 18s ease-in-out infinite alternate; }
.finale::after { content: ""; position: absolute; inset: auto 0 0; height: 40%; z-index: -2; background: rgba(6,9,6,.76); box-shadow: 0 -60px 90px rgba(6,9,6,.42); }
.cosmic-breath { position: absolute; z-index: 3; inset: 4% 9% 28%; border: 5px solid rgba(85,239,208,.16); border-radius: 58% 42% 61% 39%; opacity: .45; animation: cosmic-breath 4s steps(8) infinite; pointer-events: none; }
.finale-copy { position: relative; z-index: 8; width: min(760px, 92vw); text-align: center; text-shadow: 3px 4px 0 #090c09; transform: translateY(-8vh); }
.finale-copy h2 { font-size: clamp(46px, 7vw, 90px); }
.finale-copy > p:not(.episode-no) { margin: 10px auto 18px; font-size: clamp(16px, 1.7vw, 21px); }
.final-cta { min-height: 54px; padding-inline: 23px; }
.final-frequencies { display: flex; justify-content: center; gap: 12px; margin-top: 22px; color: #bdc8a7; font: 800 11px/1.2 "Courier New", monospace; }
footer { position: absolute; z-index: 9; bottom: 14px; color: #7f8b70; font: 800 9px/1 "Courier New", monospace; letter-spacing: .12em; }

.ship-toast { position: fixed; z-index: 110; left: 50%; bottom: 24px; padding: 13px 18px; color: var(--leaf); background: #1d241b; border: 4px solid #090b08; box-shadow: 6px 6px 0 rgba(0,0,0,.6); transform: translate(-50%, 170%); transition: transform .22s steps(3); font: 900 13px/1.2 "Courier New", monospace; }
.ship-toast small { display: block; margin-bottom: 3px; color: #8e9c73; font-size: 9px; }
.ship-toast.visible { transform: translate(-50%, 0) rotate(-.7deg); }
.spore-cursor { position: fixed; z-index: 120; top: -8px; left: -8px; width: 16px; height: 16px; border: 3px solid #0b0e0b; border-radius: 63% 37% 56% 44%; background: var(--leaf); box-shadow: 0 0 10px 2px var(--leaf); pointer-events: none; transition: width .12s steps(2), height .12s steps(2); }

@media (pointer: fine) { body, a, button { cursor: none; } }

@keyframes camera-drift { from { transform: scale(1.07) translate3d(-.5%, -.3%, 0); } to { transform: scale(1.11) translate3d(.8%, .4%, 0); } }
@keyframes grain { 0% { transform: translate(0,0); } 50% { transform: translate(1px,-1px); } 100% { transform: translate(-1px,1px); } }
@keyframes radar { 0%,100% { transform: scale(.85) rotate(0); opacity: .55; } 50% { transform: scale(1.05) rotate(9deg); opacity: 1; } }
@keyframes vein-pulse { 0%,100% { opacity: .65; } 50% { opacity: 1; } }
@keyframes float-spore { from { transform: translate3d(0,0,0) scale(.6); opacity: 0; } 20% { opacity: .75; } 50% { transform: translate3d(18px,-48vh,0) scale(1); } to { transform: translate3d(-10px,-108vh,0) scale(.55); opacity: 0; } }
@keyframes glyph-wobble { 0%,100% { transform: rotate(-8deg) scale(.96); } 50% { transform: rotate(5deg) scale(1.04); } }
@keyframes symbol-pop { 0% { transform: scale(.7) rotate(-13deg); } 60% { transform: scale(1.2) rotate(8deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes forest-startle { 0%,100% { transform: scale(1.07); } 33% { transform: scale(1.085) translateX(5px); } 66% { transform: scale(1.075) translateX(-3px); } }
@keyframes flash-transition { 0%,100% { opacity: 0; } 12% { opacity: .56; } 18% { opacity: .08; } }
@keyframes shrug { 0%,100% { transform: scale(1.07); } 30% { transform: scale(1.08) translateY(-5px) rotate(.2deg); } 60% { transform: scale(1.07) translateY(2px); } }
@keyframes orbit-chop { to { transform: rotate(360deg); } }
@keyframes root-pulse { 0%,100% { transform: scale(.98) rotate(-1deg); } 50% { transform: scale(1.02) rotate(1deg); } }
@keyframes cosmic-breath { 0%,100% { transform: scale(.98); opacity: .2; } 50% { transform: scale(1.015); opacity: .48; } }
@keyframes cosmic-zoom { from { transform: scale(1.11); } to { transform: scale(1.17); } }

@media (max-width: 760px) {
  .episode { min-height: 100svh; }
  .scene-bg { transform: scale(1.04); transition: none; }
  .film-grain { opacity: .1; }
  .leaf-progress { top: 10px; right: 10px; transform: scale(.86); transform-origin: top right; }
  .hero { min-height: 100svh; align-items: flex-start; padding: 65px 20px 184px; }
  .hero-bg { inset: 0; background-position: 65% center; }
  .hero::after { inset: 0; background: rgba(6,9,6,.28); transform: none; box-shadow: inset 0 190px 95px rgba(6,9,6,.72), inset 0 -160px 90px rgba(6,9,6,.58); }
  .hero-copy { width: 100%; }
  h1 { max-width: 6.8ch; font-size: clamp(58px, 20vw, 92px); -webkit-text-stroke-width: 3px; }
  .ticker { margin-top: 12px; }
  .tagline { width: 80%; margin: 13px 0 0; font-size: 17px; }
  .terminal-actions { position: absolute; top: calc(100svh - 170px); left: 0; width: 100%; flex-direction: column; align-items: stretch; }
  .toon-button { min-height: 55px; }
  .frequencies { position: absolute; top: calc(100svh - 38px); left: 2px; }
  .radar-cue { display: none; }
  .foreground-rocks { bottom: -8%; height: 16%; }

  .forest { min-height: 105svh; margin-top: -5vh; padding: 14vh 18px 10vh; clip-path: polygon(0 4%, 22% 7%, 48% 3%, 74% 6%, 100% 3%, 100% 100%, 0 100%); }
  .forest-bg { background-position: 68% center; }
  .forest::after { inset: 58% 0 0; background: rgba(5,9,5,.67); box-shadow: 0 -55px 70px rgba(5,9,5,.38); }
  .episode-caption { width: 100%; padding: 19px 20px 22px; }
  .episode-caption h2, .station-terminal h2 { font-size: 38px; }
  .secret-hotspot { left: 11%; top: 36%; }
  .secret-hotspot > span:last-child { max-width: 100px; }
  .spore-field i:nth-child(2n) { display: none; }
  .vine-wipe { width: 23%; height: 47%; }

  .station { min-height: 110svh; margin-top: -5vh; align-items: flex-end; padding: 14vh 17px 10vh; }
  .station-bg { background-position: 43% center; }
  .station-terminal { width: 100%; margin: 0; padding: 20px 18px 22px; background: rgba(35,46,36,.94); }
  .token-readout, .coordinate-readout, .survival-line { font-size: 9px; }
  .bulkhead-wipe { height: 16%; bottom: -9%; }

  .ruins { min-height: 105svh; margin-top: -4vh; align-items: flex-end; padding: 15vh 18px 10vh; }
  .ruins-bg { background-position: 35% center; }
  .ruins::after { inset: 55% 0 0; background: rgba(5,8,6,.62); box-shadow: 0 -65px 80px rgba(5,8,6,.35); }
  .root-light { inset: 18% 2% 34%; }

  .finale { min-height: 96svh; margin-top: -3vh; padding: 15vh 18px 9vh; }
  .finale-copy { transform: translateY(-6vh); }
  .finale-bg { background-position: 55% center; transform: scale(1.08); }
  .finale-copy h2 { font-size: clamp(48px, 15vw, 76px); }
  .final-frequencies { flex-wrap: wrap; }
  .spore-cursor { display: none; }
}

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