/* ==========================================================================
   TERRAFORM: GENESIS OF EDEN — High-End Sci-Fi / Bio-Telemetry Design System
   ========================================================================== */

:root {
  /* Typography */
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  
  /* Core Surface Palette (Deep Obsidian & Bio-Slate) */
  --bg-deep: #060911;
  --surface-hud: rgba(11, 17, 28, 0.78);
  --surface-hud-elevated: rgba(15, 23, 42, 0.88);
  --surface-card: rgba(17, 26, 44, 0.65);
  --surface-card-hover: rgba(26, 38, 64, 0.85);
  --surface-input: rgba(8, 12, 20, 0.7);
  
  /* Precision Borders */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.15);
  --border-highlight: rgba(255, 255, 255, 0.25);
  
  /* Semantic Accent Palette */
  --bio-emerald: #10b981;
  --bio-mint: #34d399;
  --cosmic-cyan: #06b6d4;
  --cosmic-sky: #38bdf8;
  --stardust-amber: #f59e0b;
  --stardust-gold: #fbbf24;
  --plasma-rose: #f43f5e;
  --singularity-purple: #8b5cf6;
  
  /* Text Contrast Hierarchy */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --text-disabled: #475569;
  
  /* Radii */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 9999px;
  
  /* Elevation & Glassmorphism */
  --blur-hud: blur(16px);
  --blur-modal: blur(24px);
  --shadow-hud: 0 4px 20px -2px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--border-subtle);
  --shadow-card: 0 4px 14px -2px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--border-subtle);
  --shadow-modal: 0 24px 60px -8px rgba(0, 0, 0, 0.85), 0 0 0 1px var(--border-medium);
  
  /* Transitions */
  --ease-snappy: cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: 0.15s var(--ease-snappy);
  --transition-normal: 0.25s var(--ease-snappy);
  --transition-smooth: 0.35s var(--ease-snappy);
}

/* Base Reset & Tabular Numbers */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-deep);
  font-family: var(--font-sans);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Fullscreen 3D WebGL Canvas */
#webgl-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  cursor: grab;
  touch-action: none;
}

#webgl-canvas.grabbing {
  cursor: grabbing;
}

/* Fullscreen Landscape Canvas (2D) */
#game-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  cursor: crosshair;
  touch-action: none;
}

/* Fullscreen FX Canvas for Click Floaters & Particle Bursts */
#fx-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 2;
  pointer-events: none;
}

/* UI Shell Overlay */
#game-container {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
}

/* ==========================================================================
   1. TOP TELEMETRY COMMAND BAR
   ========================================================================== */

#top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  min-height: 52px;
  background: var(--surface-hud);
  backdrop-filter: var(--blur-hud);
  -webkit-backdrop-filter: var(--blur-hud);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-hud);
  pointer-events: auto;
  gap: 12px;
  position: relative;
  z-index: 50;
}

/* Left: Branding & Current Stage */
.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.game-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-symbol {
  font-size: 1.1rem;
  color: var(--bio-mint);
  text-shadow: 0 0 10px rgba(52, 211, 153, 0.5);
}

.logo-title {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--text-primary);
}

.logo-tag {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--cosmic-sky);
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  letter-spacing: 1px;
}

.stage-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-left: 1px solid var(--border-subtle);
  padding-left: 14px;
}

.stage-badge-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stage-badge {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--bio-mint);
  letter-spacing: 0.2px;
}

.stardust-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--stardust-gold);
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.4);
  padding: 1px 7px;
  border-radius: var(--radius-pill);
}

.stage-desc-text {
  font-size: 0.68rem;
  color: var(--text-tertiary);
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Center: Habitability Laser Progress */
.habitability-container {
  flex: 1;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.habitability-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.habitability-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-secondary);
}

.habitability-val {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--cosmic-sky);
}

.progress-track {
  width: 100%;
  height: 6px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: var(--radius-pill);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  position: relative;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--bio-emerald), var(--cosmic-sky), var(--singularity-purple));
  border-radius: var(--radius-pill);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
  transition: width 0.3s ease;
}

/* Right: Refined Action Toolbar */
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  outline: none;
  border: 1px solid var(--border-subtle);
  background: var(--surface-card);
  color: var(--text-primary);
  padding: 6px 12px;
}

.btn:hover:not(:disabled) {
  background: var(--surface-card-hover);
  border-color: var(--border-medium);
  transform: translateY(-1px);
}

.btn-hud {
  height: 34px;
}

.btn-hud .btn-icon {
  font-size: 0.95rem;
}

