:root {
  color-scheme: dark;
  --accent: #d7b46a;
  --accent-strong: #f1cf7d;
  --ink: #f7f2e8;
  --muted: rgba(247, 242, 232, 0.72);
  --control-bg: rgba(8, 8, 10, 0.42);
  --control-border: rgba(247, 242, 232, 0.2);
  --camera-start-scale: 1;
  --camera-end-scale: 1.62;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #050505;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

body {
  min-width: 320px;
}

button,
select,
a {
  font: inherit;
}

.cinema-shell,
.stage,
.scene-stack,
.scene-layer,
.scene-frame,
.scene-image {
  position: fixed;
  inset: 0;
}

.cinema-shell {
  isolation: isolate;
  background: #050505;
}

.stage {
  z-index: 0;
  overflow: hidden;
}

.scene-stack {
  background: #050505;
}

.scene-layer {
  opacity: 0;
  transform: scale(1.035);
  filter: blur(10px) brightness(0.72);
  transition:
    opacity 1100ms ease,
    filter 1100ms ease,
    transform 1100ms ease;
  will-change: opacity, filter, transform;
}

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

.scene-layer.is-leaving {
  opacity: 0;
  transform: scale(1.08);
  filter: blur(14px) brightness(0.5);
}

.scene-frame {
  overflow: hidden;
  transform-origin: var(--camera-origin, 50% 50%);
  animation: dolly-in var(--scene-duration, 18s) linear forwards;
  will-change: transform;
}

.scene-frame::before {
  position: fixed;
  inset: -3%;
  z-index: 0;
  content: "";
  background-image: var(--scene-backdrop);
  background-position: center;
  background-size: cover;
  opacity: 0;
  filter: blur(18px) saturate(0.95) brightness(0.72);
  transform: scale(1.05);
}

.scene-image {
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--image-position, center);
  filter: saturate(1.06) contrast(1.04);
  user-select: none;
  pointer-events: none;
}

.is-morph .scene-image:first-child {
  filter: saturate(0.72) contrast(1.08) brightness(0.88);
}

.morph-target {
  opacity: 0;
  animation: morph-reveal var(--scene-duration, 18s) linear forwards;
}

.grain,
.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.grain {
  z-index: 5;
  opacity: 0.12;
  mix-blend-mode: screen;
  background-image:
    repeating-radial-gradient(circle at 18% 22%, rgba(255, 255, 255, 0.22) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.08) 0 1px, transparent 1px 3px);
  animation: grain-drift 900ms steps(4) infinite;
}

.vignette {
  z-index: 6;
  background:
    linear-gradient(to bottom, rgba(0, 0, 0, 0.46), transparent 20%, transparent 72%, rgba(0, 0, 0, 0.66)),
    radial-gradient(circle at center, transparent 38%, rgba(0, 0, 0, 0.76) 100%);
}

.caption-field {
  position: fixed;
  z-index: 15;
  left: 50%;
  bottom: 10%;
  width: min(980px, calc(100% - 44px));
  transform: translateX(-50%);
  pointer-events: none;
}

.caption-text {
  min-height: 7.5rem;
  color: #fff8e8;
  font-size: 2rem;
  line-height: 1.55;
  font-weight: 650;
  text-wrap: balance;
  white-space: pre-line;
  text-shadow:
    0 2px 8px rgba(0, 0, 0, 0.92),
    0 10px 34px rgba(0, 0, 0, 0.82),
    0 0 24px rgba(215, 180, 106, 0.24);
}

.topbar {
  position: fixed;
  z-index: 45;
  top: 18px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(1050px, calc(100% - 28px));
  min-height: 52px;
  padding: 8px;
  transform: translateX(-50%);
  border: 1px solid var(--control-border);
  border-radius: 8px;
  background: var(--control-bg);
  backdrop-filter: blur(16px);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.24);
}

.story-switch {
  display: flex;
  align-items: center;
  gap: 4px;
}

.story-link,
.icon-button,
.language-select {
  height: 36px;
  border: 1px solid rgba(247, 242, 232, 0.18);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  outline: none;
}

.story-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  padding: 0 13px;
  color: var(--muted);
  text-decoration: none;
}

