Bad coverage. Poor defensive gaps. Another awful first period.

That pretty much describes how the Flyers played for the first half of Monday’s wildly entertaining game at the reverberating Wells Fargo Center.

At the time, little did anyone believe they could overcome a 5-2 deficit against the mighty Boston Bruins.

But they regrouped, scored three unanswered goals to force a 5-5 tie, and won it in a tense, electric shootout, 6-5.

Travis Konecny scored the lone goal in the five-round shootout, which ended when Boston’s Brad Marchand overskated the puck after gently touching it but leaving it at center ice.

“That’s pretty funny that happened to him,” said goalie Carter Hart, who made a combined 11 saves in the third period and overtime — and four more in the shootout — to help orchestrate the win. “It’s happened twice now to me in the short amount of shootouts I’ve been in. Him and [John] Tavares last year.”

The ending “was pretty lucky, but for us to battle back like that, we deserved the win,” Hart said,

The comeback for the ages pushed the Flyers back into a wild-card playoff spot in the Eastern Conference.

In shootouts, the Flyers are 5-5, while Boston is 0-7.

Ivan Provorov, on his 23rd birthday, was robbed by Jaroslav Halak with one second left in overtime, setting up the shootout and Konecny’s dramatics.

“It’s a big positive for us,” Konecny said. “We went through a little stretch where we were struggling, so to come back against a team like this, it puts us right up there. We know we can compete against these teams.”

After a 1-4-1 road trip, the Flyers are 2-1 against NHL powers Washington, Tampa Bay, and Boston in the last three games.

Defenseman Travis Sanheim scored his second goal of the night, depositing a rebound with 7:02 left in regulation and knotting the score at 5-all.

Boston got two goals from David Krejci and had its three-game winning streak snapped. The Bruins have points in 13 of their last 14 games.

“If we’re not ready to play, they’re going to take it to us,” Flyers captain Claude Giroux said after Monday’s morning skate.

Giroux was inferring that the Flyers needed to set the tone against a Bruins team that entered the night tied for the most points in the NHL.

But despite Giroux’s plea, the Flyers came out flat. Again. They continued a recent trend: falling behind early and chasing the game.

They fell into a 2-0 first-period hole before Kevin Hayes answered with a power-play goal late in the period.

In the last nine games, the Flyers have been outscored in the first period, 18-8, which is not a recipe for success in the Scotty Bowman Handbook.

Kevin Hayes, converting a slick feed from Konecny, scored on a one-timer from deep inside the right circle while the Flyers were on a power play, slicing the Bruins’ lead to 2-1 with 1:38 to go in the first.

The Flyers’ defense has been pristine at the Wells Fargo Center this season — allowing a league-low 1.90 goals per home game — but they continued to have breakdowns in the second period as the Bruins built a 5-2 lead.

Thirty-three seconds into the second, David Pastrnak, after a bad pinch by Provorov, took a feed from Brad Marchand and made it 3-1 by scoring his league-best 36th goal.

Sanheim, aided by Michael Raffl’s screen, answered 39 seconds later to cut the lead to 3-2, but Boston then scored two goals in a 2:31 span to make it 5-2.

The Flyers, who spent the first two periods allowing odd-man rushes at an alarming rate, fell into a 4-2 hole as Charlie Coyle got behind Robert Hagg and beat Hart from close range.

An all-alone Krejci continued the assault, converting a Nic Aube-Kubel turnover to score from out front with 15:39 remaining in the second, giving the B’s a 5-2 cushion.

The Flyers, however, got two bizarre goals late in the second period to get within 5-4.

As he drove to the net against Halak, Sean Couturier (three points) lost control of the puck, but it trickled through the goalie’s legs to cut the deficit to 5-3 with 6:48 left in the second.

Connor Bunnaman’s first NHL goal made it 5-4 with 5:14 remaining in the session. Mark Friedman’s point shot deflected off Bunnaman and off Boston defender Matt Grzelcyk and past Halak. (It was Friedman’s first career point.)

“It’s not exactly how I imagined it, but I’ll take it,” said Bunnaman, who was recalled from the Phantoms on Sunday. “I’ve been dreaming of this, so it felt good.”

There were six goals — three by each team — in the wild second period, setting the stage for an intriguing finish.

In the second half of the game, “we started to be hard on the forecheck ... and with more zone time, you get more chances,” Sanheim said after the fourth two-goal game of his career. “And once you get one (goal), you get some momentum and kind of roll with it.”