/* ============================================================
   BACTERIA GROWER - STYLE SYSTEM
   Dark biology/lab theme with glowing accents
   ============================================================ */

/* --- CSS Custom Properties (Theming) --- */
:root {
  /* Base colors */
  --bg-primary: #0a0e1a;
  --bg-secondary: #0f1424;
  --bg-tertiary: #141a2e;
  --bg-card: #161d32;
  --bg-card-hover: #1c2540;
  --bg-panel: #0d1220;

  /* Accent colors (strain: default) */
  --accent-primary: #00ff88;
  --accent-primary-dim: #00ff8833;
  --accent-primary-glow: #00ff8866;
  --accent-secondary: #00ccff;
  --accent-secondary-dim: #00ccff33;
  --accent-tertiary: #8844ff;
  --accent-warning: #ffaa00;
  --accent-danger: #ff4466;
  --accent-achievement: #ffd700;

  /* Text colors */
  --text-primary: #e8f0ff;
  --text-secondary: #8899bb;
  --text-dim: #556688;
  --text-accent: var(--accent-primary);

  /* Borders */
  --border-color: #1e2a44;
  --border-glow: var(--accent-primary-dim);

  /* Sizing */
  --top-bar-height: 56px;
  --bottom-bar-height: 40px;
  --panel-width: 320px;
  --petri-size: 280px;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s ease;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px var(--accent-primary-dim);
}

/* Strain themes */
.strain-bioluminescent {
  --accent-primary: #00ffcc;
  --accent-primary-dim: #00ffcc33;
  --accent-primary-glow: #00ffcc66;
  --accent-secondary: #66ffee;
}

.strain-extremophile {
  --accent-primary: #ff6633;
  --accent-primary-dim: #ff663333;
  --accent-primary-glow: #ff663366;
  --accent-secondary: #ffaa33;
}

.strain-nanobacteria {
  --accent-primary: #aa66ff;
  --accent-primary-dim: #aa66ff33;
  --accent-primary-glow: #aa66ff66;
  --accent-secondary: #cc88ff;
}

.strain-archaea {
  --accent-primary: #ffd700;
  --accent-primary-dim: rgba(255, 215, 0, 0.15);
  --accent-primary-glow: rgba(255, 215, 0, 0.3);
  --accent-secondary: #daa520;
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
  -webkit-user-select: none;
}

/* --- Hex/Grid Background Pattern --- */
.bg-pattern {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image:
    linear-gradient(var(--accent-primary) 1px, transparent 1px),
    linear-gradient(90deg, var(--accent-primary) 1px, transparent 1px);
  background-size: 60px 60px;
}

.bg-pattern::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 50%, transparent 30%, var(--bg-primary) 80%);
}

/* --- Floating Background Bacteria --- */
.bg-bacteria {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.bg-bacterium {
  position: absolute;
  border-radius: 50%;
  background: var(--accent-primary);
  opacity: 0.04;
  filter: blur(2px);
}

.bg-bacterium.b1 { width: 80px; height: 80px; top: 10%; left: 5%; animation: bgFloat 25s ease-in-out infinite; }
.bg-bacterium.b2 { width: 50px; height: 50px; top: 60%; left: 15%; animation: bgFloat 20s ease-in-out infinite 3s; }
.bg-bacterium.b3 { width: 120px; height: 120px; top: 30%; right: 10%; animation: bgFloat 30s ease-in-out infinite 7s; }
.bg-bacterium.b4 { width: 40px; height: 40px; top: 80%; right: 20%; animation: bgFloat 18s ease-in-out infinite 2s; }
.bg-bacterium.b5 { width: 90px; height: 90px; bottom: 15%; left: 40%; animation: bgFloat 22s ease-in-out infinite 5s; }
.bg-bacterium.b6 { width: 60px; height: 60px; top: 20%; left: 50%; animation: bgFloat 28s ease-in-out infinite 9s; }
.bg-bacterium.b7 { width: 35px; height: 35px; top: 45%; right: 35%; animation: bgFloat 16s ease-in-out infinite 1s; }
.bg-bacterium.b8 { width: 70px; height: 70px; bottom: 30%; right: 5%; animation: bgFloat 24s ease-in-out infinite 6s; }

@keyframes bgFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(30px, -20px) scale(1.1); }
  50% { transform: translate(-20px, 30px) scale(0.9); }
  75% { transform: translate(15px, 15px) scale(1.05); }
}

/* --- Particle Canvas --- */
#particle-canvas {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  width: 100%;
  height: 100%;
}

/* --- Top Bar --- */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--top-bar-height);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(10px);
}

.top-bar-left {
  display: flex;
  gap: 24px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
}

.stat-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-primary);
  font-variant-numeric: tabular-nums;
}

.top-bar-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.game-title {
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 1px;
}

.version-tag {
  font-size: 10px;
  color: var(--text-dim);
  font-weight: 400;
  letter-spacing: 0.5px;
}

.credit-footer {
  position: fixed;
  bottom: var(--bottom-bar-height);
  right: 10px;
  transform: translateY(-4px);
  font-size: 10px;
  color: var(--text-dim);
  opacity: 0.5;
  z-index: 99;
  pointer-events: none;
}

.top-bar-right {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  outline: none;
  font-family: inherit;
}

.btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary-dim);
  box-shadow: var(--shadow-glow);
}

.btn:active {
  transform: scale(0.95);
  transition-duration: 0.06s;
  filter: brightness(0.9);
}

/* Spring-back on all clickable elements */
.btn, .building-card, .upgrade-item, .mutation-node, .strain-card, .tab {
  transition: all var(--transition-fast), transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-icon {
  font-size: 16px;
}

.btn-evolve {
  border-color: var(--accent-tertiary);
  background: linear-gradient(135deg, #1a1040, #2a1560);
  color: #cc88ff;
}

.btn-evolve:hover {
  border-color: var(--accent-tertiary);
  box-shadow: 0 0 20px rgba(136, 68, 255, 0.3);
  background: linear-gradient(135deg, #221450, #351a70);
}

.btn-evolve.can-evolve {
  animation: evolveGlow 2s ease-in-out infinite;
}

@keyframes evolveGlow {
  0%, 100% { box-shadow: 0 0 10px rgba(136, 68, 255, 0.2); }
  50% { box-shadow: 0 0 25px rgba(136, 68, 255, 0.5); }
}

.btn-settings {
  padding: 8px 10px;
}

.btn-danger {
  border-color: var(--accent-danger);
  color: var(--accent-danger);
}

.btn-danger:hover {
  background: rgba(255, 68, 102, 0.1);
  box-shadow: 0 0 20px rgba(255, 68, 102, 0.2);
}

.btn-cancel {
  background: var(--bg-tertiary);
}

.btn-confirm-evolve {
  background: linear-gradient(135deg, #1a1040, #2a1560);
  border-color: var(--accent-tertiary);
  color: #cc88ff;
}

.btn-confirm-evolve:hover {
  box-shadow: 0 0 25px rgba(136, 68, 255, 0.4);
}

.btn-save-action {
  flex: 1;
  justify-content: center;
  font-size: 12px;
}

/* --- Main Game Layout --- */
.game-layout {
  position: fixed;
  top: var(--top-bar-height);
  bottom: var(--bottom-bar-height);
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: var(--panel-width) 1fr var(--panel-width);
  z-index: 1;
  overflow: hidden;
}

/* --- Panels --- */
.panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-right: 1px solid var(--border-color);
  overflow: hidden;
}

.panel-right {
  border-right: none;
  border-left: 1px solid var(--border-color);
}

.panel-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.panel-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.panel-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* --- Custom Scrollbar --- */
.panel-content::-webkit-scrollbar {
  width: 6px;
}

.panel-content::-webkit-scrollbar-track {
  background: transparent;
}

.panel-content::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.panel-content::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

/* --- Building Cards --- */
.building-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.building-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary-dim);
  box-shadow: 0 0 12px var(--accent-primary-dim), 0 4px 16px rgba(0, 0, 0, 0.3);
  transform: translateY(-2px) translateX(2px);
}

.building-card:active {
  transform: scale(0.97) translateY(0px);
  transition-duration: 0.05s;
}

.building-card.locked {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.6);
  pointer-events: none;
}

.building-card.cant-afford {
  opacity: 0.7;
}

.building-card.cant-afford .building-cost {
  color: var(--accent-danger);
}

.building-card.can-afford .building-cost {
  color: var(--accent-primary);
}

.building-icon {
  display: none;
}

