html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: #cfd8ff;
}

#c {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

#hud {
  position: fixed;
  top: 12px;
  left: 12px;
  background: rgba(5, 8, 20, 0.55);
  border: 1px solid rgba(120, 150, 255, 0.25);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.6;
  pointer-events: auto;
  cursor: pointer;
  backdrop-filter: blur(4px);
}
#hud.collapsed { display: none; }

/* Small round button that reopens the collapsed HUD */
#hud-toggle {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 10;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

#help {
  position: fixed;
  bottom: 10px;
  left: 12px;
  font-size: 12px;
  color: #8fa0d0;
  background: rgba(5, 8, 20, 0.45);
  padding: 6px 10px;
  border-radius: 6px;
  pointer-events: none;
}

#top-right {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 10;
  display: flex;
  gap: 8px;
}
#fs-btn {
  padding: 6px 10px;
  font-size: 15px;
  line-height: 1;
}

button {
  background: #1a2340;
  color: #cfd8ff;
  border: 1px solid rgba(120, 150, 255, 0.4);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
button:hover { background: #26325c; }

#menu {
  position: fixed;
  top: 52px;
  right: 12px;
  width: 300px;
  max-height: calc(100vh - 70px);
  overflow-y: auto;
  background: rgba(8, 11, 26, 0.85);
  border: 1px solid rgba(120, 150, 255, 0.3);
  border-radius: 10px;
  padding: 14px;
  font-size: 13px;
  backdrop-filter: blur(6px);
  display: none;
}
#menu.open { display: block; }

#menu h2 { margin: 0 0 10px; font-size: 16px; }

fieldset {
  border: 1px solid rgba(120, 150, 255, 0.25);
  border-radius: 8px;
  margin: 0 0 12px;
  padding: 10px;
}
legend { font-size: 12px; color: #8fa0d0; padding: 0 6px; }

label {
  display: block;
  margin: 6px 0;
}
input[type="number"] {
  width: 90px;
  background: #0d1330;
  color: #cfd8ff;
  border: 1px solid rgba(120, 150, 255, 0.3);
  border-radius: 4px;
  padding: 3px 6px;
}
input[type="range"] {
  width: 130px;
  vertical-align: middle;
}
#menu button { margin: 6px 6px 0 0; }

#progress-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.88);
  z-index: 100;
}
#progress-text {
  font-size: 16px;
  margin-bottom: 12px;
  color: #cfd8ff;
}
#progress-bar-bg {
  width: 300px;
  height: 8px;
  background: rgba(120, 150, 255, 0.2);
  border-radius: 4px;
  overflow: hidden;
}
#progress-bar {
  width: 0%;
  height: 100%;
  background: #7896ff;
  border-radius: 4px;
  transition: width 0.1s;
}

/* ============ Mobile (touch) ============ */
/* Stop the browser hijacking touches for scroll/zoom/refresh on the game
   surface and the drawn controls. The config menu keeps default touch
   behaviour so its sliders and scroll area still work. */
body.mobile #c,
body.mobile #mobile-ui,
body.mobile #mobile-ui * {
  touch-action: none;
}
body.mobile * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
body.mobile #help { display: none; }
body.mobile #c { cursor: default; }

/* Container for the drawn touch controls. 20% opacity per spec. */
#mobile-ui {
  position: fixed;
  inset: 0;
  pointer-events: none;      /* only the interactive children catch touches */
  opacity: 0.2;
  z-index: 15;
  transition: opacity 0.25s ease;
}
#mobile-ui.hidden { opacity: 0; }
#mobile-ui.hidden * { pointer-events: none; }

/* Left cluster: W / S (accel level) stacked above the big SPACE (thrust) button */
#m-left {
  position: absolute;
  left: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.m-btn {
  pointer-events: auto;
  background: rgba(120, 150, 255, 0.35);
  color: #fff;
  border: 2px solid rgba(180, 200, 255, 0.9);
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.m-btn:active { background: rgba(120, 150, 255, 0.7); }
.m-btn.m-small { width: 66px; height: 66px; }
.m-btn.m-big   { width: 96px; height: 96px; font-size: 15px; }

/* Right cluster: virtual joystick (base + knob) */
#joy-base {
  position: absolute;
  right: 26px;
  bottom: 26px;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  border: 2px solid rgba(180, 200, 255, 0.9);
  background: rgba(120, 150, 255, 0.18);
  pointer-events: auto;
  touch-action: none;
}
#joy-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 62px;
  height: 62px;
  margin: -31px 0 0 -31px;
  border-radius: 50%;
  background: rgba(180, 200, 255, 0.55);
  border: 2px solid rgba(220, 230, 255, 0.9);
}

/* Portrait-orientation hint (mobile only): non-blocking top banner */
#portrait-hint {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  text-align: center;
  font-size: 15px;
  line-height: 1.5;
  color: #cfd8ff;
  background: rgba(0, 0, 0, 0.72);
  border: 1px solid rgba(120, 150, 255, 0.4);
  border-radius: 10px;
  padding: 10px 20px;
  pointer-events: none;
  max-width: 90vw;
}
#portrait-hint.hidden { display: none; }
.hidden { display: none !important; }

/* Make the config menu comfortable on touch screens */
body.mobile #menu {
  width: min(340px, calc(100vw - 24px));
  max-height: calc(100vh - 70px);
}
body.mobile #menu input[type="range"] { width: 150px; }
body.mobile #menu input[type="number"] { width: 110px; }
body.mobile #top-right button { padding: 10px 16px; font-size: 15px; }
