:root {
  color-scheme: dark;
  --ink: #f5f0d8;
  --muted: #aaa991;
  --violet: #b7a7ff;
  --mint: #d8ff6a;
  --coral: #ff6ab4;
  --void: #080a06;
  --line: rgba(230, 239, 188, .17);
  --safe-top: max(22px, env(safe-area-inset-top));
  --safe-right: max(22px, env(safe-area-inset-right));
  --safe-bottom: max(20px, env(safe-area-inset-bottom));
  --safe-left: max(22px, env(safe-area-inset-left));
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--void);
}

body {
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

button,
a {
  font: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 4px;
}

#experience {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100%;
  height: 100dvh;
  min-height: 520px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 46%, rgba(98, 108, 40, .2), transparent 38%),
    linear-gradient(135deg, #080a06, #11140a 52%, #090b07);
}

#world,
#surfaceTexture {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#surfaceTexture {
  z-index: -1;
  object-fit: cover;
  opacity: 0;
  filter: grayscale(1) sepia(.85) saturate(2.2) hue-rotate(28deg) contrast(1.12) brightness(.44);
  mix-blend-mode: screen;
  transform: scale(1.08);
  transition: opacity 1.4s ease, filter 1.4s ease, transform 7s cubic-bezier(.2, .7, .2, 1);
}

body[data-topology="mobius"] #surfaceTexture {
  opacity: .26;
  transform: scale(1.02) rotate(.25deg);
}

body[data-topology="torus"] #surfaceTexture,
body[data-phase="complete"] #surfaceTexture {
  opacity: .38;
  filter: saturate(1.02) contrast(1.08) brightness(.53);
  transform: scale(1);
}

#world {
  z-index: 0;
  display: block;
  touch-action: none;
  user-select: none;
  cursor: crosshair;
}

.masthead,
.topology-mark,
.progress,
.instruction {
  position: absolute;
  z-index: 4;
  pointer-events: none;
}

.masthead {
  top: var(--safe-top);
  left: var(--safe-left);
  display: flex;
  align-items: center;
  gap: 15px;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  letter-spacing: .18em;
}

.home {
  min-width: 44px;
  min-height: 44px;
  margin: -14px -10px -14px -12px;
  padding: 14px 10px 14px 12px;
  color: var(--ink);
  text-decoration: none;
  pointer-events: auto;
}

.home span {
  color: var(--mint);
}

.date {
  padding-left: 15px;
  color: var(--muted);
  border-left: 1px solid var(--line);
}

.topology-mark {
  top: var(--safe-top);
  right: var(--safe-right);
  display: grid;
  grid-template-columns: auto auto;
  align-items: baseline;
  gap: 10px;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 9px;
  letter-spacing: .15em;
  text-align: right;
}

#topologyNumber {
  color: var(--mint);
  font-size: 18px;
  letter-spacing: -.08em;
}

#topologyName {
  color: var(--muted);
}

.panel {
  position: absolute;
  z-index: 5;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.panel.is-visible {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.intro {
  top: 50%;
  left: clamp(24px, 7vw, 112px);
  width: min(690px, calc(100vw - 48px));
  transform: translateY(-48%);
  transition: opacity .6s ease, visibility .6s;
}

.eyebrow {
  margin: 0 0 20px;
  color: var(--mint);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
}

.intro h1 {
  max-width: 13ch;
  margin: 0;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: clamp(48px, 7.1vw, 104px);
  font-weight: 780;
  letter-spacing: -.075em;
  line-height: .86;
  text-transform: uppercase;
  text-wrap: balance;
}

.lede {
  margin: 28px 0 30px;
  color: #d1cfb8;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(18px, 2vw, 26px);
  line-height: 1.32;
}

.intro button,
.ending button {
  min-width: 190px;
  min-height: 52px;
  padding: 0 20px;
  border: 1px solid rgba(202, 255, 237, .45);
  border-radius: 999px;
  color: #08110e;
  background: var(--mint);
  font-weight: 750;
  letter-spacing: -.015em;
  cursor: pointer;
  box-shadow: 0 12px 44px rgba(93, 255, 206, .13);
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}

.intro button:hover,
.ending button:hover {
  transform: translateY(-2px);
  background: #a7ffe4;
  box-shadow: 0 16px 48px rgba(93, 255, 206, .2);
}

.intro button span {
  display: inline-block;
  margin-left: 20px;
}

.input-note {
  margin: 16px 0 0;
  color: #7f7a96;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 9px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.chapter {
  top: 50%;
  left: 50%;
  width: min(700px, calc(100vw - 48px));
  transform: translate(-50%, -48%);
  text-align: center;
  transition: opacity .45s ease, visibility .45s;
}

.chapter::before {
  content: "";
  position: absolute;
  inset: -18vh -16vw;
  z-index: -1;
  background: radial-gradient(circle, rgba(8, 10, 6, .95), rgba(8, 10, 6, .67) 45%, transparent 72%);
}

.chapter p {
  margin: 0 0 16px;
  color: var(--mint);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .22em;
}

.chapter h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(38px, 6vw, 86px);
  font-weight: 400;
  letter-spacing: -.055em;
  line-height: .95;
  text-wrap: balance;
}

.instruction {
  bottom: var(--safe-bottom);
  left: var(--safe-left);
  display: flex;
  flex-direction: column;
  max-width: min(520px, calc(100vw - 48px));
  gap: 5px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .45s ease, transform .45s ease;
}

body[data-phase="aim"] .instruction,
body[data-phase="moving"] .instruction {
  opacity: 1;
  transform: none;
}

#instructionMain {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(17px, 2vw, 23px);
}

