:root {
  --bg-top: #130f40;
  --bg-bottom: #050816;
  --panel: rgba(11, 18, 41, 0.82);
  --panel-border: rgba(255, 255, 255, 0.12);
  --text: #f6f2d4;
  --muted: #b8b6d4;
  --accent: #ffd166;
  --accent-2: #72f1b8;
  --accent-3: #ff7b72;
  --shadow: rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "VT323", monospace;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(77, 57, 150, 0.45), transparent 30%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  overflow-x: hidden;
}

button {
  font: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.stars,
.stars::before,
.stars::after {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.8) 0 1px, transparent 1px),
    radial-gradient(circle at 70% 10%, rgba(255, 255, 255, 0.7) 0 1px, transparent 1px),
    radial-gradient(circle at 85% 60%, rgba(255, 225, 160, 0.65) 0 1px, transparent 1px),
    radial-gradient(circle at 45% 85%, rgba(255, 255, 255, 0.65) 0 1px, transparent 1px);
  background-size: 240px 240px;
  opacity: 0.55;
  animation: drift 48s linear infinite;
}

.stars::before {
  transform: scale(1.2);
  opacity: 0.4;
  animation-duration: 70s;
}

.stars::after {
  transform: scale(0.9);
  opacity: 0.3;
  animation-duration: 32s;
}

@keyframes drift {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(240px);
  }
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1100px, calc(100% - 40px));
  margin: 0 auto;
  padding: 18px 0 32px;
}

.topbar,
.hero-grid,
.content-grid {
  display: grid;
  gap: 16px;
}

.topbar {
  grid-template-columns: 1.4fr 1fr;
  align-items: start;
  margin-bottom: 16px;
}

h1,
h2,
h3 {
  font-family: "Press Start 2P", cursive;
  margin: 0;
  line-height: 1.35;
}

h1 {
  font-size: clamp(1.35rem, 1.55vw + 0.8rem, 2rem);
}

h2 {
  font-size: clamp(0.9rem, 0.8vw + 0.75rem, 1.15rem);
}

h3 {
  font-size: 0.8rem;
}

.eyebrow,
.subtitle,
.planet-flavor,
.section-head p,
.card-copy,
.crew-copy p,
#powerupHint {
  margin: 0;
}

.eyebrow {
  color: var(--accent-2);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

.subtitle,
.planet-flavor,
.section-head p,
.card-copy,
.crew-copy p,
#powerupHint {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.2;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.panel,
.stat-card {
  background: var(--panel);
  border: 2px solid var(--panel-border);
  box-shadow: 0 12px 30px var(--shadow);
  backdrop-filter: blur(8px);
}

.stat-card {
  padding: 11px 14px;
  border-radius: 16px;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.95rem;
}

.stat-card strong {
  font-size: 1.35rem;
}

.hero-grid {
  grid-template-columns: 1.2fr 0.8fr;
  margin-bottom: 16px;
}

.panel {
  border-radius: 20px;
  padding: 18px;
}

.planet-stage {
  position: relative;
  overflow: hidden;
}

.planet-stage::after {
  content: "";
  position: absolute;
  inset: auto -20% -25% auto;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(114, 241, 184, 0.22), transparent 65%);
}

.stage-copy {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.planet-button {
  width: min(100%, 320px);
  margin: 0 auto 14px;
  display: block;
  border: 0;
  background: transparent;
  cursor: pointer;
  transition: transform 120ms ease;
}

.planet-button:hover {
  transform: translateY(-4px) scale(1.01);
}

.planet-button:active {
  transform: scale(0.98);
}

#planetCanvas,
#alienCanvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  width: 100%;
  background: radial-gradient(circle at 50% 35%, rgba(255, 255, 255, 0.16), transparent 42%);
  border-radius: 20px;
}

#miniAlienCanvas {
  width: 100%;
  max-height: 96px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(118, 209, 255, 0.08), rgba(20, 24, 46, 0.1) 44%),
    linear-gradient(180deg, rgba(18, 22, 43, 0.2) 0 74%, rgba(57, 88, 52, 0.75) 74% 100%);
  border: 2px solid rgba(255, 255, 255, 0.08);
}

.progress-block {
  display: grid;
  gap: 8px;
}

.progress-meta,
.build-stats,
.section-head,
.card-meta,
.mini-stats {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.progress-meta,
.build-stats,
.mini-stats,
.card-meta {
  font-size: 0.95rem;
}

.progress-bar {
  width: 100%;
  height: 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.08);
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #ff9f68, var(--accent-2));
  transition: width 150ms linear;
}

.side-panel {
  display: grid;
  gap: 14px;
}

.crew-habitat {
  display: grid;
  gap: 8px;
}

.habitat-head {
  align-items: end;
}

.habitat-head h3 {
  font-size: 0.68rem;
}

.habitat-head p {
  font-size: 0.88rem;
}

.crew-wrap {
  display: grid;
  grid-template-columns: 136px 1fr;
  gap: 12px;
  align-items: center;
}

#alienCanvas {
  max-width: 136px;
  margin: 0 auto;
}

.alien-portrait {
  position: relative;
  width: 136px;
  margin: 0 auto;
}

.alien-portrait #alienCanvas {
  display: block;
  max-width: 100%;
}

.main-alien-sprite {
  --pixel: 8.5px;
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  grid-template-columns: repeat(16, var(--pixel));
  grid-template-rows: repeat(16, var(--pixel));
  transform: translate(-50%, -50%);
  image-rendering: pixelated;
}

.main-alien-pixel {
  width: var(--pixel);
  height: var(--pixel);
}

