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

:root {
  --bg: #0d1117;
  --panel: #161b22;
  --border: #30363d;
  --text: #c9d1d9;
  --muted: #8b949e;
  --accent: #58a6ff;
}

html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, monospace;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.brand { font-size: 15px; }
.clock { display: flex; gap: 10px; align-items: center; flex: 1; }
.chip {
  background: #21262d;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 9px;
  font-size: 12px;
}
.chip.night { background: #1a1a40; }
.conn { font-size: 12px; color: var(--muted); }
.conn.ok { color: #3fb950; }
.conn.bad { color: #f85149; }

#layout { display: flex; flex: 1; min-height: 0; }

#stage { position: relative; flex: 1; min-width: 0; }
#world { width: 100%; height: 100%; display: block; cursor: grab; }
#world.dragging { cursor: grabbing; }

.tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(13, 17, 23, 0.92);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 9px;
  font-size: 12px;
  z-index: 5;
  white-space: nowrap;
}

#legend {
  position: absolute;
  left: 10px;
  bottom: 10px;
  display: flex;
  gap: 14px;
  align-items: center;
  background: rgba(13, 17, 23, 0.75);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 12px;
}
.hint { color: var(--muted); }

#popbar {
  position: absolute;
  right: 10px;
  top: 10px;
  display: flex;
  gap: 14px;
  background: rgba(13, 17, 23, 0.75);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 12px;
}

#sidebar {
  width: 330px;
  overflow-y: auto;
  border-left: 1px solid var(--border);
  background: var(--panel);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--bg);
}
.panel h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}
.sub { color: var(--muted); font-size: 12px; margin: 4px 0; }

.bars label { display: flex; align-items: center; gap: 8px; font-size: 12px; }
progress { flex: 1; height: 8px; accent-color: var(--accent); }

.genes { width: 100%; border-collapse: collapse; margin: 6px 0; font-size: 12px; }
.genes td { padding: 2px 4px; border-bottom: 1px solid #21262d; }
.genes td:last-child { text-align: right; color: var(--accent); }
.genes .bar { height: 4px; background: #21262d; border-radius: 2px; position: relative; min-width: 60px; }
.genes .bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 2px; }

.btn {
  background: #21262d;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 12px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  margin: 6px 4px 0 0;
}
.btn:hover { border-color: var(--accent); }
.btn.active { background: var(--accent); color: #0d1117; }
.btn.ghost { color: var(--muted); }

.chronicle { list-style: none; max-height: 320px; overflow-y: auto; }
.chronicle li {
  padding: 4px 0;
  border-bottom: 1px solid #21262d;
  font-size: 12px;
  line-height: 1.45;
}
.chronicle li .when { color: var(--muted); margin-right: 6px; }
.chronicle li.kind-hunt { color: #e0a16b; }
.chronicle li.kind-extinction, .chronicle li.kind-record { color: #f0b72f; }
.chronicle li.kind-migration, .chronicle li.kind-genesis { color: #58a6ff; }
.chronicle li.kind-season { color: #7ee787; }
.chronicle li.kind-weather { color: #a5b4fc; }
.chronicle li.flash { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: #243049; } to { background: transparent; } }

@media (max-width: 800px) {
  #layout { flex-direction: column; }
  #sidebar { width: 100%; max-height: 45%; border-left: none; border-top: 1px solid var(--border); }
}