.btn-reality {
  background: rgba(139, 92, 246, 0.15);
  border-color: rgba(139, 92, 246, 0.35);
  color: #ddd6fe;
}

.btn-reality:hover {
  background: rgba(139, 92, 246, 0.28);
  border-color: rgba(139, 92, 246, 0.6);
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.3);
}

.btn-prestige {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.25), rgba(239, 68, 68, 0.25));
  border-color: rgba(245, 158, 11, 0.5);
  color: #fef08a;
  animation: pulse-glow 2s infinite;
}

.btn-sound.muted {
  opacity: 0.55;
}

.btn-primary {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.4);
  color: #a7f3d0;
}

.btn-primary:hover {
  background: rgba(16, 185, 129, 0.35);
  border-color: rgba(16, 185, 129, 0.7);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.3);
}

.btn-accent {
  background: rgba(244, 63, 94, 0.2);
  border-color: rgba(244, 63, 94, 0.4);
  color: #fecdd3;
}

.btn-accent:hover {
  background: rgba(244, 63, 94, 0.35);
  border-color: rgba(244, 63, 94, 0.7);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-subtle);
  color: var(--text-secondary);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

.btn-supernova {
  background: linear-gradient(135deg, #ef4444, #f59e0b);
  color: #fff;
  font-weight: 700;
  border: none;
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.5);
  padding: 10px 18px;
}

.btn-supernova:hover {
  box-shadow: 0 0 24px rgba(239, 68, 68, 0.8);
  transform: translateY(-1px) scale(1.02);
}

/* ==========================================================================
   2. MAIN CONTENT & FLOATING VITAL TELEMETRY (CENTER HUD)
   ========================================================================== */

#main-content {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
  padding: 16px 20px;
}

/* Center Display: Sleek, compact top-floating vital telemetry */
#center-display {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  z-index: 20;
}

/* Active Buffs Pill Bar */
.buffs-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  pointer-events: auto;
}

.buff-pill {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 10px;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #fef08a;
  border-radius: var(--radius-pill);
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.25);
  animation: pulse-glow 2.5s infinite;
}

/* Compact Energy Telemetry Card */
.energy-card {
  pointer-events: auto;
  background: var(--surface-hud);
  backdrop-filter: var(--blur-hud);
  -webkit-backdrop-filter: var(--blur-hud);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 10px 24px;
  text-align: center;
  box-shadow: var(--shadow-hud);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 240px;
}

.energy-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.resource-symbol {
  font-size: 1.6rem;
  filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.4));
}

.resource-number {
  font-family: var(--font-mono);
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.rates-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rate-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}

.rate-badge.passive {
  background: rgba(16, 185, 129, 0.12);
  color: var(--bio-mint);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.rate-badge.click {
  background: rgba(56, 189, 248, 0.12);
  color: var(--cosmic-sky);
  border: 1px solid rgba(56, 189, 248, 0.25);
}

.click-hint {
  font-size: 0.68rem;
  color: var(--text-tertiary);
  transition: opacity 0.5s ease;
  margin-top: 2px;
}

.click-hint.hidden-hint {
  opacity: 0;
  pointer-events: none;
}

/* Visible Progression Tracker & Tier Widget */
.progression-tracker {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border-subtle);
}

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

.tier-badge {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--cosmic-sky);
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  text-transform: uppercase;
}

.pace-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--bio-mint);
  white-space: nowrap;
}

.milestone-track {
  width: 100%;
  height: 4px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: var(--radius-pill);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.milestone-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--cosmic-sky), var(--stardust-gold));
  border-radius: var(--radius-pill);
  box-shadow: 0 0 6px rgba(253, 224, 71, 0.5);
  transition: width 0.3s ease;
}

/* Multiplayer Live HUD (Co-op / PvP) */
.mp-hud-panel {
  pointer-events: auto;
  width: 320px;
  background: var(--surface-hud-elevated);
  backdrop-filter: var(--blur-hud);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  box-shadow: var(--shadow-card);
}

.mp-hud-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--cosmic-sky);
}

.btn-disconnect {
  background: transparent;
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: var(--plasma-rose);
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  font-size: 0.68rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-disconnect:hover {
  background: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.6);
}

.pvp-duel-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.duel-labels {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
}

.duel-label.my { color: var(--bio-mint); }
.duel-vs { color: var(--stardust-gold); }
.duel-label.enemy { color: var(--plasma-rose); }

.duel-bar-wrapper {
  display: flex;
  height: 8px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: var(--radius-pill);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.duel-side {
  flex: 1;
  height: 100%;
}

.duel-fill.my-fill {
  height: 100%;
  background: var(--bio-emerald);
  transition: width 0.3s;
}

.duel-fill.enemy-fill {
  height: 100%;
  background: var(--plasma-rose);
  float: right;
  transition: width 0.3s;
}

/* PvP Cataclysms Grid */
.cataclysms-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 8px;
}

