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

html {
  scroll-behavior: auto;
}

html,
body {
  background: var(--void);
  color: var(--ink);
  font-family: var(--serif);
  min-height: 100%;
  max-width: 100%;
  overflow-x: clip;
}

body {
  cursor: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  touch-action: manipulation;
}

body.has-pointer {
  cursor: none;
}

body.is-touch {
  cursor: auto;
}

body.modal-open {
  overflow: hidden;
}

img,
svg {
  display: block;
  max-width: 100%;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 1px solid var(--ink-soft);
  outline-offset: 3px;
}

body.has-pointer button,
body.has-pointer input,
body.has-pointer textarea,
body.has-pointer a {
  cursor: none;
}

a {
  color: inherit;
  text-decoration: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#story {
  position: relative;
  z-index: 1;
}

.chapter {
  position: relative;
  min-height: 100vh;
  max-width: 100%;
  padding: var(--chapter-pad) clamp(1.25rem, 5vw, 4rem);
  overflow-x: clip;
  overflow-y: visible;
}

.chapter::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 60% at 50% 20%, rgba(255, 255, 255, 0.03), transparent 60%),
    linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.25));
}

.chapter-inner {
  position: relative;
  z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
}

.chapter-kicker {
  font-family: var(--sans);
  font-size: 0.68rem;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 1.25rem;
}

.story-line {
  font-size: clamp(1.6rem, 4vw, 3.1rem);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.story-line.small {
  font-size: clamp(1.15rem, 2.4vw, 1.7rem);
  color: var(--ink-soft);
}

.story-line.whisper {
  font-size: clamp(1rem, 2vw, 1.35rem);
  font-style: italic;
  color: var(--ink-mute);
}

.center-copy {
  text-align: center;
  max-width: 28ch;
  margin: 0 auto;
}

.scene-stage {
  position: relative;
  margin-top: 3rem;
}

.grain,
.paper {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
}

.grain {
  opacity: 0.09;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain-shift 1.2s steps(4) infinite;
}

.paper {
  opacity: 0.12;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.08' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)'/%3E%3C/svg%3E");
}

@keyframes grain-shift {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-2%, 1%); }
  50% { transform: translate(1%, -2%); }
  75% { transform: translate(-1%, 2%); }
  100% { transform: translate(0, 0); }
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 35;
  background: radial-gradient(ellipse at center, transparent 42%, rgba(0, 0, 0, 0.72) 100%);
}

.hidden-msg {
  position: absolute;
  opacity: 0;
  transform: translateY(8px) scale(0.96);
  pointer-events: none;
  font-style: italic;
  font-size: clamp(1rem, 1.8vw, 1.3rem);
  color: var(--ink-soft);
  max-width: 18ch;
  transition: opacity 0.25s ease, transform 0.25s ease, color 0.25s ease;
  z-index: 6;
}

.hidden-msg.is-lit {
  opacity: 1;
  transform: translateY(0) scale(1);
  color: #f4ead8;
  text-shadow: 0 0 18px rgba(0, 0, 0, 0.8);
}

.hidden-msg.rose.is-lit { color: var(--blush); }
.hidden-msg.moon.is-lit { color: var(--moon); }

.secret-only {
  display: none;
}

body.is-secret .secret-only {
  display: block;
}

.revealable {
  filter: grayscale(1) brightness(0.78) contrast(1.05);
  transition: filter 0.55s var(--ease), transform 0.55s var(--ease), opacity 0.5s ease;
  will-change: filter;
}

.revealable.is-lit {
  filter: grayscale(0) brightness(1) contrast(1.05);
}

.revealable.is-found {
  filter: grayscale(0.15) brightness(1);
}

body.is-color-world .revealable,
body.is-color-world .chapter {
  filter: none;
}

.ink-draw {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.15;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ink-fill {
  fill: currentColor;
}

.continue-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  margin: 4rem auto 0;
  opacity: 0.28;
  pointer-events: auto;
  transition: opacity 0.8s var(--ease);
  font-family: var(--sans);
  font-size: 0.68rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--ink-mute);
}

.continue-hint.is-ready {
  opacity: 1;
  pointer-events: auto;
}

.continue-hint .arrow {
  width: 1px;
  height: 36px;
  background: var(--ink-mute);
  animation: drip 1.8s var(--ease) infinite;
}

@keyframes drip {
  0%, 100% { transform: scaleY(0.4); opacity: 0.3; transform-origin: top; }
  50% { transform: scaleY(1); opacity: 1; }
}

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

  .grain {
    animation: none;
  }

  .hidden-msg {
    opacity: 0.85;
    transform: none;
  }
}