The US Supreme Court has ruled that states can ban transgender women from competing in female school and college sports.