.cataclysm-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  background: rgba(244, 63, 94, 0.12);
  border: 1px solid rgba(244, 63, 94, 0.25);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.cataclysm-btn:hover:not(.disabled) {
  background: rgba(244, 63, 94, 0.25);
  border-color: rgba(244, 63, 94, 0.5);
  transform: translateY(-1px);
}

.cataclysm-btn.disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.cat-icon { font-size: 1rem; }
.cat-name { font-size: 0.68rem; font-weight: 600; text-align: center; }
.cat-cost { font-family: var(--font-mono); font-size: 0.65rem; color: var(--stardust-gold); }

/* ==========================================================================
   3. COLLAPSIBLE RIGHT SHOP DRAWER (UPGRADES CATALOG)
   ========================================================================== */

#shop-drawer {
  position: fixed;
  right: 18px;
  top: 72px;
  width: 360px;
  height: calc(100vh - 90px);
  background: var(--surface-hud-elevated);
  backdrop-filter: var(--blur-hud);
  -webkit-backdrop-filter: var(--blur-hud);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  z-index: 30;
  transition: transform 0.35s var(--ease-snappy), opacity 0.3s ease;
}

#shop-drawer.collapsed {
  transform: translateX(calc(100% + 24px));
}

/* Sleek Edge Tab to Collapse / Expand */
.drawer-toggle-tab {
  position: absolute;
  left: -40px;
  top: 14px;
  width: 40px;
  height: 52px;
  background: var(--surface-hud-elevated);
  backdrop-filter: var(--blur-hud);
  -webkit-backdrop-filter: var(--blur-hud);
  border: 1px solid var(--border-subtle);
  border-right: none;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  box-shadow: -4px 4px 14px rgba(0, 0, 0, 0.4);
  transition: all var(--transition-fast);
  outline: none;
}

.drawer-toggle-tab:hover {
  background: var(--surface-card-hover);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

.tab-arrow, .toggle-icon {
  font-size: 0.85rem;
  line-height: 1;
  color: var(--cosmic-sky);
  transition: transform var(--transition-normal);
}

#shop-drawer.collapsed .toggle-icon {
  transform: rotate(180deg);
}

.toggle-text {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  letter-spacing: 0.5px;
  writing-mode: vertical-rl;
  text-orientation: mixed;
}

/* Drawer Header */
.drawer-header {
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
}

.drawer-title-group {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.drawer-tag {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--bio-mint);
}

.drawer-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.drawer-shortcut-hint {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--text-tertiary);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
}

/* Category Navigation Segmented Bar */
.categories-nav {
  display: flex;
  padding: 6px 10px;
  gap: 3px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.25);
  overflow-x: auto;
}

.categories-nav::-webkit-scrollbar {
  display: none;
}

.category-tab {
  flex: 1;
  white-space: nowrap;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 6px 6px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
}

.category-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.category-tab.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-weight: 700;
}

/* Upgrades Scrollable Area */
.upgrades-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.upgrades-scroll::-webkit-scrollbar {
  width: 4px;
}

.upgrades-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-pill);
}

/* Upgrade Card Refinement */
.upgrade-card {
  display: flex;
  flex-direction: column;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
  min-height: 68px;
}

.upgrade-card.affordable:hover {
  background: var(--surface-card-hover);
  border-color: rgba(52, 211, 153, 0.4);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.upgrade-card.locked {
  opacity: 0.65;
}

.upgrade-card.shake {
  animation: shake-card 0.35s cubic-bezier(.36, .07, .19, .97) both;
  border-color: rgba(244, 63, 94, 0.7) !important;
}

.upgrade-card-main {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
}

.upgrade-icon {
  font-size: 1.5rem;
  width: 44px;
  height: 44px;
  min-width: 44px;
  max-width: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.upgrade-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.upgrade-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.upgrade-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upgrade-level {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--bio-mint);
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 1px 5px;
  border-radius: var(--radius-xs);
}

.upgrade-desc {
  font-size: 0.68rem;
  color: var(--text-secondary);
  line-height: 1.25;
}

.upgrade-cost-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.upgrade-cost {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--stardust-gold);
}

/* Micro Progress Bar inside Upgrade Cards */
.upgrade-progress-track {
  width: 100%;
  height: 2px;
  background: rgba(0, 0, 0, 0.4);
  position: relative;
}

.upgrade-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--bio-mint);
  transition: width 0.2s ease;
}