#instructionSub {
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 9px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.progress {
  right: var(--safe-right);
  bottom: var(--safe-bottom);
  width: 220px;
  text-align: right;
}

.progress-label {
  color: #77728a;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 8px;
  letter-spacing: .18em;
}

.progress ol {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.progress li {
  position: relative;
  height: 16px;
  border-top: 1px solid rgba(255,255,255,.16);
}

.progress li::before {
  content: "";
  position: absolute;
  top: -2px;
  right: 0;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #514d62;
}

.progress li span {
  display: block;
  margin-top: 5px;
  color: #77728a;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 7px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.progress li.is-current,
.progress li.is-done {
  border-color: rgba(130, 255, 216, .56);
}

.progress li.is-current::before,
.progress li.is-done::before {
  background: var(--mint);
  box-shadow: 0 0 10px var(--mint);
}

.progress li.is-current span {
  color: var(--ink);
}

.ending {
  top: 50%;
  left: clamp(24px, 8vw, 120px);
  width: min(600px, calc(100vw - 48px));
  transform: translateY(-48%);
  transition: opacity .8s ease, visibility .8s;
}

.ending h2 {
  margin: 0;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: clamp(44px, 6.2vw, 88px);
  font-weight: 780;
  letter-spacing: -.07em;
  line-height: .9;
  text-transform: uppercase;
}

.ending > p:not(.eyebrow) {
  max-width: 45ch;
  margin: 26px 0 30px;
  color: #cfceb9;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(17px, 1.8vw, 22px);
  line-height: 1.45;
}

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

noscript {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  color: white;
  background: #080a06;
  text-align: center;
}

@media (max-width: 700px) {
  #experience {
    min-height: 480px;
  }

  .masthead {
    gap: 10px;
  }

  .date {
    padding-left: 10px;
  }

  .topology-mark {
    grid-template-columns: 1fr;
    gap: 0;
  }

  #topologyName {
    max-width: 92px;
    line-height: 1.3;
  }

  .intro {
    top: 47%;
  }

  .intro h1 {
    max-width: 10ch;
    font-size: clamp(44px, 13vw, 70px);
    line-height: .88;
  }

  .lede {
    margin: 23px 0 25px;
  }

  .progress {
    bottom: calc(var(--safe-bottom) + 54px);
    width: 156px;
  }

  .progress li span,
  .progress-label {
    display: none;
  }

  .instruction {
    max-width: calc(100vw - 190px);
  }

  #instructionSub {
    display: none;
  }

  .ending {
    top: 48%;
  }

  .ending h2 {
    font-size: clamp(42px, 13vw, 64px);
  }
}

@media (max-height: 620px) and (orientation: landscape) {
  .intro {
    top: 52%;
  }

  .intro h1 {
    font-size: clamp(50px, 11vh, 78px);
    line-height: .84;
  }

  .eyebrow,
  .lede {
    margin-bottom: 13px;
  }

  .lede {
    margin-top: 15px;
    font-size: 17px;
  }

  .input-note {
    display: none;
  }
}

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

  #surfaceTexture {
    transform: none !important;
  }
}
