* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; background: #02030a; color: #e6e9f2; font-family: -apple-system, "SF Pro Text", Helvetica, Arial, sans-serif; font-size: 13px; }
canvas#scene { position: fixed; inset: 0; display: block; cursor: crosshair; }

#hud {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 24px; padding: 10px 18px;
  background: rgba(8, 12, 24, 0.72);
  border: 1px solid rgba(120, 140, 200, 0.15);
  border-radius: 10px;
  backdrop-filter: blur(12px);
  z-index: 10;
  pointer-events: none;
}
#stats { display: flex; gap: 22px; }
.stat { display: flex; flex-direction: column; align-items: flex-start; }
.stat .label { font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: #8a95b0; }
.stat .value { font-size: 17px; font-weight: 600; color: #f2f5fb; font-variant-numeric: tabular-nums; }

#left-panel {
  position: fixed; top: 16px; left: 16px; width: 280px; max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: rgba(8, 12, 24, 0.78);
  border: 1px solid rgba(120, 140, 200, 0.15);
  border-radius: 12px;
  padding: 16px;
  z-index: 10;
  backdrop-filter: blur(14px);
}
#left-panel h3 { font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: #8a95b0; margin: 14px 0 8px; font-weight: 600; }
#left-panel h3:first-child { margin-top: 0; }
#left-panel .hint { color: #8a95b0; font-size: 11px; margin: 0 0 10px; }
#left-panel ul.info { padding-left: 18px; margin: 4px 0 0; color: #aab3c8; font-size: 11.5px; line-height: 1.45; }
#left-panel ul.info li { margin-bottom: 4px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11px; color: #ccd; }

#seed-list { display: flex; flex-direction: column; gap: 6px; }
.seed-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px;
  background: rgba(30, 40, 60, 0.55);
  border: 1px solid rgba(120, 140, 200, 0.12);
  border-radius: 8px;
  color: inherit; font: inherit; cursor: pointer;
  text-align: left;
  transition: background 0.12s, border-color 0.12s;
}
.seed-btn:hover:not(.locked) { background: rgba(50, 68, 102, 0.7); border-color: rgba(140, 170, 230, 0.35); }
.seed-btn.selected { background: rgba(72, 108, 170, 0.55); border-color: rgba(170, 200, 255, 0.55); }
.seed-btn.locked { opacity: 0.5; cursor: not-allowed; }
.seed-btn .swatch { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 6px currentColor; }
.seed-btn .seed-name { flex: 1; }
.seed-btn .seed-cost { color: #ffd36a; font-variant-numeric: tabular-nums; }
.seed-btn.locked .seed-cost { color: #667; }

#regolith-panel .row { display: flex; justify-content: space-between; padding: 3px 0; font-variant-numeric: tabular-nums; border-bottom: 1px solid rgba(120, 140, 200, 0.06); }
#regolith-panel .row.muted { color: #667290; }
#regolith-panel .row:last-child { border: none; }

#atmosphere-panel .row { display: flex; align-items: center; gap: 6px; padding: 3px 0; font-variant-numeric: tabular-nums; border-bottom: 1px solid rgba(120, 140, 200, 0.06); }
#atmosphere-panel .row > span:last-child { margin-left: auto; }
#atmosphere-panel .row.pressure { font-weight: 600; color: #d9e3f5; border-bottom: 1px solid rgba(140, 170, 230, 0.2); margin-bottom: 2px; padding-bottom: 5px; }
#atmosphere-panel .row.muted { color: #7a849c; font-size: 11px; }
#atmosphere-panel .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; box-shadow: 0 0 6px currentColor; }
#atmosphere-panel .dot.o2 { background: #6fc7ff; color: #6fc7ff; }
#atmosphere-panel .dot.co2 { background: #b88aff; color: #b88aff; }
#atmosphere-panel .dot.n2 { background: #9aa4c2; color: #9aa4c2; }
#atmosphere-panel .dot.h2o { background: #5affcd; color: #5affcd; }

.modal {
  position: fixed; inset: 0;
  background: rgba(2, 3, 10, 0.82);
  display: none; align-items: center; justify-content: center;
  z-index: 100;
  backdrop-filter: blur(6px);
}
.modal.show { display: flex; }
.modal-inner {
  max-width: 560px; padding: 28px 32px;
  background: rgba(14, 20, 36, 0.94);
  border: 1px solid rgba(140, 170, 230, 0.22);
  border-radius: 14px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
}
.modal-inner h1 { margin: 0 0 10px; font-size: 28px; letter-spacing: 0.08em; }
.modal-inner h2 { margin: 0 0 8px; font-size: 18px; color: #9fc2ff; letter-spacing: 0.04em; }
.modal-inner p { color: #aab3c8; line-height: 1.5; }
#evolution-options { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.evo-choice {
  text-align: left; padding: 14px 16px;
  background: rgba(40, 60, 100, 0.35);
  border: 1px solid rgba(140, 170, 230, 0.18);
  border-radius: 10px;
  color: inherit; font: inherit; cursor: pointer;
  transition: background 0.12s, transform 0.08s;
}
.evo-choice:hover { background: rgba(72, 108, 170, 0.6); transform: translateY(-1px); }
.evo-choice strong { color: #f5f8ff; font-size: 14px; }
.evo-choice small { color: #aab3c8; font-size: 11.5px; }

#start-btn {
  margin-top: 18px; padding: 11px 22px;
  background: #5a8fff; color: #fff; border: none; border-radius: 8px;
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
}
#start-btn:hover { background: #7aa6ff; }

#origin-btn {
  margin: 10px 0 0 10px; padding: 11px 18px;
  background: transparent; color: #9fefff; border: 1px solid rgba(120, 200, 230, 0.5);
  border-radius: 8px; font: inherit; font-weight: 600; font-size: 13px; cursor: pointer;
}
#origin-btn:hover { background: rgba(70, 182, 224, 0.18); }

#flash {
  position: fixed; top: 80px; left: 50%; transform: translateX(-50%) translateY(-10px);
  padding: 10px 18px;
  background: rgba(20, 30, 50, 0.92);
  border: 1px solid rgba(140, 170, 230, 0.28);
  border-radius: 8px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
}
#flash.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.modal-inner .credit { margin: 14px 0 0; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: #667290; }

/* Singularity endgame overlay — reuses .modal/.modal-inner, darker and more dramatic. */
.singularity-modal { background: rgba(0, 0, 0, 0.9); z-index: 200; }
.singularity-inner {
  background: radial-gradient(ellipse at 50% 30%, rgba(40, 10, 60, 0.9), rgba(3, 2, 8, 0.98));
  border: 1px solid rgba(180, 140, 255, 0.28);
  box-shadow: 0 0 120px rgba(120, 60, 220, 0.35), 0 24px 80px rgba(0, 0, 0, 0.7);
  text-align: center;
}
.singularity-inner h1 {
  font-size: 34px; letter-spacing: 0.14em; color: #e8d9ff;
  text-shadow: 0 0 24px rgba(180, 140, 255, 0.8);
}
.singularity-inner p { color: #b6aed0; }
#singularity-restart {
  margin-top: 20px; padding: 12px 26px;
  background: #6a3fd6; color: #fff; border: none; border-radius: 8px;
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
}
#singularity-restart:hover { background: #8258f0; }

#made-by {
  position: fixed; bottom: 12px; right: 14px;
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: #8a95b0;
  background: rgba(8, 12, 24, 0.6);
  border: 1px solid rgba(120, 140, 200, 0.15);
  border-radius: 8px;
  padding: 6px 10px;
  backdrop-filter: blur(10px);
  z-index: 10; pointer-events: none;
}

/* Scrollbar */
#left-panel::-webkit-scrollbar { width: 6px; }
#left-panel::-webkit-scrollbar-thumb { background: rgba(140, 170, 230, 0.2); border-radius: 3px; }

#tier-indicator {
  position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%);
  padding: 5px 14px;
  font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
  color: #aab3c8;
  background: rgba(8, 12, 24, 0.6);
  border: 1px solid rgba(120, 140, 200, 0.15);
  border-radius: 8px;
  backdrop-filter: blur(10px);
  z-index: 10; pointer-events: none;
  transition: color 0.3s, border-color 0.3s;
}
#tier-indicator[data-tier="regional"] { color: #9fc2ff; border-color: rgba(140, 170, 230, 0.30); }
#tier-indicator[data-tier="ground"]   { color: #7affcd; border-color: rgba(90, 255, 205, 0.35); }

