:root {
  color-scheme: dark;
  --transition-ms: 1600ms;
  --transition-easing: cubic-bezier(0.22, 1, 0.36, 1);
  --panel-bg: rgba(8, 11, 14, 0.58);
  --panel-border: rgba(255, 255, 255, 0.16);
  --text-main: rgba(255, 250, 235, 0.92);
  --text-muted: rgba(255, 250, 235, 0.68);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #07090b;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

.experience {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-width: 320px;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 50% 40%, rgba(42, 64, 69, 0.4), transparent 40%),
    #06080a;
  color: var(--text-main);
}

.scene-root,
.flow-canvas,
.debug-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.scene-root {
  z-index: 0;
}

.scene-layer {
  position: absolute;
  inset: -3%;
  background-position: center;
  background-size: cover;
  opacity: 0;
  transform: scale(1.03);
  will-change: opacity, transform, filter, clip-path;
}

.scene-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: contrast(1.08) saturate(1.06);
}

.scene-layer::before {
  position: absolute;
  inset: 0;
  z-index: 1;
  content: "";
  background:
    radial-gradient(circle at var(--focus-x, 50%) var(--focus-y, 50%), rgba(255, 252, 226, 0.26) 0 8%, rgba(252, 232, 177, 0.13) 18%, transparent 34%);
  mix-blend-mode: screen;
  pointer-events: none;
}

.scene-layer::after {
  position: absolute;
  inset: 0;
  z-index: 2;
  content: "";
  background:
    radial-gradient(circle at var(--focus-x, 50%) var(--focus-y, 50%), transparent 0 11%, rgba(0, 0, 0, 0.18) 24%, rgba(0, 0, 0, 0.62) 56%, rgba(0, 0, 0, 0.9) 100%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.28), rgba(0, 0, 0, 0.68));
  pointer-events: none;
}

.scene-layer.is-active {
  opacity: 1;
  transform: scale(1);
}

.flow-canvas {
  z-index: 1;
  mix-blend-mode: screen;
  opacity: 0.72;
  pointer-events: none;
}

.story-copy {
  position: absolute;
  z-index: 2;
  left: clamp(20px, 7vw, 104px);
  bottom: clamp(36px, 9vh, 108px);
  width: min(560px, calc(100vw - 40px));
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.68);
  transition:
    opacity var(--transition-ms) var(--transition-easing),
    transform var(--transition-ms) var(--transition-easing),
    filter var(--transition-ms) var(--transition-easing);
}

.story-copy.is-transitioning {
  opacity: 0.18;
  transform: translateY(18px);
  filter: blur(5px);
}

.story-copy h1 {
  margin: 0 0 14px;
  max-width: 13ch;
  font-size: clamp(2.1rem, 6vh, 5rem);
  line-height: 0.96;
  letter-spacing: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.story-copy p {
  width: 100%;
  max-width: 40rem;
  margin: 0;
  color: var(--text-muted);
  font-size: clamp(1rem, 2.1vh, 1.28rem);
  line-height: 1.7;
  overflow-wrap: anywhere;
  word-break: break-all;
}

.controls {
  position: absolute;
  z-index: 5;
  top: 18px;
  right: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 36px);
  padding: 8px;
  color: rgba(255, 255, 255, 0.82);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  backdrop-filter: blur(18px);
  transition: opacity 180ms ease;
}

.controls.is-hidden {
  display: none;
}

.controls:hover,
.controls:focus-within {
  opacity: 1;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-width: 132px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 7px;
}

.segmented-button,
.plain-button,
.debug-toggle {
  min-height: 34px;
  color: rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.08);
  border: 0;
}

.segmented-button {
  padding: 0 12px;
  cursor: pointer;
}

.segmented-button.is-active {
  color: #101316;
  background: rgba(252, 232, 177, 0.92);
}

.plain-button {
  padding: 0 12px;
  border-radius: 7px;
  cursor: pointer;
}

.debug-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border-radius: 7px;
  white-space: nowrap;
}

.debug-toggle input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: #fce8b1;
}

.gaze-notice,
.calibration-overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(16px);
}

.gaze-notice[hidden],
.calibration-overlay[hidden],
.debug-canvas[hidden] {
  display: none;
}

.notice-panel {
  width: min(480px, 100%);
  padding: 26px;
  background: rgba(10, 13, 16, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
}

.notice-kicker {
  margin: 0 0 10px;
  color: rgba(252, 232, 177, 0.84);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.notice-panel h1 {
  margin: 0 0 14px;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  line-height: 1.14;
  letter-spacing: 0;
}

.notice-panel p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.68;
}

.notice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.notice-actions button,
.calibration-copy button {
  min-height: 40px;
  padding: 0 16px;
  color: #111417;
  background: #fce8b1;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
}

.notice-actions button + button,
.calibration-copy button {
  color: rgba(255, 255, 255, 0.82);
  background: rgba(255, 255, 255, 0.1);
}

.notice-error {
  margin-top: 14px;
  color: #ffb7a8;
}

.notice-status {
  margin-top: 12px;
  color: rgba(252, 232, 177, 0.82);
}

.calibration-overlay {
  background: rgba(2, 4, 6, 0.62);
}

.calibration-copy {
  position: absolute;
  left: 24px;
  bottom: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255, 255, 255, 0.78);
}

.calibration-copy p {
  margin: 0;
}

.calibration-dot {
  position: absolute;
  width: 58px;
  height: 58px;
  margin: -29px 0 0 -29px;
  background: radial-gradient(circle, #fff 0 16%, #fce8b1 17% 42%, rgba(252, 232, 177, 0.22) 43% 100%);
  border: 0;
  border-radius: 999px;
  box-shadow: 0 0 42px rgba(252, 232, 177, 0.92);
  cursor: pointer;
}

.debug-canvas {
  z-index: 6;
  pointer-events: none;
}

.status-toast {
  position: absolute;
  z-index: 9;
  left: 50%;
  bottom: 22px;
  max-width: min(520px, calc(100vw - 32px));
  padding: 9px 13px;
  color: rgba(255, 255, 255, 0.84);
  background: rgba(8, 11, 14, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.status-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 720px) {
  .controls {
    top: 10px;
    right: 10px;
    left: 10px;
    justify-content: flex-end;
  }

  .story-copy {
    left: 20px;
    right: 20px;
    bottom: 42px;
    width: auto;
    max-width: none;
  }

  .story-copy p {
    width: min(18em, 100%);
    max-width: none;
  }

  .story-copy h1 {
    font-size: clamp(2rem, 11vw, 3.4rem);
  }
}
