@import url('https://fonts.googleapis.com/css2?family=Titillium+Web:ital,wght@0,200;0,300;0,400;0,600;0,700;0,900;1,200;1,300;1,400;1,600;1,700&display=swap');

:root {
  color-scheme: light dark;
  --panel-width: 350px;
}

html, body, #app {
  height: 100%;
  margin: 0;
  font-family: 'Titillium Web', system-ui, sans-serif;
}

#app {
  position: relative;
}

#map {
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  right: var(--panel-width);
  bottom: 0;
  transition: right 0.35s cubic-bezier(.4,0,.2,1);
}

body.panel-resizing #map {
  transition: none;
}

body.panel-closed #map {
  right: 0;
}

#map-legends {
  position: absolute;
  bottom: 55px;
  left: 8px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.map-legend {
  background: rgba(255, 255, 255, 0.9);
  color: #1a1a1a;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  font-size: 0.8rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.copertura-legend-block + .copertura-legend-block {
  margin-top: 0.5rem;
}

.copertura-legend-title {
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.copertura-legend-bar {
  display: flex;
  width: 160px;
  height: 10px;
  border-radius: 2px;
  overflow: hidden;
}

.copertura-legend-bar span {
  flex: 1;
}

.copertura-legend-scale {
  display: flex;
  justify-content: space-between;
  width: 160px;
  margin-top: 0.15rem;
  font-size: 0.7rem;
  color: #444;
}

.map-legend .legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.2rem 0;
  cursor: pointer;
  user-select: none;
}

.map-legend .legend-item.legend-item-inactive {
  opacity: 0.4;
}

.copertura-legend-block {
  cursor: pointer;
  user-select: none;
}

.copertura-legend-block:hover,
.map-legend .legend-item:hover {
  opacity: 0.75;
}

.map-legend .legend-item:first-child {
  margin-top: 0;
}

.map-legend .legend-item:last-child {
  margin-bottom: 0;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
}

#panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--panel-width);
  border-left: 1px solid #ccc;
  overflow-y: auto;
  background: #ffffff;
  color: #1a1a1a;
  transition: background 0.2s, color 0.2s, transform 0.35s cubic-bezier(.4,0,.2,1);
}

#panel.closed {
  transform: translateX(100%);
}

#panel-resize-handle {
  position: absolute;
  top: 0;
  left: -4px;
  width: 8px;
  height: 100%;
  cursor: ew-resize;
  z-index: 12;
  touch-action: none;
}

body.panel-resizing #panel {
  transition: none;
}

#panel-toggle {
  position: absolute;
  right: var(--panel-width);
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 50px;
  background: #ffffff;
  border: 1px solid #ccc;
  border-right: none;
  border-radius: 6px 0 0 6px;
  cursor: pointer;
  color: #555;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  z-index: 11;
  box-shadow: -3px 0 12px rgba(0,0,0,.2);
  transition: background 0.15s, right 0.35s cubic-bezier(.4,0,.2,1);
}

body.panel-resizing #panel-toggle {
  transition: none;
}

body.panel-closed #panel-toggle {
  right: 0;
}

#map-logos {
  position: absolute;
  right: calc(var(--panel-width) + 10px);
  bottom: 10px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: right 0.35s cubic-bezier(.4,0,.2,1);
}

body.panel-resizing #map-logos {
  transition: none;
}

body.panel-closed #map-logos {
  right: 10px;
}

#map-logos a {
  display: block;
  width: 100px;
  height: 100px;
}

#map-logos img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

#map-logos .logo-ondata {
  height: 21px;
}

#panel-toggle:hover {
  background: #f0f0f0;
}

body.theme-dark #panel-toggle {
  background: #1b1e22;
  border-color: #333;
  color: #ccc;
}

body.theme-dark #panel-toggle:hover {
  background: #262a30;
}

#panel-tabs {
  display: flex;
  position: sticky;
  top: 0;
  z-index: 1;
  background: inherit;
  border-bottom: 1px solid #ccc;
}

.panel-tab {
  flex: 1;
  padding: 0.6rem 0.4rem;
  border: none;
  background: transparent;
  color: inherit;
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  opacity: 0.65;
}

.panel-tab.active {
  opacity: 1;
  border-bottom-color: #4d90c2;
  font-weight: 600;
}

