/* ============ Reset & base ============ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink: #0a0a0c;
  --paper: #e8e4da;
  --dim: rgba(232, 228, 218, 0.55);
  --font-display: Georgia, 'Times New Roman', 'Songti SC', serif;
  --font-ui: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
}

html, body { height: 100%; }

body {
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-display);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: var(--font-ui);
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

/* ============ Stage ============ */
#stage { position: fixed; inset: 0; overflow: hidden; }

#canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#veil {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 12, 0.35);
  transition: background 2.2s ease;
  mix-blend-mode: multiply;
  pointer-events: none;
}

/* ============ Cinematic overlays ============ */
.bar {
  position: absolute;
  left: 0; right: 0;
  height: 9vh;
  background: #000;
  z-index: 40;
  pointer-events: none;
}
.bar.top { top: 0; }
.bar.bottom { bottom: 0; }

.vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center,
    transparent 55%, rgba(0,0,0,0.55) 100%);
  z-index: 30;
  pointer-events: none;
}

.scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,0.015) 0px,
    rgba(255,255,255,0.015) 1px,
    transparent 1px,
    transparent 4px
  );
  z-index: 31;
  pointer-events: none;
  mix-blend-mode: overlay;
}

#grain {
  position: absolute;
  inset: -50%;
  width: 200%;
  height: 200%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  opacity: 0.05;
  z-index: 32;
  pointer-events: none;
  animation: grain 0.6s steps(6) infinite;
}

@keyframes grain {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-2%, 3%); }
  40%  { transform: translate(3%, -2%); }
  60%  { transform: translate(-3%, -1%); }
  80%  { transform: translate(2%, 2%); }
  100% { transform: translate(0, 0); }
}

#glow {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 38%, rgba(120, 160, 255, 0.14), transparent 65%);
  animation: breathe 9s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* ============ Title screen ============ */
#titleScreen {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 6vh 6vw;
  gap: 3.4vh;
  transition: opacity 2.2s ease, transform 2.2s ease;
}

#titleScreen.hide {
  opacity: 0;
  transform: scale(1.06);
  pointer-events: none;
}

.prologue {
  font-family: var(--font-ui);
  font-size: clamp(0.62rem, 1.1vw, 0.8rem);
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--dim);
  animation: fadeUp 2.4s ease both;
}

.film-title {
  font-size: clamp(2.4rem, 8vw, 6.5rem);
  font-weight: 400;
  line-height: 1.06;
  letter-spacing: 0.02em;
  text-shadow: 0 0 60px rgba(140, 170, 255, 0.25);
}
.film-title .line { display: block; animation: fadeUp 2.4s ease both; }
.film-title .line:nth-child(2) { animation-delay: 0.35s; }
.film-title .accent {
  font-style: italic;
  background: linear-gradient(90deg, #c9d6ff, #ffd6c9, #c9ffd6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: fadeUp 2.4s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(22px); }
  to { opacity: 1; transform: translateY(0); }
}

.subtitle {
  font-size: clamp(0.85rem, 1.8vw, 1.1rem);
  font-style: italic;
  color: var(--dim);
  animation: fadeUp 2.4s ease 0.8s both;
}

.begin {
  margin-top: 2vh;
  padding: 1.05em 2.6em;
  font-size: clamp(0.85rem, 1.4vw, 1rem);
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--paper);
  border: 1px solid rgba(232, 228, 218, 0.5);
  border-radius: 999px;
  background: rgba(232, 228, 218, 0.04);
  transition: all 0.5s ease;
  animation: fadeUp 2.4s ease 1.1s both;
}
.begin:hover {
  background: rgba(232, 228, 218, 0.14);
  border-color: var(--paper);
  box-shadow: 0 0 34px rgba(180, 200, 255, 0.28);
  transform: translateY(-2px);
}
.begin.ghost { border-color: rgba(232,228,218,0.25); }
.begin.ghost:hover { border-color: rgba(232,228,218,0.6); }

.hint {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(232, 228, 218, 0.32);
  animation: fadeUp 2.4s ease 1.4s both;
}

