When it comes to this fall’s congressional elections, Pennsylvania is likely to live up to its nickname as the “Keystone State.”

Before last week, Pennsylvania was already home to several competitive, high-profile races for House seats. Now, it is becoming the anchor for the Democratic effort to win back the majority in November’s midterm elections. The state Supreme Court ruled that Pennsylvania’s map for congressional seats was an unconstitutional gerrymander, and after a deadlock between the Republican-controlled legislature and Gov. Tom Wolf (D), the court drew its own map.

The result has been to take a few good opportunities for Democrats and turn them into almost sure things, while adding a bunch of other seats to the mix. Some analysts expect Democrats to gain four seats in the state, along with a couple longer shots that could tilt their way if November is really bad for Republicans.

A four-seat pickup or greater from Pennsylvania would put Democrats well on their way to the 24 seats they need to take control of the House.

“No matter how you look at it, the ruling is a big boost to Democrats’ chances of winning a House majority,” wrote David Wasserman, the House election analyst for the independent Cook Political Report. “If Democrats pick up four seats — essentially breaking even in Pennsylvania — that’s a sixth of the 24 seats they need.”

This analysis does not even account for the tightening special election in southwestern Pennsylvania on March 13, which has turned into a largely symbolic race about political momentum rather than a seat counted toward the majority. Win or lose, Democrat Conor Lamb is not expected to run in the same congressional district in November, because his home is in another district under the new, court-drawn map.

If Lamb runs in the new district, where his home is, that will be a top-tier race in the fall because it is much more competitive than the heavily Republican seat he is fighting to win in March.

The most immediate effect from the court map, issued Monday, was chaos.

With less than four weeks to file for election, some incumbents suddenly had to choose which district they were going to run in, while others who were gearing up for tough elections saw new lines that made winning much harder.

Only one Republican, Rep. Lloyd Smucker, went from girding for a tough race to learning that his new district is virtually uncompetitive.

Republicans have asked the U.S. Supreme Court, which is already hearing a couple of gerrymandering cases in other states, to intervene. But Democrats filed their initial lawsuit to state courts via a unique challenge with which federal courts have previously chosen not to intervene.

Assuming that this map stands, it will be a remarkable end for a state historic in its gerrymandering. Pennsylvania has been considered a key swing state for decades, and Democrats have won it in five of the past six presidential elections, won it three of the past four gubernatorial elections in midterm years, and split it evenly with Republicans in the past four Senate elections.

On the eve of the 2010 midterm elections, Democrats held 12 of the state’s 19 House seats. Republicans won big that year and claimed 12 seats. Then, because they controlled the legislature and the governor’s mansion, Republicans drew up an aggressive map that made swing seats friendlier to the GOP, even as the state lost a seat because of reapportionment.

Republicans sliced and diced the Philadelphia suburbs to shore up two vulnerable party members, Reps. Ryan Costello and Patrick Meehan.

At points in Montgomery County, Meehan’s district appears to be split largely along religious lines — Catholic and Protestant sections fall in Meehan’s district, while Jewish blocks go to Rep. Brendan Boyle (D).

David Daley, author of “Ratf**ked: The True Story Behind the Secret Plan to Steal America’s Democracy,” devoted a large portion of his book on gerrymandering to the Pennsylvania map because it seemed so fortified no matter what type of election occurred higher up on the ticket.

The last three elections have had different environments in Pennsylvania — great for Democrats in 2012, good for Republicans in 2014 and pretty even in 2016 — yet each election produced the same result in terms of Pennsylvania’s delegation to the House.

“That map was engineered to produce 13 Republican and five Democratic seats no matter the Democratic vote share, and it produced the same result three consecutive times,” Daley said after the state court obliterated the old map.

Since 2011, the Philadelphia region has had three House Republicans, in the suburbs, and three Democrats, predominantly in the city. Under the new map, Democrats are likely to take five of the six seats, with a chance of winning all six.

Meehan, whose GOP-drawn district traced through five counties, has already decided not to run for reelection amid a sexual-harassment scandal. His district became very Democratic-leaning in the redraw, and Republicans do not intend to mount a large fight there.

Costello saw his district shift from being one President Trump lost by 1 percentage point in 2016 to one Trump would have lost by 9 percentage points.

He faces an unhappy choice: run an uphill fight in the new suburban district or move into a rural district where there is no incumbent Republican. That district stretches to Scranton, far from his home outside Philadelphia in Chester County. A moderate, Costello would be running to represent areas more than 120 miles from his home, with median incomes that are roughly half the nearly $90,000 median in his home county.

He might face a strong conservative challenge, either this year or in future primary races.

The only certainty about the new map, really, is the sequential numbering of the new districts. For confounding reasons, Pennsylvania used to number its districts in bizarre fashion — the 2nd District, in Philadelphia, being more than 300 miles from the 3rd District, north of Pittsburgh.

Now, the numbers will start in the east and rise heading west, in logical fashion.