body {
  background:
    radial-gradient(1200px 800px at 20% 20%, #fff7e8 0%, transparent 70%),
    radial-gradient(900px 700px at 80% 80%, #e7dcc6 0%, transparent 70%),
    linear-gradient(135deg, var(--bg-a), var(--bg-b));
}

.stage {
  position: relative;
  width: 100vw;
  height: 100dvh;
}

canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

#pheromone-layer {
  z-index: 1;
  pointer-events: none;
  opacity: 0.5;
}

#scene-layer {
  z-index: 2;
  pointer-events: none;
}

#world {
  z-index: 3;
}

.label {
  position: absolute;
  top: 14px;
  left: 14px;
  color: var(--ink);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.75;
  user-select: none;
  pointer-events: none;
  z-index: 3;
}

#minimap {
  position: absolute;
  left: 24px;
  bottom: 24px;
  top: auto;
  border: 1px solid rgba(42, 31, 20, 0.45);
  border-radius: 8px;
  background: rgba(255, 252, 244, 0.55);
  box-shadow: 0 8px 18px rgba(41, 26, 10, 0.18);
  z-index: 5;
  pointer-events: none;
}

.top-left-hud {
  position: absolute;
  left: 14px;
  top: 14px;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 8px;
  z-index: 6;
  pointer-events: none;
}

.live-bug-stats {
  min-width: 170px;
  max-width: 240px;
  border: 1px solid rgba(42, 31, 20, 0.45);
  border-radius: 8px;
  background: rgba(255, 252, 244, 0.86);
  box-shadow: 0 8px 18px rgba(41, 26, 10, 0.18);
  color: #2a1f14;
  padding: 8px 10px;
}

.detection-legend {
  min-width: 220px;
  max-width: 280px;
  border: 1px solid rgba(42, 31, 20, 0.45);
  border-radius: 8px;
  background: rgba(255, 252, 244, 0.86);
  box-shadow: 0 8px 18px rgba(41, 26, 10, 0.18);
  color: #2a1f14;
  padding: 8px 10px;
  pointer-events: none;
}

.pheromone-toggle {
  min-width: 60px;
  border: 1px solid rgba(42, 31, 20, 0.45);
  border-radius: 8px;
  background: rgba(255, 252, 244, 0.86);
  box-shadow: 0 8px 18px rgba(41, 26, 10, 0.18);
  color: #2a1f14;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.3;
  padding: 6px 8px;
  cursor: pointer;
  pointer-events: auto;
}

.pheromone-toggle:hover {
  background: rgba(255, 252, 244, 0.96);
}

.pheromone-toggle:active {
  transform: translateY(1px);
}

.pheromone-toggle.is-hidden {
  opacity: 0.65;
}

.detection-legend-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 5px;
}

.detection-legend-group-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.78;
  margin-top: 6px;
  margin-bottom: 3px;
}

.detection-legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  line-height: 1.25;
  margin: 2px 0;
}

.legend-line {
  width: 24px;
  height: 0;
  border-top: 2px solid transparent;
  flex: 0 0 auto;
}

.legend-line-selected {
  border-top-color: rgba(244, 196, 48, 0.9);
}

.legend-line-food-view {
  border-top-color: rgba(228, 173, 82, 0.75);
}

.legend-line-food-smell {
  border-top-color: rgba(76, 179, 85, 0.82);
}

.legend-line-sex-smell {
  border-top-color: rgba(227, 84, 162, 0.78);
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  border: 1px solid rgba(42, 31, 20, 0.35);
  flex: 0 0 auto;
}

.legend-swatch-food {
  background: #58c368;
}

.legend-swatch-sex {
  background: #f06ebf;
}

.live-bug-total {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 6px;
}

.live-bug-species {
  display: grid;
  gap: 2px;
}

.live-bug-species-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11px;
  gap: 8px;
}

.live-bug-species-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-bug-species-count {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.sim-speed-toggle {
  position: absolute;
  right: 14px;
  bottom: 14px;
  min-width: 74px;
  width: auto;
  height: auto;
  padding: 10px 12px;
  border: 1px solid rgba(42, 31, 20, 0.45);
  border-radius: 8px;
  background: rgba(255, 252, 244, 0.78);
  box-shadow: 0 8px 18px rgba(41, 26, 10, 0.18);
  color: #2a1f14;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  z-index: 6;
}

.sim-speed-toggle:hover {
  background: rgba(255, 252, 244, 0.92);
}

.sim-speed-toggle:active {
  transform: translateY(1px);
}

@media (max-width: 720px) {
  #minimap {
    left: 16px;
    bottom: 16px;
  }

  .top-left-hud {
    left: 10px;
    top: 10px;
    gap: 6px;
    flex-wrap: wrap;
  }

  .sim-speed-toggle {
    min-width: 62px;
    width: auto;
    height: auto;
    padding: 9px 10px;
    font-size: 11px;
  }

  .live-bug-stats {
    min-width: 140px;
    max-width: 180px;
    padding: 7px 8px;
  }

  .detection-legend {
    min-width: 170px;
    max-width: 210px;
    padding: 7px 8px;
  }

  .detection-legend-row {
    font-size: 10px;
  }
}