/* ============ Film layer ============ */
#film {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  opacity: 0;
  transition: opacity 1.8s ease;
  pointer-events: none;
}
#film.on { opacity: 1; pointer-events: auto; }

.head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13vh 4vw 0;
  animation: fadeUp 1.6s ease both;
}

.chapter { display: flex; align-items: baseline; gap: 1rem; }
.act-no {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  letter-spacing: 0.4em;
  color: var(--dim);
}
.act-title {
  font-size: clamp(1.1rem, 2.2vw, 1.5rem);
  font-style: italic;
  color: var(--paper);
  text-shadow: 0 0 24px rgba(200, 215, 255, 0.35);
}

.controls { display: flex; gap: 0.7rem; }
.ctl {
  width: 42px; height: 42px;
  border: 1px solid rgba(232,228,218,0.28);
  border-radius: 50%;
  font-size: 1rem;
  color: var(--paper);
  background: rgba(10,10,12,0.25);
  backdrop-filter: blur(4px);
  transition: all 0.35s ease;
}
.ctl:hover { background: rgba(232,228,218,0.14); border-color: var(--paper); }
.ctl.muted { color: var(--dim); opacity: 0.55; }

/* ============ Narration ============ */
.narration {
  width: min(64ch, 80%);
  margin: 0 auto;
  min-height: 22vh;
  display: flex;
  align-items: flex-end;
  gap: 0.2em;
}
#narration {
  font-size: clamp(1.15rem, 2.5vw, 1.75rem);
  line-height: 1.65;
  letter-spacing: 0.015em;
  text-shadow: 0 2px 24px rgba(0,0,0,0.85), 0 0 8px rgba(0,0,0,0.6);
}
.cursor {
  font-size: 1.2em;
  color: var(--paper);
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ============ Footer ============ */
.foot { padding: 0 4vw 13vh; animation: fadeUp 1.6s ease 0.4s both; }

.seeks { display: flex; gap: 6px; margin-bottom: 1.2rem; }
.seek {
  flex: 1;
  height: 3px;
  background: rgba(232,228,218,0.18);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
  transition: background 0.3s ease;
}
.seek::after {
  content: '';
  position: absolute; inset: 0;
  background: var(--paper);
  transform: scaleX(0);
  transform-origin: left;
}
.seek.done::after { transform: scaleX(1); }
.seek.active::after { transform: scaleX(var(--p, 0)); transition: transform 0.25s linear; }
.seek.playing::after { background: #cfd8ff; }
.seek:hover { background: rgba(232,228,218,0.35); }

.foot-info {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-ui);
  font-size: 0.66rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--dim);
}
.muted.show { color: rgba(232,228,218,0.5); }

/* ============ Credits ============ */
#credits {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 1.6rem;
  padding: 6vh 6vw;
  opacity: 0;
  transition: opacity 2.4s ease;
  pointer-events: none;
}
#credits.on { opacity: 1; pointer-events: auto; }
#credits h2 {
  font-size: clamp(2rem, 6vw, 4.4rem);
  font-weight: 400;
  font-style: italic;
  animation: fadeUp 2s ease both;
}
.credits-line {
  font-family: var(--font-ui);
  font-size: clamp(0.7rem, 1.4vw, 0.85rem);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--dim);
  animation: fadeUp 2s ease 0.5s both;
}
.credits-note {
  font-size: clamp(0.95rem, 2vw, 1.2rem);
  font-style: italic;
  color: var(--paper);
  max-width: 46ch;
  line-height: 1.7;
  animation: fadeUp 2s ease 0.9s both;
}
.credit-actions { display: flex; gap: 1.2rem; flex-wrap: wrap; justify-content: center; animation: fadeUp 2s ease 1.3s both; }

/* ============ Responsive ============ */
@media (max-width: 640px) {
  .head { padding-top: 11vh; }
  .act-no { display: none; }
  .foot { padding-bottom: 11vh; }
  .narration { min-height: 26vh; }
}
