:root {
  --space-black: #05070d;
  --moon-grey: #8a8a8f;
  --moon-grey-dark: #2a2a30;
  --accent-amber: #f2a640;
  --accent-blue: #2ec4e6;
  --accent-green: #3ddc84;
  --accent-purple: #8b5cf6;
  --alert-red: #c23b3b;
  --panel-bg: rgba(10, 14, 24, 0.85);
  --panel-border: rgba(242, 166, 64, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--space-black);
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

#game-root {
  position: relative;
  width: 100vw;
  height: 100vh;
  max-width: 1000px;
  max-height: 750px;
  margin: 0 auto;
  overflow: hidden;
  background: var(--space-black);
  box-shadow: 0 0 60px rgba(0,0,0,0.6);
}

@media (min-width: 1000px) {
  html, body { display: flex; align-items: center; justify-content: center; }
  #game-root { border-radius: 16px; }
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#overlay-root {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
#overlay-root > * {
  pointer-events: auto;
}

/* ---------- Landing screen prompt ---------- */
.landing-prompt {
  position: absolute;
  left: 50%;
  bottom: 8%;
  transform: translateX(-50%);
  text-align: center;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 16px 24px;
  backdrop-filter: blur(4px);
  animation: fadeUp 0.5s ease-out;
  width: min(90%, 420px);
}
.landing-title {
  color: var(--accent-amber);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  text-shadow: 0 0 10px rgba(242,166,64,0.4);
}
.landing-sub {
  color: #cfd3da;
  font-size: 13px;
  margin-bottom: 12px;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateX(-50%) translateY(16px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---------- Buttons ---------- */
.btn-primary {
  background: linear-gradient(180deg, #3ddc84, #26a35f);
  color: #06210f;
  font-weight: 800;
  font-size: 14px;
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  cursor: pointer;
  box-shadow: 0 4px 0 #1c7847, 0 6px 12px rgba(0,0,0,0.4);
  transition: transform 0.08s ease;
}
.btn-primary:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #1c7847, 0 2px 6px rgba(0,0,0,0.4);
}

/* ---------- Dev stub panels (temporary, removed as screens are built out) ---------- */
.stub-panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--panel-bg);
  border: 1px dashed var(--panel-border);
  border-radius: 14px;
  padding: 22px 28px;
  text-align: center;
  width: min(90%, 440px);
}
.stub-label {
  color: var(--accent-amber);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.stub-desc {
  color: #cfd3da;
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.4;
}

/* ---------- HUD (used by exploration screens, built in next phase) ---------- */
.hud-top {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  font-size: 12px;
  color: #fff;
}

/* ---------- Exploration HUD (Screen 2+) ---------- */
.hud-panel {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.hud-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.hud-row-sub {
  align-items: center;
}
.bar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 5px 10px;
}
.bar-label {
  font-size: 12px;
  color: #cfd3da;
  font-weight: 700;
  min-width: 18px;
}
.bar-track {
  width: 90px;
  height: 8px;
  background: rgba(255,255,255,0.12);
  border-radius: 5px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 100%;
  border-radius: 5px;
  transition: width 0.15s linear;
}
.bar-oxygen { background: linear-gradient(90deg, #2ec4e6, #4fc3f7); }
.bar-energy { background: linear-gradient(90deg, #f2a640, #ffcf7a); }

.gadget-badges {
  display: flex;
  gap: 6px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 5px 8px;
}
.badge {
  font-size: 15px;
  opacity: 0.28;
  filter: grayscale(1);
  transition: all 0.25s ease;
}
.badge-on {
  opacity: 1;
  filter: none;
  transform: scale(1.15);
}
.crystal-counter {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 5px 10px;
  color: #cfa8ff;
  font-size: 13px;
  font-weight: 700;
}

.parts-counter {
  background: var(--panel-bg);
  border: 1px solid rgba(61,220,132,0.4);
  border-radius: 8px;
  padding: 5px 10px;
  color: var(--accent-green);
  font-size: 13px;
  font-weight: 700;
}

.scanner-compass {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 5px 10px;
  transition: box-shadow 0.15s ease;
}
.scanner-compass.compass-ping {
  box-shadow: 0 0 0 3px rgba(46,196,230,0.35);
}
.compass-arrow {
  color: var(--accent-blue);
  font-size: 14px;
  font-weight: 800;
}
.compass-dist {
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}
.compass-label {
  color: #9aa4b0;
  font-size: 10px;
}

/* ---------- Repair screen (Screen 4) ---------- */
.repair-bar-group {
  flex: 1;
  justify-content: space-between;
}
.repair-bar-group .bar-track {
  flex: 1;
  width: auto;
  margin: 0 8px;
}
.bar-repair {
  background: linear-gradient(90deg, #3ddc84, #6ee8a8);
}
.repair-pct {
  color: var(--accent-green);
  font-size: 13px;
  font-weight: 800;
  min-width: 36px;
  text-align: right;
}

.repair-tray {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-height: 34%;
  overflow-y: auto;
  padding: 4px;
}
.tray-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  color: #fff;
  transition: transform 0.08s ease, border-color 0.15s ease;
}
.tray-item:hover {
  border-color: rgba(61,220,132,0.6);
}
.tray-item:active {
  transform: scale(0.94);
}
.tray-icon {
  font-size: 20px;
}
.tray-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #cfd3da;
  white-space: nowrap;
}

/* ---------- Mission summary (Screen 5) ---------- */
.summary-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 22px 26px;
  text-align: center;
  width: min(92%, 420px);
  max-height: 88%;
  overflow-y: auto;
  backdrop-filter: blur(4px);
  animation: fadeUp 0.5s ease-out;
}
.summary-title {
  color: var(--accent-amber);
  font-weight: 800;
  font-size: 18px;
  margin-bottom: 4px;
  text-shadow: 0 0 12px rgba(242,166,64,0.4);
}
.summary-rank {
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.5px;
  margin-bottom: 14px;
  opacity: 0.9;
}
.summary-score {
  color: var(--accent-green);
  font-weight: 800;
  font-size: 42px;
  line-height: 1;
  text-shadow: 0 0 16px rgba(61,220,132,0.4);
}
.summary-score-label {
  color: #9aa4b0;
  font-size: 11px;
  letter-spacing: 1px;
  margin-bottom: 16px;
}
.summary-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
  text-align: left;
}
.summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: #cfd3da;
  padding: 4px 2px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.summary-row span:last-child {
  font-weight: 700;
  color: #fff;
}
.summary-bonus span:last-child {
  color: var(--accent-green);
}
.summary-perfect {
  border-bottom: none;
}
.summary-perfect span:last-child {
  color: var(--accent-amber);
}

.tip-banner {
  position: absolute;
  top: 68px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 8px 16px;
  color: var(--accent-amber);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  animation: fadeUp 0.4s ease-out;
  pointer-events: none;
}
.tip-fade { opacity: 0; transition: opacity 0.6s ease; }

.gadget-toast {
  position: absolute;
  top: 68px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-bg);
  border: 1px solid rgba(61,220,132,0.45);
  border-radius: 10px;
  padding: 8px 16px;
  color: var(--accent-green);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  animation: fadeUp 0.3s ease-out;
  pointer-events: none;
}

/* ---------- Touch controls ---------- */
.joy-base {
  position: absolute;
  left: 24px;
  bottom: 24px;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(255,255,255,0.25);
  touch-action: none;
}
.joy-stick {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34px;
  height: 34px;
  margin-left: -17px;
  margin-top: -17px;
  border-radius: 50%;
  background: rgba(242,166,64,0.85);
  transition: transform 0.05s linear;
}
.jump-btn {
  position: absolute;
  right: 24px;
  bottom: 24px;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  background: rgba(61,220,132,0.28);
  border: 2px solid rgba(61,220,132,0.6);
  color: #3ddc84;
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  user-select: none;
}
.jump-btn:active {
  background: rgba(61,220,132,0.5);
}
