Temba Bavuma's gritty 65 despite hamstring injury anchors South Africa's chase