:root {
  color-scheme: dark;
  --bg: #020511;
  --cyan: #75f8ff;
  --cyan-soft: rgba(117, 248, 255, 0.72);
  --amber: #ffd28a;
  --red: #ff6474;
  --glass: rgba(5, 16, 34, 0.56);
  --glass-strong: rgba(5, 18, 38, 0.84);
  --line: rgba(117, 248, 255, 0.28);
  --text: #ecfbff;
  --muted: rgba(236, 251, 255, 0.68);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  touch-action: none;
}

button {
  color: inherit;
  font: inherit;
}

#space-canvas {
  position: fixed;
  inset: 0;
  display: block;
  width: 100vw;
  height: 100dvh;
  background: radial-gradient(circle at 50% 45%, #08152f 0%, #020511 52%, #000 100%);
}

.is-hidden {
  display: none !important;
}

.start-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: calc(24px + var(--safe-top)) calc(20px + var(--safe-right))
    calc(24px + var(--safe-bottom)) calc(20px + var(--safe-left));
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, rgba(70, 160, 255, 0.2), transparent 34%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.18), rgba(2, 5, 17, 0.92));
}

.start-screen__stars,
.start-screen__stars::before,
.start-screen__stars::after {
  position: absolute;
  inset: -20%;
  content: "";
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.95) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(117, 248, 255, 0.9) 0 1px, transparent 1.4px),
    radial-gradient(circle, rgba(255, 210, 138, 0.75) 0 1px, transparent 1.3px);
  background-position:
    0 0,
    53px 71px,
    109px 29px;
  background-size:
    191px 211px,
    307px 283px,
    389px 347px;
  animation: star-drift 70s linear infinite;
}

.start-screen__stars::before {
  opacity: 0.55;
  transform: scale(0.7);
  animation-duration: 45s;
}

.start-screen__stars::after {
  opacity: 0.35;
  transform: scale(1.45);
  animation-duration: 110s;
  animation-direction: reverse;
}

@keyframes star-drift {
  from {
    translate: 0 0;
  }
  to {
    translate: -389px 211px;
  }
}

.mission-panel {
  position: relative;
  z-index: 1;
  width: min(760px, 100%);
  padding: clamp(32px, 7vw, 72px) clamp(22px, 6vw, 64px);
  border: 1px solid rgba(117, 248, 255, 0.25);
  border-radius: 30px;
  background:
    linear-gradient(135deg, rgba(8, 26, 56, 0.74), rgba(2, 5, 17, 0.48)),
    rgba(2, 5, 17, 0.58);
  box-shadow:
    0 0 70px rgba(59, 182, 255, 0.14),
    inset 0 0 46px rgba(117, 248, 255, 0.04);
  text-align: center;
  backdrop-filter: blur(18px);
}

.mission-panel::before,
.mission-panel::after {
  position: absolute;
  top: 18px;
  bottom: 18px;
  width: 1px;
  content: "";
  background: linear-gradient(transparent, rgba(117, 248, 255, 0.55), transparent);
}

.mission-panel::before {
  left: 18px;
}

.mission-panel::after {
  right: 18px;
}

.mission-panel__eyebrow {
  margin: 0 0 10px;
  color: var(--cyan);
  font-size: clamp(0.68rem, 1.6vw, 0.82rem);
  font-weight: 800;
  letter-spacing: 0.36em;
}

.mission-panel h1 {
  margin: 0;
  font-size: clamp(2.7rem, 10vw, 7.8rem);
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: -0.075em;
  text-shadow:
    0 0 18px rgba(117, 248, 255, 0.44),
    0 0 70px rgba(87, 126, 255, 0.3);
}

.mission-panel__copy {
  max-width: 560px;
  margin: 22px auto 0;
  color: var(--muted);
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  line-height: 1.65;
}

.mission-panel__status {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 28px 0 32px;
}