.panel-tab-pane {
  padding: 1rem;
}

.panel-tab-pane h2 {
  font-size: 20px;
}

.panel-tab-pane p,
.panel-tab-pane li {
  font-size: 12px;
}

body.theme-dark #panel-tabs {
  border-bottom-color: #333;
}

.panel-subtitle {
  margin: -0.5rem 0 1rem;
  font-size: 0.85rem;
  opacity: 0.7;
}

/* Tema mappa (light/dark/satellite, vedi #map-toolbar) applicato anche al
   pannello dx: solo il tema scuro passa alla palette scura, satellite resta
   bianco come il tema chiaro. */
body.theme-dark #panel {
  background: #1b1e22;
  color: #eaeaea;
  border-left-color: #333;
}

table {
  border-collapse: collapse;
  width: 100%;
}

td, th {
  border: 1px solid #ddd;
  padding: 0.25rem 0.5rem;
}

/* MapLibre's popup chrome (background, close button) always renders on a
   white .maplibregl-popup-content regardless of OS theme, but our
   `color-scheme: light dark` makes unstyled text/buttons default to white
   in dark mode — force both explicitly so the popup stays readable. */
.maplibregl-popup-content {
  background: #ffffff;
  color: #1a1a1a;
}

.maplibregl-popup-close-button {
  color: #1a1a1a;
}

/* Tab Progetto: icone piccole (28px) invece delle grandi icone circolari originali. */
.progetto-list {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.progetto-item {
  text-align: center;
}

.progetto-icon {
  --progetto-icon-bg: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #345f96;
  color: #fff;
}

.progetto-icon svg {
  width: 16px;
  height: 16px;
}

.progetto-item h3 {
  margin: 0.35rem 0 0.25rem;
  font-size: 0.95rem;
}

.progetto-item p {
  margin: 0;
  font-size: 0.85rem;
  opacity: 0.85;
}

body.theme-dark .progetto-icon {
  --progetto-icon-bg: #1b1e22;
}

.progetto-brochure {
  display: block;
  width: 100%;
  margin: 0.5rem 0;
  border-radius: 4px;
  border: 1px solid #ccc;
}

.progetto-small {
  font-size: 0.75rem;
  opacity: 0.8;
}

.progetto-disclaimer {
  margin-top: 1rem;
  font-size: 0.75rem;
  font-style: italic;
  opacity: 0.7;
}

/* Galleria thumbnail nel tab PlasticFree: click apre #pf-lightbox a 80% viewport. */
.pf-gallery {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 0.5rem 0 1rem;
}

.pf-thumb {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  width: 100%;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: none;
  cursor: pointer;
  overflow: hidden;
  font-size: 0.8rem;
}

.pf-thumb img {
  width: 100%;
  height: auto;
  object-fit: contain;
  display: block;
}

.pf-thumb span {
  padding: 0.35rem 0.5rem;
  text-align: center;
}

body.theme-dark .pf-thumb {
  color: #eaeaea;
}

.pf-credits-table {
  font-size: 0.7rem;
}

.pf-credits-table td,
.pf-credits-table th {
  border: none;
  padding: 0.2rem 0.3rem;
}

.credits-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem 0.75rem;
}

.credits-member {
  text-align: center;
}

.credits-member img {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto 0.35rem;
  display: block;
}

.credits-member h3 {
  margin: 0 0 0.15rem;
  font-size: 0.8rem;
}

.credits-member p {
  margin: 0 0 0.15rem;
  font-size: 0.7rem;
  opacity: 0.8;
}

.credits-member a {
  font-size: 0.7rem;
}

.mi-link {
  color: #4d90c2;
  font-weight: 600;
}

.tools-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.75rem;
  line-height: 1.5;
}

.tools-list li {
  margin-bottom: 0.3rem;
}

.pf-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
}

.pf-lightbox[hidden] {
  display: none;
}

.pf-lightbox figure {
  margin: 0;
  width: 80vw;
  height: 80vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #111;
  border-radius: 4px;
  overflow: hidden;
}

.pf-lightbox img {
  max-width: 100%;
  max-height: calc(80vh - 2.5rem);
  object-fit: contain;
}

