:root {
  color-scheme: dark;
  --panel: rgba(18, 23, 24, 0.78);
  --panel-strong: rgba(14, 19, 20, 0.9);
  --line: rgba(255, 255, 255, 0.18);
  --text: #f6f4ed;
  --muted: #b9c4bd;
  --accent: #f0c449;
  --accent-2: #34d1bf;
}

* {
  box-sizing: border-box;
}

html,
body,
.app-shell,
.map-wrap,
#map {
  width: 100%;
  height: 100%;
  min-height: 100vh;
  margin: 0;
}

body {
  overflow: hidden;
  background: #0b0f10;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.map-wrap {
  position: relative;
}

#map {
  z-index: 0;
  background: #121614;
}

.leaflet-container {
  font: inherit;
}

.leaflet-control-layers,
.leaflet-control-zoom a {
  background: rgba(18, 23, 24, 0.86);
  border: 1px solid var(--line);
  color: var(--text);
  backdrop-filter: blur(14px);
}

.leaflet-control-layers label {
  color: var(--text);
}

.hud {
  position: absolute;
  z-index: 500;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(18px);
}

.top-left {
  top: 18px;
  left: 18px;
  width: min(460px, calc(100vw - 36px));
  padding: 18px;
}

.title-block {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.eyebrow,
.stats-grid span,
.metric span,
.speed-control span {
  color: var(--muted);
  display: block;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 2px 0 0;
  font-size: clamp(1.65rem, 3vw, 2.45rem);
  line-height: 1;
  letter-spacing: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.stats-grid div,
.metric {
  min-width: 0;
}

.stats-grid strong,
.metric strong {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
  font-size: 1rem;
  line-height: 1.2;
}

.right-panel {
  top: 18px;
  right: 18px;
  width: min(220px, calc(100vw - 36px));
  display: grid;
  gap: 14px;
  padding: 16px;
}

.icon-button,
.play-button {
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: var(--panel-strong);
  color: var(--text);
  cursor: pointer;
  font: inherit;
}

.icon-button {
  width: 40px;
  height: 40px;
  font-size: 1.35rem;
}

.map-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 800;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.map-buttons button {
  pointer-events: auto;
  touch-action: manipulation;
}

.play-button {
  flex: 0 0 64px;
  width: 64px;
  height: 48px;
  font-size: 0.84rem;
  font-weight: 800;
}

.icon-button:hover,
.play-button:hover {
  border-color: rgba(240, 196, 73, 0.9);
  color: var(--accent);
}

.control-bar {
  position: absolute;
  z-index: 520;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  width: min(980px, calc(100vw - 36px));
  display: flex;
  align-items: center;
  gap: 16px;
  border: 1px solid var(--line);
  background: rgba(14, 19, 20, 0.86);
  padding: 14px;
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(20px);
}

.timeline {
  flex: 1;
  min-width: 0;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.timeline-labels {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 6px;
}

.speed-control {
  display: grid;
  gap: 4px;
  min-width: 112px;
}

.animal-control {
  display: grid;
  gap: 6px;
}

.top-animal-control {
  margin-top: 14px;
}

.animal-control span {
  color: var(--muted);
  display: block;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.animal-control select {
  width: 100%;
}

.track-legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin-top: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 750;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.65);
}

.legend-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

select {
  height: 34px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 0 8px;
  font: inherit;
}

.track-dot {
  width: 22px;
  height: 22px;
  border: 3px solid #111;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 7px rgba(240, 196, 73, 0.28), 0 0 30px rgba(240, 196, 73, 0.75);
}

.fix-canvas {
  pointer-events: none;
}

.start-dot,
.end-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #101414;
}

.start-dot {
  background: var(--accent-2);
}

.end-dot {
  background: #ff7e67;
}

@media (max-width: 720px) {
  body {
    overflow: auto;
  }

  .right-panel {
    top: auto;
    right: 18px;
    bottom: 116px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(360px, calc(100vw - 36px));
  }

  .right-panel .metric:nth-child(2) {
    grid-column: span 2;
  }

  .control-bar {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .timeline {
    flex-basis: calc(100% - 64px);
  }

  .speed-control {
    width: 100%;
  }
}