.alien-title {
  font-family: "Press Start 2P", cursive;
  font-size: 0.66rem;
  margin: 0 0 8px;
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
}

.mini-stats div {
  display: grid;
}

.content-grid {
  grid-template-columns: repeat(3, 1fr);
  align-items: start;
}

.card-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  min-height: 188px;
}

.shop-card,
.unlock-button {
  width: 100%;
  border: 2px solid rgba(255, 255, 255, 0.09);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.03)),
    rgba(7, 11, 28, 0.94);
  color: var(--text);
  cursor: pointer;
  padding: 11px 13px;
  text-align: left;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    box-shadow 120ms ease;
}

.shop-card {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.shop-card:hover,
.unlock-button:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 209, 102, 0.45);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.22);
}

.shop-card:disabled,
.unlock-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.card-title,
.card-cost {
  display: block;
}

.card-title {
  font-family: "Press Start 2P", cursive;
  font-size: 0.6rem;
  margin-bottom: 6px;
}

.card-cost {
  color: var(--accent);
  font-size: 0.95rem;
}

.card-value {
  font-size: 1.1rem;
}

.orbit-track {
  display: grid;
  gap: 10px;
  margin: 12px 0 14px;
  min-height: 364px;
}

.system-nav {
  display: grid;
  grid-template-columns: 34px 1fr 34px;
  gap: 8px;
  align-items: center;
}

.system-nav-button {
  width: 34px;
  height: 30px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  cursor: pointer;
  font-family: "Press Start 2P", cursive;
  font-size: 0.58rem;
}

.system-nav-button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.system-nav-label {
  color: var(--muted);
  text-align: center;
  font-size: 0.95rem;
}

.solar-system-view {
  position: relative;
  height: 330px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 18px;
  background:
    radial-gradient(circle at center, rgba(255, 209, 102, 0.08), transparent 26%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
}

.system-sun {
  position: absolute;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: "Press Start 2P", cursive;
  font-size: 0.5rem;
  color: #3c2100;
  background: radial-gradient(circle at 35% 35%, #fff1b8, #ffd166 62%, #ff9f68);
  box-shadow: 0 0 28px rgba(255, 209, 102, 0.45);
  z-index: 2;
  animation: sunPulse 2.8s ease-in-out infinite;
}

.orbit-ring {
  position: absolute;
  border: 1px dashed rgba(255, 255, 255, 0.14);
  border-radius: 50%;
  animation: ringGlow 5.5s ease-in-out infinite;
}

.orbit-mover {
  position: absolute;
  inset: 0;
  animation: orbitSpin var(--orbit-speed) linear infinite;
  transform: rotate(var(--orbit-angle));
}

.orbit-planet {
  position: absolute;
  width: 58px;
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  transition: transform 120ms ease;
}

.orbit-planet:hover {
  transform: translateY(-2px);
}

.orbit-planet-body {
  display: grid;
  justify-items: center;
  gap: 4px;
  animation: orbitCounterSpin var(--orbit-speed) linear infinite;
}

.orbit-planet.complete .orbit-planet-canvas,
.orbit-planet.current .orbit-planet-canvas {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08);
}

.orbit-planet.current .orbit-planet-canvas {
  box-shadow:
    0 0 0 2px rgba(255, 209, 102, 0.55),
    0 0 18px rgba(255, 209, 102, 0.2);
}

.orbit-planet.selected .orbit-planet-canvas {
  box-shadow:
    0 0 0 3px rgba(114, 241, 184, 0.75),
    0 0 22px rgba(114, 241, 184, 0.24);
}

.orbit-planet.locked {
  position: absolute;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  place-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 2px dashed rgba(255, 255, 255, 0.16);
  color: var(--muted);
  font-family: "Press Start 2P", cursive;
  font-size: 0.72rem;
  animation: orbitCounterSpin var(--orbit-speed) linear infinite;
}

.orbit-planet-canvas {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: rgba(255, 255, 255, 0.04);
}

.orbit-label {
  font-family: "Press Start 2P", cursive;
  font-size: 0.42rem;
  color: var(--muted);
}

.system-summary {
  color: var(--muted);
  font-size: 0.95rem;
}

.unlock-button {
  text-align: center;
  font-family: "Press Start 2P", cursive;
  font-size: 0.58rem;
}

@keyframes orbitSpin {
  from {
    transform: rotate(var(--orbit-angle));
  }
  to {
    transform: rotate(calc(var(--orbit-angle) + 360deg));
  }
}

@keyframes orbitCounterSpin {
  from {
    transform: rotate(calc(-1 * var(--orbit-angle)));
  }
  to {
    transform: rotate(calc(-1 * (var(--orbit-angle) + 360deg)));
  }
}

@keyframes sunPulse {
  0%,
  100% {
    box-shadow: 0 0 24px rgba(255, 209, 102, 0.38);
  }
  50% {
    box-shadow: 0 0 36px rgba(255, 209, 102, 0.62);
  }
}

@keyframes ringGlow {
  0%,
  100% {
    border-color: rgba(255, 255, 255, 0.12);
  }
  50% {
    border-color: rgba(114, 241, 184, 0.22);
  }
}

@media (max-width: 980px) {
  .topbar,
  .hero-grid,
  .content-grid,
  .crew-wrap {
    grid-template-columns: 1fr;
  }

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

  .planet-button {
    width: min(100%, 260px);
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 18px, 1220px);
    padding-top: 18px;
  }

  .panel,
  .stat-card {
    border-radius: 18px;
  }

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

  .progress-meta,
  .build-stats,
  .card-meta,
  .section-head {
    flex-direction: column;
  }

  .mini-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}
