Dean Elgar helped himself to a little tipple before bed after day one at the Wanderers - something many other South Africans who have failed to stock up would have been envious of as the country navigates its third alcohol ban as part of coronavirus restrictions - but it was not necessarily to soothe his senses.

Elgar had gone in on 92 not out, just a couple of shots away from his first Test hundred in 15 months, as well as shouldering the responsibility of steering his side into a strong position after Sri Lanka had mustered just 157 in their first innings.

"I had a glass of wine and it made me sleep very well but I've been in the nineties overnight in first-class cricket before so it's not my first time," Elgar said. "I didn't feel anything; I didn't feel anxious. And I woke up nice and early as well thinking I might not wake up to my alarm. But no, I didn't feel too nervous starting today's play."

The jitters, if there had been any, had come during the course of the opening day. After racing to 39 off the first 44 balls he faced, Elgar was made to knuckle down, especially against Dasun Shanaka, who teased in the channel outside off and nipped the ball off the seam. Sri Lanka's attack improved as the first afternoon wore on and they demanded discipline from Elgar and Rassie van der Dussen. Elgar's next 53 runs took 75 balls.

"We had to absorb a little bit and there were quite a few moments when we went through the gears," he said. "You have to be able to adapt. You can't just be batting in one gear and expect to be consistent."

Elgar expected he would have to shift tempo again on day two but it took just 14 balls for him to bring up his 13th Test hundred, becoming the first South African opener to raise his bat to triple figures in 11 home Tests. With the hard work having brought reward and van der Dussen well set, South Africa seemed to be shaping up to bat once - but when Elgar was dismissed off the edge to first slip, it sparked a collapse of 9 for 84 to leave South Africa on 302, a lead of 145. Elgar called the total "quite under-par, especially after that partnership".

Elgar and van der Dussen put on 184 for the second wicket but no other South African stand contributed more than 34 runs (that too involved Elgar with his opening partner Aiden Markram). The inability for the other batsmen to kick on and South Africa's penchant for collapsing - this was the eighth time in 16 innings they have lost five wickets for less than 50 runs - is something Elgar was willing to interrogate more critically, although he wasn't sure what is holding them back.

"It's maybe the nature of the pitches we are playing on, especially now. When you come into bat you've really got to be on the ball and it shows you how important it is to have batters in. I went out and then Rassie went out which is not ideal.

"But maybe from a mental point of view we lacked a little bit, or maybe we don't trust our technique. We've got to take conditions into account. Once you are able to get through that time and respect conditions, you can conquer the conditions. Being our first series at home we have played in a long time, we will address it and take it from there. I think it's a mental thing and guys need to be made aware of it."

It's something for South Africa to analyse post-series, around the bonfire, with some tipple for those who indulge. As things stand, South Africa can sleep on a favourable match situation and with a series win in sight, and Elgar warned Sri Lanka that it is the tourists who may need to keep the nightmares at bay.

"With covers on the pitch overnight, there's a bit of moisture and it's still on top of the grass when we start the day's play and the wicket deteriorates," Elgar said. "Hopefully tomorrow morning, the wicket still has sideways movement which has caused quite a bit of trouble and there is still that moisture and deterioration."

Firdose Moonda is ESPNcricinfo's South Africa correspondent