.threshold-film {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: grid;
  overflow: hidden;
  background: #02050a;
  color: #f7f0df;
  isolation: isolate;
}
.threshold-film[hidden] { display: none; }
.threshold-film-media,
.threshold-film-media video,
.threshold-film-fallback { position: absolute; inset: 0; width: 100%; height: 100%; }
.threshold-film-media video,
.threshold-film-fallback { object-fit: cover; }
.threshold-film-fallback { display: none; background: #071018 center / cover no-repeat; }
.threshold-film::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(2,5,10,.22), transparent 24%, transparent 58%, rgba(2,5,10,.82)), radial-gradient(circle at 50% 46%, transparent 25%, rgba(1,4,9,.42) 100%);
}
.threshold-film-chapter {
  position: absolute;
  z-index: 3;
  top: max(22px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 8px 13px;
  border: 1px solid rgba(216,177,97,.36);
  border-radius: 999px;
  background: rgba(5,10,18,.62);
  color: #ead095;
  font: 700 clamp(10px, 1vw, 12px)/1.1 system-ui, sans-serif;
  letter-spacing: .18em;
  text-transform: uppercase;
  backdrop-filter: blur(12px);
}
.threshold-film-story {
  position: relative;
  z-index: 3;
  align-self: end;
  justify-self: center;
  width: min(880px, calc(100% - 40px));
  margin-bottom: max(72px, calc(env(safe-area-inset-bottom) + 58px));
  text-align: center;
}
.threshold-film-caption {
  min-height: 2.7em;
  margin: 0;
  color: #fffaf0;
  font: 600 clamp(18px, 2.2vw, 30px)/1.34 Georgia, serif;
  letter-spacing: .005em;
  text-wrap: balance;
  text-shadow: 0 2px 12px #000, 0 0 28px rgba(0,0,0,.85);
  transition: opacity .22s ease, transform .22s ease;
}
.threshold-film-caption.is-changing { opacity: 0; transform: translateY(5px); }
.threshold-film-narrator {
  display: block;
  margin-top: 8px;
  color: #86ded7;
  font: 700 10px/1 system-ui, sans-serif;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.threshold-film-progress {
  position: absolute;
  z-index: 4;
  right: 22px;
  bottom: max(22px, env(safe-area-inset-bottom));
  left: 22px;
  height: 2px;
  overflow: hidden;
  border-radius: 2px;
  background: rgba(255,255,255,.16);
}
.threshold-film-progress i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, #73ddd6, #e7bd6e); box-shadow: 0 0 12px #70d8d2; }
.threshold-film-morrow {
  position: absolute;
  z-index: 2;
  right: 8vw;
  bottom: 6vh;
  width: 138px;
  height: 218px;
  overflow: hidden;
  opacity: 0;
  filter: drop-shadow(0 12px 18px rgba(0,0,0,.8));
  transform: translateY(12px);
  transition: opacity .8s ease, transform .8s ease;
}
.threshold-film-morrow::before {
  content: "";
  position: absolute;
  width: 768px;
  height: 512px;
  left: -72px;
  top: -16px;
  background: url("assets/morrow/morrow-sprite-v2.png") 0 0 / 768px 512px no-repeat;
}
.threshold-film.is-morrow-visible .threshold-film-morrow { opacity: .9; transform: none; }
.threshold-film-controls {
  position: absolute;
  z-index: 5;
  right: max(22px, env(safe-area-inset-right));
  top: max(22px, env(safe-area-inset-top));
  display: flex;
  gap: 8px;
}
.threshold-film button {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 999px;
  background: rgba(4,9,16,.7);
  color: #f8f3e7;
  font: 750 12px/1 system-ui, sans-serif;
  letter-spacing: .06em;
  cursor: pointer;
  backdrop-filter: blur(12px);
}
.threshold-film button:hover,
.threshold-film button:focus-visible { border-color: #83e2da; background: rgba(12,28,38,.88); outline: 2px solid transparent; box-shadow: 0 0 0 2px rgba(131,226,218,.3); }
.threshold-film-continue { display: none; background: linear-gradient(110deg, #69d8d5, #edc56e) !important; color: #071018 !important; border: 0 !important; }
.threshold-film.is-static .threshold-film-media video { display: none; }
.threshold-film.is-static .threshold-film-fallback { display: block; }
.threshold-film.is-static .threshold-film-continue { display: inline-flex; align-items: center; }
.threshold-film.is-static .threshold-film-story { margin-bottom: max(104px, calc(env(safe-area-inset-bottom) + 86px)); }
.threshold-film.is-static .threshold-film-caption { min-height: auto; }
.director-replay-film {
  width: 100%;
  min-height: 48px;
  margin-top: 14px;
  border: 1px solid rgba(126,221,211,.35);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(56,145,151,.16), rgba(215,174,93,.12));
  color: #eaf8f5;
  font: 700 13px/1.2 system-ui, sans-serif;
  cursor: pointer;
}
.director-replay-film:hover,
.director-replay-film:focus-visible { border-color: #81ded6; background-color: rgba(75,165,166,.18); outline: none; }
body.threshold-film-open { overflow: hidden !important; }
body.threshold-film-open > :not(.threshold-film) { pointer-events: none; }

@media (max-width: 700px) {
  .threshold-film-chapter { top: max(66px, calc(env(safe-area-inset-top) + 56px)); max-width: calc(100% - 28px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .threshold-film-controls { top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); }
  .threshold-film button { min-height: 40px; padding-inline: 13px; }
  .threshold-film-story { width: calc(100% - 28px); margin-bottom: max(66px, calc(env(safe-area-inset-bottom) + 54px)); }
  .threshold-film-caption { font-size: clamp(17px, 5.2vw, 23px); }
  .threshold-film-progress { right: 14px; bottom: max(14px, env(safe-area-inset-bottom)); left: 14px; }
  .threshold-film-morrow { right: 4vw; bottom: 8vh; transform: scale(.72) translateY(12px); transform-origin: right bottom; }
  .threshold-film.is-morrow-visible .threshold-film-morrow { transform: scale(.72); }
}

@media (prefers-reduced-motion: reduce) {
  .threshold-film-caption { transition: none; }
  .threshold-film-morrow { transition: none; }
}
