:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #07111f;
  color: #f8fafc;
}
* { box-sizing: border-box; }
html, body, .map3d-shell { margin: 0; min-height: 100%; }
body { overflow: hidden; }
#map3d { position: fixed; inset: 0; }
.map3d-header {
  position: fixed;
  z-index: 6;
  top: 14px;
  left: 14px;
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  max-width: min(360px, calc(100vw - 28px));
  padding: 12px 15px 13px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 20px;
  background: rgba(7,17,31,.82);
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 50px rgba(0,0,0,.32);
}
.map3d-header a {
  color: #fde68a;
  text-decoration: none;
  font-weight: 900;
  font-size: .86rem;
}
.map3d-header h1 {
  margin: 0;
  color: #fff;
  font-size: clamp(1.65rem, 6vw, 2.6rem);
  line-height: .96;
  letter-spacing: -.045em;
}
.map3d-controls {
  position: fixed;
  z-index: 6;
  left: 14px;
  right: 14px;
  bottom: 14px;
  display: grid;
  grid-template-columns: minmax(132px, .55fr) minmax(0, 1.25fr);
  gap: 10px 12px;
  padding: 12px;
  border-radius: 24px;
  background: rgba(15,23,42,.89);
  border: 1px solid rgba(255,255,255,.14);
  backdrop-filter: blur(14px);
  box-shadow: 0 20px 54px rgba(0,0,0,.34);
}
.map3d-controls input[type="hidden"] { display: none; }
.map3d-controls button {
  border: 0;
  border-radius: 17px;
  color: #111827;
  background: #fbbf24;
  font-weight: 950;
  cursor: pointer;
}
.load3d-btn {
  min-height: 48px;
  align-self: start;
  padding: 0 18px;
}
.map3d-controls button.secondary {
  color: #fff;
  background: #7c3aed;
}
.map3d-controls button.ghost {
  color: #c4b5fd;
  background: rgba(167,139,250,.18);
}
.map3d-timeline {
  display: grid;
  gap: 8px;
  padding: 10px 12px 12px;
  border-radius: 19px;
  background: rgba(255,255,255,.07);
}
.timeline-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: rgba(248,250,252,.78);
  font-size: .82rem;
}
.timeline-line strong {
  color: #fff;
  font-size: 1.2rem;
}
#yearSlider3d {
  width: 100%;
  padding: 0;
  accent-color: #fbbf24;
}
.map3d-actions {
  display: flex;
  gap: 8px;
}
.map3d-actions button {
  flex: 1;
  min-height: 43px;
  padding: 0 12px;
}
.map3d-status {
  grid-column: 1 / -1;
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(2,6,23,.34);
  color: rgba(248,250,252,.86);
  border: 1px solid rgba(255,255,255,.10);
  font-weight: 850;
  font-size: .82rem;
  text-align: center;
}
.map3d-legend {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 11px 12px;
  border-radius: 19px;
  background: rgba(2,6,23,.30);
  border: 1px solid rgba(255,255,255,.10);
  color: rgba(248,250,252,.84);
  font-weight: 850;
  font-size: .76rem;
}
.map3d-legend strong {
  color: #fff;
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.legend-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px 10px;
}
.map3d-legend span {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  white-space: nowrap;
}
.map3d-legend i {
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
  border-radius: 5px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.22);
}
.legend-source {
  margin: 0;
  color: rgba(248,250,252,.68);
  font-size: .74rem;
  font-weight: 750;
}
.maplibregl-ctrl-bottom-left,
.maplibregl-ctrl-bottom-right { display: none; }
@media (max-width: 760px) {
  .map3d-header {
    top: 10px;
    left: 10px;
    max-width: calc(100vw - 20px);
    padding: 10px 12px 11px;
    border-radius: 18px;
  }
  .map3d-header a { font-size: .8rem; }
  .map3d-header h1 { font-size: clamp(1.45rem, 7vw, 2rem); }
  .map3d-controls {
    left: 10px;
    right: 10px;
    bottom: 10px;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 9px;
    border-radius: 21px;
    max-height: 39vh;
    overflow: auto;
  }
  .load3d-btn { min-height: 44px; }
  .map3d-legend {
    padding: 9px 10px;
    gap: 7px;
    font-size: .72rem;
  }
  .legend-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 8px;
  }
  .map3d-legend i { width: 12px; height: 12px; border-radius: 4px; }
  .legend-source { font-size: .7rem; }
  .map3d-timeline { padding: 8px 9px 9px; }
  .map3d-actions { gap: 7px; }
  .map3d-actions button { min-height: 42px; font-size: .9rem; }
  .map3d-status { padding: 7px 10px; font-size: .74rem; }
}
@media (max-height: 680px) and (max-width: 760px) {
  .map3d-header { padding: 9px 11px; }
  .map3d-header h1 { font-size: 1.35rem; }
  .map3d-controls { max-height: 35vh; }
  .legend-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .map3d-legend strong, .legend-source { display: none; }
}
