:root {
  --bg: #090d0f;
  --panel: #111819;
  --panel-2: #161f21;
  --line: #22302f;
  --text: #dfe9e5;
  --muted: #8ba09a;
  --accent: #5fd6a4;
  --danger: #ff7a6b;
  --radius: 12px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px 28px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #101718, #0b1012);
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.stats {
  display: flex;
  gap: 24px;
  margin: 0;
}

.stats div {
  display: flex;
  flex-direction: column;
}

.stats dt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.stats dd {
  margin: 0;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

.link {
  margin-left: auto;
  font-size: 13px;
  color: var(--danger);
}

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  padding: 18px 24px 32px;
  align-items: start;
}

.world-panel {
  min-width: 0;
}

#world {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0b1013;
}

.creature {
  transition: transform 0.7s linear;
}

.creature circle {
  transition: opacity 0.7s linear, r 0.7s linear;
}

.creature.dim {
  opacity: 0.22;
}

.food {
  fill: #3f7d52;
}

.hint,
.note {
  color: var(--muted);
  font-size: 13px;
  margin: 10px 2px 0;
}

aside {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.card h2 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}

form {
  display: flex;
  gap: 8px;
}

input[type='text'] {
  flex: 1;
  min-width: 0;
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #0c1214;
  color: var(--text);
  font: inherit;
}

input[type='text']:focus-visible,
button:focus-visible,
.lineages button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button {
  padding: 9px 13px;
  border-radius: 9px;
  border: 0;
  background: var(--accent);
  color: #06120c;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button:disabled {
  opacity: 0.55;
  cursor: progress;
}

.preview {
  margin-top: 12px;
  padding: 12px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.preview-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.preview-head strong {
  font-size: 15px;
}

.badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #23312f;
  color: var(--muted);
}

.badge.predator {
  background: #3a1f1c;
  color: #ffb1a6;
}

.genes {
  display: grid;
  gap: 6px;
  margin: 0;
}

.gene {
  display: grid;
  grid-template-columns: 82px 1fr 40px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.bar {
  height: 6px;
  border-radius: 999px;
  background: #0c1214;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.gene .value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.lineages,
.feed {
  list-style: none;
  margin: 0;
  padding: 0;
}

.lineages li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid #1a2524;
}

.lineages li:last-child {
  border-bottom: 0;
}

.lineages button {
  flex: 1;
  text-align: left;
  background: none;
  color: var(--text);
  padding: 0;
  font-weight: 500;
}

.lineages .count {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 13px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}

.feed-card {
  max-height: 340px;
  display: flex;
  flex-direction: column;
}

.feed {
  overflow-y: auto;
  font-size: 13px;
}

.feed li {
  padding: 4px 0;
  border-bottom: 1px solid #1a2524;
  color: var(--text);
}

.feed .tick {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-right: 6px;
}

.feed li.death {
  color: #b9a0a0;
}

.feed li.hunt {
  color: #ffb1a6;
}

.feed li.spawn {
  color: var(--accent);
}

.empty {
  color: var(--muted);
}

.error {
  color: var(--danger);
  font-size: 13px;
  margin: 10px 0 0;
}

@media (max-width: 900px) {
  main {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .creature,
  .creature circle {
    transition: none;
  }
}