.building-info {
  flex: 1;
  min-width: 0;
}

.building-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.building-production {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 1px;
}

.building-bps-increase {
  font-size: 10px;
  color: var(--accent-primary);
  opacity: 0.8;
  margin-top: 1px;
  white-space: nowrap;
}

.building-right {
  text-align: right;
  flex-shrink: 0;
}

.building-count {
  font-size: 18px;
  font-weight: 800;
  color: var(--accent-primary);
  line-height: 1;
}

.building-cost {
  font-size: 11px;
  font-weight: 600;
  margin-top: 2px;
  transition: color 0.4s ease;
}

/* Smooth color transitions for all affordability states */
.building-card.can-afford .building-count {
  color: var(--accent-primary);
  transition: color 0.4s ease;
}

.building-card.cant-afford .building-count {
  color: var(--text-dim);
  transition: color 0.4s ease;
}

.upgrade-item {
  transition: all var(--transition-fast), border-color 0.4s ease, opacity 0.4s ease;
}

.mutation-cost {
  transition: color 0.4s ease;
}

/* Building milestone celebration burst */
.building-milestone {
  animation: milestoneBurst 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes milestoneBurst {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(255, 215, 0, 0);
  }
  20% {
    transform: scale(1.08);
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.6), 0 0 60px rgba(255, 215, 0, 0.3), inset 0 0 20px rgba(255, 215, 0, 0.1);
    border-color: var(--accent-achievement);
    background: linear-gradient(135deg, var(--bg-card), rgba(255, 215, 0, 0.1));
  }
  40% {
    transform: scale(1.03);
  }
  60% {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(255, 215, 0, 0);
    border-color: var(--border-color);
    background: var(--bg-card);
  }
}

/* Building purchase pop animation */
.building-purchased {
  animation: buildingPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes buildingPop {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(0, 255, 136, 0);
  }
  30% {
    transform: scale(1.06);
    box-shadow: 0 0 25px rgba(0, 255, 136, 0.5), inset 0 0 15px rgba(0, 255, 136, 0.15);
    border-color: var(--accent-primary);
    background: linear-gradient(135deg, var(--bg-card), rgba(0, 255, 136, 0.12));
  }
  60% {
    transform: scale(0.98);
    box-shadow: 0 0 12px rgba(0, 255, 136, 0.2);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(0, 255, 136, 0);
    border-color: var(--border-color);
    background: var(--bg-card);
  }
}

/* Building milestone progress bar */
.building-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--bg-primary);
}

.building-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  transition: width var(--transition-normal);
  border-radius: 0 2px 2px 0;
}

/* --- Tab Bar --- */
.tab-bar {
  display: flex;
  gap: 2px;
  background: var(--bg-primary);
  border-radius: 8px;
  padding: 3px;
}

.tab {
  flex: 1;
  padding: 7px 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
  position: relative;
}

.tab:hover {
  color: var(--text-secondary);
  background: var(--bg-tertiary);
}

.tab.active {
  color: var(--accent-primary);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

/* Tab content with crossfade transition */
.tab-content {
  display: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.tab-content.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
  animation: tabFadeIn 0.3s ease forwards;
}

@keyframes tabFadeIn {
  0% {
    opacity: 0;
    transform: translateY(8px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Upgrades Grid --- */
.upgrades-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 8px;
  padding: 4px;
}

.upgrade-item {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  border: 2px solid var(--border-color);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.upgrade-item:hover {
  border-color: var(--accent-primary);
  box-shadow: 0 0 15px var(--accent-primary-dim);
  transform: scale(1.05);
  z-index: 2;
}

.upgrade-item:active {
  transform: scale(0.95);
}

.upgrade-item.purchased {
  border-color: var(--accent-primary);
  background: linear-gradient(135deg, var(--bg-card), rgba(0, 255, 136, 0.08));
  opacity: 0.6;
  pointer-events: none;
}

.upgrade-item.purchased::after {
  content: '✓';
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 10px;
  color: var(--accent-primary);
}

.upgrade-item.locked {
  opacity: 0.25;
  pointer-events: none;
  filter: grayscale(1);
}

.upgrade-item.can-afford {
  border-color: var(--accent-primary-dim);
}

.upgrade-item.cant-afford {
  opacity: 0.65;
}

/* Upgrade purchase flash/unlock animation */
.upgrade-purchased-anim {
  animation: upgradePurchaseFlash 0.6s ease-out forwards;
  pointer-events: none;
}

@keyframes upgradePurchaseFlash {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(0, 255, 136, 0);
    filter: brightness(1);
  }
  15% {
    transform: scale(1.2);
    box-shadow: 0 0 30px rgba(0, 255, 136, 0.7), 0 0 60px rgba(0, 255, 136, 0.3);
    filter: brightness(2);
    border-color: #fff;
  }
  40% {
    transform: scale(0.9);
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.4);
    filter: brightness(1.3);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(0, 255, 136, 0);
    filter: brightness(1);
    opacity: 0.6;
    border-color: var(--accent-primary);
    background: linear-gradient(135deg, var(--bg-card), rgba(0, 255, 136, 0.08));
  }
}

/* Upgrade tooltip */
.upgrade-tooltip {
  position: fixed;
  z-index: 1000;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px 14px;
  max-width: 250px;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.upgrade-tooltip.visible {
  opacity: 1;
}

.upgrade-tooltip-name {
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.upgrade-tooltip-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  line-height: 1.4;
}

.upgrade-tooltip-cost {
  font-size: 12px;
  font-weight: 700;
}

/* --- Prestige/Mutations --- */
.prestige-info {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.prestige-stat {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px 12px;
  text-align: center;
}

.prestige-label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.prestige-value {
  display: block;
  font-size: 18px;
  font-weight: 800;
  color: var(--accent-tertiary);
}

.prestige-preview {
  color: var(--accent-warning);
}

/* Mutation tree nodes */
.mutation-node {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.mutation-node:hover {
  border-color: var(--accent-tertiary);
  box-shadow: 0 0 15px rgba(136, 68, 255, 0.2);
}

.mutation-node.purchased {
  border-color: var(--accent-tertiary);
  background: linear-gradient(135deg, var(--bg-card), rgba(136, 68, 255, 0.08));
}

.mutation-node.locked {
  opacity: 0.35;
  pointer-events: none;
}

.mutation-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.mutation-info {
  flex: 1;
}

.mutation-name {
  font-weight: 700;
  font-size: 13px;
}

.mutation-desc {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: pre-line;
}

.mutation-level {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent-tertiary);
}

.mutation-cost {
  font-size: 11px;
  color: var(--text-dim);
}

/* Strain cards */
.strain-card {
  padding: 14px;
  margin-bottom: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.strain-card:hover {
  border-color: var(--accent-secondary-dim);
  box-shadow: 0 0 15px var(--accent-secondary-dim);
}

.strain-card.active-strain {
  border-color: var(--accent-primary);
  background: linear-gradient(135deg, var(--bg-card), var(--accent-primary-dim));
}

.strain-card.locked {
  opacity: 0.3;
  pointer-events: none;
}

.strain-card-name {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
}

.strain-card-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

.strain-card-cost {
  font-size: 11px;
  color: var(--accent-warning);
  margin-top: 4px;
}

/* --- Organic Background Blobs (lava lamp effect) --- */
.center-area::before,
.center-area::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.07;
}

.center-area::before {
  width: 300px;
  height: 300px;
  background: var(--accent-primary);
  top: 10%;
  left: -5%;
  animation: blobFloat1 20s ease-in-out infinite;
}

.center-area::after {
  width: 250px;
  height: 250px;
  background: var(--accent-secondary);
  bottom: 5%;
  right: -5%;
  animation: blobFloat2 25s ease-in-out infinite;
}

@keyframes blobFloat1 {
  0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.07; }
  25% { transform: translate(40px, 30px) scale(1.2); opacity: 0.1; }
  50% { transform: translate(20px, -20px) scale(0.9); opacity: 0.06; }
  75% { transform: translate(-30px, 15px) scale(1.1); opacity: 0.09; }
}

@keyframes blobFloat2 {
  0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.06; }
  25% { transform: translate(-35px, -25px) scale(1.15); opacity: 0.08; }
  50% { transform: translate(15px, 35px) scale(0.85); opacity: 0.05; }
  75% { transform: translate(25px, -10px) scale(1.05); opacity: 0.07; }
}

/* --- Center Area --- */
.center-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 20px;
}

/* Bacteria count display */
.bacteria-count-area {
  text-align: center;
  margin-bottom: 24px;
  z-index: 2;
}

.bacteria-count {
  font-size: 48px;
  font-weight: 900;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  text-shadow: 0 0 30px var(--accent-primary-dim);
  transition: transform 0.1s ease;
}

.bacteria-count.bump {
  transform: scale(1.05);
}

/* Pulse animation for significant bacteria count changes (click) */
.bacteria-pulse {
  animation: bacteriaPulse 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes bacteriaPulse {
  0% {
    transform: scale(1);
    text-shadow: 0 0 30px var(--accent-primary-dim);
    filter: brightness(1);
  }
  40% {
    transform: scale(1.12);
    text-shadow: 0 0 50px var(--accent-primary-glow), 0 0 80px var(--accent-primary-dim);
    filter: brightness(1.3);
  }
  100% {
    transform: scale(1);
    text-shadow: 0 0 30px var(--accent-primary-dim);
    filter: brightness(1);
  }
}

.bacteria-label {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: var(--text-dim);
  margin-top: 2px;
}

.bps-display {
  margin-top: 6px;
  font-size: 14px;
  color: var(--text-secondary);
}

.bps-value {
  color: var(--accent-secondary);
  font-weight: 700;
}

/* --- Petri Dish --- */
.petri-dish-container {
  position: relative;
  z-index: 2;
}

.petri-dish {
  width: var(--petri-size);
  height: var(--petri-size);
  border-radius: 50%;
  position: relative;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.petri-dish:active {
  transform: scale(0.96);
  transition-duration: 0.06s;
}

/* Satisfying spring-back after click release */
.petri-dish {
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.petri-dish-inner {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 40%,
    rgba(0, 255, 136, 0.08) 0%,
    rgba(0, 255, 136, 0.03) 40%,
    rgba(10, 14, 26, 0.9) 80%
  );
  border: 2px solid var(--accent-primary-dim);
  box-shadow:
    0 0 30px var(--accent-primary-dim),
    0 0 60px rgba(0, 255, 136, 0.1),
    inset 0 0 40px rgba(0, 255, 136, 0.05);
  animation: petriPulse 3s ease-in-out infinite;
  overflow: hidden;
}

@keyframes petriPulse {
  0%, 100% {
    box-shadow:
      0 0 30px var(--accent-primary-dim),
      0 0 60px rgba(0, 255, 136, 0.1),
      inset 0 0 40px rgba(0, 255, 136, 0.05);
    border-color: var(--accent-primary-dim);
  }
  50% {
    box-shadow:
      0 0 40px var(--accent-primary-glow),
      0 0 80px rgba(0, 255, 136, 0.15),
      inset 0 0 50px rgba(0, 255, 136, 0.08);
    border-color: var(--accent-primary-glow);
  }
}

.petri-glow {
  position: absolute;
  inset: -20%;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-primary-dim) 0%, transparent 60%);
  opacity: 0.5;
  animation: petriGlow 4s ease-in-out infinite alternate;
}

@keyframes petriGlow {
  0% { opacity: 0.3; transform: scale(0.95); }
  100% { opacity: 0.6; transform: scale(1.05); }
}

#petri-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

/* Petri dish biological texture overlay */
.petri-dish-inner::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(ellipse 3px 3px at 20% 30%, rgba(0, 255, 136, 0.06) 0%, transparent 100%),
    radial-gradient(ellipse 4px 2px at 55% 25%, rgba(0, 204, 255, 0.05) 0%, transparent 100%),
    radial-gradient(ellipse 2px 4px at 75% 65%, rgba(0, 255, 136, 0.04) 0%, transparent 100%),
    radial-gradient(ellipse 3px 3px at 35% 70%, rgba(0, 204, 255, 0.05) 0%, transparent 100%),
    radial-gradient(ellipse 2px 3px at 60% 50%, rgba(0, 255, 136, 0.03) 0%, transparent 100%),
    radial-gradient(ellipse 4px 2px at 15% 55%, rgba(0, 255, 136, 0.04) 0%, transparent 100%),
    radial-gradient(ellipse 3px 4px at 85% 40%, rgba(0, 204, 255, 0.04) 0%, transparent 100%),
    radial-gradient(ellipse 2px 2px at 45% 85%, rgba(0, 255, 136, 0.05) 0%, transparent 100%);
  animation: bioTexture 20s ease-in-out infinite;
  pointer-events: none;
  z-index: 1;
  opacity: 0.7;
}