.pf-lightbox figcaption {
  color: #fff;
  padding: 0.5rem 1rem;
  text-align: center;
  font-size: 0.9rem;
}

.pf-lightbox-close {
  position: absolute;
  top: calc(10vh - 2rem);
  right: calc(10vw - 1rem);
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  border: none;
  background: #fff;
  color: #1a1a1a;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

/* Tooltip hover fontanella: sfondo semi-trasparente cosi non copre
   del tutto i colori dei layer di copertura/isocrone sotto il cursore. */
.fontanella-tooltip-popup .maplibregl-popup-content {
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.fontanella-popup {
  max-width: 260px;
  color: #1a1a1a;
}

.fontanella-popup h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  color: #1a1a1a;
}

.fontanella-popup dl {
  margin: 0;
}

.fontanella-popup dt {
  font-weight: bold;
  color: #555;
  font-size: 0.8rem;
  margin-top: 0.4rem;
}

.fontanella-popup dd {
  margin: 0;
  color: #1a1a1a;
}

.fontanella-tooltip {
  color: #1a1a1a;
  font-size: 0.85rem;
  max-width: 200px;
  white-space: normal;
  overflow-wrap: break-word;
}

.fontanella-popup a {
  display: inline-block;
  margin-top: 0.75rem;
  color: #0b6e99;
  font-weight: bold;
}

.route-popup {
  max-width: 220px;
  color: #1a1a1a;
}

.route-popup h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  color: #1a1a1a;
}

.route-popup dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto auto;
  column-gap: 0.6rem;
}

.route-popup dt {
  font-weight: bold;
  color: #555;
  font-size: 0.8rem;
}

.route-popup dd {
  margin: 0;
  color: #1a1a1a;
  text-align: right;
}

.route-elevation-chart {
  display: block;
  width: 100%;
  height: 44px;
  margin-top: 0.6rem;
}

.route-elevation-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: #777;
  margin-top: 0.1rem;
}

#map-top-bar {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#map-toolbar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.9);
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

#map-toolbar button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: #1a1a1a;
  cursor: pointer;
}

#map-toolbar button:hover {
  background: rgba(0, 0, 0, 0.08);
}

#map-toolbar button.active {
  background: rgba(0, 0, 0, 0.14);
}

.theme-btn-group {
  display: flex;
  gap: 0.05rem;
}

.toolbar-sep {
  width: 1px;
  height: 20px;
  background: rgba(0, 0, 0, 0.15);
  margin: 0 0.1rem;
}

.toolbar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  cursor: pointer;
}

.toolbar-toggle:hover {
  background: rgba(0, 0, 0, 0.08);
}

.toolbar-toggle:has(input:checked) {
  background: rgba(0, 0, 0, 0.14);
}

.zoom-wrap {
  display: flex;
  align-items: center;
  margin: 0 0.2rem;
}

#zoom-slider {
  width: 100px;
}

#zoom-badge {
  min-width: 1.6rem;
  text-align: center;
  font-size: 0.8rem;
  color: #1a1a1a;
}

#search-area {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  width: min(420px, calc(100% - 16px));
  display: flex;
  flex-direction: column;
}

#search-chips {
  display: none;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.3rem;
}

#search-chips.visible {
  display: flex;
}

.search-chip {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 12px;
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
  color: #1a1a1a;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.search-chip button {
  border: none;
  background: transparent;
  cursor: pointer;
  color: #666;
  font-size: 0.7rem;
}

#searchbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.search-icon {
  display: flex;
  color: #666;
}

#search-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 0.9rem;
  background: transparent;
  color: #1a1a1a;
}

#search-clear,
#filter-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  color: #1a1a1a;
  display: flex;
  align-items: center;
  position: relative;
}

#filter-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  background: #e74c3c;
  color: #fff;
  border-radius: 50%;
  width: 14px;
  height: 14px;
  font-size: 0.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

#search-dd {
  display: none;
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow-y: auto;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

#search-dd.open {
  display: block;
}

.search-dd-cat {
  font-size: 0.7rem;
  font-weight: 600;
  color: #888;
  padding: 0.3rem 0.6rem 0.1rem;
}

.search-dd-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0.6rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: #1a1a1a;
}

.search-dd-item:hover {
  background: rgba(0, 0, 0, 0.06);
}

