:root {
  --bg-primary: #06060f;
  --bg-secondary: #0c0c1e;
  --bg-panel: rgba(12, 12, 30, 0.75);
  --border-glow: rgba(100, 200, 255, 0.2);
  --text-primary: #e0e8ff;
  --text-secondary: #8090b0;
  --text-muted: #506080;
  --neon-cyan: #00f0ff;
  --neon-green: #00ff88;
  --neon-red: #ff3366;
  --neon-blue: #3399ff;
  --neon-amber: #ffaa00;
  --neon-purple: #cc66ff;
  --neon-pink: #ff66cc;
  --neon-white: #eef4ff;
  --gatherer-color: #00ff88;
  --predator-color: #ff3366;
  --builder-color: #3399ff;
  --explorer-color: #ffaa00;
  --hybrid-color: #cc66ff;
  --food-color: #00ffaa;
  --energy-color: #ffee44;
  --panel-radius: 12px;
  --panel-blur: 16px;
  --font-mono: "Courier New", "Consolas", monospace;
  --font-sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --z-canvas: 1;
  --z-particles: 2;
  --z-hud: 10;
  --z-announcements: 20;
  --z-modal: 30;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#simulation-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: var(--z-canvas);
  display: block;
}

#particle-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: var(--z-particles);
  pointer-events: none;
  display: block;
}

.hud-panel {
  position: absolute;
  z-index: var(--z-hud);
  background: var(--bg-panel);
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
  border: 1px solid var(--border-glow);
  border-radius: var(--panel-radius);
  padding: 12px 16px;
  pointer-events: auto;
  transition:
    opacity 0.3s ease,
    transform 0.3s ease;
}

.hud-panel:focus-within {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.15);
}

#panel-stats {
  top: 16px;
  left: 16px;
  min-width: 220px;
}

#panel-performance {
  top: 16px;
  right: 16px;
  min-width: 160px;
  text-align: right;
}

#panel-events {
  bottom: 16px;
  left: 16px;
  right: 16px;
  max-width: 600px;
  max-height: 120px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--text-muted) transparent;
}

#panel-charts {
  bottom: 16px;
  right: 16px;
  width: 280px;
  height: 200px;
}

#panel-generation {
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  min-width: 180px;
}

.panel-title {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--neon-cyan);
  line-height: 1.1;
}

.stat-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 3px 0;
}

.stat-row .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.stat-row .count {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 30px;
  text-align: right;
}

.sparkline-container {
  width: 60px;
  height: 20px;
  display: inline-block;
  vertical-align: middle;
  margin-left: 8px;
}

.event-entry {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  padding: 2px 0;
  border-bottom: 1px solid rgba(100, 200, 255, 0.05);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-entry .timestamp {
  color: var(--text-muted);
  margin-right: 8px;
}

.event-entry.event-birth {
  color: var(--neon-green);
}
.event-entry.event-death {
  color: var(--neon-red);
}
.event-entry.event-evolution {
  color: var(--neon-purple);
}
.event-entry.event-world {
  color: var(--neon-amber);
}
.event-entry.event-milestone {
  color: var(--neon-cyan);
}

.chart-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.hud-panel::-webkit-scrollbar {
  width: 4px;
}

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

.hud-panel::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 2px;
}

@media (max-width: 768px) {
  .hud-panel {
    padding: 8px 12px;
    border-radius: 8px;
  }

  #panel-stats {
    top: 8px;
    left: 8px;
    min-width: 180px;
  }

  #panel-performance {
    top: 8px;
    right: 8px;
    min-width: 120px;
  }

  #panel-events {
    bottom: 8px;
    left: 8px;
    right: 8px;
    max-height: 80px;
    font-size: 10px;
  }

  #panel-charts {
    display: none;
  }

  #panel-generation {
    top: 8px;
  }

  .stat-value {
    font-size: 18px;
  }
}

@media (max-width: 480px) {
  #panel-charts {
    display: none;
  }

  #panel-stats {
    min-width: 150px;
  }

  #panel-performance {
    min-width: 100px;
  }

  .stat-value {
    font-size: 16px;
  }
  .stat-label {
    font-size: 10px;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
  white-space: nowrap;
}

*:focus-visible {
  outline: 2px solid var(--neon-cyan);
  outline-offset: 2px;
}

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