/* TERRITORY SELECTION PANEL */

#select-territory {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid rgba(229, 59, 82, 0.4);
  border-radius: 8px;
  background: var(--red-soft);
  color: #ff7184;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: 160ms ease;
}

#select-territory:hover,
#select-territory.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

#map.territory-select-mode {
  cursor: crosshair;
}

.territory-panel {
  position: absolute;
  z-index: 800;
  top: 84px;
  right: 20px;
  width: min(340px, calc(100vw - 32px));
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(16, 16, 18, 0.97);
  color: var(--text);
  box-shadow: 0 12px 45px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(14px);
}

.territory-panel[hidden] {
  display: none !important;
}

.territory-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.territory-panel h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.territory-panel-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.icon-button {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-hover);
  color: #c9c2c7;
  font-size: 20px;
  cursor: pointer;
}

.selection-counter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
}

.selection-counter strong {
  color: #55d6be;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.selection-actions {
  margin: 12px 0 18px;
}

.secondary-button {
  min-height: 32px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-hover);
  color: #c5c0c4;
  font-size: 10px;
  cursor: pointer;
}

.secondary-button:hover {
  background: #252326;
}

#territory-form {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

#territory-form label {
  color: #c5c0c4;
  font-size: 11px;
  font-weight: 600;
}

#minecraft-nickname {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  background: #09090a;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  transition: border-color 150ms ease;
}

#minecraft-nickname:focus {
  border-color: var(--red);
}

.primary-button {
  min-height: 40px;
  margin-top: 5px;
  border: 0;
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background 150ms ease;
}

.primary-button:hover {
  background: var(--red-hover);
}

.primary-button:disabled {
  opacity: 0.55;
  cursor: wait;
}

#territory-message {
  min-height: 16px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

#territory-message.error {
  color: #ff687b;
}

#territory-message.success {
  color: #55d6be;
}

.territory-selected {
  pointer-events: none;
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
}

@media (max-width: 600px) {
  #select-territory {
    min-height: 33px;
    padding: 0 9px;
    font-size: 10px;
  }

  .territory-panel {
    top: 74px;
    right: 10px;
    width: min(340px, calc(100vw - 20px));
    padding: 16px;
  }
}
