@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600&family=Rajdhani:wght@500;600&display=swap');

:root {
  --ink: #0b1220;
  --panel: rgba(12, 18, 32, 0.75);
  --panel-strong: rgba(12, 18, 32, 0.92);
  --line: rgba(255, 255, 255, 0.08);
  --accent: #64b6ff;
  --accent-2: #ffb347;
  --danger: #ff5c7c;
  --good: #52ffa2;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", system-ui, sans-serif;
  background: radial-gradient(circle at top, #16233a 0%, #0a0f1a 55%, #06080f 100%);
  color: #e8eef9;
  height: 100vh;
  overflow: hidden;
}

#game-root {
  position: relative;
  height: 100vh;
  width: 100vw;
}

.top-controls {
  position: absolute;
  top: 36px;
  right: 24px;
  z-index: 12;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  pointer-events: auto;
}

.drop-panel {
  position: absolute;
  top: 42px;
  right: 0;
  width: min(380px, 90vw);
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 20px 45px rgba(5, 10, 20, 0.5);
}

.settings-card {
  max-width: min(640px, 92vw);
  max-height: min(80vh, 720px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-body {
  overflow-y: auto;
  padding-right: 6px;
  display: grid;
  gap: 14px;
}

.settings-section {
  display: grid;
  gap: 8px;
}

.settings-row {
  display: grid;
  grid-template-columns: 1fr 140px;
  gap: 10px;
  align-items: center;
  font-size: 12px;
  color: rgba(232, 238, 249, 0.85);
}

.settings-row input {
  width: 100%;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(8, 12, 20, 0.6);
  color: #e8eef9;
  padding: 6px 8px;
  font-size: 12px;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
}

.play-toggle {
  position: absolute;
  right: 24px;
  bottom: 24px;
  z-index: 12;
  pointer-events: auto;
}

.tutorial-message {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 12px;
  border-radius: 10px;
  background: rgba(12, 18, 32, 0.85);
  border: 1px solid rgba(255, 179, 71, 0.45);
  color: rgba(255, 219, 153, 0.95);
  font-size: 12px;
  white-space: pre-line;
  z-index: 12;
  pointer-events: none;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}

.tutorial-message.moon {
  width: auto;
  max-width: none;
  white-space: pre;
  display: inline-block;
}

.victory-card {
  max-width: 520px;
}

.victory-body {
  display: grid;
  gap: 10px;
  font-size: 14px;
  line-height: 1.4;
  color: rgba(232, 238, 249, 0.9);
}

.victory-chart-wrap {
  margin-top: 8px;
  background: rgba(6, 10, 18, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 8px;
}

#victory-chart {
  width: 100%;
  height: auto;
  display: block;
}

.victory-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 11px;
  color: rgba(232, 238, 249, 0.75);
  margin-top: 6px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-item::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.35);
}

.legend-item[data-legend="weight"]::before {
  background: #ff4d5a;
}

.legend-item[data-legend="money"]::before {
  background: #f7c84b;
}

.legend-item[data-legend="compute"]::before {
  background: #40a9ff;
}

.legend-item[data-legend="delivered"]::before {
  background: #42f58a;
}

#game-canvas {
  position: absolute;
  inset: 0;
  z-index: 4;
}

#hud {
  position: absolute;
  inset: 0;
  padding: 18px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  pointer-events: none;
  z-index: 2;
}

