:root {
  color-scheme: dark;
  --black: #000;
  --white: #f4f4f2;
  --phi: #ad0000;
  --muted: #818181;
}

* { box-sizing: border-box; }

html { background: var(--black); }

body {
  margin: 0;
  min-width: 20rem;
  overflow-x: hidden;
  background: var(--black);
  color: var(--white);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, a { font: inherit; }

.orbit-stage {
  position: relative;
  min-height: 100svh;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 50% 64%, rgba(12, 33, 47, .16), transparent 32%),
    var(--black);
}

.orbit-stage::after {
  content: "";
  position: absolute;
  z-index: 2;
  right: 0;
  bottom: -1px;
  left: 0;
  height: clamp(7rem, 16vh, 12rem);
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0%,
    rgba(0, 0, 0, .16) 24%,
    rgba(0, 0, 0, .72) 72%,
    var(--black) 100%
  );
  pointer-events: none;
}

.brand-banner {
  position: absolute;
  z-index: 6;
  top: 50%;
  left: 50%;
  width: min(63vw, 55rem);
  height: auto;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: top 1.8s cubic-bezier(.2,.8,.2,1), transform 1.8s cubic-bezier(.2,.8,.2,1), opacity 1.15s ease;
  pointer-events: none;
  user-select: none;
}

.earth {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 0;
  transform: translateY(100%);
  transition: transform 1.8s cubic-bezier(.2,.8,.2,1), opacity 1.15s ease;
  pointer-events: none;
  user-select: none;
}

.game-mount {
  position: absolute;
  z-index: 3;
  inset: 0;
  opacity: 0;
  transition: opacity 1.1s ease;
}

.game-mount canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.orbit-stage.ready .game-mount { opacity: 1; }

.hud {
  position: absolute;
  z-index: 5;
  bottom: max(1.2rem, env(safe-area-inset-bottom));
  left: max(1.1rem, env(safe-area-inset-left));
  width: auto;
  max-width: calc(100vw - max(2.2rem, env(safe-area-inset-left) + env(safe-area-inset-right)));
  opacity: 0;
  transition: opacity 1s ease;
  font: 500 .68rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .1em;
  text-transform: uppercase;
  text-align: left;
  color: rgba(244,244,242,.72);
}

.orbit-stage.ready .hud { opacity: 1; }

.hud-level {
  margin-bottom: .5rem;
  color: rgba(244,244,242,.88);
}

.hud-meter { margin-top: .48rem; }

.hud-track {
  width: 1.65rem;
  max-width: 100%;
  height: .58rem;
  background: rgba(244,244,242,.16);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(244,244,242,.08);
}

.hud-fill {
  height: 100%;
  transition: width .4s ease;
}

.hud-progress-fill {
  width: 0;
  background: #f2c94c;
}

.hud-progress-track {
  background: rgba(242,201,76,.16);
  box-shadow: inset 0 0 0 1px rgba(242,201,76,.2);
}

.hud-stamina-track {
  width: 1.5rem;
  transition: width .35s ease, box-shadow .25s ease;
}

.hud-stamina-fill {
  width: 100%;
  background: #2db7ff;
  box-shadow: 0 0 .65rem rgba(45,183,255,.4);
  transition: none;
}

.hud.exhausted .hud-stamina-track {
  box-shadow: inset 0 0 0 1px rgba(255,192,72,.55), 0 0 .7rem rgba(255,154,46,.22);
}

.tier-banner {
  position: absolute;
  z-index: 7;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  text-align: center;
  font: 600 .95rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--white);
  text-shadow: 0 0 1.2rem rgba(0,0,0,.9);
  opacity: 0;
  pointer-events: none;
  transition: opacity .6s ease;
  white-space: nowrap;
}

.tier-banner.show { opacity: 1; }

