M’Bark Boussoufa’s last-minute goal sent Morocco through as group winners and left the fate of a toothless South Africa very much in the balance