:root {
  --bg: #0a1020;
  --accent: #ffb547;                    /* sunlight amber */
  --accent-dim: rgba(255, 181, 71, 0.4);
  --life: #6fe3a0;                      /* habitable / living */
  --cold: #8cc8ff;
  --hot: #ff8a5c;
  --panel: rgba(10, 16, 32, 0.82);
  --text: #e8eefc;
  --muted: #9aa8c7;
  --orbit: #ffe066;
  --lock: #66d9ff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Nunito', system-ui, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

/* Body labels, positioned from JS */
#labels {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.label {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  font-size: 11px;
  line-height: 1.25;
  color: var(--text);
  text-shadow: 0 0 4px #000, 0 0 2px #000;
  white-space: nowrap;
  will-change: transform;
}
.label b { font-weight: 700; font-size: 12px; }
.label span { color: var(--muted); }
.label-planet { opacity: 0.85; }
.label .climate-cold { color: var(--cold); }
.label .climate-good { color: var(--life); }
.label .climate-hot { color: var(--hot); }
.label .climate-none { color: var(--muted); }
.mass-note {
  position: absolute;
  left: 0;
  top: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 0 4px #000, 0 0 2px #000;
  white-space: nowrap;
  will-change: transform, opacity;
}
.label-bh {
  padding: 2px 6px;
  background: rgba(20, 22, 30, 0.75);
  border-radius: 6px;
}

/* Top bar */
#topbar {
  position: fixed;
  top: 10px;
  left: 16px;
  display: flex;
  align-items: baseline;
  gap: 14px;
  pointer-events: none;
}
#topbar h1 {
  margin: 0;
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: 24px;
  letter-spacing: 0.01em;
}
#topbar h1 span { color: var(--life); }
#count { font-size: 12px; color: var(--muted); }

#controls {
  position: fixed;
  top: 10px;
  right: 16px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  max-width: calc(100vw - 32px);
}

button {
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  touch-action: manipulation;
}
button:hover { border-color: var(--accent-dim); }
button.active { border-color: var(--accent); color: var(--accent); }
#zones.active { border-color: var(--life); color: var(--life); }

.speed {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 2px 12px;
}
.speed input { width: 90px; accent-color: var(--accent); }
.speed output { min-width: 32px; color: var(--accent); }

#hint {
  position: fixed;
  left: 16px;
  bottom: 16px;
  max-width: 300px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
  background: var(--panel);
  border-radius: 12px;
  pointer-events: none;
  transition: opacity 0.6s;
}
#hint.hidden { opacity: 0; }
#hint .zone-word { color: var(--life); }

/* Dock: body picker on the left, release mode on the right */
#palette {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  padding: 8px 12px 10px;
  background: linear-gradient(180deg, rgba(255, 181, 71, 0.08), transparent 40%), var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  touch-action: none;
}
.palette-title {
  margin: 0 0 6px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.palette-row { display: flex; align-items: center; gap: 14px; }
.palette-items { display: flex; gap: 6px; }
.item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 74px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 6px 8px;
  cursor: grab;
  touch-action: none;
}
.item:hover { border-color: rgba(255, 255, 255, 0.12); background: rgba(255, 255, 255, 0.06); }
.item b { font-size: 11px; font-weight: 700; }
.item small { font-size: 10px; color: var(--muted); }
.icon {
  width: 30px;
  height: 30px;
  margin-bottom: 2px;
  border-radius: 50%;
  background: var(--fill);
  background-size: cover;
  box-shadow: 0 0 var(--glow, 6px) var(--glow-color, rgba(255, 255, 255, 0.15));
}
.icon.sun { --fill: radial-gradient(circle, #fffbe8 30%, #ffd36a); --glow: 14px; --glow-color: #ffc94a; }
.icon.red-dwarf { --fill: radial-gradient(circle, #ffd27a 15%, #ff5a1a); --glow: 10px; --glow-color: #ff6a2e; }
.icon.brown-dwarf {
  --fill: radial-gradient(circle, #ff7a4a, #8a1f2a), url(../assets/textures/2k_jupiter.jpg) center;
  --glow: 8px; --glow-color: #b8322a;
  background-blend-mode: multiply;
}
.icon.gas-giant { --fill: url(../assets/textures/2k_jupiter.jpg) center; }
.icon.ice-giant { --fill: url(../assets/textures/2k_neptune.jpg) center; }
.icon.planet { --fill: url(../assets/textures/2k_earth_daymap.jpg) center; }
.item:active .icon { transform: scale(1.12); }

.modes {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  overflow: hidden;
}
.modes button {
  border: none;
  border-radius: 0;
  padding: 4px 14px;
  font-size: 12px;
  background: transparent;
}
.modes button + button { border-top: 1px solid rgba(255, 255, 255, 0.1); }
.modes button.active { background: rgba(255, 181, 71, 0.15); }
.modes button[data-mode="orbit"].active { color: var(--orbit); background: rgba(255, 224, 102, 0.12); }
.modes button[data-mode="lock"].active { color: var(--lock); background: rgba(102, 217, 255, 0.12); }

@media (max-width: 720px) {
  #topbar h1 { font-size: 18px; }
  #controls { top: 44px; }
  #hint { display: none; }
  .item { min-width: 58px; padding: 4px; }
  .item small { display: none; }
}

/* Six dock items plus the mode switch don't fit side by side on a phone: stack them. */
@media (max-width: 460px) {
  #palette { padding: 6px 8px 8px; }
  .palette-row { flex-direction: column; gap: 6px; }
  .palette-items { gap: 2px; }
  .item { min-width: 0; width: 54px; padding: 4px 2px; }
  .item b { font-size: 10px; line-height: 1.1; text-align: center; }
  .modes { flex-direction: row; }
  .modes button + button { border-top: none; border-left: 1px solid rgba(255, 255, 255, 0.1); }
}
