* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #05070c;
  color: #f5f7fb;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  background: rgba(23, 28, 38, 0.86);
  color: #fff;
  font: inherit;
  cursor: pointer;
}

button:hover:not(:disabled),
button:focus-visible {
  background: rgba(44, 74, 105, 0.95);
}

button:disabled {
  color: rgba(255, 255, 255, 0.45);
  cursor: not-allowed;
}

#game {
  display: block;
  width: 100vw;
  height: 100vh;
  touch-action: none;
}

.hud {
  position: fixed;
  left: 16px;
  right: 16px;
  top: 16px;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.hud__row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hud__row--status {
  width: min(760px, calc(100vw - 32px));
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  background: rgba(6, 10, 17, 0.68);
  backdrop-filter: blur(10px);
}

.meter {
  min-width: 110px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  background: rgba(6, 10, 17, 0.68);
  backdrop-filter: blur(10px);
}

.meter--wide {
  min-width: 190px;
}

.meter span,
.hud__row--status span:first-child {
  display: block;
  color: #aab3c2;
  font-size: 12px;
  line-height: 1.1;
  text-transform: uppercase;
}

.meter strong,
.hud__row--status span:last-child {
  display: block;
  margin-top: 2px;
  color: #fff;
  font-size: 16px;
  line-height: 1.2;
}

.crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.crosshair::before,
.crosshair::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.9);
}

.crosshair::before {
  left: 8px;
  top: 0;
  width: 2px;
  height: 18px;
}

.crosshair::after {
  left: 0;
  top: 8px;
  width: 18px;
  height: 2px;
}

.mobile-controls {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  display: none;
  grid-template-columns: auto 1fr auto;
  align-items: end;
  gap: 12px;
  z-index: 8;
  pointer-events: none;
}

.mobile-controls button {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  background: rgba(6, 10, 17, 0.74);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.34);
  touch-action: none;
  pointer-events: auto;
  user-select: none;
}

.mobile-controls__move {
  --stick-x: 0px;
  --stick-y: 0px;
}

.mobile-controls__move,
.mobile-controls__look {
  position: relative;
  width: 116px;
  height: 116px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.72);
  font-weight: 800;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.34);
  touch-action: none;
  pointer-events: auto;
  user-select: none;
}

.mobile-controls__move {
  background:
    radial-gradient(circle at center, rgba(117, 217, 255, 0.28), rgba(6, 10, 17, 0.66) 62%),
    rgba(6, 10, 17, 0.72);
}

.mobile-controls__look {
  justify-self: center;
  background:
    radial-gradient(circle at center, rgba(255, 214, 112, 0.18), rgba(6, 10, 17, 0.66) 62%),
    rgba(6, 10, 17, 0.7);
}

.mobile-controls__move::before,
.mobile-controls__move::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  background: rgba(255, 255, 255, 0.18);
  transform: translate(-50%, -50%);
}

.mobile-controls__move::before {
  width: 76px;
  height: 2px;
}

.mobile-controls__move::after {
  width: 2px;
  height: 76px;
}

.mobile-controls__move-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(117, 217, 255, 0.88);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.36);
  transform: translate(calc(-50% + var(--stick-x)), calc(-50% + var(--stick-y)));
}

.mobile-controls__move span,
.mobile-controls__look span {
  position: relative;
  z-index: 1;
  font-size: 13px;
  letter-spacing: 0;
}

.mobile-controls__actions {
  display: grid;
  gap: 7px;
}

.mobile-controls__actions button {
  min-width: 58px;
  min-height: 52px;
}

.mobile-controls__actions .mobile-controls__fire {
  min-width: 78px;
  min-height: 64px;
  background: rgba(211, 63, 73, 0.92);
}

.cutscene {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: radial-gradient(circle at 50% 70%, rgba(38, 75, 112, 0.45), rgba(2, 4, 10, 0.96) 58%);
  pointer-events: none;
  z-index: 5;
}

.cutscene[hidden] {
  display: none;
}

.cutscene__stars {
  position: absolute;
  inset: -40%;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.9) 0 1px, transparent 2px) 12px 20px / 80px 80px,
    radial-gradient(circle, rgba(155, 210, 255, 0.8) 0 1px, transparent 2px) 44px 70px / 120px 120px;
  animation: starRush 1.4s linear infinite;
}

.cutscene__ship {
  position: absolute;
  left: 50%;
  bottom: 12%;
  width: 38px;
  height: 112px;
  transform: translateX(-50%);
  border-radius: 50% 50% 12px 12px;
  background: linear-gradient(#dce8f2, #8a96a9 62%, #c43c44 63%);
  box-shadow: 0 42px 34px rgba(255, 119, 36, 0.7);
  animation: shipLaunch 2.4s ease-in-out infinite;
}

.cutscene div:last-child {
  position: relative;
  display: grid;
  gap: 6px;
  text-align: center;
  text-transform: uppercase;
}

.cutscene strong {
  font-size: clamp(26px, 5vw, 52px);
  letter-spacing: 0;
}

.cutscene span {
  color: #b9d7ff;
  font-size: 15px;
}

@keyframes starRush {
  from {
    transform: translateY(-8%) scale(1);
  }
  to {
    transform: translateY(8%) scale(1.18);
  }
}

@keyframes shipLaunch {
  0% {
    transform: translateX(-50%) translateY(20px) scale(0.85);
  }
  60% {
    transform: translateX(-50%) translateY(-80px) scale(1.08);
  }
  100% {
    transform: translateX(-50%) translateY(-170px) scale(0.46);
  }
}

.travel {
  position: fixed;
  right: 16px;
  top: 16px;
  width: min(270px, calc(100vw - 32px));
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(7, 9, 14, 0.76);
  backdrop-filter: blur(12px);
}

.travel h1 {
  margin: 0 0 10px;
  font-size: 18px;
  letter-spacing: 0;
}

.travel button {
  display: block;
  width: 100%;
  min-height: 38px;
  margin-top: 8px;
}

.travel p {
  margin: 10px 0 0;
  color: #b9c2d0;
  font-size: 13px;
  line-height: 1.35;
}

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(circle at center, rgba(29, 55, 86, 0.44), rgba(4, 6, 11, 0.88));
}

.overlay.is-hidden {
  display: none;
}

.overlay__panel {
  width: min(520px, 100%);
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(9, 12, 19, 0.9);
}

.overlay__panel h2 {
  margin: 0 0 10px;
  font-size: clamp(26px, 5vw, 42px);
  letter-spacing: 0;
}

.overlay__panel p {
  margin: 0 0 16px;
  color: #c8d0dc;
  line-height: 1.5;
}

.load-error {
  padding: 10px 12px;
  border: 1px solid rgba(255, 150, 120, 0.5);
  border-radius: 6px;
  background: rgba(100, 30, 24, 0.32);
  color: #ffd0c4;
}

.overlay__panel button {
  min-height: 42px;
  padding: 0 16px;
  background: #d33f49;
}

@media (max-width: 700px) {
  .hud {
    top: auto;
    bottom: 138px;
    left: 12px;
    right: 12px;
  }

  .travel {
    left: 12px;
    right: 12px;
    top: 12px;
    width: auto;
  }

  .meter {
    flex: 1 1 100px;
  }
}

@media (pointer: coarse), (max-width: 700px) {
  .mobile-controls {
    display: grid;
  }

  .crosshair {
    opacity: 0.72;
  }
}