.mission-panel__status span {
  padding: 7px 12px;
  border: 1px solid rgba(117, 248, 255, 0.22);
  border-radius: 999px;
  background: rgba(117, 248, 255, 0.07);
  color: rgba(236, 251, 255, 0.78);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.launch-button {
  position: relative;
  display: inline-grid;
  place-items: center;
  min-width: 210px;
  min-height: 62px;
  padding: 0 42px;
  border: 1px solid rgba(117, 248, 255, 0.68);
  border-radius: 999px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.26), transparent 44%),
    linear-gradient(135deg, rgba(27, 174, 255, 0.38), rgba(93, 255, 221, 0.14));
  box-shadow:
    0 0 26px rgba(117, 248, 255, 0.28),
    inset 0 0 18px rgba(117, 248, 255, 0.15);
  cursor: pointer;
  font-weight: 900;
  letter-spacing: 0.16em;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease;
}

.launch-button:hover,
.launch-button:focus-visible {
  transform: translateY(-2px) scale(1.02);
  border-color: #fff;
  box-shadow:
    0 0 42px rgba(117, 248, 255, 0.48),
    inset 0 0 24px rgba(117, 248, 255, 0.22);
  outline: none;
}

.launch-button:active {
  transform: translateY(1px) scale(0.99);
}

.launch-button__ring {
  position: absolute;
  inset: -11px;
  border: 1px solid rgba(117, 248, 255, 0.22);
  border-radius: inherit;
  animation: launch-ring 2.2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes launch-ring {
  50% {
    scale: 1.05;
    opacity: 0.35;
  }
}

.mission-panel__hint {
  margin: 28px 0 0;
  color: rgba(236, 251, 255, 0.54);
  font-size: 0.78rem;
  line-height: 1.7;
}

.cockpit {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.cockpit__glass {
  position: absolute;
  pointer-events: none;
}

.cockpit__glass--top {
  top: -2px;
  left: 10vw;
  right: 10vw;
  height: clamp(36px, 8vh, 76px);
  border-right: 1px solid rgba(117, 248, 255, 0.2);
  border-bottom: 1px solid rgba(117, 248, 255, 0.24);
  border-left: 1px solid rgba(117, 248, 255, 0.2);
  border-radius: 0 0 50% 50% / 0 0 100% 100%;
  background:
    linear-gradient(180deg, rgba(4, 13, 29, 0.95), rgba(4, 13, 29, 0.28) 78%, transparent),
    radial-gradient(ellipse at center, transparent 48%, rgba(5, 14, 31, 0.88));
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.cockpit__glass--left,
.cockpit__glass--right {
  top: 15vh;
  bottom: 8vh;
  width: clamp(38px, 7vw, 110px);
  background:
    linear-gradient(90deg, rgba(3, 9, 21, 0.96), rgba(3, 9, 21, 0.34) 62%, transparent),
    repeating-linear-gradient(180deg, rgba(117, 248, 255, 0.08) 0 2px, transparent 2px 36px);
  opacity: 0.78;
}

.cockpit__glass--left {
  left: -2px;
  transform: skewY(-8deg);
  border-right: 1px solid rgba(117, 248, 255, 0.2);
}

.cockpit__glass--right {
  right: -2px;
  transform: skewY(8deg);
  border-left: 1px solid rgba(117, 248, 255, 0.2);
  scale: -1 1;
}

.reticle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 58px;
  height: 58px;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 0 8px rgba(117, 248, 255, 0.65));
}

.reticle::before {
  position: absolute;
  inset: 24px;
  border: 1px solid rgba(236, 251, 255, 0.88);
  border-radius: 50%;
  content: "";
}

.reticle span {
  position: absolute;
  background: var(--cyan-soft);
}

.reticle span:nth-child(1),
.reticle span:nth-child(2) {
  left: 50%;
  width: 1px;
  height: 13px;
}

.reticle span:nth-child(1) {
  top: 0;
}

.reticle span:nth-child(2) {
  bottom: 0;
}

.reticle span:nth-child(3),
.reticle span:nth-child(4) {
  top: 50%;
  width: 13px;
  height: 1px;
}

.reticle span:nth-child(3) {
  left: 0;
}

.reticle span:nth-child(4) {
  right: 0;
}

.hud {
  position: absolute;
  top: calc(22px + var(--safe-top));
  width: min(235px, 40vw);
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, var(--glass-strong), rgba(8, 23, 47, 0.38));
  box-shadow:
    inset 0 0 24px rgba(117, 248, 255, 0.05),
    0 0 28px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(8px);
}