.controls-hint {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: max(1.2rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  margin: 0;
  color: rgba(244,244,242,.66);
  font: 500 .72rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .1em;
  text-align: center;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 1s ease;
  white-space: nowrap;
}

.skip-intro {
  position: absolute;
  z-index: 8;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  padding: .6rem .7rem;
  border: 0;
  color: rgba(244,244,242,.48);
  background: transparent;
  font-size: .8rem;
  letter-spacing: .08em;
  cursor: pointer;
}

.skip-intro:hover,
.skip-intro:focus-visible { color: var(--white); }
.skip-intro:focus-visible { outline: 1px solid var(--phi); outline-offset: 3px; }

.orbit-stage.show-title .brand-banner { opacity: 1; }

.orbit-stage.framed .brand-banner {
  top: max(1rem, env(safe-area-inset-top));
  transform: translate(-50%, 0);
}

.orbit-stage.framed .earth {
  opacity: 1;
  transform: translateY(0);
}

.orbit-stage.ready .controls-hint { opacity: 1; }
.orbit-stage.ready .skip-intro { display: none; }

.touch-controls,
.touch-controls-hint { display: none; }

.touch-controls {
  position: absolute;
  z-index: 8;
  right: max(1.1rem, env(safe-area-inset-right));
  bottom: max(3.5rem, calc(env(safe-area-inset-bottom) + 3.5rem));
  left: max(1.1rem, env(safe-area-inset-left));
  align-items: flex-end;
  justify-content: space-between;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .7s ease, visibility 0s linear .7s;
}

.touch-pad,
.touch-hold {
  border: 1px solid rgba(244, 244, 242, .32);
  color: rgba(244, 244, 242, .76);
  background: rgba(0, 0, 0, .34);
  box-shadow: inset 0 0 1.2rem rgba(244, 244, 242, .035);
  touch-action: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.touch-pad {
  position: relative;
  width: clamp(6.5rem, 27vw, 8rem);
  aspect-ratio: 1;
  padding: 0;
  border-radius: 50%;
}

.touch-pad::before,
.touch-pad::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  background: rgba(244, 244, 242, .12);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.touch-pad::before { width: 58%; height: 1px; }
.touch-pad::after { width: 1px; height: 58%; }

.touch-pad-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 38%;
  aspect-ratio: 1;
  border: 1px solid rgba(244, 244, 242, .5);
  border-radius: 50%;
  background: rgba(244, 244, 242, .1);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.touch-hold {
  width: clamp(5.2rem, 22vw, 6.5rem);
  aspect-ratio: 1;
  padding: 0;
  border-radius: 50%;
  font: 600 .72rem/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.touch-pad.pressed,
.touch-pad.active,
.touch-hold.active {
  border-color: rgba(255, 255, 255, .78);
  color: var(--white);
  background: rgba(173, 0, 0, .28);
  box-shadow: 0 0 1.2rem rgba(173, 0, 0, .24), inset 0 0 1rem rgba(255, 255, 255, .06);
}

.black-buffer {
  min-height: 52svh;
  background: var(--black);
}

.manifest {
  display: grid;
  place-items: center;
  min-height: 100svh;
  padding: 8rem max(1.25rem, 6vw);
  border-top: 1px solid #151515;
}

.manifest-inner { width: min(100%, 44rem); text-align: center; }

.manifest p {
  margin: 0;
  color: #d9d9d7;
  font-size: clamp(1.05rem, 1.7vw, 1.3rem);
  line-height: 1.85;
}

.manifest .intent { color: var(--phi); }

.manifest-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 4rem;
}

.contact {
  display: inline-block;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  text-decoration: none;
  font: .82rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .12em;
}

.replay-intro { cursor: pointer; }

.contact:hover,
.contact:focus-visible { color: var(--phi); }

.contact:focus-visible { outline: 1px solid var(--phi); outline-offset: 4px; }

@media (max-aspect-ratio: 3/4) {
  .brand-banner { width: 68vw; }
  .orbit-stage.framed .brand-banner { top: max(1.5rem, env(safe-area-inset-top)); }
  .controls-hint { bottom: max(1.5rem, env(safe-area-inset-bottom)); font-size: .65rem; }
  .hud { font-size: .6rem; }
}

@media (any-pointer: coarse) {
  .hud {
    bottom: calc(max(3.5rem, env(safe-area-inset-bottom) + 3.5rem) + clamp(6.5rem, 27vw, 8rem) + 1rem);
  }
  .touch-controls { display: flex; }
  .orbit-stage.ready .touch-controls {
    opacity: 1;
    visibility: visible;
    pointer-events: none;
    transition-delay: 0s;
  }
  .orbit-stage.ready .touch-controls > * { pointer-events: auto; }
  .keyboard-controls-hint { display: none; }
  .touch-controls-hint { display: inline; }
  .controls-hint {
    bottom: max(.9rem, env(safe-area-inset-bottom));
    font-size: .65rem;
  }
}

@media (any-pointer: coarse) and (orientation: landscape) {
  .hud {
    bottom: calc(max(2.8rem, env(safe-area-inset-bottom) + 2.8rem) + clamp(5.5rem, 18vh, 7rem) + .75rem);
  }
  .touch-controls {
    right: max(1.5rem, env(safe-area-inset-right));
    bottom: max(2.8rem, calc(env(safe-area-inset-bottom) + 2.8rem));
    left: max(1.5rem, env(safe-area-inset-left));
  }

  .touch-pad { width: clamp(5.5rem, 18vh, 7rem); }
  .touch-hold { width: clamp(4.8rem, 16vh, 6rem); }
}

@media (prefers-reduced-motion: reduce) {
  .brand-banner,
  .earth,
  .game-mount,
  .hud,
  .controls-hint,
  .touch-controls { transition: none; }
}

.orbit-stage.intro-reset .brand-banner,
.orbit-stage.intro-reset .earth,
.orbit-stage.intro-reset .game-mount,
.orbit-stage.intro-reset .hud,
.orbit-stage.intro-reset .controls-hint,
.orbit-stage.intro-reset .touch-controls { transition: none; }
