* {
  box-sizing: border-box;
}

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

#scene {
  display: block;
  width: 100%;
  height: 100%;
}

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: #04131a;
  color: #e7fbff;
  font-size: 18px;
  font-weight: 800;
}

body:not(.is-loading) .loading-screen {
  display: none;
}

body.is-loading #hud,
body.is-loading #startPanel {
  visibility: hidden;
  pointer-events: none;
}

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.panel {
  position: absolute;
  border: 1px solid rgba(126, 230, 255, 0.26);
  background: rgba(2, 14, 22, 0.68);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(8px);
}

.left-hud-stack {
  position: absolute;
  left: 16px;
  top: 16px;
  width: min(340px, calc(100vw - 32px));
  display: grid;
  gap: 12px;
}

.systems {
  position: relative;
  padding: 14px;
}

.brand {
  margin-bottom: 10px;
  color: #9df4ff;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.meters {
  display: grid;
  gap: 8px;
}

.meters label {
  display: grid;
  grid-template-columns: 64px 1fr 48px;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

meter {
  width: 100%;
  height: 10px;
}

meter::-webkit-meter-bar {
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

meter::-webkit-meter-optimum-value {
  border-radius: 999px;
  background: linear-gradient(90deg, #44ffc7, #45b8ff);
}

meter::-webkit-meter-suboptimum-value,
meter::-webkit-meter-even-less-good-value {
  border-radius: 999px;
  background: linear-gradient(90deg, #ffcc55, #ff5f65);
}

.stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(149, 238, 255, 0.14);
  font-size: 13px;
}

.stats span {
  padding: 5px 8px;
  border: 1px solid rgba(149, 238, 255, 0.22);
  background: rgba(255, 255, 255, 0.06);
}

.radar-wrap {
  right: 16px;
  top: 16px;
  width: 228px;
  padding: 10px;
}

#radar {
  width: 100%;
  aspect-ratio: 208 / 170;
}

#notifications {
  display: grid;
  gap: 8px;
  width: 100%;
}

.toast {
  padding: 10px 12px;
  border-left: 3px solid #66f7ff;
  background: rgba(2, 14, 22, 0.78);
  color: #e7fbff;
  font-size: 13px;
}

.toast.warn {
  border-color: #ffc857;
}

.toast.danger {
  border-color: #ff5f65;
}

#reticle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(157, 244, 255, 0.42);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

#reticle span,
#reticle::before,
#reticle::after {
  position: absolute;
  display: block;
  content: "";
  background: rgba(157, 244, 255, 0.72);
}

#reticle span {
  left: 50%;
  top: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

#reticle::before {
  left: 10px;
  right: 10px;
  top: 50%;
  height: 1px;
}

#reticle::after {
  left: 50%;
  top: 10px;
  bottom: 10px;
  width: 1px;
}

#startPanel {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 8, 12, 0.62);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

#startPanel[hidden] {
  display: none;
}

.start-dialog {
  width: min(560px, 100%);
  max-height: calc(100vh - 32px);
  max-height: calc(100svh - 32px);
  max-height: calc(100dvh - 32px);
  padding: 22px;
  border: 1px solid rgba(126, 230, 255, 0.32);
  background: rgba(2, 14, 22, 0.92);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.34);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.start-dialog h1,
.start-dialog h2 {
  margin: 0 0 8px;
  max-width: 100%;
  overflow: visible;
  font-size: clamp(20px, 6.4vw, 46px);
  line-height: 1.15;
  white-space: nowrap;
}

.start-dialog p {
  margin: 0 0 16px;
  color: #c6eef4;
  line-height: 1.45;
}

.start-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.start-dialog .gameblocks-credit {
  margin: 18px 0 0;
  color: rgba(198, 238, 244, 0.72);
  font-size: 12px;
  line-height: 1.2;
  text-align: center;
}

.gameblocks-credit a {
  color: inherit;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.start-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
  margin: 0;
}

.start-controls div {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 8px;
  align-items: center;
  padding: 7px 0;
  border-top: 1px solid rgba(149, 238, 255, 0.14);
}

.start-controls dt {
  color: #ffffff;
  font-weight: 800;
}

.start-controls dd {
  margin: 0;
  color: #c6eef4;
  font-size: 13px;
}

.controls {
  display: none;
}

kbd {
  min-width: 28px;
  padding: 4px 7px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font: inherit;
  text-align: center;
}

#gameOver {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 8, 12, 0.68);
}

#gameOver[hidden] {
  display: none;
}

#gameOver > div {
  width: min(420px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid rgba(126, 230, 255, 0.28);
  background: rgba(2, 14, 22, 0.92);
}

#gameOver h2 {
  margin: 0 0 10px;
}

#gameOver p {
  color: #c6eef4;
}

button {
  pointer-events: auto;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(126, 230, 255, 0.42);
  background: #10abc0;
  color: #001014;
  font-weight: 800;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

@media (max-width: 760px) {
  .left-hud-stack {
    left: 16px;
    top: 16px;
  }

  .radar-wrap {
    top: auto;
    right: 12px;
    bottom: 12px;
    width: clamp(144px, 38vw, 180px);
    padding: 8px;
  }

  #radar {
    width: 100%;
  }

  .start-actions,
  .start-controls {
    grid-template-columns: 1fr;
  }

  .start-dialog {
    max-height: calc(100vh - 32px);
    max-height: calc(100svh - 32px);
    max-height: calc(100dvh - 32px);
  }
}
