/* Keep controls outside the plotted area so every statewide cluster is tappable. */
#territory-map {
  display: grid;
  grid-template-columns: minmax(0,1fr) 52px;
  grid-template-rows: minmax(0,1fr);
  position: relative;
  touch-action: auto;
  color: var(--ink);
  background: var(--surface);
  border-radius: inherit;
}
.map-viewport {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
}
#territory-map .map-tools {
  position: static;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-left: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  box-shadow: none;
}
#territory-map .map-tools button {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  min-height: 48px;
  padding: 0;
  flex: none;
  border: 0;
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
}
#territory-map .map-tools .icon { width: 19px; height: 19px; }
#territory-map .map-tools button:enabled:hover { background: var(--cream); }
#territory-map .map-tools button:enabled:active { background: var(--press); color: var(--surface); }
#territory-map .map-tools :focus-visible { outline: 2px solid var(--ink); outline-offset: -4px; }
#territory-map .markers { position: absolute; inset: 0; pointer-events: none; }
#territory-map .map-pin,
#territory-map .cluster {
  position: absolute;
  transform: translate(-50%,-50%);
  display: grid;
  place-items: center;
  pointer-events: auto;
  width: 48px;
  min-width: 48px;
  height: 48px;
  min-height: 48px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
  outline: none;
  font: 700 11px/1 Geist, sans-serif;
}
#territory-map .map-pin > span,
#territory-map .cluster > span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1.5px solid var(--ink);
  border-radius: 9px;
  background: var(--pin);
  color: var(--emblem-ink);
}
#territory-map .map-pin.selected > span {
  width: 38px;
  height: 38px;
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}
#territory-map .map-pin .icon { width: 19px; height: 19px; }
#territory-map .cluster > span {
  width: 44px;
  height: 34px;
  border-radius: 18px;
  color: var(--surface);
  border-color: var(--surface);
  background: var(--blue);
  font-variant-numeric: tabular-nums;
}
#territory-map .cluster:is(:hover,:active) > span { background: var(--press); }
#territory-map .markers button:focus-visible > span { outline: 2px solid var(--ink); outline-offset: 2px; }
#territory-map .map-area,
#territory-map .map-source,
#territory-map .map-scale {
  box-shadow: none;
  background: var(--surface);
  color: var(--ink);
  font-family: Geist, sans-serif;
  pointer-events: none;
}
#territory-map .map-area { position: absolute; top: 7px; left: 7px; font-size: 10px; }
#territory-map .map-foot { pointer-events: none; }
#territory-map .map-scale { border-color: var(--ink); }
#territory-map .map-choices[hidden] { display: none; }
#territory-map .map-choices {
  position: absolute;
  inset: 0;
  z-index: 3;
  overflow: auto;
  touch-action: pan-y;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  padding: 0 12px 8px;
}
.map-choices-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.map-choices-head button { display: grid; width: 48px; height: 48px; place-items: center; padding: 0; }
.map-choice {
  display: grid;
  align-content: center;
  gap: 3px;
  width: 100%;
  min-height: 48px;
  padding: 8px 0;
  text-align: left;
  border-top: 1px solid var(--line);
}
.map-choice small { font-size: 12px; color: var(--soft); }
.map-choice:focus-visible,.map-choice:hover { color: var(--ink); background: var(--cream); }
.tag, .row-icon, .emblem-preview > span {
  background: var(--color);
  color: var(--emblem-ink);
  border: 1px solid var(--ink);
}
.outcome .icon {
  padding: 2px;
  width: 22px;
  height: 22px;
  border: 1px solid var(--ink);
  border-radius: 5px;
  background: var(--color);
  color: var(--emblem-ink);
}
.outcome[aria-pressed="true"] { color: var(--ink); background: var(--yellow); outline-color: var(--ink); }
.swatch i { background: var(--color); border: 1px solid var(--ink); }
.field-workflow #territory-map {display:block;background:#dceadc}
.field-workflow .map-viewport {height:100%;width:100%;position:relative}
.field-workflow #territory-map .map-tools {position:absolute;right:7px;top:50%;transform:translateY(-50%);display:grid;gap:1px;background:white;border:1px solid #cfddd8;border-radius:9px;box-shadow:0 2px 9px #20383122}
.field-workflow #territory-map .map-tools button {border:0;color:#26485d}
.field-workflow #territory-map .map-area {color:#2a5949}
.field-workflow #territory-map .map-pin>span {border-radius:50% 50% 50% 5px;border:2px solid white;box-shadow:0 1px 4px #31434c5c}
.field-workflow #territory-map .map-pin.selected>span {outline:2px solid #1267bc;outline-offset:1px}
.field-workflow .tag {border-color:color-mix(in srgb,var(--color) 65%,#516478);border-radius:99px;background:color-mix(in srgb,var(--color) 60%,white);color:#1f3445;min-height:48px}
.field-workflow .tag .icon:last-child {width:12px;height:12px}
.field-workflow #territory-map .map-viewport {width:calc(100% - 55px)}
.field-workflow #territory-map .map-tools {right:3px}
