:root {
  --cyan: 120, 235, 255;
  --off: #ece8e1;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; width: 100%;
  background: #000; color: var(--off);
  overflow: hidden; overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  font-family: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
}
#stage { position: fixed; inset: 0; overflow: hidden; background: #000; }
#poster-pic, #poster, .layer {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: center 35%;
}
[data-orient="h"] #poster, [data-orient="h"] .layer { object-position: center center; }
#poster { transition: filter 600ms ease; }
.layer { opacity: 0; transition: opacity 300ms ease; background: transparent; pointer-events: none; }
.layer.on { opacity: 1; }
#v-flare { transition-duration: 200ms; }

/* Still-image fallback: subtle cyan glow + brightness while he speaks. */
#glow {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background:
    radial-gradient(ellipse 34% 20% at 50% 30%, rgba(var(--cyan), .30), transparent 70%),
    radial-gradient(ellipse 22% 14% at 50% 64%, rgba(var(--cyan), .16), transparent 70%);
  mix-blend-mode: screen; transition: opacity 300ms ease;
}
[data-orient="h"] #glow {
  background:
    radial-gradient(ellipse 18% 24% at 50% 30%, rgba(var(--cyan), .28), transparent 70%),
    radial-gradient(ellipse 12% 16% at 50% 62%, rgba(var(--cyan), .14), transparent 70%);
}
#stage.glow #glow { opacity: 1; animation: pulse 1.6s ease-in-out infinite; }
#stage.glow #poster, #stage.glow #v-idle { filter: brightness(1.12) saturate(1.06); }
#stage.surge #glow { animation: surge 1.4s ease-out 1; }
@keyframes pulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
@keyframes surge { 0% { opacity: 0; } 15% { opacity: 1; } 100% { opacity: 0; } }

/* Passcode-screen background; crossfades away after a correct passcode. */
#gate-pic, #gate-bg, #v-gate {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: center 20%; pointer-events: none;
}
#gate-pic { background: #000; opacity: 1; transition: opacity 600ms ease; }
#stage.entered #gate-pic { opacity: 0; }
#stage:not(.entered) #vignette { opacity: 0; }

#vignette {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to top, rgba(0,0,0,.85) 0%, rgba(0,0,0,.35) 22%, transparent 40%);
  transition: opacity 600ms ease;
}

#bottom {
  position: absolute; left: 0; right: 0; bottom: 0;
  min-height: 25%;
  padding: 0 calc(20px + var(--safe-r)) calc(18px + var(--safe-b)) calc(20px + var(--safe-l));
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 14px;
}

#subs {
  margin: 0; max-width: min(92vw, 860px); min-height: 2.8em;
  text-align: center; font-style: italic; font-weight: 400;
  font-size: clamp(18px, 2.4vw + 10px, 30px); line-height: 1.35; letter-spacing: .01em;
  color: var(--off);
  text-shadow: 0 1px 2px rgba(0,0,0,.95), 0 0 18px rgba(0,0,0,.9), 0 0 40px rgba(0,0,0,.7);
  opacity: 0; transform: translateY(4px); transition: opacity 700ms ease, transform 700ms ease;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
#subs.on { opacity: 1; transform: none; transition-duration: 250ms; }

#gate-form { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 8px; }
#gate {
  display: flex; gap: 8px; width: min(100%, 360px);
  transition: opacity 500ms ease, transform 500ms ease;
}
#gate-form:has(#gate.gone) { pointer-events: none; }
#gate.gone { opacity: 0; transform: translateY(8px); pointer-events: none; }
#gate.gone ~ #status { min-height: 0; }
#gate.shake { animation: shake 380ms ease; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
#code {
  flex: 1; min-width: 0; height: 48px; padding: 0 16px;
  font: 16px/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .3em;
  color: var(--off); background: rgba(0,0,0,.55);
  border: 1px solid rgba(var(--cyan), .28); border-radius: 2px; outline: none;
  -webkit-appearance: none; appearance: none;
}
#code::placeholder { letter-spacing: .2em; color: rgba(236,232,225,.35); font-style: italic; font-family: inherit; }
#code:focus { border-color: rgba(var(--cyan), .7); box-shadow: 0 0 14px rgba(var(--cyan), .25); }
#enter {
  height: 48px; min-width: 88px; padding: 0 18px; cursor: pointer;
  font-family: inherit; font-style: italic; font-size: 17px; line-height: 1; letter-spacing: .06em;
  color: rgb(var(--cyan)); background: rgba(0,0,0,.55);
  border: 1px solid rgba(var(--cyan), .45); border-radius: 2px;
  text-shadow: 0 0 10px rgba(var(--cyan), .5);
}
#enter:disabled { opacity: .5; }
#status { margin: 0; min-height: 1.3em; font-style: italic; font-size: 15px; color: rgba(236,232,225,.75); text-shadow: 0 1px 3px #000; }
#status[data-kind="err"] { color: #d8f7ff; }

#controls { display: flex; gap: 14px; }
#controls[hidden] { display: none; }
#controls button {
  width: 48px; height: 48px; display: grid; place-items: center; cursor: pointer;
  background: rgba(0,0,0,.45); border: 1px solid rgba(236,232,225,.18); border-radius: 50%;
  color: rgba(236,232,225,.8); padding: 0;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
#controls button:focus-visible, #enter:focus-visible { outline: 2px solid rgba(var(--cyan), .9); outline-offset: 2px; }
#controls svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
#controls .slash { display: none; }
#controls [aria-pressed="true"] { color: rgba(var(--cyan), 1); border-color: rgba(var(--cyan), .5); }
#controls [aria-pressed="true"] .slash { display: inline; }
#btn-end { color: rgba(236,232,225,.9) !important; }

#fx-hotspot {
  position: absolute; top: var(--safe-t); right: var(--safe-r); width: 56px; height: 56px;
  background: transparent; border: 0; padding: 0; opacity: 0;
}
#fx-panel {
  position: absolute; top: calc(16px + var(--safe-t)); right: calc(16px + var(--safe-r));
  width: min(280px, calc(100vw - 32px)); padding: 16px; display: flex; flex-direction: column; gap: 12px;
  background: rgba(0,0,0,.82); border: 1px solid rgba(var(--cyan), .25); border-radius: 4px;
  font-size: 15px;
}
#fx-panel[hidden] { display: none; }
#fx-panel input[type=range] { width: 100%; height: 44px; accent-color: rgb(var(--cyan)); }
#fx-panel .row { display: flex; gap: 10px; }
#fx-panel .row button { flex: 1; min-height: 44px; font: inherit; color: var(--off); background: transparent; border: 1px solid rgba(236,232,225,.25); border-radius: 2px; }

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

@media (orientation: landscape) and (max-height: 500px) {
  #bottom { gap: 8px; padding-bottom: calc(10px + var(--safe-b)); }
  #subs { font-size: 18px; min-height: 2.6em; }
}
@media (prefers-reduced-motion: reduce) {
  #stage.glow #glow { animation: none; opacity: .8; }
}
