#map-controls {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#compass,
#layer-control,
#expand-control {
  position: relative;
  transition: opacity .25s ease;
}

#layers-toggle,
#expand-map-toggle {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 50%;
  background: rgba(12,16,20,0.86);
  backdrop-filter: blur(14px);
  color: rgba(255,255,255,0.88);
  cursor: pointer;
  box-shadow: 0 18px 45px rgba(0,0,0,0.35);
  transition: background .2s, border-color .2s, transform .2s, opacity .25s;
}

#layers-toggle:hover,
#expand-map-toggle:hover {
  background: rgba(20,24,28,0.94);
  border-color: rgba(255,255,255,0.24);
  transform: scale(1.04);
}

#layers-toggle.active,
#expand-map-toggle.active {
  background: rgba(38,34,24,0.96);
  border-color: rgba(207,171,55,0.45);
  box-shadow:
    0 0 0 1px rgba(207,171,55,0.15),
    0 8px 24px rgba(0,0,0,0.35);
}

#layers-toggle svg,
#expand-map-toggle svg {
  width: 20px;
  height: 20px;
}

#layers-panel {
  position: absolute;
  top: 64px;
  right: 0;
  min-width: 180px;
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  border-radius: 18px;
  background: rgba(12,16,20,.94);
  border: 1px solid rgba(255,255,255,.1);
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 50px rgba(0,0,0,.4);
  z-index: 31;
}

#layers-panel.open {
  display: flex;
}

.layer-option {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
  color: rgba(255,255,255,.88);
  font-size: 13px;
  font-weight: 600;
  transition: background .15s ease;
}

.layer-option:hover {
  background: rgba(255,255,255,.04);
}

.layer-option input {
  display: none;
}

.layer-option .toggle {
  position: relative;
  width: 34px;
  height: 20px;
  flex-shrink: 0;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  transition: .2s;
}

.layer-option .toggle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(255,255,255,.9);
  transform: translateY(-50%);
  transition: .2s;
}

.layer-option input:checked + .toggle {
  background: rgba(207,171,55,.25);
  border-color: rgba(207,171,55,.55);
}

.layer-option input:checked + .toggle::after {
  left: 16px;
  background: #cfab37;
}

#compass {
  z-index: 100;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(8, 12, 16, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(8px);
  opacity: 0.7;
  cursor: pointer;
  transition: opacity .25s ease, border-color .2s ease, background .2s ease;
}

#compass:hover {
  border-color: rgba(207,171,55,.35);
  background: rgba(8, 12, 16, 0.34);
}

#compass-needle {
  position: absolute;
  inset: 0;
  transform-origin: center center;
}

.compass-label {
  position: absolute;
  top: 9px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(217, 184, 95, 0.8);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}

.compass-arrow {
  position: absolute;
  top: 27px;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 8px;
  background: rgba(217, 184, 95, 0.8);
  border-radius: 999px;
  box-shadow: 0 0 8px rgba(217, 184, 95, 0.3);
}

.compass-arrow::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 6px solid rgba(217, 184, 95, 0.9);
}

body.is-resizing-elevation {
  cursor: ns-resize;
}

body.is-resizing-elevation canvas {
  pointer-events: none;
}

canvas {
  touch-action: none;
}

body:not(.map-ready) #compass,
body:not(.map-ready) #layer-control,
body:not(.map-ready) #expand-control {
  opacity: 0;
  pointer-events: none;
}

@media (min-width: 769px) {
  #map-controls {
    top: 18px;
    right: 18px;
    bottom: auto;
    flex-direction: row;
    align-items: center;
  }

  #expand-control {
    display: none;
  }
}

@media (max-width: 768px) {
  #map-controls {
    right: 14px;
    bottom: 18px;
    gap: 8px;
  }

  #compass {
    width: 37px;
    height: 37px;
    opacity: 0.72;
  }

  .compass-label {
    top: 6px;
    font-size: 10px;
  }

  .compass-arrow {
    top: 23px;
    width: 1.5px;
    height: 7px;
  }

  .compass-arrow::before {
    top: -6px;
    border-left-width: 4px;
    border-right-width: 4px;
  }

  #layers-toggle,
  #expand-map-toggle {
    width: 39px;
    height: 39px;
    opacity: 0.72;
    background: rgba(8, 12, 16, 0.48);
    border-color: rgba(255,255,255,0.08);
    backdrop-filter: blur(10px);
  }

  #layers-toggle svg,
  #expand-map-toggle svg {
    width: 18px;
    height: 18px;
  }

  #mini-map,
  #status {
    display: none;
  }

  #right-panel.map-expanded {
    position: fixed;
    inset: 0;
    z-index: 999;
    background: #05080c;
    height: 100dvh;
    overflow: hidden;
  }

  #right-panel.map-expanded #app {
    height: 100dvh;
  }

  #right-panel.map-expanded #mini-map,
  /* #right-panel.map-expanded #elevation-panel, */
  #right-panel.map-expanded .mobile-mountain-header {
    display: none !important;
  }

  #right-panel.map-expanded #map-controls {
    right: 18px;
    bottom: 18px;
  }
}

@media (max-width: 768px) {
  #right-panel.map-expanded #elevation-panel {
    display: none;
  }

  #right-panel.map-expanded #elevation-panel.is-open {
    display: block !important;
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 12px;

    transform: none;
    width: auto;

    margin: 0;
    z-index: 60;
  }

  #right-panel.map-expanded.elevation-open #map-controls {
    bottom: calc(var(--elevation-panel-height, 220px) + 18px);
  }

  #layers-panel {
    top: auto;
    right: 48px;
    bottom: 0;
    min-width: 170px;
  }

  .collapse-icon {
    display: none;
    }

    #expand-map-toggle.is-expanded .expand-icon {
    display: none;
    }

    #expand-map-toggle.is-expanded .collapse-icon {
    display: block;
    }
}

@media (max-width: 768px) and (orientation: landscape) {
  #map-controls {
    top: 14px;
    right: 14px;
    bottom: auto;
    flex-direction: row;
    gap: 8px;
  }

  #layers-panel {
    top: 48px;
    right: 0;
    bottom: auto;
  }
}