:root {
  --bg: #050814;
  --surface: #121931;
  --surface-2: #192242;
  --border: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.24);
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #6366f1;
  --accent-soft: rgba(99, 102, 241, 0.2);
  --green: #22c55e;
  --green-soft: rgba(34, 197, 94, 0.2);
  --red: #f43f5e;
  --amber: #f59e0b;
  --cyan: #38bdf8;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

/* =========================================================
   FULLSCREEN INTERACTIVE SPACE VIEWPORT (index.html)
   ========================================================= */
.space-viewport {
  position: relative;
  width: 100vw;
  height: 100dvh;
  min-height: 620px;
  overflow: hidden;
  user-select: none;
  background: #040611;
}

.space-bg-layer {
  position: absolute;
  inset: -8%;
  background-image:
    radial-gradient(circle at 50% 45%, rgba(6, 10, 26, 0.15) 0%, rgba(4, 6, 17, 0.55) 100%),
    url('/assets/space-bg.jpg');
  background-size: cover;
  background-position: center;
  transition: transform 1.1s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
  z-index: 0;
}

#spaceCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.flight-trail-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

/* Top Floating HUD */
.hud-top {
  position: absolute;
  top: 12px;
  left: 14px;
  right: 14px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}

.hud-brand,
.hud-pills {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 14px;
  color: #fff;
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.45);
}

.hud-title {
  font-weight: 850;
  font-size: 15px;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
}

.hud-theme {
  font-size: 11.5px;
  color: #cbd5e1;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
  max-width: 44vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-pill {
  background: rgba(9, 14, 34, 0.65);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 800;
  color: #f8fafc;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.hud-btn {
  cursor: pointer;
}

.hud-pill-glow {
  border-color: rgba(56, 189, 248, 0.5);
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.25);
}

