:root {
  color-scheme: dark;
  --ink: #071413;
  --ink-soft: #102421;
  --bone: #e8dec2;
  --bone-dim: #aca58e;
  --bronze: #c58a4a;
  --bronze-hot: #e2b06c;
  --blood: #7c281d;
  --foam: #dcebdc;
  --line: color-mix(in oklab, var(--bone) 24%, transparent);
  --safe-top: max(20px, env(safe-area-inset-top));
  --safe-right: max(24px, env(safe-area-inset-right));
  --safe-bottom: max(20px, env(safe-area-inset-bottom));
  --safe-left: max(24px, env(safe-area-inset-left));
}

* { box-sizing: border-box; }

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

body {
  color: var(--bone);
  font-family: "Avenir Next Condensed", "Gill Sans", sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

button,
input { font: inherit; }

button { -webkit-tap-highlight-color: transparent; }

#experience,
#viewport,
#viewport canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

#viewport canvas {
  display: block;
  touch-action: none;
  cursor: grab;
}

#viewport canvas:active { cursor: grabbing; }

.hud {
  position: fixed;
  z-index: 5;
  opacity: 0;
  transition: opacity 900ms cubic-bezier(.16, 1, .3, 1), transform 900ms cubic-bezier(.16, 1, .3, 1);
  pointer-events: none;
}

body.is-ready .hud { opacity: 1; }
body.ui-hidden .hud { opacity: 0 !important; pointer-events: none !important; }

.eyebrow {
  margin: 0 0 5px;
  color: var(--bronze-hot);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .28em;
  line-height: 1.4;
  text-transform: uppercase;
}

.masthead {
  top: var(--safe-top);
  left: var(--safe-left);
  right: var(--safe-right);
  display: flex;
  align-items: start;
  justify-content: space-between;
  transform: translateY(-12px);
}

body.is-ready .masthead { transform: translateY(0); }

.masthead h1 {
  margin: 0;
  color: var(--bone);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, serif;
  font-size: clamp(30px, 3.5vw, 58px);
  font-weight: 500;
  letter-spacing: -.035em;
  line-height: .92;
  text-shadow: 0 2px 22px rgba(3, 10, 9, .7);
}

.masthead__subtitle {
  margin: 7px 0 0 2px;
  color: var(--bone-dim);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, serif;
  font-size: 12px;
  font-style: italic;
  letter-spacing: .07em;
}

.telemetry {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-top: 4px;
  color: var(--bone-dim);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .19em;
}

.telemetry strong { color: var(--foam); font-weight: 700; }

.telemetry__pulse {
  width: 5px;
  height: 5px;
  background: #9dcf9e;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(157, 207, 158, .12);
  animation: pulse 2.2s ease-in-out infinite;
}

.telemetry__divider { width: 24px; height: 1px; background: var(--line); }

.readout {
  top: 35%;
  left: var(--safe-left);
  width: min(228px, 28vw);
  transform: translateX(-10px);
}

body.is-ready .readout { transform: translateX(0); }

.readout__line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
  color: var(--bronze-hot);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .2em;
}

.readout__line i { width: 32px; height: 1px; background: var(--bronze); }

.readout dl { display: grid; gap: 8px; margin: 0; }
.readout dl div { display: flex; justify-content: space-between; gap: 12px; }
.readout dt { color: var(--bone-dim); font-size: 10px; letter-spacing: .06em; }
.readout dd { margin: 0; color: var(--bone); font-size: 10px; letter-spacing: .04em; }
.readout dd strong { font-size: 12px; font-weight: 600; }

.danger-scale {
  width: 100%;
  height: 2px;
  margin: 16px 0 9px;
  overflow: hidden;
  background: color-mix(in oklab, var(--bone) 16%, transparent);
}

.danger-scale span {
  display: block;
  width: 72%;
  height: 100%;
  background: linear-gradient(90deg, var(--bronze), #b74431);
  transform-origin: left;
  transition: width 300ms ease-out;
}

.readout > p {
  margin: 0;
  color: var(--bone-dim);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, serif;
  font-size: 10px;
  font-style: italic;
  line-height: 1.45;
}

.vortex-label {
  top: 48%;
  right: 17%;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--bone);
  opacity: .58;
}

body.is-ready .vortex-label { opacity: .58; }
.vortex-label > span { width: 38px; height: 1px; background: var(--line); }
.vortex-label p { margin: 0; }
.vortex-label b { display: block; font-family: "Iowan Old Style", serif; font-size: 10px; letter-spacing: .18em; }
.vortex-label small { display: block; margin-top: 3px; color: var(--bronze-hot); font-size: 7px; letter-spacing: .18em; }