.hud--left {
  left: calc(20px + var(--safe-left));
  clip-path: polygon(0 0, 100% 0, 88% 100%, 0 100%);
}

.hud--right {
  right: calc(20px + var(--safe-right));
  clip-path: polygon(12% 0, 100% 0, 100% 100%, 0 100%);
  text-align: right;
}

.hud__label,
.hud__small,
.hud p {
  margin: 0;
}

.hud__label {
  color: var(--cyan);
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.28em;
}

.hud p:not(.hud__label):not(.hud__small) {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.85rem;
}

.hud strong {
  color: var(--text);
  font-size: clamp(1.45rem, 3.5vw, 2.25rem);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-shadow: 0 0 14px rgba(117, 248, 255, 0.3);
}

.hud__target {
  overflow: hidden;
  min-height: 1.2em;
  color: var(--amber) !important;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud__small {
  margin-top: 7px;
  color: rgba(236, 251, 255, 0.56);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.15em;
}

.meter {
  overflow: hidden;
  width: 100%;
  height: 7px;
  margin-top: 10px;
  border: 1px solid rgba(117, 248, 255, 0.24);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.4);
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(62, 155, 255, 0.75), var(--cyan));
  box-shadow: 0 0 14px rgba(117, 248, 255, 0.52);
  transition: width 100ms linear;
}

.meter--hyper span {
  background: linear-gradient(90deg, #7c6cff, var(--cyan), #fff);
}

.icon-button {
  position: absolute;
  bottom: calc(22px + var(--safe-bottom));
  left: calc(20px + var(--safe-left));
  padding: 9px 12px;
  border: 1px solid rgba(117, 248, 255, 0.28);
  border-radius: 999px;
  background: rgba(5, 16, 34, 0.7);
  color: rgba(236, 251, 255, 0.76);
  cursor: pointer;
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  pointer-events: auto;
}

.notice {
  position: absolute;
  bottom: calc(74px + var(--safe-bottom));
  left: 50%;
  max-width: min(560px, calc(100vw - 32px));
  margin: 0;
  padding: 9px 14px;
  border: 1px solid rgba(255, 210, 138, 0.3);
  border-radius: 999px;
  background: rgba(24, 16, 5, 0.72);
  color: var(--amber);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-align: center;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 220ms ease;
  pointer-events: none;
}

.notice.is-visible {
  opacity: 1;
}

.touch-controls {
  position: fixed;
  inset: 0;
  z-index: 12;
  pointer-events: none;
}

.stick {
  position: absolute;
  bottom: calc(32px + var(--safe-bottom));
  left: calc(28px + var(--safe-left));
  width: 126px;
  height: 126px;
  border: 1px solid rgba(117, 248, 255, 0.32);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(117, 248, 255, 0.12), rgba(5, 16, 34, 0.42) 68%),
    rgba(5, 16, 34, 0.28);
  box-shadow: inset 0 0 30px rgba(117, 248, 255, 0.08);
  pointer-events: auto;
  touch-action: none;
}

.stick__knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 54px;
  height: 54px;
  border: 1px solid rgba(236, 251, 255, 0.66);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.32), rgba(117, 248, 255, 0.14));
  box-shadow: 0 0 18px rgba(117, 248, 255, 0.28);
  transform: translate(-50%, -50%);
}

.stick__label {
  position: absolute;
  right: 0;
  bottom: -21px;
  left: 0;
  color: rgba(236, 251, 255, 0.52);
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.24em;
  text-align: center;
}

