:root {
  --ink: #14201c;
  --paper: #f2f5f1;
  --muted: #5c6b63;
  --panel: rgba(242, 245, 241, 0.92);
  --line: rgba(20, 32, 28, 0.12);
  --cell: #2456c8;
  --rose: #b86e00;
  --likely: #0f8a55;
  --focus: #14201c;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: "Archivo", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 50% at 10% 0%, #d9e8df 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 100%, #e4dcc8 0%, transparent 50%),
    #e8eee8;
}

#map {
  position: fixed;
  inset: 0;
  z-index: 0;
}

.panel {
  position: fixed;
  z-index: 500;
  top: 1rem;
  left: 1rem;
  width: min(22.5rem, calc(100vw - 2rem));
  padding: 1.15rem 1.2rem 1.25rem;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 18px 50px rgba(20, 32, 28, 0.14);
  animation: rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.brand {
  margin: 0 0 0.35rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--rose);
}

h1 {
  margin: 0 0 0.55rem;
  font-size: clamp(1.55rem, 4vw, 1.9rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.lede {
  margin: 0 0 1rem;
  color: rgba(20, 32, 28, 0.78);
  font-size: 0.95rem;
  line-height: 1.45;
}

.lede code,
.note code {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.82em;
  color: var(--focus);
  background: rgba(20, 32, 28, 0.06);
  padding: 0.05em 0.25em;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 0.85rem;
  margin: 0 0 1rem;
  padding: 0.85rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.stats div:last-child {
  grid-column: 1 / -1;
}

.stats dt {
  margin: 0 0 0.2rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.stats dd {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.35;
}

.legend {
  list-style: none;
  margin: 0 0 0.9rem;
  padding: 0;
  display: grid;
  gap: 0.45rem;
  font-size: 0.84rem;
  color: rgba(20, 32, 28, 0.88);
}

.legend li {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.swatch {
  width: 0.85rem;
  height: 0.85rem;
  flex: 0 0 auto;
  border: 2px solid currentColor;
}

.swatch.cell {
  color: var(--cell);
  background: color-mix(in srgb, var(--cell) 28%, transparent);
}

.swatch.rose {
  color: var(--rose);
  border-radius: 50%;
  background: color-mix(in srgb, var(--rose) 28%, transparent);
}

.swatch.likely {
  color: var(--likely);
  background: color-mix(in srgb, var(--likely) 35%, transparent);
}

.note {
  margin: 0 0 1rem;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

button {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  font-size: 0.86rem;
  padding: 0.55rem 0.85rem;
  background: var(--ink);
  color: var(--paper);
  transition: transform 0.15s ease, background 0.15s ease;
}

button:hover {
  background: #0b1512;
  transform: translateY(-1px);
}

button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

button.ghost:hover {
  background: rgba(20, 32, 28, 0.05);
}

.leaflet-container {
  background: #d5ddd6;
  font: inherit;
}

.leaflet-control-attribution {
  background: rgba(242, 245, 241, 0.85) !important;
  color: rgba(20, 32, 28, 0.65) !important;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.65rem !important;
}

.leaflet-control-attribution a {
  color: var(--rose) !important;
}

.leaflet-popup-content-wrapper {
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 12px 30px rgba(20, 32, 28, 0.18);
}

.leaflet-popup-tip {
  background: var(--paper);
}

.leaflet-popup-content {
  margin: 0.7rem 0.85rem;
  font-size: 0.86rem;
  line-height: 1.4;
}

.leaflet-popup-content strong {
  display: block;
  margin-bottom: 0.2rem;
  font-size: 0.95rem;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 640px) {
  .panel {
    top: auto;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 46vh;
    overflow: auto;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
  }
}