.helm {
  right: var(--safe-right);
  bottom: var(--safe-bottom);
  width: min(410px, calc(100vw - 48px));
  padding: 16px 18px 13px;
  background: linear-gradient(100deg, rgba(8, 20, 18, .72), rgba(8, 20, 18, .4));
  border-top: 1px solid var(--line);
  pointer-events: auto;
  transform: translateY(12px);
  backdrop-filter: blur(9px) saturate(.8);
}

body.is-ready .helm { transform: translateY(0); }
.helm__caption { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.helm__caption output { color: var(--bone); font-family: "Iowan Old Style", serif; font-size: 12px; font-style: italic; }
.helm__controls { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; margin-top: 8px; }

.helm button,
.view-switcher button {
  color: var(--bone);
  background: none;
  border: 0;
  cursor: pointer;
}

.helm button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 4px;
  color: var(--bronze-hot);
  font-size: 11px;
  font-weight: 800;
}

.helm button span { color: var(--bone-dim); font-size: 7px; letter-spacing: .14em; }
.helm button:hover,
.helm button:focus-visible { color: var(--bone); }
.helm button:active { transform: translateY(1px); }

.rudder { position: relative; display: grid; place-items: center; height: 20px; }
.rudder::before { content: ""; position: absolute; inset: 9px 0 auto; height: 1px; background: var(--line); }
.rudder::after { content: ""; position: absolute; left: 50%; top: 5px; width: 1px; height: 9px; background: var(--bone-dim); }
.rudder input { position: relative; z-index: 2; width: 100%; height: 20px; margin: 0; opacity: 0; cursor: ew-resize; }
.rudder__wake { position: absolute; z-index: 1; left: 50%; top: 6px; width: 26px; height: 7px; background: var(--bronze-hot); clip-path: polygon(0 50%, 100% 0, 88% 50%, 100% 100%); transform: translateX(-50%); transition: transform 90ms linear; }

.helm__hint { margin: 3px 0 0; color: var(--bone-dim); font-size: 8px; letter-spacing: .13em; text-align: center; text-transform: uppercase; }

.view-switcher {
  left: var(--safe-left);
  bottom: var(--safe-bottom);
  display: flex;
  gap: 22px;
  pointer-events: auto;
  transform: translateY(10px);
}

body.is-ready .view-switcher { transform: translateY(0); }

.view-switcher button {
  display: grid;
  grid-template-columns: 22px auto;
  grid-template-rows: auto auto;
  column-gap: 7px;
  padding: 4px 0;
  text-align: left;
}

.view-switcher__icon { grid-row: 1 / span 2; align-self: center; color: var(--bronze-hot); font-size: 15px; }
.view-switcher b { font-size: 9px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.view-switcher small { color: var(--bone-dim); font-size: 8px; }
.view-switcher button:hover b,
.view-switcher button:focus-visible b { color: var(--bronze-hot); }

.reticle { top: 50%; left: 50%; width: 28px; height: 28px; transform: translate(-50%, -50%); opacity: .3; }
body.is-ready .reticle { opacity: .3; }
.reticle::before,
.reticle::after { content: ""; position: absolute; background: var(--bone); }
.reticle::before { left: 13px; top: 0; width: 1px; height: 28px; }
.reticle::after { left: 0; top: 13px; width: 28px; height: 1px; }
.reticle span { position: absolute; inset: 8px; border: 1px solid var(--bone); border-radius: 50%; background: rgba(7, 20, 19, .25); }

.vignette {
  position: fixed;
  z-index: 3;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 43%, transparent 32%, rgba(4, 10, 9, .12) 72%, rgba(3, 8, 7, .57) 130%),
    linear-gradient(180deg, rgba(4, 10, 9, .21), transparent 26%, transparent 72%, rgba(4, 10, 9, .29));
}