.touch-actions {
  position: absolute;
  right: calc(24px + var(--safe-right));
  bottom: calc(34px + var(--safe-bottom));
  display: flex;
  align-items: flex-end;
  gap: 14px;
  pointer-events: auto;
}

.touch-button {
  width: 76px;
  height: 76px;
  border: 1px solid rgba(117, 248, 255, 0.34);
  border-radius: 50%;
  background: rgba(5, 16, 34, 0.58);
  box-shadow: inset 0 0 20px rgba(117, 248, 255, 0.08);
  color: rgba(236, 251, 255, 0.78);
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  touch-action: none;
}

.touch-button--hyper {
  width: 94px;
  height: 94px;
  border-color: rgba(255, 210, 138, 0.52);
  background:
    radial-gradient(circle, rgba(255, 210, 138, 0.16), rgba(5, 16, 34, 0.62) 65%),
    rgba(5, 16, 34, 0.58);
  color: var(--amber);
}

.touch-button.is-active {
  border-color: #fff;
  box-shadow:
    0 0 28px rgba(117, 248, 255, 0.32),
    inset 0 0 28px rgba(117, 248, 255, 0.16);
}

.look-zone {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 45vw;
  pointer-events: auto;
  touch-action: none;
}

.error-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 50;
  width: min(480px, calc(100vw - 32px));
  padding: 28px;
  border: 1px solid rgba(255, 100, 116, 0.42);
  border-radius: 22px;
  background: rgba(20, 5, 11, 0.9);
  box-shadow: 0 0 60px rgba(255, 100, 116, 0.18);
  transform: translate(-50%, -50%);
  text-align: center;
}

.error-panel h2 {
  margin: 0 0 10px;
  color: var(--red);
  font-size: 1.2rem;
}

.error-panel p {
  margin: 0;
  color: rgba(255, 236, 239, 0.8);
  line-height: 1.6;
}

body.is-hyperdrive .reticle {
  animation: reticle-pulse 0.16s linear infinite;
}

body.is-hyperdrive .cockpit__glass--top {
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.4),
    0 0 44px rgba(117, 248, 255, 0.26);
}

@keyframes reticle-pulse {
  50% {
    scale: 1.14;
    opacity: 0.7;
  }
}

@media (pointer: coarse) {
  .hud {
    top: calc(12px + var(--safe-top));
    width: min(196px, 42vw);
    padding: 10px 12px;
  }

  .hud strong {
    font-size: 1.28rem;
  }

  .hud p:not(.hud__label):not(.hud__small) {
    font-size: 0.72rem;
  }

  .icon-button {
    top: calc(12px + var(--safe-top));
    bottom: auto;
    left: 50%;
    transform: translateX(-50%);
  }

  .notice {
    bottom: calc(196px + var(--safe-bottom));
    width: max-content;
    font-size: 0.62rem;
  }
}

@media (max-width: 680px) {
  .mission-panel {
    border-radius: 22px;
  }

  .mission-panel__hint {
    font-size: 0.68rem;
  }

  .hud--left {
    left: calc(10px + var(--safe-left));
  }

  .hud--right {
    right: calc(10px + var(--safe-right));
  }

  .notice {
    bottom: calc(182px + var(--safe-bottom));
    max-width: calc(100vw - 190px);
    padding: 8px 10px;
    border-radius: 14px;
    font-size: 0.58rem;
    white-space: normal;
  }

  .cockpit__glass--left,
  .cockpit__glass--right {
    width: 24px;
    opacity: 0.52;
  }
}

@media (max-height: 500px) and (pointer: coarse) {
  .hud {
    padding: 8px 10px;
  }

  .stick {
    bottom: calc(18px + var(--safe-bottom));
    width: 104px;
    height: 104px;
  }

  .touch-actions {
    right: calc(16px + var(--safe-right));
    bottom: calc(18px + var(--safe-bottom));
  }

  .touch-button {
    width: 62px;
    height: 62px;
  }

  .touch-button--hyper {
    width: 78px;
    height: 78px;
  }
}