.search-dd-badge {
  font-size: 0.65rem;
  color: #888;
}

.search-dd-empty {
  padding: 0.5rem 0.6rem;
  font-size: 0.8rem;
  color: #888;
}

#filter-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 3;
}

#filter-overlay.visible {
  display: block;
}

#filter-modal {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
  background: #fff;
  border-radius: 8px;
  padding: 1rem 1.2rem;
  width: min(360px, calc(100% - 32px));
  color: #1a1a1a;
}

#filter-modal.visible {
  display: block;
}

.fm-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.fm-header button {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1rem;
}

.fm-group {
  margin-bottom: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.fm-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.fm-footer button {
  padding: 0.35rem 0.8rem;
  border-radius: 4px;
  border: 1px solid #ccc;
  background: #fff;
  color: #1a1a1a;
  cursor: pointer;
}

#fm-apply {
  background: #0b6e99;
  color: #fff;
  border-color: #0b6e99;
}

/* ── Pannello Statistiche: clone dello stile donut/ranking di
   bivariate/tpl (colori neutri via rgba, leggibili in chiaro e scuro). */
.fsec h3 {
  font-size: 0.75rem;
  font-weight: 700;
  color: inherit;
  opacity: 0.65;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
}

.sep {
  border: none;
  border-top: 1px solid rgba(127, 127, 127, 0.3);
  margin: 0.75rem 0;
}

.stats-table {
  width: 100%;
  table-layout: fixed;
  font-size: 12px;
  margin-bottom: 0.75rem;
}

.stats-table th,
.stats-table td {
  border: 1px solid rgba(127, 127, 127, 0.3);
  padding: 0.3rem 0.4rem;
  text-align: center;
  word-break: break-word;
}

.stats-table thead th {
  background: rgba(127, 127, 127, 0.15);
  font-weight: 700;
}

/* Griglia bivariata "offerta × carico" copertura, stessa geometria/palette
   della legenda 3×3 di bivariate/tpl, riadattata alle 8 circoscrizioni. */
.biv-grid-card {
  margin-bottom: 0.75rem;
}

.biv-grid-intro {
  font-size: 0.75rem;
  opacity: 0.85;
  margin: 0 0 0.6rem;
}

.biv-grid-axes {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
}

.biv-grid-ylabel {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.65;
  white-space: nowrap;
  align-self: center;
}

.biv-grid-main {
  flex: 1;
  min-width: 0;
}

.biv-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  aspect-ratio: 1 / 1;
  gap: 3px;
  width: 100%;
}

.biv-cell {
  border-radius: 4px;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 3px;
  padding: 4px;
  cursor: help;
}

.biv-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  color: #fff;
  font-size: 0.55rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.6);
  transition: opacity 0.15s;
}

.biv-dot-dim {
  opacity: 0.25;
}

.biv-grid-xticks {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  opacity: 0.65;
  margin-top: 2px;
}

.biv-grid-xlabel {
  text-align: center;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.65;
  margin-top: 2px;
}

.biv-grid-note {
  font-size: 0.7rem;
  opacity: 0.75;
  margin-top: 0.5rem;
}

.stats-table tbody tr:nth-child(even) {
  background: rgba(127, 127, 127, 0.06);
}

.donut-card {
  background: rgba(127, 127, 127, 0.08);
  border: 1px solid rgba(127, 127, 127, 0.25);
  border-radius: 10px;
  padding: 0.6rem 0.6rem 0.5rem;
}

.donut-svg-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 0.5rem;
}

.donut-svg {
  width: 100%;
  height: auto;
  max-width: 200px;
  display: block;
  overflow: visible;
}

.donut-seg {
  cursor: pointer;
  opacity: 0.9;
  transition: opacity 0.15s, filter 0.15s;
}

.donut-seg:hover {
  opacity: 1;
  filter: brightness(1.15);
}

.donut-seg.donut-dim {
  opacity: 0.25;
}

.donut-total {
  font-size: 16px;
  font-weight: 700;
  fill: currentColor;
  font-family: inherit;
}

.donut-label {
  font-size: 8px;
  fill: currentColor;
  opacity: 0.65;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.donut-leg-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.25rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.12s, opacity 0.15s;
}