@keyframes bioTexture {
  0%, 100% { transform: rotate(0deg) scale(1); opacity: 0.7; }
  25% { transform: rotate(2deg) scale(1.02); opacity: 0.8; }
  50% { transform: rotate(-1deg) scale(0.98); opacity: 0.6; }
  75% { transform: rotate(1deg) scale(1.01); opacity: 0.75; }
}

/* Petri dish idle bubbling/movement overlay */
.petri-dish-inner::before {
  content: '';
  position: absolute;
  inset: 10%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 25% 35%, rgba(0, 255, 136, 0.06) 0%, transparent 30%),
    radial-gradient(circle at 70% 60%, rgba(0, 255, 136, 0.04) 0%, transparent 25%),
    radial-gradient(circle at 50% 80%, rgba(0, 204, 255, 0.03) 0%, transparent 20%);
  animation: petriBubble 8s ease-in-out infinite;
  pointer-events: none;
  z-index: 1;
}

@keyframes petriBubble {
  0%, 100% {
    transform: translate(0, 0) scale(1);
    opacity: 0.6;
  }
  25% {
    transform: translate(5px, -8px) scale(1.05);
    opacity: 0.8;
  }
  50% {
    transform: translate(-3px, 5px) scale(0.95);
    opacity: 0.5;
  }
  75% {
    transform: translate(7px, 3px) scale(1.02);
    opacity: 0.7;
  }
}

/* Mitosis cell-split visual on click (spawned via JS) */
.mitosis-cell {
  position: absolute;
  border-radius: 50%;
  background: var(--accent-primary);
  pointer-events: none;
  z-index: 3;
  opacity: 0.7;
  animation: mitosisAnim 0.7s ease-out forwards;
}

.mitosis-cell.left {
  animation-name: mitosisLeft;
}

.mitosis-cell.right {
  animation-name: mitosisRight;
}

@keyframes mitosisLeft {
  0% {
    transform: scale(1) translate(0, 0);
    opacity: 0.7;
    border-radius: 50%;
  }
  30% {
    transform: scale(1.1, 0.85) translate(0, 0);
    opacity: 0.8;
    border-radius: 45% 55% 55% 45%;
  }
  60% {
    transform: scale(0.8) translate(-12px, 0);
    opacity: 0.6;
    border-radius: 50%;
  }
  100% {
    transform: scale(0.5) translate(-20px, 0);
    opacity: 0;
  }
}

@keyframes mitosisRight {
  0% {
    transform: scale(1) translate(0, 0);
    opacity: 0.7;
    border-radius: 50%;
  }
  30% {
    transform: scale(1.1, 0.85) translate(0, 0);
    opacity: 0.8;
    border-radius: 55% 45% 45% 55%;
  }
  60% {
    transform: scale(0.8) translate(12px, 0);
    opacity: 0.6;
    border-radius: 50%;
  }
  100% {
    transform: scale(0.5) translate(20px, 0);
    opacity: 0;
  }
}

/* Petri dish rings */
.petri-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid var(--accent-primary);
  opacity: 0;
  pointer-events: none;
}

.ring-1 {
  inset: 15%;
  opacity: 0.1;
  animation: ringPulse 4s ease-in-out infinite;
}

.ring-2 {
  inset: 30%;
  opacity: 0.08;
  animation: ringPulse 4s ease-in-out infinite 1.3s;
}

.ring-3 {
  inset: 45%;
  opacity: 0.06;
  animation: ringPulse 4s ease-in-out infinite 2.6s;
}

@keyframes ringPulse {
  0%, 100% { opacity: 0.04; transform: scale(1); }
  50% { opacity: 0.12; transform: scale(1.02); }
}

/* Click ripple effect */
.click-ripple-container {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  overflow: hidden;
  pointer-events: none;
}

.click-ripple {
  position: absolute;
  border-radius: 50%;
  border: 2px solid var(--accent-primary);
  opacity: 0.6;
  animation: rippleOut 0.6s ease-out forwards;
  pointer-events: none;
}

@keyframes rippleOut {
  0% {
    transform: scale(0);
    opacity: 0.6;
  }
  100% {
    transform: scale(3);
    opacity: 0;
  }
}

