:root {
  color-scheme: dark;
  --ink: #020407;
  --panel: rgba(4, 10, 16, 0.9);
  --chrome: #b8d7e7;
  --soft: #7693a3;
  --accent: 70 183 255;
  --ember: 255 145 63;
  --signal: 0.62;
  --heat: 0.22;
  --memory: 0.5;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  background: var(--ink);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #000;
  color: #e7f5fb;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button,
a {
  font: inherit;
}

button {
  color: inherit;
}

#aether-field {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 50% 33%, rgba(16, 47, 69, 0.28), transparent 45%),
    #000;
}

.shell {
  position: relative;
  z-index: 2;
  width: min(100%, 430px);
  height: 100svh;
  min-height: 480px;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background:
    linear-gradient(90deg, rgba(157, 220, 255, 0.04), transparent 8%, transparent 92%, rgba(157, 220, 255, 0.04)),
    #020407;
  border-inline: 1px solid rgba(150, 220, 255, 0.12);
  opacity: 0;
  transform: scale(1.015);
  transition: opacity 680ms ease, transform 900ms cubic-bezier(.17,.78,.18,1);
}

body.entered .shell {
  opacity: 1;
  transform: none;
}

.mast {
  min-height: 43px;
  padding: max(7px, env(safe-area-inset-top)) 10px 6px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid rgba(var(--accent), 0.26);
  background: linear-gradient(180deg, rgba(1, 3, 5, 0.98), rgba(3, 8, 13, 0.84));
}

.mast p {
  margin: 0;
}

.made-by {
  color: rgb(var(--ember));
  font-size: 7px;
  letter-spacing: 0.24em;
  font-weight: 650;
}

.wordmark {
  margin-top: 3px !important;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
  letter-spacing: 0.08em;
}

.wordmark span {
  color: var(--soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 8px;
}

.readout {
  display: grid;
  justify-items: end;
  gap: 3px;
  color: #7db4cf;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 8px;
  letter-spacing: 0.08em;
}

.instrument {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(200px, 47%) minmax(94px, 24%) minmax(100px, 29%);
  overflow: hidden;
}

.scene {
  position: relative;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
  background: #020509;
  border-bottom: 1px solid rgba(var(--accent), 0.26);
  touch-action: pan-y;
}

.scene-blur {
  position: absolute;
  inset: -9%;
  z-index: -2;
  background-position: center;
  background-size: cover;
  filter: blur(18px) brightness(0.36) saturate(1.22);
  transform: scale(1.08);
  opacity: 0.8;
  transition: background-image 700ms ease;
}

.scene-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  opacity: 0;
  filter:
    saturate(calc(0.72 + var(--signal) * 0.55))
    contrast(calc(0.94 + var(--signal) * 0.12))
    brightness(calc(0.78 + var(--heat) * 0.23));
  transform: scale(1.045) translate3d(0, 0, 0);
  transition: opacity 900ms ease;
  will-change: opacity, transform;
}

.scene-image.active {
  opacity: 1;
  animation: camera-breathe 8s ease-in-out both;
}

@keyframes camera-breathe {
  0% { transform: scale(1.035) translate3d(-0.4%, 0.6%, 0); }
  52% { transform: scale(1.075) translate3d(0.7%, -0.4%, 0); }
  100% { transform: scale(1.055) translate3d(-0.2%, -0.7%, 0); }
}

.scene-vignette {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.48), transparent 24%, transparent 53%, rgba(0, 0, 0, 0.9)),
    radial-gradient(ellipse at center, transparent 38%, rgba(0, 0, 0, 0.55));
  pointer-events: none;
}

.scene-scan {
  position: absolute;
  inset: 0;
  opacity: 0.12;
  background: repeating-linear-gradient(180deg, transparent 0 3px, rgba(177, 226, 255, 0.14) 4px);
  mix-blend-mode: screen;
  pointer-events: none;
}