.upgrade-card.affordable .upgrade-progress-bar {
  background: var(--bio-emerald);
}

/* ==========================================================================
   4. MODALS & CINEMATIC TERMINALS
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(4, 7, 13, 0.82);
  backdrop-filter: var(--blur-modal);
  -webkit-backdrop-filter: var(--blur-modal);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  animation: fade-in 0.2s ease;
}

.modal-card {
  width: 90%;
  max-width: 540px;
  background: var(--surface-hud-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  animation: slide-up 0.25s var(--ease-snappy);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.2);
}

.modal-header-text, .reality-header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.modal-tag {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--cosmic-sky);
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
}

.reality-sub {
  font-size: 0.72rem;
  color: var(--text-tertiary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  transition: all var(--transition-fast);
}

.modal-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.modal-body {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-intro {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* 🧬 Evolution Reveal Modal */
.evolution-modal-card {
  width: 90%;
  max-width: 480px;
  background: rgba(8, 14, 26, 0.96);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: var(--radius-lg);
  box-shadow: 0 0 50px rgba(56, 189, 248, 0.2), inset 0 0 20px rgba(139, 92, 246, 0.1);
  padding: 30px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  animation: slide-up 0.3s var(--ease-snappy);
  position: relative;
  overflow: hidden;
}

.evolution-badge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--cosmic-sky);
  letter-spacing: 2px;
  background: rgba(56, 189, 248, 0.12);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(56, 189, 248, 0.25);
}

.evolution-icon-anim {
  font-size: 3.4rem;
  margin: 4px 0;
  filter: drop-shadow(0 0 16px rgba(56, 189, 248, 0.6));
  animation: float-soft 3s ease-in-out infinite;
}

.evolution-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
}

.evolution-organism {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--singularity-purple);
}

.evolution-text {
  font-size: 0.82rem;
  color: #cbd5e1;
  line-height: 1.55;
  background: rgba(0, 0, 0, 0.35);
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  text-align: left;
}

.evolution-btn {
  margin-top: 8px;
  padding: 10px 22px;
  font-size: 0.85rem;
}

/* 🌀 Reality Engine / Prestige Modal */
.reality-modal-card {
  max-width: 620px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.reality-body {
  padding: 18px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.rebirth-banner {
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.rebirth-stats {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.stardust-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.stardust-val {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  color: var(--stardust-gold);
  font-weight: 800;
}

.pending-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pending-val {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--cosmic-sky);
  font-weight: 700;
}

.reality-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--singularity-purple);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1.5px;
}

.reality-divider::before, .reality-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border-subtle);
}

.reality-divider span {
  padding: 0 10px;
}

.talents-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.talent-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.talent-card.affordable-talent:hover {
  background: var(--surface-card-hover);
  border-color: rgba(139, 92, 246, 0.5);
  transform: translateY(-1px);
}

.talent-card.locked-talent {
  opacity: 0.5;
  cursor: not-allowed;
}

.talent-card.maxed {
  border-color: rgba(52, 211, 153, 0.4);
  background: rgba(16, 185, 129, 0.06);
  cursor: default;
}

.talent-icon {
  font-size: 1.5rem;
  min-width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.talent-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.talent-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.talent-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
}

.talent-level {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--singularity-purple);
  background: rgba(139, 92, 246, 0.12);
  padding: 1px 6px;
  border-radius: var(--radius-xs);
}

.talent-desc {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.talent-cost {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--stardust-gold);
}

.talent-maxed-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--bio-mint);
}

/* 📜 Logbook Modal */
.logbook-card {
  max-width: 580px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.logbook-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.logbook-entry {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.logbook-entry.unlocked {
  border-left: 3px solid var(--bio-mint);
}

.logbook-entry.locked-entry {
  opacity: 0.45;
  border-left: 3px solid var(--text-tertiary);
}

.entry-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.entry-icon { font-size: 1.1rem; }
.entry-title { font-weight: 700; font-size: 0.82rem; flex: 1; }
.entry-date { font-family: var(--font-mono); font-size: 0.68rem; color: var(--text-tertiary); }
.entry-body { font-size: 0.75rem; color: #cbd5e1; line-height: 1.4; }
.locked-text { font-style: italic; color: var(--text-tertiary); }

.logbook-section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--cosmic-sky);
  padding: 6px 2px;
  border-bottom: 1px solid var(--border-subtle);
  margin-top: 6px;
}

.logbook-section-title.mt-4 {
  margin-top: 18px;
}

.badge-mini {
  background: rgba(56, 189, 248, 0.12);
  color: var(--cosmic-sky);
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  font-size: 0.65rem;
}

.achievements-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 4px;
}