.click-hint {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-dim);
  opacity: 0.7;
  z-index: 2;
  transition: opacity var(--transition-slow);
}

.click-hint.hidden {
  opacity: 0;
}

/* --- Floating Numbers --- */
.floating-numbers {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}

.floating-number {
  position: absolute;
  font-size: 20px;
  font-weight: 800;
  color: var(--accent-primary);
  text-shadow: 0 0 10px var(--accent-primary-dim);
  pointer-events: none;
  animation: floatUp 1s ease-out forwards;
  z-index: 20;
}

@keyframes floatUp {
  0% {
    opacity: 1;
    transform: translateY(0) translateX(0) scale(1);
  }
  20% {
    opacity: 0.95;
    transform: translateY(-20px) translateX(8px) scale(1.15);
  }
  40% {
    opacity: 0.8;
    transform: translateY(-40px) translateX(-5px) scale(1.1);
  }
  60% {
    opacity: 0.5;
    transform: translateY(-60px) translateX(6px) scale(1.0);
  }
  80% {
    opacity: 0.2;
    transform: translateY(-75px) translateX(-3px) scale(0.9);
  }
  100% {
    opacity: 0;
    transform: translateY(-90px) translateX(4px) scale(0.7);
  }
}

/* Alternate floating direction variations (applied via JS) */
.floating-number.drift-left {
  animation-name: floatUpLeft;
}

@keyframes floatUpLeft {
  0% {
    opacity: 1;
    transform: translateY(0) translateX(0) scale(1);
  }
  20% {
    opacity: 0.95;
    transform: translateY(-20px) translateX(-10px) scale(1.15);
  }
  40% {
    opacity: 0.8;
    transform: translateY(-40px) translateX(4px) scale(1.1);
  }
  60% {
    opacity: 0.5;
    transform: translateY(-60px) translateX(-8px) scale(1.0);
  }
  80% {
    opacity: 0.2;
    transform: translateY(-75px) translateX(2px) scale(0.9);
  }
  100% {
    opacity: 0;
    transform: translateY(-90px) translateX(-5px) scale(0.7);
  }
}

.building-afforded {
  animation: affordableNotify 1.5s ease-in-out forwards;
}
@keyframes affordableNotify {
  0% { transform: scale(1); box-shadow: 0 0 0px var(--accent-primary); }
  20% { transform: scale(1.04); box-shadow: 0 0 20px var(--accent-primary); }
  40% { transform: scale(1); box-shadow: 0 0 8px var(--accent-primary-dim, rgba(100,200,100,0.3)); }
  60% { transform: scale(1.03); box-shadow: 0 0 15px var(--accent-primary); }
  100% { transform: scale(1); box-shadow: 0 0 0px var(--accent-primary); }
}

.petri-flash {
  animation: petriClickFlash 0.25s ease-out forwards;
}
@keyframes petriClickFlash {
  0% { filter: brightness(1); }
  40% { filter: brightness(1.6); box-shadow: inset 0 0 40px rgba(255,255,255,0.4); }
  100% { filter: brightness(1); }
}
.game-layout.click-jitter {
  animation: clickJitter 0.15s ease-out 1;
}
@keyframes clickJitter {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(1px, -1px); }
  50% { transform: translate(-1px, 1px); }
  75% { transform: translate(1px, 1px); }
}

@keyframes numberBurst {
  0% { transform: scale(1); opacity: 1; filter: drop-shadow(0 0 0px var(--accent-primary)); }
  15% { transform: scale(1.4); filter: drop-shadow(0 0 12px var(--accent-primary)); }
  100% { transform: scale(1); opacity: 0; filter: drop-shadow(0 0 0px var(--accent-primary)); }
}

/* Combo indicator - compact side display */
.combo-indicator {
  position: fixed;
  z-index: 25;
  font-weight: 800;
  font-size: 13px;
  color: var(--accent-warning);
  text-shadow: 0 0 10px rgba(255, 170, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  transition: transform 0.12s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  white-space: nowrap;
  background: rgba(10, 14, 26, 0.85);
  border: 1px solid rgba(255, 170, 0, 0.3);
  border-radius: 8px;
  padding: 4px 10px;
  backdrop-filter: blur(4px);
}

.combo-indicator .combo-label {
  display: block;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.7;
  margin-bottom: 1px;
}

.combo-indicator .combo-bar {
  height: 3px;
  background: var(--accent-warning);
  border-radius: 2px;
  margin-top: 3px;
  transition: width 0.15s ease;
  box-shadow: 0 0 6px rgba(255, 170, 0, 0.5);
}

.combo-indicator.combo-ready {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  text-shadow: 0 0 12px var(--accent-primary-glow);
  animation: comboReady 0.6s ease infinite alternate;
}

.combo-indicator.combo-ready .combo-bar {
  background: var(--accent-primary);
  box-shadow: 0 0 8px var(--accent-primary-glow);
}

@keyframes comboReady {
  from { box-shadow: 0 0 8px var(--accent-primary-dim); }
  to { box-shadow: 0 0 16px var(--accent-primary-glow); }
}

.combo-indicator.fading {
  opacity: 0;
  transform: translateY(10px) scale(0.8);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

/* Screen shake animation */
.screen-shake {
  animation: screenShake 0.3s ease-out;
}

@keyframes screenShake {
  0% { transform: translate(0, 0); }
  15% { transform: translate(-3px, 2px); }
  30% { transform: translate(3px, -2px); }
  45% { transform: translate(-2px, -1px); }
  60% { transform: translate(2px, 1px); }
  75% { transform: translate(-1px, 1px); }
  100% { transform: translate(0, 0); }
}

.screen-shake-strong {
  animation: screenShakeStrong 0.4s ease-out;
}

@keyframes screenShakeStrong {
  0% { transform: translate(0, 0); }
  10% { transform: translate(-5px, 3px); }
  20% { transform: translate(5px, -4px); }
  30% { transform: translate(-4px, -2px); }
  40% { transform: translate(4px, 3px); }
  50% { transform: translate(-3px, 2px); }
  60% { transform: translate(3px, -1px); }
  70% { transform: translate(-2px, 1px); }
  80% { transform: translate(1px, -1px); }
  100% { transform: translate(0, 0); }
}

/* --- Bottom Bar --- */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-bar-height);
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 20px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
}

.achievements-ticker {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  overflow: hidden;
}

