* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: #111;
}

body {
  font-family: Arial, sans-serif;
}

.page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.map-viewport {
  position: relative;
  width: min(100%, 920px);
  aspect-ratio: 1;
  overflow: hidden;
  background: #222;
  cursor: default;
  touch-action: none;
  user-select: none;
}

.map-viewport.is-panning {
  cursor: grabbing;
}

.legend {
  position: absolute;
  right: 12px;
  top: 12px;
  z-index: 5;
  display: grid;
  gap: 7px;
  min-width: 142px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  background: rgba(12, 12, 12, 0.82);
  color: #fff;
  font-size: 13px;
  line-height: 1.2;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}

.legend__item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
}

.legend__item:hover {
  color: #e8e8e8;
}

.legend__item.is-off {
  opacity: 0.38;
}

.legend__dot {
  width: 10px;
  height: 10px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.65);
  flex: 0 0 auto;
}

.legend__dot--safe {
  background: #00e676;
}

.legend__dot--fixed-vehicle {
  background: #ff1744;
}

.legend__dot--garage {
  background: #c77dff;
}

.legend__dot--secret-room {
  background: #4cc9f0;
}

.route-controls,
.circle-controls {
  position: absolute;
  left: 12px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  background: rgba(10, 10, 10, 0.76);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
}

.route-controls {
  top: 12px;
}

.circle-controls {
  top: 54px;
}

.tool-button,
.circle-phase {
  height: 30px;
  border: 0;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font: 700 12px/1 Arial, sans-serif;
  cursor: pointer;
  white-space: nowrap;
}

.tool-button {
  padding: 0 10px;
}