/* 4 Space Tribe Sectors / Planets */
.space-sectors {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.sector-node {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  pointer-events: auto;
  cursor: pointer;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.sector-node:hover {
  transform: translate(-50%, -50%) scale(1.08);
}

.sector-orb {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 18px;
  position: relative;
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 26px rgba(99, 102, 241, 0.35);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.sector-orb.planet-pragmatists {
  background: radial-gradient(circle at 30% 30%, #67e8f9, #0284c7 65%, #082f49);
  box-shadow: 0 0 26px rgba(56, 189, 248, 0.45);
}

.sector-orb.planet-optimizers {
  background: radial-gradient(circle at 30% 30%, #a5b4fc, #4f46e5 65%, #1e1b4b);
  box-shadow: 0 0 26px rgba(99, 102, 241, 0.5);
}

.sector-orb.planet-comfort {
  background: radial-gradient(circle at 30% 30%, #fde68a, #d97706 65%, #451a03);
  box-shadow: 0 0 26px rgba(245, 158, 11, 0.45);
}

.sector-orb.planet-contrarians {
  background: radial-gradient(circle at 30% 30%, #f9a8d4, #db2777 65%, #500724);
  box-shadow: 0 0 26px rgba(236, 72, 153, 0.45);
}

.sector-node.active-target .sector-orb {
  transform: scale(1.22);
  box-shadow: 0 0 36px rgba(56, 189, 248, 0.9);
}

.sector-node.my-tribe .sector-orb {
  border-color: #4ade80;
  box-shadow: 0 0 36px rgba(34, 197, 94, 0.85);
}

.sector-label {
  font-size: 10.5px;
  font-weight: 800;
  color: #e2e8f0;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.95);
  background: rgba(5, 8, 20, 0.55);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  white-space: nowrap;
}

/* Floating Peer Crew Astronauts */
.crew-layer {
  position: absolute;
  inset: 0;
  z-index: 14;
  pointer-events: none;
}

.crew-mate {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: auto;
  cursor: pointer;
  animation: zeroG 4.2s ease-in-out infinite;
  z-index: 14;
}

.crew-mate.selected {
  z-index: 45;
  animation: none;
}

.crew-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff, #cbd5e1 65%, #475569);
  border: 2px solid #38bdf8;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 900;
  color: #0f172a;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.5);
  transition: transform 0.2s ease;
}

.crew-mate:hover .crew-dot,
.crew-mate.selected .crew-dot {
  transform: scale(1.22);
  border-color: #22c55e;
}

.crew-mate.is-twin .crew-dot {
  border-color: #fbbf24;
  box-shadow: 0 0 14px rgba(251, 191, 36, 0.8);
}

.crew-name {
  margin-top: 2px;
  font-size: 10px;
  font-weight: 750;
  color: #e2e8f0;
  text-shadow: 0 1px 6px #000;
  white-space: nowrap;
}

.crew-bubble {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(230px, 70vw);
  background: rgba(10, 16, 38, 0.96);
  backdrop-filter: blur(14px);
  border: 1.5px solid rgba(56, 189, 248, 0.65);
  border-radius: 13px;
  padding: 8px 11px;
  font-size: 12px;
  line-height: 1.35;
  color: #f8fafc;
  text-align: center;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.8);
  z-index: 50;
}

.crew-bubble.align-left {
  left: 0;
  transform: translateX(-10%);
}

.crew-bubble.align-right {
  left: auto;
  right: 0;
  transform: translateX(10%);
}

.crew-bubble.flip-down {
  bottom: auto;
  top: calc(100% + 8px);
}

/* Player Astronaut + Attached Speech Bubble */
.player-actor {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 12;
  transition: left 0.9s cubic-bezier(0.22, 1, 0.36, 1), top 0.9s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.astronaut-sprite {
  pointer-events: auto;
  cursor: pointer;
}

.speech-bubble {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  width: min(340px, 84vw);
  background: rgba(11, 17, 38, 0.86);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1.5px solid rgba(129, 140, 248, 0.55);
  border-radius: 18px;
  padding: 11px 15px;
  text-align: center;
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.55);
  transition: border-color 0.25s ease, transform 0.2s ease, opacity 0.2s ease;
  pointer-events: auto;
}

.speech-bubble.collapsed {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) scale(0.92);
}

.speech-bubble::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 8px 8px 0 8px;
  border-style: solid;
  border-color: rgba(129, 140, 248, 0.6) transparent transparent transparent;
}

.speech-bubble.phase-guess {
  border-color: rgba(245, 158, 11, 0.75);
}

.speech-bubble.phase-hit {
  border-color: rgba(34, 197, 94, 0.85);
}

.speech-bubble.phase-miss {
  border-color: rgba(244, 63, 94, 0.8);
}

.bubble-tag {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #38bdf8;
  margin-bottom: 4px;
}

.speech-bubble.phase-guess .bubble-tag {
  color: #fcd34d;
}

.speech-bubble.phase-hit .bubble-tag {
  color: #4ade80;
}

.speech-bubble.phase-miss .bubble-tag {
  color: #fb7185;
}

.bubble-text {
  font-size: 15.5px;
  font-weight: 750;
  color: #f8fafc;
  line-height: 1.32;
}

.astronaut-sprite {
  width: 78px;
  height: 90px;
  animation: zeroG 3.6s ease-in-out infinite;
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.astro-svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 8px 18px rgba(56, 189, 248, 0.38));
}

.thruster-flame {
  opacity: 0.22;
  transform-origin: 60px 106px;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.player-actor.flying .thruster-flame {
  opacity: 1;
  transform: scaleY(1.45);
}

@keyframes zeroG {
  0%, 100% { transform: translateY(0px) rotate(-1.5deg); }
  50% { transform: translateY(-7px) rotate(1.5deg); }
}

/* Floating Space Choice Beacons (NO heavy outer card!) */
.choices-orbit {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 14px;
  z-index: 20;
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.beacons-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.beacon-btn {
  position: relative;
  overflow: hidden;
  text-align: left;
  background: rgba(10, 16, 36, 0.62);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  padding: 12px 13px;
  color: #f8fafc;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.beacon-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: rgba(56, 189, 248, 0.8);
  box-shadow: 0 8px 24px rgba(56, 189, 248, 0.2);
}

.beacon-btn:disabled {
  cursor: default;
}

.beacon-btn.mine {
  border-color: #818cf8;
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.35);
}

.beacon-btn.winner {
  border-color: #22c55e;
  box-shadow: 0 0 18px rgba(34, 197, 94, 0.35);
}

.beacon-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: rgba(99, 102, 241, 0.28);
  transition: width 0.65s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 0;
}

.beacon-btn.winner .beacon-fill {
  background: rgba(34, 197, 94, 0.3);
}

.beacon-inner {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.beacon-sub {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.beacon-pct {
  font-size: 14px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.space-action-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.space-cta {
  border: 0;
  border-radius: 999px;
  padding: 11px 20px;
  font-size: 13.5px;
  font-weight: 800;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, #6366f1, #0ea5e9);
  box-shadow: 0 8px 24px rgba(14, 165, 233, 0.35);
  transition: transform 0.12s ease;
}

.space-cta:active {
  transform: scale(0.97);
}

.space-cta.green {
  background: linear-gradient(135deg, #22c55e, #10b981);
  color: #052e16;
  box-shadow: 0 8px 24px rgba(34, 197, 94, 0.35);
}

.space-cta.ghost {
  background: rgba(15, 23, 46, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: #e2e8f0;
  box-shadow: none;
}

/* End-of-Flight Floating Dock (transparent over space, leaves planet/crew visible!) */
.dock-overlay {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 25;
  max-width: 620px;
  margin: 0 auto;
  background: rgba(8, 13, 30, 0.76);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 20px;
  padding: 14px 15px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65);
}

.dock-overlay.hidden {
  display: none;
}

.dock-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.dock-rank-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 0 4px;
}

.rank-chip {
  flex: 0 0 auto;
  font-size: 11.5px;
  font-weight: 750;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
  cursor: pointer;
}

.rank-chip.mine {
  border-color: #4ade80;
  background: rgba(34, 197, 94, 0.2);
}

.dock-inline-form {
  display: grid;
  grid-template-columns: 1fr 1.3fr auto;
  gap: 7px;
  margin-top: 8px;
}

.dock-input {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  padding: 9px 13px;
  color: #fff;
  font-size: 13px;
  outline: none;
}

.dock-input::placeholder {
  color: #94a3b8;
}

@media (max-width: 600px) {
  .beacons-grid {
    grid-template-columns: 1fr;
    gap: 7px;
  }
  .beacon-btn {
    padding: 10px 13px;
    font-size: 13px;
  }
  .astronaut-sprite {
    width: 62px;
    height: 74px;
  }
  .bubble-text {
    font-size: 14px;
  }
  .dock-inline-form {
    grid-template-columns: 1fr;
  }
}

/* Shared / Utility / Insights Page Styles */
.mini-tag {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #e2e8f0;
}

.mini-tag.mine {
  background: rgba(99, 102, 241, 0.45);
  color: #e0e7ff;
}

.mini-tag.guess {
  background: rgba(245, 158, 11, 0.35);
  color: #fde68a;
}

.mini-tag.crown {
  background: rgba(34, 197, 94, 0.35);
  color: #bbf7d0;
}

.toast {
  position: fixed;
  top: 64px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: #f8fafc;
  color: #0f172a;
  font-weight: 800;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  z-index: 60;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Insights Dashboard (insights.html) */
.shell {
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 16px 40px;
}

.shell-wide {
  max-width: 960px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #22c55e);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 18px;
  color: #fff;
}

.brand-title {
  font-weight: 800;
  font-size: 18px;
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
}

.stats-pills {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
}

.pill-accent {
  background: var(--accent-soft);
  border-color: rgba(99, 102, 241, 0.4);
  color: #c7d2fe;
}

.badge {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.badge-partner {
  background: rgba(245, 158, 11, 0.18);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.insights-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 10px;
  text-align: center;
}

.stat-val {
  font-size: 20px;
  font-weight: 800;
}

.stat-lbl {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

.insights-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 16px;
}

.prompt-text {
  font-size: 19px;
  font-weight: 800;
  margin: 0 0 12px;
}

.dual-bar-row {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dual-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 13px;
}

.dual-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
}

.bar-track {
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 5px;
}

.bar-actual {
  height: 100%;
  background: #22c55e;
  border-radius: 999px;
}

.bar-perceived {
  height: 100%;
  background: #f59e0b;
  border-radius: 999px;
}

.legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 5px;
}

.form-grid {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  padding: 11px 13px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn {
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 750;
  cursor: pointer;
}

.btn-primary {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
}
