For 90 minutes, Switzerland and Costa Rica exchanged scoring opportunities, frisky attacks, and countless missed chances at Nizhny Novgorod Stadium in an entertaining back-and-forth match that came down to an 88th minute go-ahead goal, an overturned penalty kick decision, and a stoppage time, game-tying penalty-kick goal that only counted because the ball deflected off the crossbar and Switzerland goalkeeper Yann Sommer's head before rolling into the net.

Due to what unfolded at Spartak Stadium between Serbia and Brazil, what happened between Switzerland and Costa Rica didn't ended up mattering much.

On Wednesday, Switzerland and Costa Rica battled to a thrilling 2-2 draw that involved two goals in the final minutes. The result was enough for Switzerland to gain entrance into the knockout stages of the World Cup. Even if Switzerland had lost, though, it would've advanced past the group stage due to Brazil's 2-0 win over Serbia, which vaulted Brazil to the top of Group E and secured Switzerland's position in second above Serbia. 

Switzerland lines up to face Sweden in the Round of 16 on Tuesday. 

Switzerland entered the match tied with Brazil with four points and one point ahead of Serbia. Against a point-less Costa Rica team that had nothing to play for (except the chance to win a World Cup game), Switzerland, only needing a win or a draw to advance, held a vast majority of the possession, but failed to capitalize by creating the kind of scoring chances that Costa Rica generated with only a minor share of the ball.

Switzerland survived an early flurry with Sommer making two key saves on Joel Campbell and Celso Borges in a span of seconds to deny Costa Rica of a goal in the opening 10 minutes and the crossbar making an equally crucial save on another shot from distance. Switzerland was on the ropes early, controlling most of the possession, but looking vulnerable against Costa Rica's assault.

Switzerland survived, and then it pounced. In the 31st minute, a cross sent in from the side by Stephan Lichtsteiner was headed back into the middle of the box by Breel Embolo. The ball fell to Blerim Dzemaili, who buried the bouncing ball from in close. Switzerland -- again, only needing a tie to advance -- had a 1-0 lead over Costa Rica.

Costa Rica kept coming, but their chances never led to the final product they desired. At halftime, Switzerland led the possession battle 67-33, but Costa Rica had an advantage in shots on goal (4-1). Still, Switzerland entered the break with a 1-0 lead, primed to journey out of the group stages.

But Costa Rica would just not go away. On the other side of break, Campbell got separation in the box and fired just wide to the left. Finally, the breakthrough came in the 56th minute when Kendall Waston rose above the Switzerland defense and redirected a corner into the bottom corner. 

Tie game.

Suddenly, Switzerland found itself in a nervy situation. A tie still guaranteed them a spot in the final 16 and with Serbia trailing Brazil by a goal at the time, even a loss to Costa Rica wouldn't prevent Switzerland from going through. But it was a couple bad bounces away from losing its spot.

Speaking of bad bounces, Switzerland was denied by the post in the 78th minute.

But in the 88th minute, Josip Drmic provided Switzerland with a goal that appeared to be the game-winner, precisely slotting home a cross into the lower corner.

Madness ensued. First, Costa Rica thought it earned a penalty on the other end, but the penalty decision was overturned after a VAR review determined Costa Rica was offside. In stoppage time moments later, Campbell drew another penalty when he went down at the edge of the box. This decision wouldn't be overturned and Costa Rica buried the penalty.

And by buried I really mean drilled the ball off the crossbar so that it would bounce down and deflect off Sommer's head, which led to an own goal.

And that's how Costa Rica, who really should've put away more of its chances, earned its lone point at the 2018 World Cup. Meanwhile, Switzerland would've finished in second place even if it had hung on for a 2-1 win because Brazil beat Serbia by two goals and increased its goal-differential advantage. Switzerland didn't win, though, so it finishes the group-stage portion of the tournament with five points while Brazil racked up seven.

Switzerland won't mind. Survive and advance is the name of the game and Switzerland survived an onslaught of attacks from Costa Rica to advance to the Round of 16. Onto the next one ...

Switzerland vs. Costa Rica score, live updates

If the live blog doesn't load properly, click here.

For news, stories, results and more, follow us:

- @CBSSportsSoccer - @RGonzalezCBS - Facebook