.donut-leg-row:hover {
  background: rgba(127, 127, 127, 0.12);
}

.donut-leg-row.donut-dim {
  opacity: 0.4;
}

.donut-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.donut-leg-label {
  font-size: 0.65rem;
  flex: 1;
}

.donut-leg-bar-wrap {
  width: 40px;
  height: 3px;
  background: rgba(127, 127, 127, 0.25);
  border-radius: 2px;
  overflow: hidden;
}

.donut-leg-bar {
  height: 100%;
  border-radius: 2px;
}

.donut-leg-count {
  font-size: 0.65rem;
  font-weight: 600;
  min-width: 22px;
  text-align: right;
}

.donut-leg-pct {
  font-size: 0.65rem;
  opacity: 0.65;
  min-width: 34px;
  text-align: right;
}

.stats-inline {
  display: flex;
  justify-content: space-between;
  gap: 0.25rem;
  font-size: 0.65rem;
  opacity: 0.75;
  padding: 0.4rem 0.1rem 0;
}

.stats-inline strong {
  color: inherit;
  opacity: 1;
  font-size: 0.85rem;
  font-weight: 700;
}

.rank-section {
  background: rgba(127, 127, 127, 0.08);
  border: 1px solid rgba(127, 127, 127, 0.25);
  border-radius: 8px;
  overflow: hidden;
}

.rank-hdr {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.6rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.65;
  border-bottom: 1px solid rgba(127, 127, 127, 0.25);
  background: rgba(127, 127, 127, 0.08);
}

.rank-hdr-unit {
  margin-left: auto;
  font-size: 0.6rem;
  font-weight: 400;
  opacity: 0.7;
}

.rank-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.6rem;
  border-bottom: 1px solid rgba(127, 127, 127, 0.25);
  transition: background 0.12s;
}

.rank-row:last-child {
  border-bottom: none;
}

.rank-row.rank-clickable {
  cursor: pointer;
}

.rank-row.rank-clickable:hover {
  background: rgba(127, 127, 127, 0.12);
}

.rank-num {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(127, 127, 127, 0.25);
  font-size: 0.6rem;
  font-weight: 700;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rank-name {
  font-size: 0.65rem;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-bar-wrap {
  width: 50px;
  height: 4px;
  background: rgba(127, 127, 127, 0.25);
  border-radius: 3px;
  flex-shrink: 0;
  overflow: hidden;
}

.rank-bar {
  height: 100%;
  border-radius: 3px;
}

.rank-val {
  font-size: 0.65rem;
  font-weight: 700;
  flex-shrink: 0;
  min-width: 28px;
  text-align: right;
}

.rank-row-extra {
  display: none;
}

.rank-section.rank-expanded .rank-row-extra {
  display: flex;
}

.rank-toggle {
  display: block;
  width: 100%;
  padding: 0.35rem 0.6rem;
  border: none;
  background: transparent;
  color: inherit;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.7;
  cursor: pointer;
  text-align: center;
}

.rank-toggle:hover {
  opacity: 1;
  background: rgba(127, 127, 127, 0.12);
}

.stats-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem;
  font-size: 0.68rem;
  padding: 0.35rem 0.5rem;
  margin: 0.4rem 0;
  background: rgba(127, 127, 127, 0.1);
  border-radius: 6px;
}

.breadcrumb-item {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-weight: 600;
}

.breadcrumb-sep {
  opacity: 0.5;
}

.breadcrumb-x {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 0.7rem;
  opacity: 0.6;
  padding: 0 0.15rem;
  line-height: 1;
}

.breadcrumb-x:hover {
  opacity: 1;
}

@media (max-width: 768px) {
  #map-top-bar {
    left: 0;
    top: 70px;
    transform: none;
  }

  #map-toolbar {
    flex-direction: column;
    border-radius: 0 0 4px 0;
  }

  .theme-btn-group {
    flex-direction: column;
    gap: 0.05rem;
  }

  .toolbar-sep {
    width: 20px;
    height: 1px;
    margin: 0.1rem 0;
  }

  .zoom-wrap {
    margin: 0.2rem 0;
  }

  #zoom-slider {
    writing-mode: vertical-lr;
    direction: rtl;
    width: 20px;
    height: 80px;
  }
}
