Contrastive Representation Learning for Robust Sim-to-Real Transfer of Adaptive Humanoid Locomotion