.hud-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hud-title {
  font-family: "Rajdhani", sans-serif;
  font-size: 28px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hud-sub {
  font-size: 14px;
  color: rgba(232, 238, 249, 0.7);
}

.orb {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  position: relative;
  box-shadow: inset -12px -12px 18px rgba(0, 0, 0, 0.45), 0 10px 22px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.earth-large {
  position: absolute;
  width: 168px;
  height: 168px;
  left: 24px;
  bottom: 24px;
  z-index: 2;
  pointer-events: auto;
}

.earth-factory {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 110px;
  height: 70px;
  border-radius: 10px;
  background: rgba(12, 18, 32, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding: 8px 8px 6px;
  text-align: center;
  box-shadow: 0 6px 14px rgba(5, 10, 20, 0.35);
  pointer-events: auto;
  z-index: 3;
}

.earth-factory-overlay,
.moon-factory-overlay {
  pointer-events: auto;
}

.orbit-queue-button {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) !important;
  transition: box-shadow 0.15s ease;
  padding: 2px 6px;
  font-size: 10px;
  z-index: 4;
  pointer-events: auto;
  min-width: 0;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.orbit-queue-button:hover,
.orbit-queue-button.btn:hover {
  transform: translate(-50%, -50%) !important;
  box-shadow: 0 6px 20px rgba(100, 182, 255, 0.15);
}

.orbit-queue-button:active,
.orbit-queue-button:focus {
  transform: translate(-50%, -50%) !important;
}

.moon-factory {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 110px;
  height: 70px;
  border-radius: 10px;
  background: rgba(12, 18, 32, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding: 8px 8px 6px;
  text-align: center;
  box-shadow: 0 6px 14px rgba(5, 10, 20, 0.35);
  pointer-events: auto;
  z-index: 3;
}

.moon-factory-content {
  display: grid;
  justify-items: center;
  gap: 6px;
}

.moon-factory .metric {
  font-size: 11px;
  margin-bottom: 0;
}

.moon-factory .btn {
  padding: 4px 8px;
  font-size: 11px;
}

.earth-factory-content {
  display: grid;
  justify-items: center;
  gap: 6px;
}

.earth-factory .metric {
  font-size: 11px;
  margin-bottom: 0;
}

.earth-factory .btn {
  padding: 4px 8px;
  font-size: 11px;
}

.earth-production {
  position: absolute;
  left: 24px;
  bottom: 24px;
  width: 168px;
  height: 168px;
  z-index: 10;
  pointer-events: none;
}

.earth-queue {
  position: absolute;
  left: 24px;
  bottom: 24px;
  width: 168px;
  height: 168px;
  z-index: 12;
  pointer-events: none;
}

.progress {
  height: 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, rgba(100, 182, 255, 0.9), rgba(255, 179, 71, 0.9));
}

.earth-panel {
  position: absolute;
  left: 190px;
  bottom: 120px;
  width: min(260px, 70vw);
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 10px;
  box-shadow: 0 20px 45px rgba(5, 10, 20, 0.5);
  z-index: 12;
  pointer-events: auto;
}

.moon-production {
  position: absolute;
  right: 24px;
  top: 210px;
  width: 108px;
  height: 108px;
  z-index: 10;
  pointer-events: none;
}

.moon-queue {
  position: absolute;
  right: 24px;
  top: 210px;
  width: 108px;
  height: 108px;
  z-index: 12;
  pointer-events: none;
}

.moon-factory {
  width: 84px;
  height: 52px;
  padding: 6px;
  gap: 4px;
}

.moon-factory .metric {
  font-size: 10px;
}

.moon-panel {
  position: absolute;
  right: 120px;
  top: 20px;
  width: min(260px, 70vw);
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 10px;
  box-shadow: 0 20px 45px rgba(5, 10, 20, 0.5);
  z-index: 12;
  pointer-events: auto;
}

.queue-list {
  min-height: 32px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11px;
  color: rgba(232, 238, 249, 0.8);
}

.queue-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.queue-item button {
  pointer-events: auto;
  border: none;
  background: transparent;
  color: rgba(232, 238, 249, 0.7);
  cursor: pointer;
  padding: 0 2px;
  font-size: 12px;
  line-height: 1;
}

.queue-note {
  font-size: 11px;
  color: rgba(255, 179, 71, 0.8);
}
.earth-factory-overlay,
.moon-factory-overlay {
  position: absolute;
  inset: 0;
  margin: auto;
  cursor: pointer;
}

.earth-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: move;
}

.btn.mini {
  padding: 2px 8px;
  font-size: 12px;
  line-height: 1;
}

.earth-panel-header .btn,
.earth-panel-header button {
  cursor: pointer;
}

.moon-right {
  position: absolute;
  width: 108px;
  height: 108px;
  right: 24px;
  top: 210px;
  z-index: 2;
  pointer-events: none;
}

.orb::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0) 40%),
    radial-gradient(circle at 70% 70%, rgba(0, 0, 0, 0.65), rgba(0, 0, 0, 0) 55%);
  mix-blend-mode: screen;
}

.orb::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(120deg, rgba(0, 0, 0, 0.6) 10%, rgba(0, 0, 0, 0) 45%);
}

.orb.earth {
  background-image: url("/space/assets/earth_blue_marble_1024.jpg");
  box-shadow: inset -12px -12px 18px rgba(0, 0, 0, 0.4), 0 0 12px rgba(100, 182, 255, 0.4), 0 10px 22px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
}

.orb::before,
.orb::after {
  pointer-events: none;
}

.orb.moon {
  background-image: url("/space/assets/moon_lroc_wac_1024.jpg");
  box-shadow: inset -10px -10px 16px rgba(0, 0, 0, 0.5), 0 10px 20px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.hud-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  width: 100%;
  max-width: none;
  margin-top: -14px;
}

.panel.status {
  grid-column: 1 / -1;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  backdrop-filter: blur(8px);
  pointer-events: auto;
}

.panel.wide {
  width: min(900px, 95vw);
}

.panel.status {
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px 14px;
  align-items: center;
  padding-left: 38px;
}

.panel.status .panel-title {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%) rotate(180deg);
  transform-origin: center;
  writing-mode: vertical-rl;
  margin-bottom: 0;
}

.panel.status::before {
  content: "";
  position: absolute;
  left: 28px;
  top: 10px;
  bottom: 10px;
  width: 1px;
  background: rgba(255, 255, 255, 0.12);
}

.panel.status .metric {
  margin-bottom: 0;
  font-size: 12px;
}

.panel-title {
  font-family: "Rajdhani", sans-serif;
  font-size: 14px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

.metric {
  font-size: 13px;
  margin-bottom: 6px;
  color: rgba(232, 238, 249, 0.85);
}

.button-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.button-row.single {
  grid-template-columns: 1fr;
}

.btn {
  font-family: "Space Grotesk", sans-serif;
  font-size: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: linear-gradient(140deg, rgba(100, 182, 255, 0.9), rgba(100, 182, 255, 0.25));
  color: #08111f;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(100, 182, 255, 0.25);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(232, 238, 249, 0.9);
}

.btn[disabled] {
  background: rgba(180, 190, 210, 0.2);
  border-color: rgba(180, 190, 210, 0.2);
  color: rgba(232, 238, 249, 0.45);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.panel-note {
  font-size: 11px;
  color: rgba(232, 238, 249, 0.55);
  margin-top: 6px;
}

.rules {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: rgba(232, 238, 249, 0.8);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 14, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 20;
}

.overlay.hidden {
  display: none;
}

.hidden {
  display: none;
}

.overlay-card {
  width: min(900px, 95vw);
  max-height: min(80vh, 800px);
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.overlay-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.overlay-title {
  font-family: "Rajdhani", sans-serif;
  font-size: 16px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

#assumptions-body {
  white-space: pre-wrap;
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 12px;
  line-height: 1.6;
  color: rgba(232, 238, 249, 0.85);
  overflow: auto;
}

@media (max-width: 900px) {
  #hud {
    padding: 16px;
  }

  .hud-grid {
    grid-template-columns: 1fr;
  }
}