.ticker-label {
  font-size: 12px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.ticker-scroll {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.ticker-text {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  display: inline-block;
  direction: ltr;
  text-align: left;
}

/* --- Toast Notifications --- */
.toast-container {
  position: fixed;
  top: calc(var(--top-bar-height) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 12px 18px;
  border-radius: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  color: var(--text-primary);
  animation: toastIn 0.35s ease-out forwards;
  pointer-events: auto;
  max-width: 320px;
  backdrop-filter: blur(10px);
}

.toast.removing {
  animation: toastOut 0.3s ease-in forwards;
}

.toast-info {
  border-left: 3px solid var(--accent-secondary);
}

.toast-achievement {
  border-left: 3px solid var(--accent-achievement);
  background: linear-gradient(135deg, var(--bg-secondary), rgba(255, 215, 0, 0.05));
  animation: toastIn 0.35s ease-out forwards, achievementShine 1.5s ease 0.35s;
}

.toast-warning {
  border-left: 3px solid var(--accent-warning);
}

.toast-prestige {
  border-left: 3px solid var(--accent-tertiary);
  background: linear-gradient(135deg, var(--bg-secondary), rgba(136, 68, 255, 0.08));
}

.toast-icon {
  margin-right: 8px;
  font-size: 16px;
}

.toast-message {
  line-height: 1.4;
}

@keyframes toastIn {
  0% {
    transform: translateY(-20px);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes toastOut {
  0% {
    transform: translateY(0);
    opacity: 1;
  }
  100% {
    transform: translateY(-20px);
    opacity: 0;
  }
}

@keyframes achievementShine {
  0% {
    box-shadow: var(--shadow-lg);
  }
  30% {
    box-shadow: var(--shadow-lg), 0 0 30px rgba(255, 215, 0, 0.4);
  }
  100% {
    box-shadow: var(--shadow-lg);
  }
}

/* --- Modals --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  min-width: 380px;
  max-width: 500px;
  animation: modalIn 0.3s ease;
}

.modal-evolve {
  border-color: var(--accent-tertiary);
  box-shadow: var(--shadow-lg), 0 0 40px rgba(136, 68, 255, 0.15);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  transition: color var(--transition-fast);
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 20px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.setting-row.danger {
  justify-content: center;
}

.setting-divider {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 12px 0;
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  transition: all var(--transition-fast);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: all var(--transition-fast);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent-primary-dim);
  border-color: var(--accent-primary);
}

.toggle-switch input:checked + .toggle-slider::before {
  background: var(--accent-primary);
  transform: translateX(20px);
}

/* Import textarea */
.import-textarea {
  width: 100%;
  height: 120px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 12px;
  padding: 10px;
  resize: vertical;
  margin-bottom: 14px;
}

.import-textarea:focus {
  outline: none;
  border-color: var(--accent-primary-dim);
}

/* Evolve modal */
.evolve-preview {
  text-align: center;
}

.evolve-dna-helix {
  height: 60px;
  position: relative;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dna-strand {
  width: 100px;
  height: 4px;
  border-radius: 2px;
  position: absolute;
}

.dna-strand.strand-1 {
  background: linear-gradient(90deg, var(--accent-tertiary), var(--accent-primary));
  animation: dnaRotate 3s ease-in-out infinite;
}

.dna-strand.strand-2 {
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-tertiary));
  animation: dnaRotate 3s ease-in-out infinite 1.5s;
}

@keyframes dnaRotate {
  0% { transform: rotate(0deg) scaleX(1); }
  25% { transform: rotate(0deg) scaleX(0.3); }
  50% { transform: rotate(0deg) scaleX(1); }
  75% { transform: rotate(0deg) scaleX(0.3); }
  100% { transform: rotate(0deg) scaleX(1); }
}

.evolve-description {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 16px;
}

.evolve-gain, .evolve-total {
  display: flex;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--bg-card);
  border-radius: 8px;
  margin-bottom: 6px;
}

.evolve-gain-label, .evolve-total-label {
  color: var(--text-secondary);
  font-size: 13px;
}

.evolve-gain-value {
  font-weight: 800;
  color: var(--accent-warning);
  font-size: 15px;
}

.evolve-total-value {
  font-weight: 800;
  color: var(--accent-tertiary);
  font-size: 15px;
}

.evolve-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* --- Evolve Screen Dramatic Animation --- */
.evolve-flash {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: radial-gradient(circle at 50% 50%, #ffffff, var(--accent-tertiary), #0a0e1a);
  animation: evolveFlash 2.5s ease forwards;
  pointer-events: none;
  overflow: hidden;
}

.evolve-flash::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 200px;
  height: 600px;
  transform: translate(-50%, -50%);
  background: linear-gradient(
    0deg,
    transparent 0%,
    var(--accent-tertiary) 20%,
    var(--accent-primary) 40%,
    #ffffff 50%,
    var(--accent-primary) 60%,
    var(--accent-tertiary) 80%,
    transparent 100%
  );
  animation: evolveDNASpin 2.5s ease forwards;
  opacity: 0.8;
  filter: blur(3px);
}

.evolve-flash::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 200px;
  height: 600px;
  transform: translate(-50%, -50%);
  background: linear-gradient(
    0deg,
    transparent 0%,
    var(--accent-primary) 20%,
    var(--accent-tertiary) 40%,
    #ffffff 50%,
    var(--accent-tertiary) 60%,
    var(--accent-primary) 80%,
    transparent 100%
  );
  animation: evolveDNASpinReverse 2.5s ease forwards;
  opacity: 0.6;
  filter: blur(4px);
}

@keyframes evolveFlash {
  0% { opacity: 0; }
  10% { opacity: 1; background: radial-gradient(circle at 50% 50%, #ffffff, var(--accent-tertiary), #0a0e1a); }
  30% { opacity: 1; background: radial-gradient(circle at 50% 50%, #ffffff 10%, var(--accent-tertiary) 40%, #0a0e1a 80%); }
  50% { opacity: 0.9; background: radial-gradient(circle at 50% 50%, var(--accent-tertiary) 0%, #0a0e1a 60%); }
  70% { opacity: 0.5; }
  100% { opacity: 0; }
}

@keyframes evolveDNASpin {
  0% { transform: translate(-50%, -50%) rotate(0deg) scaleX(1); opacity: 0; }
  15% { opacity: 0.9; }
  25% { transform: translate(-50%, -50%) rotate(90deg) scaleX(0.3); }
  50% { transform: translate(-50%, -50%) rotate(180deg) scaleX(1); }
  75% { transform: translate(-50%, -50%) rotate(270deg) scaleX(0.3); }
  100% { transform: translate(-50%, -50%) rotate(360deg) scaleX(1); opacity: 0; }
}

@keyframes evolveDNASpinReverse {
  0% { transform: translate(-50%, -50%) rotate(0deg) scaleX(0.3); opacity: 0; }
  15% { opacity: 0.7; }
  25% { transform: translate(-50%, -50%) rotate(-90deg) scaleX(1); }
  50% { transform: translate(-50%, -50%) rotate(-180deg) scaleX(0.3); }
  75% { transform: translate(-50%, -50%) rotate(-270deg) scaleX(1); }
  100% { transform: translate(-50%, -50%) rotate(-360deg) scaleX(0.3); opacity: 0; }
}

/* --- Number roll animation --- */
.number-roll {
  display: inline-block;
  transition: transform 0.2s ease;
}

.number-roll.rolling {
  animation: numberRoll 0.15s ease;
}

@keyframes numberRoll {
  0% { transform: translateY(-4px); opacity: 0.6; }
  100% { transform: translateY(0); opacity: 1; }
}

/* --- Responsive Design --- */
@media (max-width: 1100px) {
  :root {
    --panel-width: 260px;
  }
}

@media (max-width: 900px) {
  .game-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }

  .panel-left, .panel-right {
    display: none;
  }

  .panel-left.mobile-visible,
  .panel-right.mobile-visible {
    display: flex;
    position: fixed;
    top: var(--top-bar-height);
    bottom: var(--bottom-bar-height);
    width: 300px;
    z-index: 200;
    box-shadow: var(--shadow-lg);
  }

  .panel-left.mobile-visible {
    left: 0;
    animation: slideInLeft 0.25s ease;
  }

  .panel-right.mobile-visible {
    right: 0;
    animation: slideInRight 0.25s ease;
  }

  .top-bar-center { display: none; }

  :root {
    --petri-size: 220px;
  }

  .bacteria-count {
    font-size: 36px;
  }

  /* Mobile bottom nav */
  .bottom-bar {
    height: auto;
    padding: 6px 10px;
    flex-direction: column;
    gap: 4px;
  }

  .mobile-nav {
    display: flex;
    gap: 6px;
  }
}

@media (max-width: 500px) {
  :root {
    --petri-size: 180px;
    --top-bar-height: 48px;
  }

  .bacteria-count {
    font-size: 28px;
  }

  .stat-item:last-child {
    display: none;
  }

  .modal {
    min-width: unset;
    margin: 16px;
    width: calc(100% - 32px);
  }
}

@keyframes slideInLeft {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

/* ============================================================
   EVENTS, BUFFS, BOOSTS & POWER-UPS
   ============================================================ */

/* --- Random Events: Floating clickable elements --- */
.random-event {
  position: fixed;
  z-index: 50;
  width: 70px;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 215, 0, 0.15) 0%, rgba(255, 215, 0, 0.05) 60%, transparent 100%);
  border: 2px solid rgba(255, 215, 0, 0.6);
  box-shadow:
    0 0 20px rgba(255, 215, 0, 0.4),
    0 0 40px rgba(255, 215, 0, 0.2),
    inset 0 0 15px rgba(255, 215, 0, 0.1);
  animation: eventFloat 2s ease-in-out infinite, eventPulse 1s ease-in-out infinite;
  transition: transform 0.15s ease;
  transform: translate(-50%, -50%);
}

.random-event:hover {
  transform: translate(-50%, -50%) scale(1.2);
  box-shadow:
    0 0 30px rgba(255, 215, 0, 0.6),
    0 0 60px rgba(255, 215, 0, 0.3),
    inset 0 0 20px rgba(255, 215, 0, 0.2);
}

.random-event:active {
  transform: translate(-50%, -50%) scale(0.9);
}

.event-icon {
  font-size: 28px;
  line-height: 1;
  filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.6));
}

/* Event color variants */
.event-golden {
  border-color: rgba(255, 215, 0, 0.7);
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.4), 0 0 40px rgba(255, 215, 0, 0.2);
}

.event-mutant {
  border-color: rgba(0, 255, 136, 0.7);
  background: radial-gradient(circle, rgba(0, 255, 136, 0.15) 0%, transparent 100%);
  box-shadow: 0 0 20px rgba(0, 255, 136, 0.4), 0 0 40px rgba(0, 255, 136, 0.2);
}

.event-contamination {
  border-color: rgba(255, 68, 102, 0.7);
  background: radial-gradient(circle, rgba(255, 68, 102, 0.15) 0%, transparent 100%);
  box-shadow: 0 0 20px rgba(255, 68, 102, 0.4), 0 0 40px rgba(255, 68, 102, 0.2);
}

.event-grant {
  border-color: rgba(0, 204, 255, 0.7);
  background: radial-gradient(circle, rgba(0, 204, 255, 0.15) 0%, transparent 100%);
  box-shadow: 0 0 20px rgba(0, 204, 255, 0.4), 0 0 40px rgba(0, 204, 255, 0.2);
}

.event-accident {
  border-color: rgba(255, 170, 0, 0.7);
  background: radial-gradient(circle, rgba(255, 170, 0, 0.15) 0%, transparent 100%);
  box-shadow: 0 0 20px rgba(255, 170, 0, 0.4), 0 0 40px rgba(255, 170, 0, 0.2);
}

.event-phage {
  border-color: rgba(136, 68, 255, 0.7);
  background: radial-gradient(circle, rgba(136, 68, 255, 0.15) 0%, transparent 100%);
  box-shadow: 0 0 20px rgba(136, 68, 255, 0.4), 0 0 40px rgba(136, 68, 255, 0.2);
}

/* Event float/bob animation */
@keyframes eventFloat {
  0%, 100% { margin-top: 0; }
  50% { margin-top: -12px; }
}

/* Event glow pulse */
@keyframes eventPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.3); }
}

