.rd-map {
  --rd-map-bg: #f8fafc;
  --rd-map-border: #cbd5e1;
  --rd-map-control-bg: #ffffff;
  --rd-map-control-fg: #0f172a;
  --rd-map-tooltip-bg: #0f172a;
  --rd-map-tooltip-fg: #f8fafc;
  --rd-map-label: #0f172a;

  position: relative;
  display: block;
  width: 100%;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  background:
    radial-gradient(circle at 20% 20%, #e0f2fe 0%, transparent 45%),
    radial-gradient(circle at 80% 10%, #dbeafe 0%, transparent 40%),
    linear-gradient(160deg, #f8fafc 0%, #e2e8f0 100%);
  border: 1px solid var(--rd-map-border);
  border-radius: 16px;
  isolation: isolate;
}

.rd-map--zoomable {
  cursor: grab;
}

.rd-map--zoomable:active {
  cursor: grabbing;
}

.rd-map__svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  will-change: transform;
}

.rd-map--animated .rd-map__svg {
  transition: transform 120ms ease-out;
}

.rd-map__province {
  outline: none;
  transition: fill 140ms ease, stroke-width 140ms ease, filter 140ms ease;
  vector-effect: non-scaling-stroke;
}

.rd-map--animated .rd-map__province {
  transition:
    fill 160ms ease,
    stroke-width 160ms ease,
    filter 160ms ease,
    opacity 160ms ease;
}

.rd-map__province:focus-visible {
  stroke: var(--rd-map-focus-stroke, #f59e0b);
  stroke-width: 2;
  filter: drop-shadow(0 0 2px rgba(245, 158, 11, 0.8));
}

.rd-map__province--hovered {
  filter: brightness(1.05);
}

.rd-map__province--selected {
  stroke-width: 1.6;
  filter: drop-shadow(0 1px 2px rgba(15, 23, 42, 0.25));
}

.rd-map__province--disabled {
  pointer-events: none;
  opacity: 0.7;
}

.rd-map__label {
  fill: var(--rd-map-label);
  font-size: 9px;
  font-weight: 700;
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
  pointer-events: none;
  paint-order: stroke;
  stroke: rgba(255, 255, 255, 0.85);
  stroke-width: 2px;
}

.rd-map__marker {
  cursor: pointer;
  outline: none;
}

.rd-map__marker-icon {
  overflow: visible;
  filter: drop-shadow(0 2px 3px rgba(15, 23, 42, 0.24));
  vector-effect: non-scaling-stroke;
}

.rd-map__marker-icon * {
  vector-effect: non-scaling-stroke;
}

.rd-map__marker:focus-visible .rd-map__marker-icon {
  filter: drop-shadow(0 0 4px rgba(245, 158, 11, 0.92));
}

.rd-map__marker:focus-visible .rd-map__marker-icon * {
  stroke: #f59e0b;
  stroke-width: 2.5;
}

.rd-map__tooltip {
  position: absolute;
  z-index: 3;
  min-width: 140px;
  max-width: 220px;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  background: var(--rd-map-tooltip-bg);
  color: var(--rd-map-tooltip-fg);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.28);
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 12px));
  display: grid;
  gap: 0.15rem;
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
  font-size: 0.8rem;
  line-height: 1.25;
}

.rd-map__tooltip strong {
  font-size: 0.9rem;
}

.rd-map__tooltip span {
  opacity: 0.9;
}

.rd-map__popup {
  position: absolute;
  z-index: 5;
  min-width: 180px;
  max-width: min(280px, calc(100% - 2rem));
  padding: 0.85rem 2.25rem 0.85rem 0.9rem;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 12px;
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.24);
  transform: translate(-50%, calc(-100% - 16px));
  display: grid;
  gap: 0.45rem;
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
  font-size: 0.85rem;
  line-height: 1.3;
}

.rd-map__popup::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -0.48rem;
  width: 0.9rem;
  height: 0.9rem;
  background: #ffffff;
  border-right: 1px solid rgba(15, 23, 42, 0.12);
  border-bottom: 1px solid rgba(15, 23, 42, 0.12);
  transform: translateX(-50%) rotate(45deg);
}

.rd-map__popup-content {
  display: grid;
  gap: 0.2rem;
}

.rd-map__popup-content strong {
  font-size: 0.98rem;
}

.rd-map__popup-content span {
  color: #475569;
}

.rd-map__popup-close {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  width: 1.55rem;
  height: 1.55rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: #f1f5f9;
  color: #334155;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.rd-map__popup-close:hover {
  background: #e2e8f0;
}

.rd-map__popup-close:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.rd-map__controls {
  position: absolute;
  right: 0.75rem;
  bottom: 0.75rem;
  z-index: 4;
  display: grid;
  gap: 0.35rem;
}

.rd-map__control {
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--rd-map-border);
  border-radius: 10px;
  background: var(--rd-map-control-bg);
  color: var(--rd-map-control-fg);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
  touch-action: manipulation;
}

.rd-map__control:hover {
  background: #f1f5f9;
}

.rd-map__control:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

@media (max-width: 640px) {
  .rd-map {
    border-radius: 12px;
  }

  .rd-map__control {
    width: 2.5rem;
    height: 2.5rem;
  }

  .rd-map__tooltip {
    font-size: 0.75rem;
  }
}