.circle-phase {
  appearance: none;
  width: 52px;
  padding: 0 22px 0 9px;
  border-radius: 4px;
  background-image: linear-gradient(45deg, transparent 50%, #fff 50%),
    linear-gradient(135deg, #fff 50%, transparent 50%);
  background-position:
    calc(100% - 13px) 13px,
    calc(100% - 8px) 13px;
  background-size:
    5px 5px,
    5px 5px;
  background-repeat: no-repeat;
}

.tool-button--clear {
  color: rgba(255, 255, 255, 0.82);
  font-weight: 400;
}

.tool-button:hover:not(:disabled),
.circle-phase:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.tool-button.is-active {
  background: rgba(235, 238, 240, 0.88);
  color: #151719;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.72),
    0 0 0 1px rgba(0, 0, 0, 0.5);
}

.tool-button.is-active:hover {
  background: rgba(255, 255, 255, 0.96);
  color: #111;
}

.tool-button:disabled,
.circle-phase:disabled {
  cursor: default;
  opacity: 0.36;
}

.zoom-controls {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 5;
  display: grid;
  gap: 6px;
}

.zoom-control {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  background: rgba(12, 12, 12, 0.82);
  color: #fff;
  font: 700 20px/1 Arial, sans-serif;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}

.zoom-control:hover:not(:disabled) {
  background: rgba(34, 34, 34, 0.9);
}

.zoom-control:disabled {
  cursor: default;
  opacity: 0.42;
}

.zoom-control--reset {
  font-size: 13px;
}

.minimap {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 5;
  width: 150px;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 6px;
  background: #111;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}

.minimap:active {
  cursor: grabbing;
}

.minimap__map {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.78;
}

.minimap__viewport {
  position: absolute;
  border: 2px solid #fff;
  background: rgba(255, 255, 255, 0.16);
  pointer-events: none;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.8),
    0 0 10px rgba(0, 0, 0, 0.45);
}

.map-wrap {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
  --pin-scale: 1;
}

.map {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.circle-layer,
.plane-route {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.circle-layer {
  pointer-events: auto;
}

.safe-circle {
  fill: rgba(255, 255, 255, 0.025);
  stroke: rgba(245, 248, 250, 0.54);
  stroke-width: calc(0.45px * var(--pin-scale));
  filter: drop-shadow(0 0 calc(1px * var(--pin-scale)) rgba(0, 0, 0, 0.72));
}

.safe-circle-hit {
  fill: none;
  stroke: rgba(255, 255, 255, 0.001);
  stroke-width: 18px;
  cursor: grab;
  pointer-events: visibleStroke;
  vector-effect: non-scaling-stroke;
}

.plane-route__line {
  fill: none;
  stroke: rgba(238, 242, 244, 0.42);
  stroke-width: calc(0.5px * var(--pin-scale));
  stroke-linecap: round;
  filter: drop-shadow(0 0 calc(1px * var(--pin-scale)) rgba(0, 0, 0, 0.8));
}

.plane-route__hit-line {
  fill: none;
  stroke: rgba(255, 255, 255, 0.001);
  stroke-width: 18px;
  stroke-linecap: round;
  cursor: grab;
  pointer-events: visibleStroke;
  vector-effect: non-scaling-stroke;
}

.pin {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 10px;
  height: 10px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #00e676;
  box-shadow:
    0 0 0 2px rgba(0, 0, 0, 0.65),
    0 0 10px rgba(0, 230, 118, 0.85);
  transform: translate(-50%, -50%) scale(var(--pin-scale));
  transform-origin: center;
}

.plane-route-marker {
  position: absolute;
  left: var(--x);
  top: var(--y);
  z-index: 2;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(238, 242, 244, 0.82);
  border-radius: 50%;
  background: rgba(10, 10, 10, 0.32);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.58),
    0 0 4px rgba(0, 0, 0, 0.78);
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  transform: translate(-50%, -50%) scale(var(--pin-scale));
  transform-origin: center;
  -webkit-user-drag: none;
}

.plane-route-marker::before {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
}

.plane-route-marker[data-point="end"] {
  width: 0;
  height: 0;
  border: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 14px solid rgba(238, 242, 244, 0.74);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  cursor: grab;
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.82));
  transform: translate(-50%, -50%) rotate(var(--route-angle, 0deg)) scale(var(--pin-scale));
}

.plane-route-marker[data-point="end"]::before {
  inset: -12px -16px;
}

.plane-route-marker:active {
  cursor: grabbing;
}

.pin::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(0, 230, 118, 0.65);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.pin[data-status="temporary"],
.pin[data-status="preview"] {
  background: #ff9f1c;
  box-shadow:
    0 0 0 2px rgba(0, 0, 0, 0.65),
    0 0 10px rgba(255, 159, 28, 0.9);
}

.pin[data-status="temporary"]::after,
.pin[data-status="preview"]::after {
  border-color: rgba(255, 159, 28, 0.7);
}

.pin[data-type="secret-room"] {
  background: #4cc9f0;
  border-color: #fff;
  box-shadow:
    0 0 0 2px rgba(0, 0, 0, 0.65),
    0 0 10px rgba(76, 201, 240, 0.9);
}

.pin[data-type="secret-room"]::after {
  border-color: rgba(76, 201, 240, 0.7);
}

.pin[data-type="fixed-vehicle"] {
  background: #ff1744;
  border-color: #fff;
  box-shadow:
    0 0 0 2px rgba(0, 0, 0, 0.65),
    0 0 10px rgba(255, 23, 68, 0.9);
}

.pin[data-type="fixed-vehicle"]::after {
  border-color: rgba(255, 23, 68, 0.7);
}

.pin[data-type="garage"] {
  background: #c77dff;
  border-color: #fff;
  box-shadow:
    0 0 0 2px rgba(0, 0, 0, 0.65),
    0 0 10px rgba(199, 125, 255, 0.9);
}

.pin[data-type="garage"]::after {
  border-color: rgba(199, 125, 255, 0.7);
}

@media (max-width: 520px) {
  .page {
    padding: 12px;
  }

  .legend {
    right: 8px;
    top: 8px;
    min-width: 0;
    padding: 8px 9px;
    font-size: 12px;
  }

  .legend__item {
    gap: 6px;
  }

  .route-controls,
  .circle-controls {
    left: 8px;
    max-width: calc(100% - 132px);
    overflow-x: auto;
  }

  .route-controls {
    top: 8px;
  }

  .circle-controls {
    top: 46px;
  }

  .tool-button,
  .circle-phase {
    height: 28px;
    font-size: 11px;
  }

  .tool-button {
    padding: 0 8px;
  }

  .zoom-controls {
    right: 8px;
    bottom: 8px;
  }

  .zoom-control {
    width: 36px;
    height: 36px;
  }

  .minimap {
    left: 8px;
    bottom: 8px;
    width: 96px;
  }
}