#skill-tree-btn {
  position: fixed; top: 16px; right: 132px; z-index: 11;
  padding: 8px 14px; font: inherit; font-size: 12px; font-weight: 600;
  letter-spacing: 0.06em; color: #dfe6f5; cursor: pointer;
  background: rgba(40, 60, 100, 0.6); border: 1px solid rgba(140, 170, 230, 0.3);
  border-radius: 9px; backdrop-filter: blur(10px);
  display: none;   /* the skill tree only makes sense once the cellular game has begun */
}
body.phase-cellular #skill-tree-btn { display: block; }
#skill-tree-btn:hover { background: rgba(72, 108, 170, 0.7); }

/* Settings — always visible (even pre-cellular, even under the intro modal) so sound can be
   toggled from the very start. z-index above .modal (100) so it stays clickable while the
   intro / evolution / singularity overlays are shown. */
#settings-btn {
  position: fixed; top: 16px; right: 16px; z-index: 101;
  width: 34px; height: 34px; padding: 0; font-size: 16px;
  color: #dfe6f5; cursor: pointer;
  background: rgba(40, 60, 100, 0.6); border: 1px solid rgba(140, 170, 230, 0.3);
  border-radius: 9px; backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
}
#settings-btn:hover { background: rgba(72, 108, 170, 0.7); }

