/* ═══════════════════════════════════════════════════
   BESTIARY — Creature Encyclopedia & Animation Manager
   ═══════════════════════════════════════════════════ */

/* ── Overlay Shell ── */
.bestiary-overlay {
  position: absolute;
  top: calc(var(--topbar-height) + 12px);
  left: calc(clamp(160px, 15vw, var(--nav-width)) + 32px);
  right: 16px;
  bottom: 16px;
  z-index: 95; /* Above nav sidebar (90) and panel (80), below topbar (100) */
  background: linear-gradient(145deg, rgba(12, 16, 36, 0.97), rgba(18, 24, 52, 0.98));
  backdrop-filter: blur(16px);
  border: 1px solid rgba(90, 110, 200, 0.25);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow:
    0 12px 48px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.bestiary-overlay.hidden {
  display: none !important;
}

/* ── Header ── */
.bestiary-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid rgba(90, 110, 200, 0.2);
  background: linear-gradient(180deg, rgba(20, 28, 60, 0.8), transparent);
  flex-shrink: 0;
}

.bestiary-title-row {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 14px;
}

.bestiary-title-row h1 {
  margin: 0;
  font-size: 1.6em;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text-secondary), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.bestiary-subtitle {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-faint);
}

.bestiary-search-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bestiary-search-row input {
  flex: 1;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid rgba(90, 110, 200, 0.3);
  background: rgba(15, 19, 40, 0.7);
  color: #e8ecff;
  font-size: 0.85rem;
  outline: none;
  transition: all 0.2s;
}

.bestiary-search-row input:focus {
  border-color: var(--accent-light);
  box-shadow: 0 0 0 3px rgba(124, 140, 255, 0.15);
}

.bestiary-search-row input::placeholder {
  color: #4a5580;
}

.bestiary-count {
  font-size: 0.8rem;
  color: var(--accent-light);
  white-space: nowrap;
  font-weight: 600;
}

