:root {
  --ink: #0a0907;
  --bone: #efe6d2;
  --bone-dim: rgba(239, 230, 210, .62);
  --gold: #d4a64a;
  --gold-hi: #f3d58c;
  --blood: #9c2a1c;
  --serif: "Cormorant Garamond", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --caps: "Cinzel", "Trajan Pro", "Times New Roman", serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; color: var(--bone); overflow: hidden; }
body { font-family: var(--serif); -webkit-font-smoothing: antialiased; }

#stage { position: fixed; inset: 0; display: grid; place-items: center; background: #000; }
#stage.idle { cursor: none; }

canvas#film {
  width: min(100vw, calc(100vh * 2.388));
  height: auto;
  aspect-ratio: 1920 / 804;
  display: block;
  background: #000;
}

/* ---------- gate (title / loader) ---------- */
.gate {
  position: absolute; inset: 0; z-index: 3;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; text-align: center;
  background:
    radial-gradient(60% 50% at 50% 46%, rgba(120, 82, 34, .22), transparent 70%),
    radial-gradient(120% 80% at 50% 120%, rgba(30, 40, 52, .5), transparent 60%),
    #050403;
  transition: opacity 1.4s ease, visibility 1.4s;
}
.gate.gone { opacity: 0; visibility: hidden; }
.gate-kicker {
  font: 500 clamp(11px, 1.1vw, 14px)/1 var(--caps); letter-spacing: .42em; text-transform: uppercase;
  color: var(--gold); margin: 0 0 22px; opacity: .85; padding-left: .42em;
}
.gate-title {
  font: 400 clamp(40px, 7.4vw, 108px)/1 var(--caps); letter-spacing: .14em; margin: 0; padding-left: .14em;
  background: linear-gradient(180deg, #fff5dc 0%, #e2c27e 55%, #9c7434 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 6px 30px rgba(212, 166, 74, .25));
}
.gate-sub { font: italic 400 clamp(17px, 1.9vw, 26px)/1.3 var(--serif); color: var(--bone-dim); margin: 16px 0 38px; }
.gate-load { width: min(320px, 60vw); height: 1px; background: rgba(239, 230, 210, .12); overflow: hidden; }
.gate-load i { display: block; height: 100%; width: 0; background: var(--gold-hi); transition: width .25s ease; box-shadow: 0 0 12px var(--gold); }
.gate-status { font: italic 400 15px/1 var(--serif); color: var(--bone-dim); margin: 14px 0 0; min-height: 1em; }
.gate-actions { display: flex; gap: 18px; align-items: center; margin-top: 30px; flex-wrap: wrap; justify-content: center; }
.gate-note { margin: 22px 0 0; font: 400 13px/1.4 var(--serif); letter-spacing: .06em; color: rgba(239, 230, 210, .42); }

button { font: inherit; color: inherit; cursor: pointer; }
.play {
  display: inline-flex; align-items: center; gap: 12px;
  padding: 14px 30px 14px 24px; border-radius: 999px;
  border: 1px solid rgba(243, 213, 140, .55); background: rgba(212, 166, 74, .08);
  font: 600 13px/1 var(--caps); letter-spacing: .3em; text-transform: uppercase; color: var(--gold-hi);
  transition: background .3s, border-color .3s, transform .3s, opacity .3s;
}
.play svg { width: 18px; height: 18px; fill: currentColor; }
.play:not(:disabled):hover { background: rgba(212, 166, 74, .2); border-color: var(--gold-hi); transform: translateY(-1px); }
.play:disabled { opacity: .3; cursor: progress; }
.langs { display: inline-flex; border: 1px solid rgba(239, 230, 210, .18); border-radius: 999px; padding: 3px; }
.langs button {
  border: 0; background: transparent; padding: 9px 16px; border-radius: 999px;
  font: 500 15px/1 var(--serif); letter-spacing: .04em; color: var(--bone-dim);
}
.langs button.on { background: rgba(239, 230, 210, .12); color: var(--bone); }

/* ---------- control bar ---------- */
.bar {
  position: absolute; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); z-index: 2;
  transform: translateX(-50%);
  width: min(880px, calc(100vw - 32px));
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px; border-radius: 14px;
  background: rgba(8, 7, 6, .58); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(239, 230, 210, .09);
  opacity: 0; pointer-events: none; transition: opacity .5s ease;
}
#stage.ready:not(.idle) .bar, #stage.paused .bar { opacity: 1; pointer-events: auto; }
.bar button {
  border: 0; background: transparent; padding: 6px 8px; border-radius: 8px;
  font: 600 11px/1 var(--caps); letter-spacing: .14em; color: var(--bone-dim);
  display: inline-grid; place-items: center;
}
.bar button:hover { color: var(--bone); background: rgba(239, 230, 210, .08); }
.bar button.on { color: var(--gold-hi); }
.bar button.rec-on { color: #ff6b5a; }
.bar svg { width: 18px; height: 18px; fill: currentColor; }
#pp .i-pause { display: none; }
#stage.playing #pp .i-play { display: none; }
#stage.playing #pp .i-pause { display: block; }
.clock { font: 500 14px/1 var(--serif); font-variant-numeric: tabular-nums; color: var(--bone-dim); min-width: 84px; }
.scrub { position: relative; flex: 1; height: 22px; cursor: pointer; display: flex; align-items: center; }
.scrub::before { content: ""; position: absolute; left: 0; right: 0; height: 2px; background: rgba(239, 230, 210, .16); border-radius: 2px; }
.scrub i { position: absolute; left: 0; height: 2px; background: var(--gold-hi); border-radius: 2px; box-shadow: 0 0 8px rgba(243, 213, 140, .5); }
.scrub-chapters { position: absolute; inset: 0; pointer-events: none; }
.scrub-chapters b { position: absolute; top: 7px; width: 1px; height: 8px; background: rgba(239, 230, 210, .3); }

.toast {
  position: absolute; top: calc(22px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); z-index: 4;
  padding: 10px 18px; border-radius: 10px; background: rgba(8, 7, 6, .75);
  border: 1px solid rgba(239, 230, 210, .12); font: 400 15px/1.3 var(--serif); color: var(--bone);
}

@media (max-width: 560px) {
  .bar { gap: 6px; padding: 8px 10px; }
  .clock { min-width: 0; font-size: 12px; }
  #rec { display: none; }
}

/* work-in-progress badge on the start gate (v2 preview) */
.gate-wip { display: inline-block; margin: 0 0 1.1rem; padding: .3rem .8rem; border: 1px solid rgba(232, 190, 120, .55); border-radius: 999px;
  font: 600 .72rem/1.2 "Cormorant Garamond", Georgia, serif; letter-spacing: .14em; text-transform: uppercase; color: #e8be78; background: rgba(20, 14, 8, .45); }