/* Sits above the intro/evolution/singularity modals (all z-index 100, DOM-order stacked) so it
   can be opened even while the intro screen is showing, before "Begin Terraforming" is clicked. */
#settings-overlay { z-index: 101; }
.settings-inner { width: min(360px, 92vw); }
.settings-inner .st-header { margin-bottom: 4px; }
.settings-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 0 4px;
}
.settings-label { color: #dfe6f5; font-size: 13px; }

.switch { position: relative; display: inline-block; width: 44px; height: 24px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-track {
  position: absolute; inset: 0; border-radius: 12px;
  background: rgba(120, 140, 200, 0.25); border: 1px solid rgba(140, 170, 230, 0.3);
  transition: background 0.15s;
}
.switch-thumb {
  position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #aab3c8; transition: transform 0.15s, background 0.15s;
}
.switch input:checked + .switch-track { background: rgba(90, 143, 255, 0.65); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(20px); background: #fff; }

/* Cellular-game chrome stays hidden during the pre-cellular phase (cinematic + pool),
   then reveals once the moon game begins. */
body:not(.phase-cellular) #hud,
body:not(.phase-cellular) #left-panel,
body:not(.phase-cellular) #tier-indicator,
body:not(.phase-cellular) #made-by { display: none !important; }

#intro-skip {
  position: fixed; top: 16px; right: 16px; z-index: 110;
  display: none;   /* only shown during the easter-egg prologue cinematic */
  padding: 8px 14px; font: inherit; font-size: 12px; font-weight: 600;
  letter-spacing: 0.06em; color: #dfe6f5; cursor: pointer;
  background: rgba(40, 60, 100, 0.6); border: 1px solid rgba(140, 170, 230, 0.3);
  border-radius: 9px; backdrop-filter: blur(10px);
}
#intro-skip:hover { background: rgba(72, 108, 170, 0.7); }

/* Player-triggered "first drop" prompt during the opening establishing shot. */
#drop-trigger {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  display: none; z-index: 110;
  padding: 14px 30px; font: inherit; font-weight: 700; font-size: 16px; cursor: pointer;
  color: #06121c; background: linear-gradient(180deg, #9fefff, #46b6e0);
  border: none; border-radius: 12px;
  animation: dropPulse 1.6s ease-in-out infinite;
}
#drop-trigger:hover { filter: brightness(1.08); }
@keyframes dropPulse {
  0%, 100% { transform: translateX(-50%) scale(1);    box-shadow: 0 0 20px rgba(120, 220, 255, 0.40); }
  50%      { transform: translateX(-50%) scale(1.05); box-shadow: 0 0 36px rgba(120, 220, 255, 0.75); }
}

#skill-tree-overlay .st-inner, #science-overlay .st-inner {
  width: min(1100px, 94vw); max-height: 90vh; display: flex; flex-direction: column;
  padding: 20px 24px; background: rgba(14, 20, 36, 0.97);
  border: 1px solid rgba(140, 170, 230, 0.22); border-radius: 14px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
}
.st-header { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.st-header h2 { margin: 0; color: #9fc2ff; flex: 0 0 auto; }
.st-credits { margin-left: auto; font-size: 16px; font-weight: 600; color: #ffd36a; font-variant-numeric: tabular-nums; }
#st-close { background: none; border: none; color: #aab3c8; font-size: 18px; cursor: pointer; }
#st-body, #sci-body { overflow: auto; }
.st-row { display: flex; gap: 10px; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid rgba(120,140,200,0.08); }
.st-row-label { width: 64px; flex: 0 0 64px; font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: #8a95b0; align-self: center; }
.st-node {
  width: 150px; padding: 8px 10px; border-radius: 9px; font-size: 11px;
  background: rgba(30, 40, 60, 0.55); border: 1px solid rgba(120, 140, 200, 0.18);
}
.st-node .st-head { display: flex; align-items: center; gap: 7px; margin-bottom: 2px; }
.st-node .st-icon { font-size: 19px; line-height: 1; flex: 0 0 auto; }
.st-node .st-name { font-weight: 600; color: #eaf0fb; font-size: 12px; }
.st-node .st-cost { color: #ffd36a; font-variant-numeric: tabular-nums; }
.st-node button {
  margin-top: 6px; width: 100%; padding: 5px; font: inherit; font-size: 11px; font-weight: 600;
  border: none; border-radius: 6px; cursor: pointer; color: #fff; background: #5a8fff;
}
.st-node button:hover { background: #7aa6ff; }
.st-node.owned { border-color: rgba(90, 220, 140, 0.6); background: rgba(40, 90, 60, 0.4); }
.st-node.owned .st-name { color: #8fe6b0; }
.st-node.locked { opacity: 0.45; }
.st-node.needs-condition { border-color: rgba(240, 200, 90, 0.5); }
.st-node .st-note { color: #8a95b0; font-size: 10px; margin-top: 3px; }
.st-node .st-desc {
  color: #aab3c8; font-size: 10px; line-height: 1.3; margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
/* Top-down dependency-tree layout: an absolutely-positioned canvas with curved edges
   drawn behind the cards. */
#st-body, #sci-body { position: relative; }
.st-canvas { position: relative; }
.st-node-abs { position: absolute; width: 156px; }
svg.st-edges { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 0; }
.st-edge { fill: none; stroke: rgba(140, 170, 230, 0.4); stroke-width: 1.5; }
/* cards sit above the edge layer */
.st-node { z-index: 1; }

/* Docked side panel (not a blocking full-screen modal) — the 3D rockpool stays visible
   behind/beside it while the player works the milestone chain. */
#prebiotic-overlay {
  background: transparent;
  backdrop-filter: none;
  align-items: stretch;
  justify-content: flex-end;
  pointer-events: none;
}
#prebiotic-overlay .pp-inner {
  pointer-events: auto;
  width: 360px; max-width: 92vw; height: 100%; max-height: 100vh;
  margin: 0; overflow-y: auto;
  text-align: left;
  padding: 26px 22px;
  background: linear-gradient(180deg, rgba(9, 16, 28, 0.95), rgba(8, 13, 24, 0.92));
  border: none; border-left: 1px solid rgba(120, 180, 200, 0.25);
  border-radius: 0;
  box-shadow: -24px 0 60px rgba(0, 0, 0, 0.5);
}
#prebiotic-overlay h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: 0.06em; color: #aee6ff; }
.pp-sub { color: #9fb3c8; margin: 0 0 16px; text-align: left; line-height: 1.5; }
.pp-stats { display: flex; justify-content: flex-start; gap: 18px; align-items: baseline; margin-bottom: 14px; flex-wrap: wrap; }
.pp-mol { font-size: 22px; font-weight: 700; color: #eaf6ff; font-variant-numeric: tabular-nums; }
.pp-rate { color: #7fd4a0; font-variant-numeric: tabular-nums; }
#pp-spark {
  padding: 12px 26px; font: inherit; font-weight: 700; font-size: 15px; cursor: pointer;
  color: #06121c; background: linear-gradient(180deg, #8fe9ff, #46b6e0); border: none; border-radius: 10px;
  margin-bottom: 18px;
}
#pp-spark:active { transform: translateY(1px); }
#pp-milestones { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.pp-node {
  padding: 9px 12px; border-radius: 10px;
  background: rgba(30, 44, 60, 0.6); border: 1px solid rgba(120, 160, 200, 0.18);
  display: flex; align-items: center; gap: 12px;
}
.pp-node .pp-body { flex: 1; }
.pp-node .pp-name { font-weight: 600; color: #eaf0fb; }
.pp-node .pp-desc { color: #9fb3c8; font-size: 11.5px; line-height: 1.35; }
.pp-node .pp-cost { color: #ffd36a; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pp-node button {
  padding: 7px 14px; font: inherit; font-weight: 600; font-size: 12px; cursor: pointer;
  color: #fff; background: #5a8fff; border: none; border-radius: 7px; white-space: nowrap;
}
.pp-node button:disabled { background: #38436a; color: #8a95b0; cursor: default; }
.pp-node.owned { border-color: rgba(90, 220, 140, 0.5); background: rgba(36, 70, 52, 0.5); }
.pp-node.owned .pp-name { color: #8fe6b0; }
.pp-node.locked { opacity: 0.5; }

#science-btn {
  position: fixed; top: 16px; right: 248px; z-index: 11; display: none;
  padding: 8px 14px; font: inherit; font-size: 12px; font-weight: 600; letter-spacing: 0.06em;
  color: #dfe6f5; cursor: pointer; background: rgba(50, 40, 90, 0.6);
  border: 1px solid rgba(170, 150, 240, 0.35); border-radius: 9px; backdrop-filter: blur(10px);
}
#science-btn:hover { background: rgba(90, 72, 160, 0.7); }
body.researching #science-btn { display: block; }

#science-overlay .st-credits { color: #c9b8ff; }

.fork-choices { display: flex; gap: 12px; margin-top: 16px; }
.fork-choices button {
  flex: 1; display: flex; flex-direction: column; gap: 6px; text-align: left;
  padding: 16px; font: inherit; font-weight: 700; font-size: 15px; cursor: pointer; color: #eaf0fb;
  background: rgba(40, 60, 100, 0.4); border: 1px solid rgba(140, 170, 230, 0.25); border-radius: 12px;
}
.fork-choices button small { font-weight: 400; font-size: 12px; color: #aab3c8; }
.fork-choices button:hover { background: rgba(72, 108, 170, 0.55); }
#fork-consume:hover { background: rgba(120, 50, 70, 0.5); border-color: rgba(220, 120, 140, 0.5); }

#kardashev-hud {
  position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%) translateY(-34px); display: none;
  align-items: center; gap: 12px; padding: 7px 16px; z-index: 10;
  background: rgba(8, 12, 24, 0.7); border: 1px solid rgba(150, 130, 220, 0.25);
  border-radius: 10px; backdrop-filter: blur(10px); font-size: 12px; color: #dfe6f5;
}
body.researching #kardashev-hud { display: flex; }
#kardashev-hud .kh-label { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: #9a8fc0; }
#kardashev-hud .kh-val { font-weight: 600; font-variant-numeric: tabular-nums; }
#kardashev-hud .kh-bar { width: 140px; height: 6px; background: rgba(150, 130, 220, 0.18); border-radius: 3px; overflow: hidden; }
#kardashev-hud #kh-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #7a6cff, #c9b8ff); }
#kardashev-hud .kh-insight { color: #c9b8ff; font-variant-numeric: tabular-nums; }