.story-link.is-active {
  color: #1b1404;
  border-color: rgba(241, 207, 125, 0.78);
  background: linear-gradient(180deg, #f1cf7d, #b88b38);
}

.language-select {
  width: 142px;
  padding: 0 10px;
  cursor: pointer;
}

.language-select option {
  color: #111;
}

.control-cluster {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-inline-start: auto;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  padding: 0;
  cursor: pointer;
}

.icon-button:disabled {
  cursor: default;
  opacity: 0.38;
}

.icon-button:not(:disabled):hover,
.language-select:hover,
.story-link:not(.is-active):hover {
  border-color: rgba(241, 207, 125, 0.48);
  background: rgba(255, 255, 255, 0.12);
}

.scene-count {
  min-width: 48px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.progress-track {
  position: fixed;
  z-index: 42;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.1);
}

.progress-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #c29a4e, #fff0ad);
  transition: width 120ms linear;
}

.start-screen {
  position: fixed;
  z-index: 38;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 500ms ease,
    visibility 500ms ease;
  background: rgba(0, 0, 0, 0.18);
}

.start-screen.is-visible {
  opacity: 1;
  visibility: visible;
}

.start-content {
  display: grid;
  justify-items: center;
  gap: 18px;
  text-align: center;
}

.start-title {
  margin: 0;
  color: #fff7e5;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 4.5rem;
  line-height: 1;
  font-weight: 700;
  text-shadow:
    0 3px 10px rgba(0, 0, 0, 0.86),
    0 0 42px rgba(215, 180, 106, 0.24);
}

.start-button {
  min-width: 150px;
  height: 44px;
  padding: 0 22px;
  border: 1px solid rgba(255, 236, 176, 0.84);
  border-radius: 8px;
  color: #1d1505;
  background: linear-gradient(180deg, #fff0ad, #c99b41);
  cursor: pointer;
  box-shadow: 0 12px 38px rgba(0, 0, 0, 0.32);
}

.status-line {
  min-height: 1.5rem;
  margin: 0;
  color: rgba(255, 248, 232, 0.78);
  font-size: 1rem;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.82);
}

.is-paused .scene-frame,
.is-paused .morph-target,
.is-paused .grain {
  animation-play-state: paused;
}

@keyframes dolly-in {
  from {
    transform: translate3d(var(--pan-x-start), var(--pan-y-start), 0) scale(var(--camera-start-scale));
  }
  to {
    transform: translate3d(var(--pan-x-end), var(--pan-y-end), 0) scale(var(--camera-end-scale));
  }
}

@keyframes morph-reveal {
  0%,
  28% {
    opacity: 0;
    filter: saturate(0.8) contrast(1.08) brightness(0.86);
  }
  72% {
    opacity: 0.96;
  }
  100% {
    opacity: 1;
    filter: saturate(1.08) contrast(1.03) brightness(1.02);
  }
}

body[data-story="arrival"] .scene-layer {
  --camera-end-scale: 2.15;
  transition: none;
}

body[data-story="arrival"] .scene-layer.is-leaving {
  transform: scale(1);
  filter: blur(0) brightness(1);
}

body[data-story="arrival"] .scene-layer[data-scene="scene01"] {
  --camera-end-scale: 4.25;
}

@keyframes grain-drift {
  0% {
    transform: translate3d(0, 0, 0);
  }
  100% {
    transform: translate3d(-2%, 1%, 0);
  }
}

@media (max-width: 780px) {
  .topbar {
    top: 10px;
    flex-wrap: wrap;
    justify-content: center;
    width: calc(100% - 20px);
    min-height: 96px;
  }

  .story-link {
    min-width: 84px;
  }

  .control-cluster {
    margin-inline-start: 0;
  }

  .caption-field {
    bottom: 7%;
    width: calc(100% - 28px);
  }

  .caption-text {
    min-height: 8.5rem;
    font-size: 1.35rem;
    line-height: 1.55;
  }

  .start-title {
    font-size: 3.3rem;
  }

  body[data-story="arrival"] .scene-layer[data-scene="scene01"] {
    --camera-start-scale: 1;
    --camera-end-scale: 2.75;
    --camera-origin: 82% 52%;
    --image-position: 78% center;
  }

  body[data-story="arrival"] .scene-layer[data-scene="scene01"] .scene-frame::before {
    opacity: 0;
  }

  body[data-story="arrival"] .scene-layer[data-scene="scene01"] .scene-image {
    object-fit: cover;
  }
}

@media (max-width: 430px) {
  .language-select {
    width: 124px;
  }

  .icon-button {
    width: 34px;
  }

  .caption-text {
    font-size: 1.18rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .scene-frame,
  .grain,
  .morph-target {
    animation-duration: 1ms;
  }

  .scene-layer {
    transition-duration: 1ms;
  }
}
