:root {
  --ink: #16140f;
  --paper: #efe6d4;
  --paper-dim: #cfc4ae;
  --muted: #6f6758;
  --line: rgba(22, 20, 15, 0.14);
  --accent: #8b3a2a;
  --hud: rgba(18, 17, 14, 0.78);
  --hud-ink: #efe6d4;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0e0f0c;
  color: var(--ink);
  font: 13px/1.4 "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman", serif;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

canvas.dragging {
  cursor: grabbing;
}

.hud {
  position: fixed;
  top: 16px;
  left: 16px;
  right: 332px;
  display: flex;
  align-items: flex-end;
  gap: 20px;
  pointer-events: none;
  z-index: 2;
}

.hud .controls,
.hud .meter {
  pointer-events: auto;
}

.brand h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0.18em;
  font-weight: 600;
  color: var(--hud-ink);
  text-shadow: 0 1px 0 #000;
}

.brand p {
  margin: 2px 0 0;
  color: #cbbfa6;
  font-size: 12px;
  letter-spacing: 0.02em;
}

.meter {
  margin-left: auto;
  color: var(--hud-ink);
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  background: var(--hud);
  padding: 8px 10px;
  border: 1px solid rgba(239, 230, 212, 0.12);
}

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--hud);
  padding: 6px 10px;
  border: 1px solid rgba(239, 230, 212, 0.12);
}

button {
  font: inherit;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid #c5b89a;
  padding: 4px 10px;
  cursor: pointer;
}

button:hover {
  background: #f7f0e2;
}

.speed {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--hud-ink);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.speed input {
  width: 88px;
  accent-color: var(--paper);
}

.panel {
  position: fixed;
  top: 16px;
  right: 16px;
  bottom: 52px;
  width: 300px;
  background: var(--paper);
  border: 1px solid #c5b89a;
  display: flex;
  flex-direction: column;
  z-index: 2;
  min-height: 0;
}

.search {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 12px 8px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.search input {
  font: 14px/1.3 "Iowan Old Style", Palatino, serif;
  border: 0;
  border-bottom: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  padding: 4px 0;
  text-transform: none;
  letter-spacing: 0;
}

.search input:focus {
  outline: none;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0 12px 8px;
}

.filters button {
  font-size: 10px;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  background: transparent;
  color: var(--muted);
}

.filters button.on {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.find-next {
  margin: 0 12px 8px;
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.find-next:disabled {
  opacity: 0.35;
  cursor: default;
}

.species-list {
  overflow: auto;
  flex: 1;
  border-top: 1px solid var(--line);
  padding: 4px 0 8px;
}

.row {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 4px 12px;
  cursor: pointer;
  width: 100%;
  background: none;
  border: 0;
  border-radius: 0;
  text-align: left;
  font: inherit;
}

.row:hover,
.row.sel {
  background: rgba(22, 20, 15, 0.06);
}

.swatch {
  width: 44px;
  height: 32px;
  object-fit: contain;
  justify-self: center;
  image-rendering: auto;
}

.row b {
  font-weight: 600;
  font-size: 13px;
}

.row span {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 10px;
  color: var(--muted);
}

.mark {
  color: var(--accent);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.card {
  position: fixed;
  left: 16px;
  bottom: 44px;
  width: min(420px, calc(100% - 348px));
  background: var(--paper);
  border: 1px solid #c5b89a;
  padding: 14px 16px 16px;
  z-index: 3;
}

.card .close {
  position: absolute;
  top: 8px;
  right: 8px;
  border: 0;
  background: none;
  font-size: 18px;
  line-height: 1;
  color: var(--muted);
  padding: 4px 8px;
}

.card h2 {
  margin: 0 28px 2px 0;
  font-size: 20px;
  font-weight: 600;
}

.card .meta {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.web {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
}

.web h3 {
  margin: 0 0 4px;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.web p,
.web ul {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
}

.web li {
  padding: 1px 0;
}

.web .empty {
  color: var(--accent);
}

.traits {
  display: grid;
  grid-template-columns: 64px 1fr 36px;
  gap: 4px 8px;
  align-items: center;
  margin-top: 12px;
  font-size: 11px;
}

.bar {
  height: 6px;
  background: #ddd4c2;
  position: relative;
}

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

.legend {
  position: fixed;
  left: 16px;
  bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--hud-ink);
  font-size: 11px;
  z-index: 2;
  pointer-events: none;
  text-shadow: 0 1px 2px #000;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  width: 9px;
  height: 9px;
  display: block;
}

.hint {
  position: fixed;
  right: 16px;
  bottom: 16px;
  margin: 0;
  width: 360px;
  text-align: right;
  color: #cbbfa6;
  font-size: 11px;
  z-index: 2;
  pointer-events: none;
}

@media (max-width: 820px) {
  .panel {
    width: 240px;
    bottom: auto;
    height: 42vh;
  }

  .hud {
    right: 16px;
    flex-wrap: wrap;
  }

  .card {
    width: calc(100% - 32px);
    bottom: 40px;
  }

  .hint {
    display: none;
  }
}
