Mike Blake / Reuters

Over the past quarter century, the unmistakable trend in American elections is toward greater alignment between the way states vote for president and the delegations they send to Congress. After Democrats’ strong night in Tuesday’s primaries, the November midterms increasingly look like a test of which party can better defend its natural home-court advantage.

The night’s biggest headline was that the Democrats appear to have placed candidates for November in all of the California congressional districts where they feared being locked out by the state’s unusual top-two primary system. That unexpected outcome—reinforced by the party’s success at nominating its preferred candidate in each competitive seat in New Jersey—means the Democrats still have an opportunity to recapture the House this fall, primarily by winning seats in states that voted for Hillary Clinton over Donald Trump in 2016.

At the same time, Republicans are positioned to defend or expand their majority in the Senate if they can beat some of the 10 Democrats defending seats in states that voted for Trump over Clinton. The GOP has chosen strong challengers in those states that have selected nominees so far, a pattern that continued Tuesday with the victory of Montana state auditor Matt Rosendale, the favorite of party and conservative-group leaders, for the Republican Senate nomination against Democrat Jon Tester.

The question of which party can best defy the other’s home-court advantage is most urgent in the House, because the chamber has a much greater chance of switching party control than the Senate. After their apparent success in California, Democrats can come close to retaking the House majority just by sweeping away the last remaining Republicans in otherwise Democratic-leaning states.

The Cook Political Report’s nonpartisan rankings show that many of the Democrats’ top House opportunities are concentrated in blue states; among the seats that Cook rates as toss-ups or leaning toward the Democrats are five in California; three in New Jersey; two each in New York, Illinois, and Minnesota; and one each in Colorado, Virginia, and Washington. Cook rates another five seats in Pennsylvania, which Trump carried by only about 40,000 votes, as toss-ups or Democrat-leaning. Democrats also have a more long-shot chance at 10 GOP-held House seats in Clinton states that the Cook rankings rate as Republican-leaning.

For Democrats, those blue-state seats may be more promising than their comparable openings in otherwise red states (such as the suburban seats around Dallas, Houston, and Atlanta), simply because the overall local environment remains so much more hostile to Trump. “When you try to unpack what does it mean to be a swing district in a blue state versus a swing district in a red state, the extra wind is at our back in our blue states,” argues Jesse Ferguson, a longtime Democratic House strategist. “The entirety of the conversation is about how bad Republicans have become under Trump.”

California offered Republicans their best opportunity to reduce their blue-state risk. But they failed to seize the unique opening the state’s odd primary system presented them. Under that system, the top two finishers in each primary advance to the general election, regardless of party.

That created two big advantages for Republicans. One is that Republicans are usually disproportionately represented in California primaries, because younger and Latino voters, two strong Democratic constituencies, usually turn out at much lower rates compared with their numbers in general elections. Returns from the state’s large absentee-ballot vote suggested that pattern strongly continued Tuesday.

That advantage was reinforced by another: the surge of Democratic candidates whose opposition to Trump inspired them to run. In one sense, that tide measured rising Democratic energy. But, the combination of more Democratic candidates and relatively fewer Democratic voters exposed the party to a very real risk—that it could be shut out of the top two in several competitive congressional districts. The risk was especially concentrated in Orange County, a traditional Republican bastion that’s growing more competitive as it becomes more racially diverse and as the Trump-era GOP drives away more white-collar white professionals. Heading into Tuesday, Democrats feared being excluded in one, two, or even conceivably three Orange County seats.

Instead, pending the final vote counts that may stretch on for weeks, it appears likely that the Democrats weren’t shut out in any California House seats, including the three targets in Orange County. That result is a testament, in part, to the extraordinary efforts by the Democratic Congressional Campaign Committee and state party leaders to weed out second-tier candidates, rally behind one contender, and weaken targeted Republicans. But the outcome also reflected the party’s underlying growth in the five Republican-held suburban House districts around Los Angeles where Clinton beat Trump in 2016.

Overall, the California primary generated a very modest turnout: Though the final vote count will increase the total, the secretary of state reported Wednesday that only about one in five registered voters participated. But Democratic candidates on Tuesday tallied significantly more votes in each of the crucial LA-area seats than their counterparts did in 2014, the last midterm primary.

For instance: Democrats on Tuesday amassed nearly 37,000 votes in the congressional district north of Los Angeles held by Republican Steve Knight. That compares to only about 20,000 votes in 2014. The overall increase was similar in Democrat Gil Cisneros’s win in the Orange County seat that Republican Representative Ed Royce is vacating. Democrats tallied nearly 56,000 votes in the seat straddling Orange County and San Diego that Republican Darrell Issa is giving up; in 2014, they polled just below 35,000. In Mimi Walters’s Irvine-centered seat, Democrats increased their vote from about 24,000 in 2014 to nearly 44,000 last night. And in Dana Rohrabacher’s OC seat, Democrats expanded from about 30,000 votes in 2014 to nearly 49,000 Tuesday. All of these numbers will grow as the final tallies drift in.

Though Republican candidates, at this counting, still polled more primary votes than Democrats in most of these seats, their numbers generally remained static or slightly declined from 2014. None of these LA-area districts are sure things for Democrats in November, and the primary results underscored the party’s continuing challenge of mobilizing young and minority voters in midterm elections. But the big Democratic-turnout gains around Los Angeles underscore how far the party can progress toward retaking the House just by channeling the resistance to Trump in the places that have been most dubious of him from the start.

We want to hear what you think. Submit a letter to the editor or write to letters@theatlantic.com.