Relational mechanics as a gauge theory