.cinematic-bars::before,
.cinematic-bars::after { content: ""; position: fixed; z-index: 4; left: 0; width: 100%; height: 0; background: #020706; transition: height 800ms cubic-bezier(.16, 1, .3, 1); pointer-events: none; }
.cinematic-bars::before { top: 0; }
.cinematic-bars::after { bottom: 0; }
body.cinematic .cinematic-bars::before,
body.cinematic .cinematic-bars::after { height: 3.2vh; }

#loading,
.failure {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 30px;
  background:
    radial-gradient(circle at 50% 45%, rgba(30, 67, 61, .54), transparent 40%),
    var(--ink);
  text-align: center;
  transition: opacity 900ms cubic-bezier(.16, 1, .3, 1), visibility 900ms;
}

#loading.is-done { opacity: 0; visibility: hidden; }

.loading__mark { position: relative; width: 72px; height: 72px; margin-bottom: 27px; animation: rotate 5s linear infinite; }
.loading__mark span { position: absolute; inset: 0; border: 1px solid color-mix(in oklab, var(--bronze) 62%, transparent); border-radius: 50%; }
.loading__mark span:nth-child(2) { inset: 10px; border-style: dashed; animation: reverseRotate 3.4s linear infinite; }
.loading__mark span:nth-child(3) { inset: 25px; background: var(--bronze); border: 0; box-shadow: 0 0 30px rgba(197, 138, 74, .35); }

#loading h1,
.failure h1 { margin: 0; color: var(--bone); font-family: "Iowan Old Style", "Palatino Linotype", serif; font-size: clamp(42px, 8vw, 92px); font-weight: 400; letter-spacing: .12em; line-height: 1; }
#loading-status { margin: 16px 0; color: var(--bone-dim); font-family: "Iowan Old Style", serif; font-size: 12px; font-style: italic; letter-spacing: .04em; }
.loading__track { width: min(280px, 70vw); height: 1px; overflow: hidden; background: var(--line); }
.loading__track i { display: block; width: 8%; height: 100%; background: var(--bronze-hot); transition: width 600ms cubic-bezier(.16, 1, .3, 1); }

.failure[hidden] { display: none; }
.failure h1 { max-width: 750px; font-size: clamp(32px, 5vw, 68px); letter-spacing: -.02em; }
.failure > p:not(.eyebrow) { max-width: 520px; margin: 20px 0; color: var(--bone-dim); font-family: "Iowan Old Style", serif; line-height: 1.6; }
.failure a { color: var(--bronze-hot); font-size: 11px; font-weight: 700; letter-spacing: .12em; text-decoration: none; text-transform: uppercase; }

.lil-gui.lil-root {
  --background-color: rgba(8, 20, 18, .82);
  --widget-color: rgba(232, 222, 194, .1);
  --hover-color: rgba(232, 222, 194, .16);
  --focus-color: rgba(197, 138, 74, .24);
  --text-color: #e8dec2;
  --number-color: #e2b06c;
  --string-color: #c8d6c8;
  --font-size: 10px;
  --input-font-size: 10px;
  --font-family: "Avenir Next Condensed", "Gill Sans", sans-serif;
  z-index: 10;
  top: 94px;
  right: var(--safe-right);
  border-top: 1px solid rgba(197, 138, 74, .5);
  backdrop-filter: blur(12px) saturate(.7);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(12px);
  transition: opacity 450ms ease, transform 450ms cubic-bezier(.16, 1, .3, 1), visibility 450ms;
}

body.controls-open .lil-gui.lil-root { opacity: 1; visibility: visible; pointer-events: auto; transform: translateX(0); }
.lil-gui .lil-title { color: var(--bronze-hot); font-size: 9px; letter-spacing: .15em; text-transform: uppercase; }

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

@keyframes rotate { to { transform: rotate(360deg); } }
@keyframes reverseRotate { to { transform: rotate(-720deg); } }
@keyframes pulse { 50% { opacity: .45; transform: scale(.75); } }

@media (max-width: 760px) {
  :root { --safe-left: max(16px, env(safe-area-inset-left)); --safe-right: max(16px, env(safe-area-inset-right)); }
  .masthead__subtitle,
  .telemetry__divider,
  #quality-label,
  .vortex-label,
  .reticle { display: none; }
  .readout { top: 29%; width: 164px; }
  .readout dl div:nth-child(2) { display: none; }
  .helm { left: var(--safe-left); right: var(--safe-right); bottom: var(--safe-bottom); width: auto; }
  .view-switcher { top: calc(var(--safe-top) + 63px); bottom: auto; left: auto; right: var(--safe-right); }
  .view-switcher button { grid-template-columns: 19px auto; }
  .view-switcher button small { display: none; }
  .lil-gui.lil-root { top: 116px; right: var(--safe-right); max-width: calc(100vw - 32px); }
}

@media (max-height: 620px) and (orientation: landscape) {
  .readout { display: none; }
  .helm { right: var(--safe-right); bottom: 12px; width: 340px; padding-block: 10px 8px; }
  .view-switcher { bottom: 16px; }
  .masthead h1 { font-size: 31px; }
}

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

@media (pointer: coarse) {
  .helm button { min-width: 54px; min-height: 44px; }
  .view-switcher button { min-height: 44px; }
}
