Douglas Costa revealed Maurizio Sarri told him just "to enjoy the game" before he came on and scored the winner that sent Juventus into the Champions League last 16.

The Bianconeri booked their spot in the knockout phase with a 2-1 win at Lokomotiv Moscow, though they needed a brilliant 93rd-minute goal from Costa to get the three points required.

Aaron Ramsey put Juventus ahead in the third minute - poking in on the line after goalkeeper Guilherme had spilled Cristiano Ronaldo's free-kick back towards his goal - but Aleksey Miranchuk soon cancelled out the Wales international's opener.

Ronaldo was frustrated in his attempts to break a Champions League record by scoring against a 34th different opponent, yet Costa was able to find a way through, weaving through some desperate tackles and slotting a finish between Guilherme's legs following a one-two with Gonzalo Higuain.

Asked by UEFA.com what Sarri had said to him before he came on with 20 minutes to go, Costa replied: "He said I just have to enjoy the game and help my team-mates to the victory. I did that."

It was Costa's first goal since January, with injury problems restricting the 29-year-old to only four Serie A starts since January.

"It was a really hard game but we played very well," added the former Shakhtar Donetsk winger.

"It is very cold here but my team-mates were amazing. We kept calm and in the end we scored the second goal.

"I played a lot of years in Ukraine. I was ready for this game.

"This was a really important game because I have been out for a long time but I have come back and helped the team."

It was far from a vintage performance by Juventus, summed up by Ronaldo failing to score from any of his eight shots - as was the case the previous time Juventus played Lokomotiv.

Yet captain Leonardo Bonucci, who cleared off his own line before Costa's winner, was pleased with the spirit his side showed.

"I think our team adapts well to the kind of football that is needed in every situation," the defender said.

"We play the football our coach loves most of the time but we are also ready to suffer together when we have to."

Lokomotiv came away empty-handed and former Juventus loanee Benedikt Howedes admitted it was a moment of magic from Costa that proved to be the difference.

"The goal was because of the individual quality that Douglas Costa has," he added.

"We deserved more today but sometimes this is the way of football. Sometimes the individual quality wins."