.scene-signal {
  position: absolute;
  left: -18%;
  right: -18%;
  bottom: 15%;
  height: 1px;
  opacity: var(--signal);
  background: linear-gradient(90deg, transparent, rgb(var(--accent)), #fff, rgb(var(--accent)), transparent);
  box-shadow: 0 0 9px rgba(var(--accent), 0.84), 0 0 28px rgba(var(--accent), 0.45);
  transform: rotate(-2deg);
  animation: signal-sweep 4.8s ease-in-out infinite;
  pointer-events: none;
}

@keyframes signal-sweep {
  0%, 100% { transform: translateX(-9%) rotate(-2deg); opacity: 0.15; }
  48% { transform: translateX(9%) rotate(1deg); opacity: var(--signal); }
}

.chapter-title {
  position: absolute;
  z-index: 3;
  left: 13px;
  right: 13px;
  bottom: 12px;
  text-shadow: 0 2px 12px #000, 0 1px 3px #000;
  pointer-events: none;
}

.chapter-title p,
.chapter-title h1 {
  margin: 0;
}

#eyebrow {
  color: rgb(var(--accent));
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 8px;
  letter-spacing: 0.17em;
  font-weight: 700;
}

.chapter-title h1 {
  max-width: 94%;
  margin-top: 4px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(23px, 7.2vw, 32px);
  line-height: 0.94;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

#kicker {
  margin-top: 6px;
  color: #bdd4df;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 10px;
  font-style: italic;
}

.touch-zone {
  position: absolute;
  z-index: 4;
  top: 0;
  bottom: 0;
  width: 19%;
  border: 0;
  background: transparent;
}

.touch-prev { left: 0; }
.touch-next { right: 0; }

.story-panel {
  position: relative;
  min-height: 0;
  padding: 9px 12px 8px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  background:
    linear-gradient(90deg, rgba(var(--accent), 0.04), transparent 42%),
    rgba(2, 7, 11, 0.96);
  border-bottom: 1px solid rgba(var(--accent), 0.2);
}

.story-panel::-webkit-scrollbar {
  display: none;
}

.story-meta {
  position: sticky;
  top: -9px;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding-block: 7px 5px;
  color: rgb(var(--accent));
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 7px;
  letter-spacing: 0.12em;
  background: linear-gradient(180deg, #03090e 70%, transparent);
}

.story-text {
  margin: 0 0 8px;
  color: #c8d9e0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 11px;
  line-height: 1.36;
  white-space: pre-wrap;
}

.story-progress {
  position: sticky;
  bottom: -8px;
  height: 2px;
  background: rgba(92, 143, 169, 0.16);
}

.story-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, rgb(var(--accent)), rgb(var(--ember)));
  box-shadow: 0 0 8px rgba(var(--accent), 0.8);
}

.kontrol {
  position: relative;
  min-height: 0;
  padding: 7px 10px 8px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% -40%, rgba(var(--accent), 0.12), transparent 68%),
    linear-gradient(180deg, #050d13, #010305);
}

.kontrol::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border: 1px solid rgba(162, 224, 255, 0.06);
  box-shadow: inset 0 0 32px #000;
}

.control-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #7da8be;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 7px;
  letter-spacing: 0.08em;
}

#preset {
  color: rgb(var(--ember));
}

.knobs {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 3px;
  margin-top: 7px;
}

.knob-wrap {
  display: grid;
  justify-items: center;
  gap: 3px;
  min-width: 0;
}

.knob {
  position: relative;
  width: clamp(25px, 8vw, 32px);
  aspect-ratio: 1;
  border: 1px solid rgba(177, 224, 246, 0.62);
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 28%, #2d4552 0 7%, #0d1820 12% 55%, #030608 62%),
    #061019;
  box-shadow:
    inset 0 0 0 3px rgba(95, 145, 171, 0.12),
    0 0 9px rgba(var(--accent), 0.15);
  touch-action: none;
}

.knob::before {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1px dashed rgba(var(--accent), 0.18);
}

.needle {
  position: absolute;
  left: 50%;
  top: 5px;
  width: 1px;
  height: 39%;
  transform-origin: 50% calc(100% + 3px);
  background: rgb(var(--accent));
  box-shadow: 0 0 5px rgb(var(--accent));
}

.knob-label,
.knob-value {
  max-width: 100%;
  overflow: hidden;
  color: #7897a7;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 6px;
  line-height: 1;
  text-overflow: clip;
  white-space: nowrap;
}

.knob-value {
  color: #bdd9e5;
}

.sliders {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin-top: 7px;
}

.slider-wrap {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 4px;
  align-items: center;
  color: #7594a4;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 6px;
}