.ach-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  transition: all var(--transition-fast);
}

.ach-card.unlocked {
  border-left: 3px solid var(--stardust-gold);
  background: rgba(253, 224, 71, 0.03);
}

.ach-card.locked {
  opacity: 0.45;
  border-left: 3px solid var(--border-subtle);
}

.ach-icon {
  font-size: 1.4rem;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.ach-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ach-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
}

.ach-desc {
  font-size: 0.7rem;
  color: var(--text-secondary);
  line-height: 1.35;
}

.ach-status {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--stardust-gold);
}

/* 🌋 Anomaly Modal */
.anomaly-card {
  max-width: 460px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.anomaly-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.anomaly-big-icon {
  font-size: 1.8rem;
  background: rgba(139, 92, 246, 0.15);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.anomaly-header-text {
  flex: 1;
}

.anomaly-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--singularity-purple);
  letter-spacing: 1.5px;
}

.anomaly-title {
  font-size: 1.05rem;
  font-weight: 700;
}

.anomaly-desc {
  font-size: 0.8rem;
  color: #cbd5e1;
  background: rgba(0, 0, 0, 0.35);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.anomaly-choice-prompt {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--stardust-gold);
}

.anomaly-choices-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 👥 Multiplayer Modal */
.mp-modes-selection {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mp-mode-card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mp-mode-card h4 {
  font-size: 0.85rem;
  font-weight: 700;
}

.mp-mode-card p {
  font-size: 0.7rem;
  color: var(--text-secondary);
  flex: 1;
  line-height: 1.35;
}

.room-share-box {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.share-code-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
}

.code-badge {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  letter-spacing: 2px;
  color: var(--bio-mint);
  background: rgba(0, 0, 0, 0.4);
  padding: 3px 10px;
  border-radius: var(--radius-xs);
}

.modal-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 0.68rem;
}

.modal-divider::before, .modal-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-divider span {
  padding: 0 10px;
}

.join-room-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.join-room-section h4 {
  font-size: 0.82rem;
  font-weight: 700;
}

.join-input-group {
  display: flex;
  gap: 6px;
}

.join-input-group input {
  flex: 1;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  outline: none;
}

.join-input-group input:focus {
  border-color: var(--cosmic-sky);
}

/* ==========================================================================
   5. TOAST NOTIFICATIONS
   ========================================================================== */

.toast-area {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  animation: slide-up 0.25s var(--ease-snappy);
  transition: opacity 0.3s, transform 0.3s;
}

.toast-info {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--border-medium);
  color: #f8fafc;
}

.toast-success {
  background: rgba(6, 78, 59, 0.95);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #d1fae5;
}

.toast-warning {
  background: rgba(136, 19, 55, 0.95);
  border: 1px solid rgba(244, 63, 94, 0.4);
  color: #ffe4e6;
}

.toast.fade-out {
  opacity: 0;
  transform: translateY(8px);
}

/* Utility */
.hidden {
  display: none !important;
}

/* Animations */
@keyframes float-soft {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 8px rgba(245, 158, 11, 0.3); }
  50% { box-shadow: 0 0 16px rgba(245, 158, 11, 0.6); }
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes shake-card {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-3px, 0, 0); }
  40%, 60% { transform: translate3d(3px, 0, 0); }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Responsive adjustments for Tablets and Mobile */
@media (max-width: 1100px) {
  .stage-desc-text {
    display: none;
  }
}

@media (max-width: 900px) {
  #top-bar {
    padding: 6px 12px;
    gap: 10px;
    height: 48px;
  }
  
  .stage-info {
    display: none;
  }

  .habitability-container {
    max-width: 220px;
  }

  .btn-label {
    display: none;
  }

  .btn-hud {
    padding: 6px 8px;
  }

  #main-content {
    flex-direction: column;
    padding: 8px;
  }

  #center-display {
    top: 6px;
    width: 92%;
  }

  #shop-drawer {
    right: 0;
    bottom: 0;
    top: auto;
    width: 100vw;
    height: 50vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(0);
  }

  #shop-drawer.collapsed {
    transform: translateY(100%);
  }

  .drawer-toggle-tab {
    left: auto;
    right: 20px;
    top: -38px;
    width: 80px;
    height: 38px;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    border-right: 1px solid var(--border-subtle);
    border-bottom: none;
    flex-direction: row;
    gap: 6px;
  }

  .toggle-text {
    writing-mode: horizontal-tb;
  }

  .mp-modes-selection {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .logo-tag {
    display: none;
  }
  .habitability-container {
    display: none;
  }
}
