@font-face {
  font-family: "Unbounded";
  src: url("../fonts/unbounded-200.woff2") format("woff2");
  font-weight: 200;
  font-display: swap;
}

@font-face {
  font-family: "Unbounded";
  src: url("../fonts/unbounded-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Unbounded";
  src: url("../fonts/unbounded-900.woff2") format("woff2");
  font-weight: 900;
  font-display: swap;
}

:root {
  --bg: #0a0a0b;
  --fg: #f5f5f6;
  --muted: rgba(245, 245, 246, 0.62);
  --faint: rgba(245, 245, 246, 0.38);
  --line: rgba(245, 245, 246, 0.14);
  --surface: rgba(16, 16, 18, 0.86);
  --surface-solid: #111113;
  --focus: rgba(245, 245, 246, 0.9);
  --radius: 14px;
  --gutter: max(16px, env(safe-area-inset-left));
  --gutter-right: max(16px, env(safe-area-inset-right));
  --top: max(14px, env(safe-area-inset-top));
  --bottom: max(16px, env(safe-area-inset-bottom));
  --font: "Unbounded", system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

a {
  color: inherit;
}

button {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

#stage.is-dragging {
  cursor: grabbing;
}

#stage.is-pointing {
  cursor: pointer;
}

.intro {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: var(--top) var(--gutter-right) var(--bottom) var(--gutter);
  text-align: center;
  background: radial-gradient(120% 80% at 50% 50%, rgba(10, 10, 11, 0.55), rgba(10, 10, 11, 0.95) 70%);
  transition: opacity 0.9s var(--ease), visibility 0.9s;
}

.intro.is-leaving {
  opacity: 0;
  visibility: hidden;
}

.intro-logo {
  width: 64px;
  height: 64px;
}

.intro-title {
  margin: 0;
  font-weight: 200;
  font-size: clamp(2.6rem, 11vw, 6.5rem);
  letter-spacing: 0.02em;
  line-height: 1;
}

.intro-text {
  margin: 0;
  max-width: 34rem;
  color: var(--muted);
  font-size: clamp(0.78rem, 2.6vw, 0.95rem);
  line-height: 1.7;
}

.intro-start {
  margin-top: 18px;
  min-width: 180px;
  padding: 16px 40px;
  border: 1px solid var(--fg);
  border-radius: 999px;
  background: transparent;
  font-weight: 400;
  font-size: 0.95rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.3s var(--ease), color 0.3s var(--ease), opacity 0.3s;
}

.intro-start:hover:not(:disabled),
.intro-start:focus-visible {
  background: var(--fg);
  color: var(--bg);
}

a.intro-start {
  color: var(--fg);
  text-decoration: none;
  letter-spacing: 0.18em;
}

.not-found {
  touch-action: auto;
}

.intro-start:disabled {
  opacity: 0.35;
  cursor: progress;
}

.intro-hint {
  margin: 0;
  color: var(--faint);
  font-size: 0.7rem;
  line-height: 1.6;
  max-width: 26rem;
}

.intro-footer {
  position: absolute;
  bottom: var(--bottom);
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 24px;
  font-size: 0.68rem;
  color: var(--faint);
}

.intro-footer a {
  text-decoration: none;
}

.intro-footer a:hover,
.link-button:hover {
  color: var(--fg);
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-size: inherit;
  cursor: pointer;
}

.hud-top {
  position: fixed;
  top: var(--top);
  left: var(--gutter);
  right: var(--gutter-right);
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.hud-top > * {
  pointer-events: auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

.brand img {
  width: 28px;
  height: 28px;
}

.hud-actions {
  display: flex;
  gap: 8px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(10, 10, 11, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.icon-button:hover {
  border-color: var(--faint);
  background: rgba(30, 30, 33, 0.7);
}

.icon-sound-off,
.icon-button[aria-pressed="true"] .icon-sound-on {
  display: none;
}

.icon-button[aria-pressed="true"] .icon-sound-off {
  display: block;
}

.hud-zone {
  position: fixed;
  left: var(--gutter);
  bottom: var(--bottom);
  z-index: 10;
  max-width: 40vw;
  color: var(--muted);
  font-size: 0.66rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  pointer-events: none;
}

.hud-scale {
  position: fixed;
  left: 50%;
  bottom: var(--bottom);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transform: translateX(-50%);
  pointer-events: none;
  text-align: center;
}

.ruler {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
}

.ruler-bar {
  display: block;
  height: 7px;
  border: 1px solid var(--muted);
  border-top: 0;
  transition: width 0.12s linear;
}

.ruler-label {
  color: var(--muted);
  font-size: 0.62rem;
}

.scale-readout {
  font-weight: 200;
  font-size: clamp(1.3rem, 4.6vw, 2rem);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.scale-power {
  color: var(--faint);
  font-size: 0.64rem;
}

.rail {
  position: fixed;
  top: calc(var(--top) + 64px);
  bottom: calc(var(--bottom) + 96px);
  right: var(--gutter-right);
  z-index: 10;
  width: 44px;
}

.rail-track {
  position: absolute;
  inset: 0;
  cursor: ns-resize;
  touch-action: none;
}

.rail-track::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  right: 10px;
  width: 1px;
  background: var(--line);
}

.rail-ticks {
  position: absolute;
  inset: 0;
}

.rail-tick {
  position: absolute;
  right: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  transform: translateY(-50%);
  color: var(--faint);
  font-size: 0.56rem;
  white-space: nowrap;
  pointer-events: none;
}

.rail-tick::after {
  content: "";
  width: 9px;
  height: 1px;
  background: var(--faint);
}

.rail-tick span {
  opacity: 0;
  transition: opacity 0.25s;
}

.rail:hover .rail-tick span,
.rail-track:focus-visible .rail-tick span,
.rail.is-active .rail-tick span {
  opacity: 1;
}

.rail-thumb {
  position: absolute;
  right: 4px;
  width: 13px;
  height: 13px;
  border: 1.5px solid var(--fg);
  border-radius: 50%;
  background: var(--bg);
  transform: translateY(-50%);
  pointer-events: none;
}

.hud-hint {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bottom) + 104px);
  z-index: 10;
  margin: 0;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.66rem;
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
  transition: opacity 0.8s;
}

.hud-hint.is-fading {
  opacity: 0;
}

.beyond {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 12;
  width: min(560px, calc(100vw - 104px));
  padding: 28px 24px;
  transform: translate(-50%, -54%);
  text-align: center;
  pointer-events: none;
  background: radial-gradient(closest-side, rgba(10, 10, 11, 0.92), rgba(10, 10, 11, 0.6) 70%, rgba(10, 10, 11, 0));
}

.beyond-status {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.beyond-title {
  margin: 0 0 16px;
  font-weight: 200;
  font-size: clamp(1.4rem, 5vw, 2.3rem);
}

.beyond-text {
  margin: 0 auto;
  max-width: 34rem;
  color: var(--fg);
  font-size: clamp(0.76rem, 2.4vw, 0.9rem);
  line-height: 1.8;
}

.beyond-refs {
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.6rem;
  line-height: 1.6;
  color: var(--faint);
}

.beyond-refs a {
  color: var(--muted);
}

.beyond.is-readable .beyond-refs a {
  pointer-events: auto;
}

.beyond-note {
  margin: 18px 0 0;
  color: var(--faint);
  font-size: 0.58rem;
}

.panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  width: min(420px, 100vw);
  border-left: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transform: translateX(0);
  animation: panel-in 0.45s var(--ease);
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

@keyframes panel-in {
  from {
    transform: translateX(40px);
    opacity: 0;
  }
}

.panel-inner {
  position: relative;
  padding: calc(var(--top) + 10px) var(--gutter-right) calc(var(--bottom) + 24px) 28px;
}

.panel-close {
  position: absolute;
  top: calc(var(--top) + 4px);
  right: var(--gutter-right);
}

.panel-category {
  margin: 6px 0 10px;
  color: var(--muted);
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.panel-title {
  margin: 0 56px 10px 0;
  font-weight: 400;
  font-size: 1.32rem;
  line-height: 1.3;
}

.panel-size {
  margin: 0;
  font-weight: 200;
  font-size: 1.6rem;
}

.panel-measure {
  margin: 6px 0 18px;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.6;
}

.panel-figure {
  margin: 0 0 18px;
}

.panel-figure img {
  display: block;
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
}

.panel-figure figcaption {
  margin-top: 8px;
  color: var(--faint);
  font-size: 0.58rem;
  line-height: 1.6;
}

.panel-figure figcaption a {
  color: var(--muted);
}

.panel-summary {
  margin: 0 0 18px;
  font-size: 0.78rem;
  line-height: 1.8;
}

.panel-facts {
  margin: 0 0 22px;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 12px;
}

.panel-facts li {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.72rem;
  line-height: 1.75;
}

.cite {
  margin-left: 3px;
  color: var(--muted);
  font-size: 0.6rem;
  text-decoration: none;
  vertical-align: super;
}

.cite:hover {
  color: var(--fg);
}

.panel-heading {
  margin: 0 0 10px;
  color: var(--muted);
  font-weight: 400;
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.panel-refs,
.dive-refs {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.6rem;
  line-height: 1.7;
}

.panel-refs a,
.dive-refs a {
  color: var(--fg);
  text-decoration-color: var(--faint);
  word-break: break-word;
}

.primary-button,
.secondary-button {
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 0.25s, color 0.25s, border-color 0.25s;
}

.primary-button {
  width: 100%;
  margin: 0 0 22px;
  border: 1px solid var(--fg);
  background: var(--fg);
  color: var(--bg);
}

.primary-button:hover {
  background: transparent;
  color: var(--fg);
}

.secondary-button {
  border: 1px solid var(--line);
  background: rgba(10, 10, 11, 0.6);
}

.secondary-button:hover,
.secondary-button[aria-pressed="true"] {
  border-color: var(--fg);
}

.dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: min(80vh, 760px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-solid);
  color: var(--fg);
  overflow: hidden;
}

.dialog-wide {
  width: min(860px, calc(100vw - 32px));
}

.dialog::backdrop {
  background: rgba(5, 5, 6, 0.7);
  backdrop-filter: blur(4px);
}

.dialog-inner {
  display: flex;
  flex-direction: column;
  max-height: min(80vh, 760px);
  padding: 20px 22px 22px;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.dialog-head h2 {
  margin: 0;
  font-weight: 400;
  font-size: 1rem;
}

.search input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 0.82rem;
}

.search input:focus {
  outline: none;
  border-color: var(--faint);
}

.search-results {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  touch-action: pan-y;
}

.search-results button {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-radius: 10px;
  background: none;
  text-align: left;
  cursor: pointer;
}

.search-results button:hover,
.search-results button:focus-visible,
.search-results button[aria-selected="true"] {
  background: rgba(245, 245, 246, 0.07);
  outline: none;
}

.search-name {
  font-size: 0.78rem;
}

.search-meta {
  grid-column: 1;
  color: var(--faint);
  font-size: 0.6rem;
}

.search-size {
  grid-row: 1 / span 2;
  grid-column: 2;
  align-self: center;
  color: var(--muted);
  font-size: 0.66rem;
  white-space: nowrap;
}

.credits {
  overflow-y: auto;
  padding-right: 6px;
  font-size: 0.66rem;
  line-height: 1.7;
  touch-action: pan-y;
}

.credits h3 {
  margin: 22px 0 8px;
  color: var(--muted);
  font-weight: 400;
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.credits h3:first-of-type {
  margin-top: 4px;
}

.credits p {
  margin: 0 0 10px;
  color: var(--muted);
}

.credits ul,
.credits ol {
  margin: 0;
  padding-left: 18px;
}

.credits li {
  margin-bottom: 6px;
}

.credits a {
  color: var(--fg);
  text-decoration-color: var(--faint);
  word-break: break-word;
}

.dive {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: #000;
  animation: fade-in 0.8s var(--ease);
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

#dive-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.dive-top {
  position: absolute;
  top: var(--top);
  left: var(--gutter);
  right: var(--gutter-right);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dive-title {
  margin: 0;
  font-weight: 200;
  font-size: clamp(0.9rem, 3.4vw, 1.3rem);
  text-align: center;
}

.dive-card {
  position: absolute;
  left: var(--gutter);
  top: calc(var(--top) + 70px);
  width: min(380px, calc(100vw - 32px));
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(8, 8, 9, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.dive-card,
.dive-readout {
  touch-action: pan-y;
}

.dive-stage {
  margin: 0 0 8px;
  font-size: 0.9rem;
}

.dive-text {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.75;
}

.dive-readout {
  position: absolute;
  right: var(--gutter-right);
  top: calc(var(--top) + 70px);
  display: grid;
  grid-template-columns: auto auto;
  gap: 6px 14px;
  margin: 0;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(8, 8, 9, 0.72);
  font-size: 0.64rem;
}

.dive-readout dt {
  color: var(--muted);
}

.dive-readout dd {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.dive-slider {
  position: absolute;
  left: 50%;
  bottom: calc(var(--bottom) + 30px);
  width: min(520px, calc(100vw - 48px));
  transform: translateX(-50%);
  accent-color: var(--fg);
}

.dive-model {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--bottom);
  margin: 0;
  padding: 0 var(--gutter);
  color: var(--faint);
  font-size: 0.56rem;
  text-align: center;
}

.noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  font-size: 0.9rem;
}

@media (min-width: 721px) {
  .panel-open .hud-top,
  .panel-open .rail {
    right: calc(420px + var(--gutter-right));
  }

  .panel-open .hud-scale {
    left: calc((100vw - 420px) / 2);
  }

  .hud-top,
  .rail,
  .hud-scale {
    transition: right 0.45s var(--ease), left 0.45s var(--ease);
  }
}

@media (max-width: 720px) {
  .panel-open .rail,
  .panel-open .hud-scale,
  .panel-open .hud-zone,
  .panel-open .hud-hint {
    display: none;
  }

  .rail {
    width: 30px;
    bottom: calc(var(--bottom) + 112px);
  }

  .rail-tick span {
    display: none;
  }

  .hud-zone {
    bottom: auto;
    top: calc(var(--top) + 52px);
    max-width: 70vw;
  }

  .panel {
    top: auto;
    left: 0;
    width: 100%;
    max-height: 64vh;
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: 20px 20px 0 0;
    animation-name: sheet-in;
  }

  .panel-inner {
    padding-left: var(--gutter);
    padding-top: 22px;
  }

  .panel-close {
    top: 16px;
  }

  .beyond {
    width: calc(100vw - 72px);
  }

  .dive-card {
    top: auto;
    bottom: calc(var(--bottom) + 76px);
    max-height: 34vh;
    overflow-y: auto;
  }

  .dive-readout {
    left: var(--gutter);
    right: var(--gutter-right);
    top: calc(var(--top) + 58px);
    grid-template-columns: auto auto auto auto;
    font-size: 0.56rem;
    padding: 10px 12px;
  }
}

@keyframes sheet-in {
  from {
    transform: translateY(40px);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