.slider-wrap input {
  grid-column: 1 / -1;
  width: 100%;
  height: 12px;
  margin: 0;
  accent-color: rgb(var(--accent));
}

.transport {
  min-height: calc(46px + env(safe-area-inset-bottom));
  padding: 5px 7px max(5px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 38px 38px 1fr 38px;
  align-items: center;
  gap: 4px;
  border-top: 1px solid rgba(var(--accent), 0.24);
  background: #010305;
}

.transport button {
  width: 38px;
  height: 36px;
  border: 1px solid rgba(var(--accent), 0.32);
  border-radius: 2px;
  background: rgba(8, 20, 29, 0.8);
  color: #bdd9e7;
  font-size: 18px;
}

.chapter-dots {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  padding-inline: 5px;
}

.chapter-dots button {
  width: auto;
  min-width: 0;
  height: 3px;
  padding: 0;
  border: 0;
  background: rgba(119, 163, 185, 0.26);
}

.chapter-dots button.active {
  background: rgb(var(--accent));
  box-shadow: 0 0 7px rgba(var(--accent), 0.88);
}

.previous {
  position: absolute;
  right: 9px;
  bottom: calc(47px + env(safe-area-inset-bottom));
  z-index: 6;
  color: rgba(155, 193, 211, 0.5);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 6px;
  letter-spacing: 0.09em;
  text-decoration: none;
}

.door {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 48%, rgba(22, 69, 96, 0.24), transparent 29%),
    #000;
  transition: opacity 700ms ease, visibility 700ms step-end;
}

body.entered .door {
  opacity: 0;
  visibility: hidden;
}

.door-ring {
  position: absolute;
  width: min(70vw, 280px);
  aspect-ratio: 1;
  border: 1px solid rgba(165, 226, 255, 0.38);
  border-radius: 50%;
  box-shadow: 0 0 45px rgba(43, 152, 215, 0.22), inset 0 0 35px rgba(43, 152, 215, 0.12);
  animation: door-orbit 12s linear infinite;
}

.door-ring::before,
.door-ring::after,
.door-ring i {
  content: "";
  position: absolute;
  inset: 12%;
  border: 1px solid rgba(143, 213, 246, 0.19);
  border-radius: 50%;
  transform: rotate(58deg) scaleY(0.42);
}

.door-ring::after { transform: rotate(-58deg) scaleY(0.42); }
.door-ring i:nth-child(1) { transform: rotate(90deg) scaleY(0.34); }
.door-ring i:nth-child(2) { transform: rotate(22deg) scaleY(0.55); }
.door-ring i:nth-child(3) { transform: rotate(-22deg) scaleY(0.55); }

@keyframes door-orbit {
  to { transform: rotate(360deg); }
}

.door-copy {
  position: relative;
  z-index: 2;
  width: min(82vw, 330px);
  display: grid;
  justify-items: center;
  text-align: center;
}

.door-copy h2,
.door-copy p {
  margin: 0;
}

.door-copy h2 {
  margin-top: 7px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(42px, 16vw, 72px);
  letter-spacing: 0.08em;
  text-shadow: 0 0 24px rgba(75, 176, 230, 0.32);
}

.door-copy > p:not(.made-by) {
  color: #8ab5c9;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 14px;
  font-style: italic;
}

#enter {
  min-width: 190px;
  min-height: 46px;
  margin-top: 41px;
  border: 1px solid rgba(162, 224, 255, 0.58);
  background: rgba(4, 14, 22, 0.76);
  color: #d8f3ff;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  letter-spacing: 0.16em;
  box-shadow: 0 0 22px rgba(48, 161, 219, 0.12);
}

.door-copy small {
  margin-top: 15px;
  color: #577485;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 9px;
}

@media (max-height: 520px) {
  .instrument {
    grid-template-rows: minmax(186px, 46%) minmax(82px, 23%) minmax(86px, 31%);
  }
  .story-text { font-size: 10px; }
  .knobs { margin-top: 5px; }
  .sliders { margin-top: 4px; }
  .knob { width: 24px; }
  .knob-label, .knob-value { font-size: 5px; }
}

@media (min-width: 700px) {
  .shell {
    margin-top: 2vh;
    height: 96vh;
    border: 1px solid rgba(159, 220, 249, 0.22);
    box-shadow: 0 0 80px rgba(16, 69, 99, 0.18);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
