Simply put, election night 2017 was a fantastic night for the Democratic Party.

First off, the party won convincing victories in the two marquee governors’ races. In Virginia, Lt. Gov. Ralph Northam quieted pundits by defeating GOP operative Ed Gillespie. And in New Jersey, financier Phil Murphy defeated Chris Christie’s Lt. Gov. Kim Guadagno to retake the governor’s mansion for Democrats.

But the good news for the party didn’t end there. In Virginia, Democrats also won sweeping victories down ballot, particularly in the state’s House of Delegates — including in races that weren’t even on the radar of most electoral analysts. All sorts of Democrats picked up seats there, from conventional establishment types to a democratic socialist to someone who will be the first openly transgender state legislator in the United States. The Republican brand was simply toxic.

All of this is dreadful news for the GOP and President Donald Trump. Even in normal times, it’s difficult for an incumbent president’s party to defend seats in midterm elections. These are not normal times. Virginia’s results suggest Democratic voters have grown extraordinarily energized, particularly in the suburbs. And they suggest GOP control of the House of Representatives will be in real danger in 2018.

Winner: the Democratic Party

All year, it has seemed that Democrats were in disarray. The party’s shocking 2016 defeats had reduced it to a smoking ruin. Bitter wounds from that year’s presidential primary still hadn’t healed. The party fell short in several dramatic House special elections. Its leadership appeared out of touch with its voters. People knew they were against Donald Trump, true, but what were they for?

On Tuesday, though, the Democratic brand appeared to be doing just fine.

The “establishment” top-of-the-ticket nominees who were said not to be exciting base voters — like former Goldman Sachs executive Phil Murphy in New Jersey, and the much-maligned Ralph Northam in Virginia — won their respective races.

But their down-ballot candidates in competitive districts, and even some thought not to be competitive, did extremely well too. At press time, Democrats were within striking distance of retaking the Virginia House of Delegates — a truly stunning result that electoral analysts thought was unthinkable.

These victorious Democratic challengers were diverse — Hala Ayala and Elizabeth Guzman became Virginia’s first Latina state legislators, while Danica Roem will become the entire country’s first openly transgender state legislator. They also varied ideologically — Lee Carter, a member of the Democratic Socialists of America, won an underdog victory. All of this goes to show that there’s not necessarily just one path to victory for the party.

Loser: Donald Trump and Republicans

Ed Gillespie worked hard but did not embrace me or what I stand for. Don’t forget, Republicans won 4 out of 4 House seats, and with the economy doing record numbers, we will continue to win, even bigger than before! — Donald J. Trump (@realDonaldTrump) November 8, 2017

It was always clear that 2018 would be an uphill battle for Republicans. The historical trend is unmistakable that once a president is elected, his party almost always has trouble winning off-year elections. Presidents with poor approval ratings, like Donald Trump’s, also tend to see their parties struggle.

Still, the scope of the Republican wipeout in Virginia should strike even more fear into the hearts of GOP incumbents. Control of the state’s House of Delegates was not even thought to be in play, but because of enthusiastic Democratic turnout — which it’s hard to believe wasn’t motivated by backlash against Donald Trump — it may well flip. (Several races hadn’t been called at press time and may head to recounts.)

The GOP came into the night with an enormous 66-34 majority in the statehouse. Many of their incumbents had been around for years and had grown complacent, never expecting a serious challenge.

The same is true in the US House of Representatives. Nearly two-thirds of Republican House members were first elected in 2010, and most have never even run for Congress in a world without Barack Obama in the White House. Now the world has changed. More Republican incumbents are seeing a tough challenge ahead, and many are announcing that they’ll retire to avoid it.

As for Trump himself, the Virginia debacle should be a major warning that he needs to change his political approach — or Democrats could very well retake the House, which would be a disaster for his presidency. Yet he has already become so toxically unpopular to so many voters that it could be too late.

Winner: Ralph Northam, Loser: pundits’ guts

The last 3 weeks of the VA governor's race has been all bad for Dems. https://t.co/7VpSw1nbW7 — Chris Cillizza (@CillizzaCNN) November 7, 2017

No Democratic candidate was second-guessed in recent weeks more than Ralph Northam. His campaign was called uninspiring. He was deemed to have no charisma. Liberals excoriated him for hedging in response to Ed Gillespie’s anti-immigrant attacks. Pundits assumed that, like Hillary Clinton, he was about to blow it.

But Northam didn’t just win — he romped. At press time, he led Gillespie by more than 8 points, and some analysts estimated his lead would likely grow further as more votes were counted. It was already clear, though, that he’d outperformed Clinton’s 5-point win in Virginia in 2016 and what polling averages were showing for this race. Turns out the Army doctor wasn’t such a weak and incompetent candidate after all.

Loser: Ed Gillespie’s demagogic campaign

Ed Gillespie was a longtime Republican and lobbyist who hoped to begin a political career in his own right. In 2014, he ran an under-the-radar campaign for US Senate in Virginia, and came shockingly close to upsetting incumbent Mark Warner (he was less than a point away from winning). So in 2016, he started putting things into motion for a run for governor the following year, and the GOP establishment enthusiastically backed him.

Then he found himself in a world where Donald Trump was the president of the United States.

What’s more, the party coalitions were changing — working-class white voters were increasingly drawn to the party by Trump, while educated suburban voters who demographically resembled Ed Gillespie were deserting the party.

So Gillespie made a bet. He thought that he could mobilize Trump voters through an ad campaign emphasizing hot-button culture war issues, but also keep the educated suburbanites on his side with his establishment credentials and an economic pitch.

To many political analysts, it seemed like a promising strategy. But it proved enormously controversial, as Gillespie was heavily criticized for ads stoking fears of criminal immigrant gangs and “sanctuary cities” (which Virginia doesn’t even have).

And in the end, it appears to have backfired spectacularly. Educated suburban voters abandoned Gillespie in droves and overwhelmingly backed Democrats. It’s not clear how much of that was due to a general anti-Trump backlash or Northam’s strength, and how much was due to disgust with Gillespie’s demagogic tactics.

But if Gillespie won, his victory would have sent a message that the Trumpist playbook was the most effective path to Republican victory across the nation. His defeat makes clear that’s not necessarily the case.

Winner: lower-income people in Maine (and maybe Virginia) who soon could be eligible for Medicaid

Obamacare appeared to be on the ropes at the beginning of the year, and most of the Republican bills to repeal it wiped out its expansion of Medicaid. But the GOP efforts to repeal the program derailed, meaning it’s still possible for more states to opt in to the expansion (which the Supreme Court made optional).

Up in Maine, the state legislature has been trying to opt in to the expansion for some time — but five separate efforts to do so have been vetoed by the state’s conservative governor, Paul LePage.

Finally, proponents of the idea decided to go over LePage’s head and take the question directly to voters. On Tuesday, they won overwhelmingly.

That’s not the end of the story — as Sarah Kliff writes, there are ways LePage could still throw a wrench into the process. But the vote is an unmistakable win for Medicaid expansion and indeed Obamacare itself. If implemented, estimates indicate this will result in 80,000 more Maine residents getting health insurance — and other states may look to copy Maine’s playbook.