/* Event collected animation: scale up + burst + fade */
.random-event.event-collected {
  animation: eventCollect 0.5s ease-out forwards;
  pointer-events: none;
}

@keyframes eventCollect {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    filter: brightness(1);
  }
  30% {
    transform: translate(-50%, -50%) scale(1.6);
    opacity: 1;
    filter: brightness(2.5);
    box-shadow:
      0 0 40px rgba(255, 215, 0, 0.8),
      0 0 80px rgba(255, 215, 0, 0.4),
      0 0 120px rgba(255, 215, 0, 0.2);
  }
  100% {
    transform: translate(-50%, -50%) scale(2.5);
    opacity: 0;
    filter: brightness(3);
  }
}

/* Event expired animation: shrink + fade */
.random-event.event-expired {
  animation: eventExpire 0.5s ease-in forwards;
  pointer-events: none;
}

@keyframes eventExpire {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(0.2);
    opacity: 0;
    filter: grayscale(1);
  }
}

/* --- Boost Area (below petri dish) --- */
.boost-area {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  z-index: 2;
  flex-wrap: wrap;
  justify-content: center;
}

/* --- Buff Bar --- */
.buff-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 44px;
}

.buff-item {
  position: relative;
  width: 44px;
  height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--accent-primary);
  box-shadow: 0 0 12px var(--accent-primary-dim);
  animation: buffPulse 1.5s ease-in-out infinite;
}

.buff-icon {
  font-size: 16px;
  line-height: 1;
}

.buff-timer {
  font-size: 9px;
  font-weight: 800;
  color: var(--accent-primary);
  margin-top: 1px;
}

/* Buff ring SVG (circular timer) */
.buff-ring {
  position: absolute;
  inset: -3px;
  width: calc(100% + 6px);
  height: calc(100% + 6px);
  transform: rotate(-90deg);
}

.buff-ring-bg {
  fill: none;
  stroke: var(--border-color);
  stroke-width: 2;
}

.buff-ring-fill {
  fill: none;
  stroke: var(--accent-primary);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dashoffset: 0;
  transition: stroke-dasharray 0.5s linear;
}

@keyframes buffPulse {
  0%, 100% { box-shadow: 0 0 8px var(--accent-primary-dim); }
  50% { box-shadow: 0 0 16px var(--accent-primary-glow); }
}

/* --- Boost Button --- */
.boost-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-card);
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: not-allowed;
  transition: all 0.3s ease;
  font-family: inherit;
  position: relative;
  overflow: hidden;
  z-index: 2;
  text-transform: uppercase;
  opacity: 0.5;
}

.boost-btn .boost-combo-req {
  font-size: 10px;
  font-weight: 600;
  opacity: 0.7;
  letter-spacing: 0;
  text-transform: none;
}

/* Boost ready (charged by combo) */
.boost-btn.boost-charged {
  border-color: var(--accent-warning);
  background: linear-gradient(135deg, #2a1800, #3d2200);
  color: var(--accent-warning);
  cursor: pointer;
  opacity: 1;
  animation: boostReady 1.5s ease-in-out infinite;
}

.boost-btn.boost-charged:hover {
  background: linear-gradient(135deg, #3d2200, #5a3300);
  box-shadow:
    0 0 20px rgba(255, 170, 0, 0.4),
    0 0 40px rgba(255, 170, 0, 0.2);
  transform: scale(1.05);
}

.boost-btn.boost-charged:active {
  transform: scale(0.95);
}

/* Boost ready glow animation */
@keyframes boostReady {
  0%, 100% { box-shadow: 0 0 8px rgba(255, 170, 0, 0.2); }
  50% { box-shadow: 0 0 20px rgba(255, 170, 0, 0.5), 0 0 40px rgba(255, 170, 0, 0.2); }
}

/* Boost on cooldown */
.boost-btn.on-cooldown {
  opacity: 0.4;
  border-color: var(--border-color);
  background: var(--bg-card);
  color: var(--text-dim);
  cursor: not-allowed;
  animation: none;
  box-shadow: none;
}

.boost-btn.on-cooldown:hover {
  transform: none;
  box-shadow: none;
  background: var(--bg-card);
}

.boost-cooldown {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.8;
}

/* Shimmer effect on boost button when ready */
.boost-btn:not(.on-cooldown)::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent 40%,
    rgba(255, 170, 0, 0.15) 48%,
    rgba(255, 170, 0, 0.3) 50%,
    rgba(255, 170, 0, 0.15) 52%,
    transparent 60%
  );
  animation: boostShimmer 3s ease-in-out infinite;
}

@keyframes boostShimmer {
  0% { transform: translateX(-100%) translateY(-100%); }
  100% { transform: translateX(100%) translateY(100%); }
}

/* --- Boost Active: Screen-wide pulsing glow --- */
body.boost-active::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  border: 3px solid var(--accent-warning);
  border-radius: 0;
  animation: boostScreenGlow 1s ease-in-out infinite;
  box-shadow:
    inset 0 0 60px rgba(255, 170, 0, 0.1),
    inset 0 0 120px rgba(255, 170, 0, 0.05);
}

@keyframes boostScreenGlow {
  0%, 100% {
    border-color: rgba(255, 170, 0, 0.2);
    box-shadow:
      inset 0 0 40px rgba(255, 170, 0, 0.05),
      inset 0 0 80px rgba(255, 170, 0, 0.02);
  }
  50% {
    border-color: rgba(255, 170, 0, 0.5);
    box-shadow:
      inset 0 0 60px rgba(255, 170, 0, 0.12),
      inset 0 0 120px rgba(255, 170, 0, 0.06);
  }
}

/* --- Power-up Bar --- */
.powerups-bar {
  display: flex;
  gap: 8px;
  margin-top: 30px;
  z-index: 2;
  flex-wrap: wrap;
  justify-content: center;
}

.powerup-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--accent-secondary-dim);
  border-radius: 10px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
}

.powerup-btn:hover {
  border-color: var(--accent-secondary);
  box-shadow: 0 0 15px var(--accent-secondary-dim);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}

.powerup-btn:active {
  transform: scale(0.95);
}

.powerup-btn.cant-afford {
  opacity: 0.5;
  cursor: not-allowed;
}

.powerup-btn.cant-afford:hover {
  transform: none;
  box-shadow: none;
}

.powerup-icon {
  font-size: 16px;
}

.powerup-name {
  font-weight: 700;
}

.powerup-cost {
  font-size: 11px;
  color: var(--accent-secondary);
  margin-left: 4px;
}

.powerup-btn.cant-afford .powerup-cost {
  color: var(--accent-danger);
}

/* --- Language Selector --- */
.lang-selector {
  display: flex;
  gap: 8px;
}

.lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
}

