.mapa-civilizacoes {
  --mapa-ink: #3c2314;
  --mapa-paper: #fffaf4;
  --mapa-bronze: #b98c58;
}

.mapa-civilizacoes .leaflet-container {
  background: #d8d2c5;
  font-family: inherit;
  touch-action: pan-x pan-y;
}

.mapa-civilizacoes .leaflet-control-zoom a {
  color: var(--mapa-ink);
}

.mapa-timeline {
  border: 1px solid rgba(229, 213, 192, 0.32);
  background: rgba(60, 35, 20, 0.88);
  box-shadow: 0 10px 28px rgba(41, 24, 15, 0.2);
}

.mapa-info {
  border: 1px solid rgba(229, 213, 192, 0.32);
  background: rgba(60, 35, 20, 0.92);
  box-shadow: 0 10px 28px rgba(41, 24, 15, 0.2);
}

.mapa-info-fechar {
  display: inline-flex;
  width: 2rem;
  height: 2rem;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(229, 213, 192, 0.4);
  border-radius: 0.5rem;
  color: #fffaf4;
  font-size: 1.25rem;
  line-height: 1;
}

.mapa-info-fechar:hover,
.mapa-info-fechar:focus-visible {
  background: rgba(255, 250, 244, 0.12);
}

.mapa-info-dados {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.4rem 0.7rem;
  font-size: 0.78rem;
}

.mapa-info-dados dt {
  color: #b98c58;
  font-weight: 700;
}

.mapa-info-dados dd {
  margin: 0;
  color: #fffaf4;
  overflow-wrap: anywhere;
}

.mapa-artigo-link {
  display: inline-flex;
  margin-top: 0.8rem;
  color: #b98c58;
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: underline;
}

.mapa-artigo-link:hover,
.mapa-artigo-link:focus-visible {
  color: #fffaf4;
}

.mapa-legenda {
  color: #57504a;
  font-size: 0.78rem;
}

.mapa-legenda-busca input {
  width: min(220px, 100%);
  min-height: 2.2rem;
  border: 1px solid #e5d5c0;
  border-radius: 0.55rem;
  background: #fffaf4;
  color: #3c2314;
  padding: 0.4rem 0.65rem;
}

.mapa-legenda-busca input:focus {
  border-color: #b98c58;
  outline: 2px solid rgba(185, 140, 88, 0.2);
}

.mapa-legenda-itens {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.45rem 0.75rem;
  max-height: 9rem;
  margin-top: 0.75rem;
  overflow-y: auto;
  padding: 0.15rem 0.15rem 0.15rem 0;
}

.mapa-legenda-item {
  display: inline-flex;
  align-items: center;
  min-height: 2.1rem;
  gap: 0.45rem;
  border: 1px solid transparent;
  border-radius: 0.45rem;
  color: #3c2314;
  padding: 0.3rem 0.45rem;
  text-align: left;
  transition: background-color 160ms ease, border-color 160ms ease;
}

button.mapa-legenda-item {
  width: 100%;
  cursor: pointer;
  font: inherit;
}

.mapa-legenda-item:hover,
.mapa-legenda-item:focus-visible,
.mapa-legenda-item.is-active {
  border-color: #e5d5c0;
  background: #f6f1e8;
  outline: none;
}

.mapa-legenda-empty {
  grid-column: 1 / -1;
  color: #78716c;
  font-style: italic;
}

.mapa-legenda-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.mapa-legenda-swatch {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 999px;
}

.mapa-legenda-imperios { background: #8f4f36; }
.mapa-legenda-reinos { background: #b98c58; }
.mapa-legenda-culturas { background: #56756b; }

.mapa-timeline input[type="range"] {
  height: 1.25rem;
  accent-color: var(--mapa-bronze);
  cursor: pointer;
}

.mapa-timeline input[type="range"]:disabled {
  cursor: wait;
  opacity: 0.7;
}

.mapa-tempo-btn {
  min-height: 2.35rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid rgba(229, 213, 192, 0.42);
  border-radius: 0.55rem;
  color: #fffaf4;
  font-size: 0.72rem;
  font-weight: 700;
  transition: background-color 160ms ease, border-color 160ms ease;
}

.mapa-tempo-btn:hover,
.mapa-tempo-btn:focus-visible {
  border-color: #b98c58;
  background: rgba(185, 140, 88, 0.22);
  outline: none;
}

.mapa-tempo-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.mapa-velocidade {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: #e5d5c0;
  font-size: 0.72rem;
  font-weight: 700;
}

.mapa-velocidade select {
  min-height: 2.35rem;
  border: 1px solid rgba(229, 213, 192, 0.42);
  border-radius: 0.55rem;
  background: #3c2314;
  color: #fffaf4;
  padding: 0.35rem 0.5rem;
}

.mapa-civilizacoes .leaflet-popup-content-wrapper,
.mapa-civilizacoes .leaflet-popup-tip {
  background: var(--mapa-paper);
}

.mapa-civilizacoes .leaflet-popup-content {
  min-width: 190px;
  margin: 15px 17px;
  color: var(--mapa-ink);
}

.mapa-civilizacoes .leaflet-interactive:focus {
  outline: 3px solid #fffaf4;
  outline-offset: 2px;
}

.mapa-popup h3 {
  margin: 0 0 0.6rem;
  color: var(--mapa-ink);
  font-size: 1rem;
  font-weight: 700;
}

.mapa-popup dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 0.75rem;
  margin: 0;
  font-size: 0.78rem;
}

.mapa-popup dt {
  color: #8c6239;
  font-weight: 700;
}

.mapa-popup dd {
  margin: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 640px) {
  .mapa-civilizacoes .leaflet-popup-content {
    max-width: min(250px, calc(100vw - 72px));
  }

  .mapa-timeline {
    bottom: 0.75rem;
    padding: 0.8rem;
  }

  .mapa-info {
    right: 0.75rem;
    top: 0.75rem;
  }

  .mapa-tempo-btn {
    padding-inline: 0.55rem;
  }

  .mapa-velocidade {
    width: 100%;
    justify-content: flex-end;
  }
}