SANTA CLARA — Levi’s Stadium shares a parking lot with the Great America amusement park, which was closed Wednesday to accommodate the sold-out World Cup match.

The rollercoaster ride, it turned out, was inside the stadium.

The United States got a goal late in the first half against Bosnia and Herzegovina, then grabbed the handlebars for the dips and curves and rolls after a controversial red card reduced them to 10 men for the final 30-plus minutes.

They didn’t fly out, scoring again in the 82nd minute against the run of play to claim a nervy 2-0 win in the round of 32 clash and a date against Belgium on Monday in Seattle.

Great, America.

Barring some sort of reversal, they’ll do it without striker Folarin Balogun, who scored the first goal and was arguably the best player on the field until his studs-up tackle on Bosnia defender Tarik Muharemovic in the 62nd minute.

There didn’t seem to be malicious intent, a component of whether to award a red, and Brazilian referee Rafael Claus initially didn’t think the challenge warranted even a yellow card.

But the VAR crew caught it and summoned Claus to the sideline video monitor, where they saw Balogun’s right cleat slam into the calf and Achilles tendon of Muharemovic’s right leg and then badly twist his right ankle upon impact. Claus ran back on the field and reached into his right pocket for his red card.

As Balogun walked off the field at one end, the Bosnians began attacking at the other, forcing a pair of saves by goalkeeper Matt Freese in the moments after they gained a man advantage.

After another 15 minutes of relentless defending, the Yanks regained possession of the ball and drew a free kick just outside the penalty box that midfielder Malik Tillman curled over a defensive wall to the absolute roars of the 69,000 fans — most of them standing all 90 minutes — inside the home of the NFL’s San Francisco 49ers.

It is technically only the Yanks’ second knockout-stage victory in World Cup history and their first in nearly a quarter-century, although that is skewed by an expanded 48-team tournament that added a round of 32. And by an opponent that in any other year a) wouldn’t have qualified for the World Cup and b) wouldn’t have advanced out to the knockout stage after finishing third in its already diluted group.

But when you have the World Cup pedigree of the U.S., when you had lost 10 straight games in all competitions against European teams, when you had defeated only one European foe in the last 21 World Cup meetings, you don’t quibble.

You bask in the incessant chants of “U-S-A, U-S-A. You survive and advance.

It also helps that they’ve felt the pressure of knockout World Cup soccer before, about half the roster having played in the 3-1 loss against the Netherlands in the 2022 round of 16 in Qatar.

“It gives us a little bit of experience going into it, maybe a little bit of calmness,” winger Christian Pulisic said a day earlier. “Yeah, we’re ready for this moment. Having that experience last time can allow us to go into this with a little bit of a clear mind and more prepared, for sure.

“Your first time, you feel those nerves even more. It can be that much more difficult. When you’ve been there before, you say, ‘OK, I can handle this.’ I think a lot of guys feel that way.”

And they did, when Bosnia bunkered on defense and held them scoreless for most of the first half — a departure from the first three games, when they led 1-0 by the 11th minute.

But defensive fatigue is greatest at the end of each half, and a Bosnia giveaway plus three unlucky deflections resulted in a 45th-minute goal.

Tillman’s pass was not originally intended for Balogun, but it bounced off one defender, then another to the feet of Balogun. His shot hit the right boot of goalkeeper Nikola Vasilj … and caromed between his legs into the net.

Tillman’s free kick, however, went exactly where he aimed it, rising above the jumping heads in the wall and spinning into the upper left corner past the diving Vasilj to make it 2-0 and 69,000 people exhale.

Balogun and Tillman scored goals for a country they barely knew as kids and even as young adults.

Balogun was born in Brooklyn to Nigerian parents living in England. His mother, seven months pregnant, was denied boarding for the flight back to London and forced to have her son in the States, inadvertently giving him birthright citizenship. They returned a month or two later, and Balogun grew up as an English kid who aspired to play for its national team.

Tillman grew up wanting to play for Germany and did for several of its youth national teams. He was born in Germany to a German mother and American serviceman father who left the family when he was a toddler. He never lived in the States but applied for a U.S. passport and switched allegiances when, like Balogun, his national team of choice spurned him.