.lang-btn:hover {
  border-color: var(--accent-primary-dim);
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.lang-btn.active {
  border-color: var(--accent-primary);
  background: var(--accent-primary-dim);
  color: var(--accent-primary);
  box-shadow: 0 0 12px var(--accent-primary-dim);
}

.lang-btn.active:hover {
  background: var(--accent-primary-dim);
}

/* --- Utility classes --- */
.hidden { display: none !important; }
.invisible { visibility: hidden; }
.no-select { user-select: none; }

/* ============================================================
   NEW FEATURE STYLES
   ============================================================ */

/* --- Volume slider --- */
.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 120px;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  outline: none;
  margin: 0 8px;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent-primary);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent-primary-dim);
}

.volume-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: var(--accent-primary);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.volume-label {
  font-size: 0.8em;
  color: var(--text-secondary);
  min-width: 36px;
  text-align: right;
}

/* --- Sector headers in buildings panel --- */
.sector-header {
  padding: 8px 12px;
  font-size: 0.75em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--accent-secondary);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  border-top: 1px solid var(--border-color);
  margin-top: 4px;
}

.sector-header:first-child {
  margin-top: 0;
}

.sector-milestone-icon {
  display: inline;
  font-size: 12px;
  cursor: help;
  vertical-align: middle;
  margin-left: 4px;
}

/* --- Boost button rework --- */
.boost-btn.boost-active {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  animation: boost-pulse 0.5s ease infinite alternate;
  color: var(--bg-primary);
  font-weight: 700;
  border-color: var(--accent-primary);
  box-shadow: 0 0 20px var(--accent-primary-glow);
}

.boost-combo-level {
  display: block;
  font-size: 0.7em;
  color: var(--accent-warning);
  margin-top: 2px;
}

@keyframes boost-pulse {
  from { box-shadow: 0 0 10px var(--accent-primary-dim); }
  to { box-shadow: 0 0 30px var(--accent-primary-glow); }
}

/* --- Achievement tooltip on bottom bar --- */
.achievement-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--accent-achievement);
  border-radius: 8px;
  padding: 10px 14px;
  min-width: 280px;
  max-width: 400px;
  z-index: 200;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.achievement-tooltip-title {
  font-weight: 700;
  color: var(--accent-achievement);
  margin-bottom: 6px;
  font-size: 0.85em;
}

.achievement-tooltip-item {
  font-size: 0.78em;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.achievement-tooltip-more {
  font-size: 0.72em;
  color: var(--text-dim);
  margin-top: 4px;
  font-style: italic;
}

/* --- Achievement overview modal --- */
.modal-achievements .modal-body {
  max-height: 70vh;
  overflow-y: auto;
}

.achievements-summary {
  text-align: center;
  margin-bottom: 16px;
}

.achievements-progress-bar {
  width: 100%;
  height: 12px;
  background: var(--bg-tertiary);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 8px;
}

.achievements-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-achievement));
  border-radius: 6px;
  transition: width 0.5s ease;
}

.achievements-progress-text {
  font-size: 0.9em;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.achievements-bonus-text {
  font-size: 0.8em;
  color: var(--accent-primary);
}

.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}

.achievement-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  transition: var(--transition-fast);
}

.achievement-card.unlocked {
  border-color: var(--accent-achievement);
  box-shadow: 0 0 6px rgba(255, 215, 0, 0.15);
}

.achievement-card.locked {
  opacity: 0.5;
}

.achievement-card-icon {
  font-size: 1.3em;
  min-width: 28px;
  text-align: center;
}

.achievement-card-info {
  flex: 1;
  min-width: 0;
}

.achievement-card-name {
  font-size: 0.8em;
  font-weight: 600;
  color: var(--text-primary);
}

.achievement-card-desc {
  font-size: 0.7em;
  color: var(--text-secondary);
}

/* --- Challenge cards --- */
.challenges-desc {
  font-size: 0.8em;
  color: var(--text-secondary);
  padding: 8px 12px;
  margin: 0;
}

.challenges-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 8px;
}

.challenge-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 12px;
  transition: var(--transition-fast);
}

.challenge-card.completed {
  border-color: var(--accent-primary);
  background: rgba(0, 255, 136, 0.05);
}

.challenge-card.active {
  border-color: var(--accent-warning);
  background: rgba(255, 170, 0, 0.05);
  box-shadow: 0 0 12px rgba(255, 170, 0, 0.1);
}

.challenge-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.challenge-name {
  font-weight: 600;
  font-size: 0.85em;
  color: var(--text-primary);
}

.challenge-status {
  font-size: 0.72em;
  color: var(--accent-primary);
}

.challenge-desc {
  font-size: 0.75em;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.challenge-reward {
  font-size: 0.72em;
  color: var(--accent-secondary);
  margin-bottom: 6px;
}

.challenge-start-btn {
  font-size: 0.75em;
  padding: 4px 12px;
  background: var(--accent-primary-dim);
  color: var(--accent-primary);
  border: 1px solid var(--accent-primary);
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.challenge-start-btn:hover {
  background: var(--accent-primary);
  color: var(--bg-primary);
}

/* --- Sector upgrades --- */
.sector-upgrades-section {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.section-title {
  font-size: 0.85em;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 8px 0;
  padding: 0 4px;
}

.sector-upgrades-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 4px;
}

.sector-upgrade-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.sector-upgrade-card:hover {
  border-color: var(--accent-secondary);
  background: var(--bg-card-hover);
}

.sector-upgrade-card.can-afford {
  border-color: var(--accent-primary);
}

.sector-upgrade-card.can-afford:hover {
  box-shadow: 0 0 10px var(--accent-primary-dim);
}

.sector-upgrade-card.maxed {
  opacity: 0.6;
  cursor: default;
}

.sector-upgrade-name {
  font-size: 0.8em;
  font-weight: 600;
  color: var(--text-primary);
}

.sector-upgrade-level {
  font-size: 0.72em;
  color: var(--text-secondary);
}

.sector-upgrade-cost {
  font-size: 0.72em;
  color: var(--accent-tertiary);
  margin-top: 2px;
}

/* --- Auto-buyer section --- */
.auto-buyer-section {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.auto-buyer-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0;
  max-height: 200px;
  overflow-y: auto;
}

.auto-buyer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  font-size: 0.75em;
  color: var(--text-primary);
}

.auto-buyer-row label:first-child {
  flex: 1;
}

/* --- Tab styling for challenges tab --- */
.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.tab-bar .tab {
  font-size: 0.72em;
  padding: 6px 8px;
}

/* --- Bottom bar achievement count --- */
#ticker-label {
  transition: color var(--transition-fast);
}

#ticker-label:hover {
  color: var(--accent-achievement);
}

/* --- Anti-cheat penalty visuals --- */
.petri-dish.penalized {
  animation: penalized-pulse 0.3s ease infinite alternate;
}

.petri-dish.penalized .petri-glow {
  background: radial-gradient(circle, rgba(255, 68, 102, 0.3) 0%, transparent 70%) !important;
}

.petri-dish.penalized .petri-ring {
  border-color: var(--accent-danger) !important;
  box-shadow: 0 0 15px rgba(255, 68, 102, 0.3) !important;
}

@keyframes penalized-pulse {
  from { filter: none; }
  to { filter: brightness(0.7) saturate(0.5) hue-rotate(-30deg); }
}

.penalty-number {
  color: var(--accent-danger) !important;
  font-weight: 700;
  font-size: 14px !important;
  text-shadow: 0 0 8px rgba(255, 68, 102, 0.6);
}

/* ---- Streak Indicator ---- */
.streak-indicator {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 12px;
  background: rgba(0, 255, 136, 0.1);
  border: 1px solid var(--accent-primary);
  border-radius: 16px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-primary);
  z-index: 15;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.streak-indicator.visible { opacity: 1; }
.streak-indicator.hot { animation: streakPulse 0.4s ease-in-out infinite; }
@keyframes streakPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(0,255,136,0.2); transform: translateX(-50%) scale(1); }
  50% { box-shadow: 0 0 20px rgba(0,255,136,0.5); transform: translateX(-50%) scale(1.05); }
}

/* ---- Crit Visual Burst ---- */
.crit-burst {
  position: fixed;
  pointer-events: none;
  z-index: 25;
  font-size: 24px;
  font-weight: 900;
  color: #ffd700;
  text-shadow: 0 0 16px #ffaa00, 0 0 8px #ff8800;
  animation: critBurst 0.6s cubic-bezier(0.68, -0.55, 0.27, 1.55) forwards;
}
@keyframes critBurst {
  0% { transform: scale(0.3); opacity: 1; }
  50% { transform: scale(1.3); }
  100% { transform: scale(0.6); opacity: 0; }
}
.floating-number.critical {
  color: #ffd700 !important;
  text-shadow: 0 0 16px #ffaa00, 0 0 8px #ff8800;
  font-weight: 900;
}

