Text this: All-loop group-theory constraints for four-point amplitudes of SU(N), SO(N), and Sp(N) gauge theories