/* ── Category Filters ── */
.bestiary-filters {
  display: flex;
  gap: 6px;
  padding: 12px 24px;
  border-bottom: 1px solid rgba(90, 110, 200, 0.12);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.bestiary-filter {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid rgba(90, 110, 200, 0.25);
  background: rgba(20, 28, 60, 0.5);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.bestiary-filter:hover {
  background: rgba(40, 55, 110, 0.6);
  border-color: rgba(124, 140, 255, 0.4);
  color: var(--text-secondary);
  transform: translateY(-1px);
}

.bestiary-filter.active {
  background: linear-gradient(135deg, var(--accent), #4355c4);
  border-color: var(--accent-light);
  color: #fff;
  box-shadow: 0 2px 8px rgba(83, 102, 214, 0.35);
}

/* Category-specific active colors */
.bestiary-filter[data-category="predator"].active {
  background: linear-gradient(135deg, #c0392b, #a93226);
  border-color: #e74c3c;
  box-shadow: 0 2px 8px rgba(192, 57, 43, 0.35);
}

.bestiary-filter[data-category="herbivore"].active {
  background: linear-gradient(135deg, #27ae60, #229954);
  border-color: #2ecc71;
  box-shadow: 0 2px 8px rgba(39, 174, 96, 0.35);
}

.bestiary-filter[data-category="omnivore"].active {
  background: linear-gradient(135deg, #d4a017, #b8860b);
  border-color: #f0c040;
  box-shadow: 0 2px 8px rgba(212, 160, 23, 0.35);
}

.bestiary-filter[data-category="mythical"].active {
  background: linear-gradient(135deg, #8e44ad, #7d3c98);
  border-color: #bb6bd9;
  box-shadow: 0 2px 8px rgba(142, 68, 173, 0.35);
}

/* ── Stats Bar ── */
.bestiary-stats-bar {
  display: flex;
  gap: 20px;
  padding: 10px 24px;
  border-bottom: 1px solid rgba(90, 110, 200, 0.12);
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--text-faint);
}

.bestiary-stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.bestiary-stat-item strong {
  color: var(--text-secondary);
  font-weight: 600;
}

/* ── Card Grid ── */
.bestiary-grid {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-content: start;
  align-items: flex-start;
}

.bestiary-grid::-webkit-scrollbar {
  width: 6px;
}

.bestiary-grid::-webkit-scrollbar-track {
  background: transparent;
}

.bestiary-grid::-webkit-scrollbar-thumb {
  background: rgba(124, 140, 255, 0.2);
  border-radius: 3px;
}

.bestiary-grid::-webkit-scrollbar-thumb:hover {
  background: rgba(124, 140, 255, 0.35);
}

/* ── Animal Card ── */
.bestiary-card {
  background: rgba(20, 28, 56, 0.6);
  border: 1px solid rgba(90, 110, 200, 0.2);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-height: fit-content;
  height: auto;
  width: 180px;
  flex-shrink: 0;
}

.bestiary-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: 12px 12px 0 0;
  opacity: 0;
  transition: opacity 0.3s;
}

.bestiary-card:hover {
  border-color: rgba(124, 140, 255, 0.45);
  background: rgba(28, 38, 72, 0.8);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(124, 140, 255, 0.1);
}

.bestiary-card:hover::before {
  opacity: 1;
}

.bestiary-card:active {
  transform: translateY(-1px);
}

/* Category top-bar colors */
.bestiary-card[data-category="predator"]::before {
  background: linear-gradient(90deg, #ff4444, #ff6666);
}
.bestiary-card[data-category="herbivore"]::before {
  background: linear-gradient(90deg, #44cc66, #66ee88);
}
.bestiary-card[data-category="omnivore"]::before {
  background: linear-gradient(90deg, #ffaa22, #ffcc55);
}
.bestiary-card[data-category="mythical"]::before {
  background: linear-gradient(90deg, #aa44ff, #cc66ff);
}

/* Card Sprite Preview */
.bestiary-card-sprite {
  width: 64px;
  height: 64px;
  image-rendering: pixelated;
  border-radius: 8px;
  background: rgba(10, 14, 32, 0.5);
  border: 1px solid rgba(90, 110, 200, 0.15);
  transition: transform 0.3s ease;
}

.bestiary-card:hover .bestiary-card-sprite {
  transform: scale(1.1);
}

.bestiary-card-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: #e0e6ff;
  text-align: center;
}

.bestiary-card-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.bestiary-card-badge.predator {
  background: rgba(255, 68, 68, 0.15);
  color: #ff6666;
  border: 1px solid rgba(255, 68, 68, 0.25);
}

.bestiary-card-badge.herbivore {
  background: rgba(68, 204, 102, 0.15);
  color: #66ee88;
  border: 1px solid rgba(68, 204, 102, 0.25);
}

.bestiary-card-badge.omnivore {
  background: rgba(255, 170, 34, 0.15);
  color: #ffcc55;
  border: 1px solid rgba(255, 170, 34, 0.25);
}

.bestiary-card-badge.mythical {
  background: rgba(170, 68, 255, 0.15);
  color: #cc66ff;
  border: 1px solid rgba(170, 68, 255, 0.25);
}

.bestiary-card-stats {
  display: flex;
  gap: 8px;
  width: 100%;
  justify-content: center;
}

.bestiary-card-stat {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 0.65rem;
  color: var(--text-faint);
}

.bestiary-card-stat .stat-icon {
  font-size: 0.7rem;
}

.bestiary-card-stat .stat-value {
  color: #9aa0c0;
  font-weight: 600;
}

.bestiary-card-map-count {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 0.6rem;
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(124, 140, 255, 0.2);
  color: var(--accent-light);
  font-weight: 700;
}

.bestiary-card-habitat {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 0.7rem;
}

/* ═══════════════════════════════════════════════════
   DETAIL VIEW
   ═══════════════════════════════════════════════════ */

.bestiary-detail {
  position: absolute;
  inset: 0;
  background: linear-gradient(145deg, rgba(10, 14, 32, 0.98), rgba(16, 22, 48, 0.99));
  z-index: 10;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  animation: bestiarySlideIn 0.3s ease;
}

.bestiary-detail.hidden {
  display: none !important;
}

@keyframes bestiarySlideIn {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.bestiary-detail-header {
  display: flex;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid rgba(90, 110, 200, 0.2);
  gap: 12px;
  flex-shrink: 0;
}

.bestiary-back-btn {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid rgba(90, 110, 200, 0.3);
  background: rgba(20, 28, 60, 0.5);
  color: var(--accent-light);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 600;
}

.bestiary-back-btn:hover {
  background: rgba(40, 55, 110, 0.6);
  border-color: var(--accent-light);
  color: var(--text-secondary);
}

.bestiary-detail-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: #e0e6ff;
}

.bestiary-detail-category {
  margin-left: auto;
}

/* Detail Content Grid */
.bestiary-detail-content {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  padding: 24px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* Left Column: Sprite + Animation */
.bestiary-detail-left {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.bestiary-sprite-showcase {
  background: rgba(10, 14, 32, 0.6);
  border: 1px solid rgba(90, 110, 200, 0.2);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

.bestiary-sprite-showcase::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center bottom, rgba(124, 140, 255, 0.06) 0%, transparent 70%);
  pointer-events: none;
}

.bestiary-sprite-large {
  width: 128px;
  height: 128px;
  image-rendering: pixelated;
  border-radius: 8px;
  position: relative;
  z-index: 1;
}

.bestiary-sprite-shadow {
  width: 48px;
  height: 8px;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.35) 0%, transparent 70%);
  border-radius: 50%;
  margin-top: -4px;
  z-index: 0;
  animation: shadowPulse 2s ease-in-out infinite;
}

@keyframes shadowPulse {
  0%, 100% { transform: scaleX(1); opacity: 0.6; }
  50% { transform: scaleX(0.85); opacity: 0.4; }
}

.bestiary-color-swatch {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 0.7rem;
  color: var(--text-faint);
}

.bestiary-color-dot {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Animation Controls */
.bestiary-anim-panel {
  background: rgba(10, 14, 32, 0.6);
  border: 1px solid rgba(90, 110, 200, 0.2);
  border-radius: 12px;
  padding: 14px;
}

.bestiary-anim-panel h3 {
  margin: 0 0 10px 0;
  font-size: 0.8rem;
  color: var(--accent-light);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.bestiary-anim-states {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
}

.bestiary-anim-state-btn {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid rgba(90, 110, 200, 0.25);
  background: rgba(20, 28, 60, 0.5);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-transform: capitalize;
}

.bestiary-anim-state-btn:hover {
  background: rgba(40, 55, 110, 0.6);
  color: var(--text-secondary);
}

.bestiary-anim-state-btn.active {
  background: var(--accent);
  border-color: var(--accent-light);
  color: #fff;
}

.bestiary-anim-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.bestiary-anim-play-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(90, 110, 200, 0.3);
  background: rgba(20, 28, 60, 0.5);
  color: var(--accent-light);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.bestiary-anim-play-btn:hover {
  background: var(--accent);
  color: #fff;
}

.bestiary-anim-info {
  font-size: 0.7rem;
  color: var(--text-faint);
}

.bestiary-anim-info strong {
  color: #9aa0c0;
}

.bestiary-anim-speed {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.65rem;
  color: var(--text-faint);
}

.bestiary-anim-speed input[type="range"] {
  width: 60px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  border-radius: 2px;
  background: rgba(90, 110, 200, 0.2);
  cursor: pointer;
  border: none;
}

.bestiary-anim-speed input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 1px solid var(--accent-light);
  cursor: pointer;
}

/* Frame strip */
.bestiary-frame-strip {
  display: flex;
  gap: 4px;
}

.bestiary-frame-thumb {
  width: 40px;
  height: 40px;
  image-rendering: pixelated;
  border-radius: 4px;
  border: 2px solid rgba(90, 110, 200, 0.2);
  background: rgba(10, 14, 32, 0.5);
  transition: all 0.15s;
  cursor: pointer;
}

.bestiary-frame-thumb.active {
  border-color: var(--accent-light);
  box-shadow: 0 0 8px rgba(124, 140, 255, 0.3);
}

/* Right Column: Stats + Relationships */
.bestiary-detail-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  padding-right: 4px;
}

/* Stat Section */
.bestiary-section {
  background: rgba(10, 14, 32, 0.5);
  border: 1px solid rgba(90, 110, 200, 0.15);
  border-radius: 12px;
  padding: 16px;
}

.bestiary-section h3 {
  margin: 0 0 12px 0;
  font-size: 0.8rem;
  color: var(--accent-light);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.bestiary-section h3 .section-icon {
  font-size: 0.9rem;
}

/* Stat Bars */
.bestiary-stat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.bestiary-stat-row:last-child {
  margin-bottom: 0;
}

.bestiary-stat-label {
  width: 85px;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  flex-shrink: 0;
}

.bestiary-stat-bar-track {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: rgba(10, 14, 32, 0.6);
  overflow: hidden;
  position: relative;
}

.bestiary-stat-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
  position: relative;
}

.bestiary-stat-bar-fill.health {
  background: linear-gradient(90deg, #2ecc71, #44ff66);
}

.bestiary-stat-bar-fill.speed {
  background: linear-gradient(90deg, #3498db, #5dade2);
}

.bestiary-stat-bar-fill.power {
  background: linear-gradient(90deg, #e74c3c, #ff6b6b);
}

.bestiary-stat-bar-fill.defense {
  background: linear-gradient(90deg, #f39c12, #f1c40f);
}

.bestiary-stat-bar-fill.fertility {
  background: linear-gradient(90deg, #e91e90, #ff69b4);
}

.bestiary-stat-bar-fill.hunger {
  background: linear-gradient(90deg, #9b59b6, #bb6bd9);
}

.bestiary-stat-value {
  width: 40px;
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 600;
  text-align: right;
  flex-shrink: 0;
}

/* Relationship display */
.bestiary-relation-group {
  margin-bottom: 10px;
}

.bestiary-relation-group:last-child {
  margin-bottom: 0;
}

.bestiary-relation-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.bestiary-relation-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.bestiary-relation-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.bestiary-relation-chip canvas {
  width: 16px;
  height: 16px;
  image-rendering: pixelated;
  border-radius: 2px;
}

.bestiary-relation-chip.prey {
  background: rgba(255, 68, 68, 0.12);
  color: #ff8888;
  border: 1px solid rgba(255, 68, 68, 0.2);
}

.bestiary-relation-chip.prey:hover {
  background: rgba(255, 68, 68, 0.25);
  border-color: rgba(255, 68, 68, 0.4);
}

.bestiary-relation-chip.predator {
  background: rgba(255, 170, 34, 0.12);
  color: #ffcc88;
  border: 1px solid rgba(255, 170, 34, 0.2);
}

.bestiary-relation-chip.predator:hover {
  background: rgba(255, 170, 34, 0.25);
  border-color: rgba(255, 170, 34, 0.4);
}

.bestiary-relation-none {
  font-size: 0.72rem;
  color: #4a5580;
  font-style: italic;
}

/* Breeding section */
.bestiary-breed-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.bestiary-breed-item {
  background: rgba(10, 14, 32, 0.4);
  border: 1px solid rgba(90, 110, 200, 0.12);
  border-radius: 8px;
  padding: 8px 10px;
  text-align: center;
}

.bestiary-breed-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-secondary);
  display: block;
}

.bestiary-breed-label {
  font-size: 0.65rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Properties table */
.bestiary-props-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.bestiary-prop {
  display: flex;
  justify-content: space-between;
  padding: 4px 8px;
  border-radius: 4px;
  background: rgba(10, 14, 32, 0.3);
  font-size: 0.72rem;
}

.bestiary-prop-label {
  color: var(--text-faint);
}

.bestiary-prop-value {
  color: var(--text-secondary);
  font-weight: 600;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .bestiary-detail-content {
    grid-template-columns: 1fr;
  }

  .bestiary-grid {
    gap: 10px;
    padding: 14px 16px;
  }

  .bestiary-card {
    width: 150px;
  }

  .bestiary-header {
    padding: 14px 16px 12px;
  }

  .bestiary-filters {
    padding: 8px 16px;
  }

  .bestiary-title-row h1 {
    font-size: 1.3em;
  }
}

@media (max-width: 900px) {
  .bestiary-overlay {
    left: 16px; /* Nav sidebar hidden on mobile */
  }
}

@media (max-width: 600px) {
  .bestiary-overlay {
    top: 50px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    border-radius: 10px;
  }

  .bestiary-grid {
    gap: 8px;
    padding: 10px 12px;
  }

  .bestiary-card {
    padding: 10px;
    width: 130px;
  }

  .bestiary-card-sprite {
    width: 48px;
    height: 48px;
  }

  .bestiary-detail-content {
    padding: 14px;
    gap: 14px;
  }
}

/* ── Empty state ── */
.bestiary-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: #4a5580;
}

.bestiary-empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.5;
}

.bestiary-empty-text {
  font-size: 0.9rem;
  margin: 0;
}

/* ═══════════════════════════════════════════════════
   GRAPHS — Population Analytics & Visualization
   ═══════════════════════════════════════════════════ */

/* ── Overlay Shell ── */
.graphs-overlay {
  position: absolute;
  top: calc(var(--topbar-height) + 12px);
  left: calc(clamp(160px, 15vw, var(--nav-width)) + 32px);
  right: 16px;
  bottom: 16px;
  z-index: 95; /* Above nav sidebar (90) and panel (80), below topbar (100) */
  background: linear-gradient(145deg, rgba(12, 16, 36, 0.97), rgba(18, 24, 52, 0.98));
  backdrop-filter: blur(16px);
  border: 1px solid rgba(90, 110, 200, 0.25);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow:
    0 20px 40px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(120, 140, 220, 0.1);
}

.graphs-overlay.hidden {
  display: none !important;
}

/* ── Header ── */
.graphs-header {
  flex-shrink: 0;
  padding: 12px 16px 8px;
  border-bottom: 1px solid rgba(90, 110, 200, 0.2);
  background: linear-gradient(90deg,
    rgba(20, 30, 60, 0.8) 0%,
    rgba(30, 40, 80, 0.6) 100%);
}

.graphs-title-row {
  display: flex;
  align-items: baseline;
  gap: 16px;
  position: relative;
  padding-right: 40px; /* Make room for close button */
}

.graphs-close-btn {
  position: absolute;
  top: 6px;
  right: 8px;
  background: rgba(80, 90, 110, 0.8);
  border: 1px solid rgba(90, 110, 200, 0.3);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  color: rgba(220, 230, 250, 0.9);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.graphs-close-btn:hover {
  background: rgba(100, 110, 130, 0.9);
  border-color: rgba(120, 140, 220, 0.5);
  color: rgba(240, 250, 255, 1);
}

.graphs-title-row h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  background: linear-gradient(45deg, #00d4ff, #09c);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.graphs-subtitle {
  margin: 0;
  font-size: 0.9rem;
  color: rgba(160, 180, 220, 0.8);
  font-weight: 400;
}

/* ── Controls ── */
.graphs-controls {
  flex-shrink: 0;
  padding: 8px 16px;
  border-bottom: 1px solid rgba(90, 110, 200, 0.15);
  background: rgba(20, 25, 45, 0.4);
  display: flex;
  gap: 20px;
  align-items: center;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.control-group label {
  font-weight: bold;
  font-size: 0.85rem;
  color: rgba(180, 200, 240, 0.9);
  min-width: 120px;
}

.control-group input {
  width: 60px;
  padding: 6px 8px;
  border: 1px solid rgba(90, 110, 200, 0.3);
  border-radius: 4px;
  background: rgba(30, 40, 60, 0.8);
  color: rgba(220, 230, 250, 0.9);
  font-size: 0.85rem;
}

.control-group input:focus {
  outline: none;
  border-color: rgba(0, 212, 255, 0.5);
  box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.2);
}

.control-group button {
  padding: 6px 12px;
  border: 1px solid rgba(90, 110, 200, 0.3);
  border-radius: 4px;
  background: rgba(30, 40, 60, 0.8);
  color: rgba(220, 230, 250, 0.9);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.control-group button:hover {
  background: rgba(50, 60, 80, 0.8);
  border-color: rgba(120, 140, 220, 0.5);
}

/* ── Graph Container ── */
.graphs-container {
  flex: 1;
  padding: 12px 16px;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: center;
}

#populationGraph {
  border: 1px solid rgba(90, 110, 200, 0.3);
  border-radius: 8px;
  background: rgba(10, 15, 25, 0.8);
  max-width: 100%;
  height: auto;
}

/* ── Legend ── */
.graphs-legend {
  flex-shrink: 0;
  padding: 8px 16px;
  border-top: 1px solid rgba(90, 110, 200, 0.15);
  background: rgba(20, 25, 45, 0.4);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: rgba(180, 200, 240, 0.9);
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(90, 110, 200, 0.3);
}

/* ── Info Bar ── */
.graphs-info {
  flex-shrink: 0;
  padding: 6px 16px;
  border-top: 1px solid rgba(90, 110, 200, 0.2);
  background: rgba(15, 20, 35, 0.6);
  font-size: 0.75rem;
  color: rgba(160, 180, 220, 0.8);
  text-align: center;
}

#graphStats {
  font-family: inherit;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px 8px;
  border-radius: 4px;
  display: inline-block;
}