/* --- Mutation Milestones --- */
.mutation-milestones {
  white-space: pre-wrap;
  font-family: monospace;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-secondary);
  padding: 6px 8px;
  background: rgba(0,0,0,0.2);
  border-radius: 6px;
  margin-top: 8px;
}

/* --- Prestige Ascension Crown Effect --- */
.prestige-crown { position: fixed; top: 50%; left: 50%; z-index: 2001; pointer-events: none; transform: translate(-50%, -50%); }
.crown-particle { position: absolute; width: 12px; height: 12px; background: radial-gradient(circle, #ffd700, #ffaa00); border-radius: 50%; box-shadow: 0 0 12px #ffd700; animation: crownAscend 1.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards; }
@keyframes crownAscend {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  40% { transform: translate(var(--tx), var(--ty)) scale(1.2); opacity: 1; }
  100% { transform: translate(var(--tx), calc(var(--ty) - 180px)) scale(0.3); opacity: 0; }
}

/* --- BPS Tick Indicator --- */
.bps-tick { position: fixed; pointer-events: none; z-index: 18; font-size: 14px; font-weight: 700; color: var(--accent-secondary); text-shadow: 0 0 8px var(--accent-secondary); animation: bpsTickFloat 0.8s ease-out forwards; }
@keyframes bpsTickFloat {
  0% { transform: translateY(0) scale(0.8); opacity: 0; }
  20% { opacity: 1; transform: translateY(0) scale(1.1); }
  100% { opacity: 0; transform: translateY(-60px) scale(0.7); }
}

/* --- Welcome Back Wave --- */
.welcome-wave { position: fixed; inset: 0; z-index: 15; pointer-events: none; }
.wave-ring { position: absolute; border-radius: 50%; border: 2px solid var(--accent-secondary); left: 50%; top: 50%; transform: translate(-50%, -50%); animation: waveExpand 1.2s ease-out forwards; opacity: 0.7; }
.wave-ring:nth-child(2) { animation-delay: 0.15s; border-color: var(--accent-primary); }
.wave-ring:nth-child(3) { animation-delay: 0.3s; }
@keyframes waveExpand {
  0% { width: 0; height: 0; opacity: 0.7; }
  100% { width: 400px; height: 400px; opacity: 0; }
}

/* --- Panel Slide Transitions --- */
@keyframes slideInLeft { from { transform: translateX(-20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideInRight { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.panel-slide-left { animation: slideInLeft 0.25s ease-out; }
.panel-slide-right { animation: slideInRight 0.25s ease-out; }

/* --- Building Mastery Stars --- */
.mastery-stars { display: inline; margin-left: 4px; font-size: 10px; color: #ffd700; text-shadow: 0 0 4px rgba(255,215,0,0.5); pointer-events: none; vertical-align: middle; }

/* --- Building Count Bump Animation --- */
.building-count.count-bump {
  animation: countBump 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes countBump {
  0% { transform: scale(1); text-shadow: 0 0 0 transparent; }
  50% { transform: scale(1.15); text-shadow: 0 0 12px var(--accent-primary); }
  100% { transform: scale(1); text-shadow: 0 0 0 transparent; }
}

/* --- Tab Underline Animation --- */
.tab::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent-primary);
  border-radius: 2px;
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.tab.active::after {
  transform: scaleX(1);
  box-shadow: 0 0 12px var(--accent-primary);
}

/* --- Building Icon Breathe on Hover --- */
.building-card:hover .building-icon {
  animation: iconBreathe 0.8s ease-in-out infinite;
}
@keyframes iconBreathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08) rotate(4deg); }
}

/* --- Buy Quantity Bar --- */
.buy-quantity-bar {
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.qty-btn {
  flex: 1;
  padding: 4px 2px;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.qty-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--accent-primary-dim);
}

.qty-btn.active {
  background: var(--accent-primary-dim);
  color: var(--accent-primary);
  border-color: var(--accent-primary);
  box-shadow: 0 0 6px var(--accent-primary-dim);
}

/* --- Talent Tree --- */
.talent-tree-section {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.talent-tree-section .section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
}

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

.talent-node {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.talent-node:hover {
  background: var(--bg-card-hover);
}

.talent-node.locked {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.talent-node.available {
  border-color: var(--accent-primary-dim);
  box-shadow: 0 0 8px var(--accent-primary-dim);
  cursor: pointer;
}

.talent-node.available:hover {
  border-color: var(--accent-primary);
  box-shadow: 0 0 14px var(--accent-primary-dim);
}

.talent-node.purchased {
  border-color: var(--accent-primary);
  background: linear-gradient(135deg, rgba(0, 255, 136, 0.08), var(--bg-card));
  cursor: default;
}

.talent-node-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.talent-node.purchased .talent-node-name {
  color: var(--accent-primary);
}

.talent-node-effect {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.talent-node-cost {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-tertiary);
}

.talent-node.purchased .talent-node-cost {
  color: var(--accent-primary);
}

.talent-node-prereqs {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 3px;
  font-style: italic;
}

/* Dev skip button */
.dev-skip-btn {
  display: block;
  margin: 15px auto 0;
  padding: 6px 16px;
  border: 1px dashed var(--accent-warning);
  border-radius: 8px;
  background: rgba(255, 165, 0, 0.08);
  color: var(--accent-warning);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  z-index: 2;
  transition: background 0.2s;
}
.dev-skip-btn:hover {
  background: rgba(255, 165, 0, 0.18);
}

/* Auto-clicker bar */
.auto-clicker-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
  z-index: 2;
}
.auto-clicker-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--accent-primary-dim);
  border-radius: 10px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.auto-clicker-btn:hover {
  background: var(--bg-secondary);
  border-color: var(--accent-primary);
}
.auto-clicker-btn.cant-afford {
  opacity: 0.5;
  cursor: not-allowed;
}
.ac-icon { font-size: 18px; }
.ac-cost { color: var(--accent-primary); margin-left: 4px; }
.ac-count {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
}

/* Building background visual */
.center-area {
  position: relative;
}
.building-bg-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 120px;
  opacity: 0.06;
  pointer-events: none;
  z-index: 0;
  transition: opacity 0.5s;
}

/* ============================================================
   LEADERBOARD & USERNAME
   ============================================================ */

/* --- Header username display & leaderboard button --- */
.username-display {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  margin-right: 4px;
}

.btn-header-icon {
  padding: 6px 10px;
  font-size: 16px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-primary);
}

.btn-header-icon:hover {
  border-color: var(--accent-achievement);
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.2);
  background: rgba(255, 215, 0, 0.05);
}

/* --- Username registration modal --- */
.modal-small {
  text-align: center;
  max-width: 360px;
}

.modal-small h2 {
  color: var(--accent-primary);
  margin-bottom: 8px;
}

.modal-small p {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 12px;
}

.username-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  text-align: center;
  margin-bottom: 8px;
  outline: none;
  transition: border-color var(--transition-fast);
}

.username-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 12px var(--accent-primary-dim);
}

.username-input::placeholder {
  color: var(--text-dim);
}

.error-text {
  color: var(--accent-danger);
  font-size: 12px;
  min-height: 18px;
  margin-bottom: 8px;
}

/* --- Leaderboard modal --- */
.modal-leaderboard {
  min-width: 380px;
  max-width: 480px;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

.leaderboard-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.leaderboard-table td {
  font-size: 13px;
  padding: 8px 10px;
  color: var(--text-primary);
  border-bottom: 1px solid rgba(30, 42, 68, 0.5);
}

.leaderboard-table td:last-child {
  font-family: 'Consolas', 'Monaco', monospace;
  color: var(--accent-primary);
  text-align: right;
}

.leaderboard-table tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

.leaderboard-table tr.lb-self {
  background: rgba(0, 255, 136, 0.08);
  border-left: 3px solid var(--accent-primary);
}

.leaderboard-table tr.lb-self td {
  font-weight: 700;
}

.lb-rank-1 td:first-child { color: #ffd700; font-weight: 800; }
.lb-rank-2 td:first-child { color: #c0c0c0; font-weight: 800; }
.lb-rank-3 td:first-child { color: #cd7f32; font-weight: 800; }

.leaderboard-empty {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  padding: 20px;
}

.loading-text {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  padding: 20px;
}
