Mitt Romney is poised to win Pennsylvania — if he can stay competitive in the moderate suburbs and put up large numbers in Pennsylvania’s conservative pockets. “If he runs up big margins in the central and western parts of the state, and holds his own in the Philadelphia suburbs, he can win it, even if he gets his butt beat in Philadelphia,” says former Republican senator Rick Santorum. “Even then, he’ll need a little magic.”

The last Republican to win Pennsylvania was George H. W. Bush in 1988. Ever since, Republican nominees have struggled to build a statewide coalition. They keep winning rural areas and coal country, but white-collar voters have drifted away, and the steelworkers who once heartily backed Ronald Reagan have moved toward the Democratic party. In the final hours, Romney must woo those former Republican voters back.

It won’t be easy. “Republicans have been here before,” says G. Terry Madonna, a political scientist at Franklin and Marshall College. “In 2000 and 2004, George W. Bush got to within three or four points in the last week, and ended up losing both times. They know how to get to the red zone, but they haven’t figure out how to get into the end zone.” Four years ago, John McCain lost every county in suburban Philadelphia.

Romney’s senior advisers, however, are increasingly optimistic. Pennsylvania wasn’t originally part of their electoral calculus, and only recently have they begun to spend money on television advertising in the state. But after Romney’s impressive performance in the first presidential debate, they saw their internal poll numbers rise in Pennsylvania, and eventually they decided to make a surprise play. Now they’re in a dead heat in the polls.

A Pittsburgh Tribune-Review poll released late last week shows Romney and President Barack Obama tied at 47 percent. Obama still leads by four points in the Real Clear Politics poll average, but Romney has momentum. “It’s one of those states where the president is underperforming,” says Kevin Madden, a Romney adviser. “It’s competitive, and we believe that suburban swing voters are troubled by the president’s leadership.”

Speaking on background, a top Romney official says Pennsylvania is now the must-watch state in the campaign’s Boston headquarters. “You’ve got to win either Pennsylvania or Ohio,” the official says. “If you lose Ohio and its 18 electoral votes, you’ve got to make that up somewhere else, and Pennsylvania’s 20 electoral votes are a perfect substitute. But it’s tight, and no one really knows where either state will end up.”

Winning Pennsylvania is complicated. In a way, it’s a microcosm of America. It has big, deep-blue cities, sprawling, deep-red rural counties, and highly populated suburbs. It has a pro-life Democratic senator (Bob Casey), but five times elected a pro-choice Republican (Arlen Specter) to the upper chamber. It counts a Democratic grandee (Ed Rendell) as a former governor, and Pat Toomey, the former Club for Growth president, as a senator.

The mixed political scene intrigues Romney advisers. They may have entered the Pennsylvania fray late, but the state Republican party is well organized, and outside groups, such as Americans for Prosperity, have experienced staffers on the ground and hundreds of volunteers. “The Tea Party has rallied the ranks,” says J. D. Mullane, a columnist for the Bucks County Courier Times. “Energized? They’re nuke-powered.”

But door knocking won’t be the deciding factor. For Romney to win, five key counties need to either shift toward Romney or see depressed Democratic turnout. And most important, these shifts need to happen in a synchronized fashion. For example, even if Romney does better than McCain in the suburbs, he needs turnout among Philadelphia Democrats to be average and Republican turnout in western Pennsylvania to be heavy.

To get a sense of how these counties will vote, you need to understand the sensibility of their residents. The various regions, from Bucks County in the southeast to Cambria County in the southwest, are separate and unique political cultures, and some are unpredictable. Romney advisers are keeping a close watch on all five counties as Election Day nears, and the Obama campaign, for its part, is sending Bill Clinton to a few of the areas on Monday.

Bucks County

2008 result: Obama +9

2004 result: Kerry +3

Bucks County is a tale of two suburbs. In upper Bucks, there are thousands of stucco-and-brick mansions that are home to well educated, socially liberal professionals. Many of them moved here from New Jersey or New York, and they are moderate Republicans of the Arlen Specter school, or centrist, Clinton-admiring Democrats. In lower Bucks, you have thousands of Levittown homes, built after World War II by William Levitt as a sequel to his famous New York suburb. The people here are blue-collar Democrats. Many of them had union jobs at Fairless Works, a U.S. Steel mill, until it closed, and now work in non-industrial sectors. Together, these two suburban areas and their 600,000 residents form a capricious political powerhouse.

To win Bucks, you need to win the hearts of the Reagan Democrats and the fickle soccer moms who live in the palaces on former farmland. This can be a political tightrope act, but it’s necessary to win the state, especially for Republicans running statewide. George W. Bush campaigned hard in Bucks during his 2004 run but failed to connect, and he narrowly lost Pennsylvania because of his soft support in the Philadelphia suburbs. Romney, though, has a real chance of winning Bucks County. As a reserved, Harvard-trained businessman, Romney appeals temperamentally to upper-Bucks Republicans, and his economic-focused campaign appeals to Levittown’s many out-of-work residents.

Philadelphia County

2008 result: Obama +67

2004 result: Kerry +60

Philadelphia has over 1.5 million residents and it’s the undisputed base of the state Democratic party. By winning 67 percent of the city’s vote four years ago, Obama made the rest of the state almost irrelevant. He is hoping for a boost here this year, and politicos from both parties expect him to carry the county by a similar margin. The looming question is whether Philadelphia turnout will be enough to keep Obama ahead overall.

In 2008, Obama garnered 30,000 more votes in Philadelphia than Kerry did, giving him more than half-a-million votes in a single county. That was about one-sixth of Obama’s statewide total — and his approximate margin of victory. In the rest of the state, Obama and McCain more or less tied, but McCain ended up losing by about 600,000 votes.

McCain’s effective tie in 66 of Pennsylvania’s 67 counties wasn’t enough, and Romney’s campaign knows that it has to come out well ahead in the rest of the state in order to eke out a victory once the Philadelphia returns are tallied. You can be sure that Obama adviser David Axelrod is counting on Philadelphia’s old-fashioned Democratic and public-union machine, which is managed by Representative Bob Brady, to show up.

Luzerne County

2008 result: Obama +8

2004 result: Kerry +3

Luzerne County is in the Scranton–Wilkes-Barre metropolitan area in northeastern Pennsylvania. It went for Obama four years ago, but Romney advisers think they can win here, since the county is trending Republican. Senator Toomey nearly won Luzerne County two years ago, coming within a thousand votes of victory in a county that Obama carried by eight points. According to local election officials, Democrats still outnumber Republicans in registration by a hefty margin, but Republican and independent registrations have jumped markedly since Obama’s 2008 campaign.

Luzerne has a history of flirting with Republican presidential nominees. President Bush came close to winning the county in 2004, even though two years later nearly 70 percent of its vote went to Democrat Ed Rendell in his successful run for reelection to the governor’s office. It may also be warming up to Romney’s pro-growth economic plan. According to Citizens Voice, a local newspaper, “nearly one in every three children in Scranton lived in poverty in 2011,” per the U.S. Census, and the entire region has struggled during the recession.

The Romney campaign has a bustling campaign office in Luzerne. Their goal is to repeat Toomey’s 2010 model, which means a near-constant focus on the economy with a bipartisan message. Vice President Joe Biden may have been raised here, but the Scranton area is no longer a union haven. These voters are looking for an economic alternative, and they’re unhappy with Washington. Two years ago, Republican Lou Barletta, a vocal critic of illegal immigration, won the area’s congressional seat.

Cambria County

2008 result: Obama +1

2004 result: Bush +2

Cambria County is east of Pittsburgh, and it’s the critical swing county in the state’s southwest region. Obama won here by a percentage point four years ago, and in 2004, Bush carried the county by two points. It includes Johnstown, a Democratic city that was the late John Murtha’s political base for decades, as well as Republican-leaning suburbs closer to Pittsburgh. Voters here list the economy as their top issue, but they view it through a different prism than do Bucks County voters. Cambria County is full of families who grew up with fathers who worked in coal mines and steel mills, and many of the best jobs in the county remain in the energy sector. Expect Obama to pay a price for his regulations.

“Cambria is dead even,” says G. Terry Madonna. “These are working-class, blue-collar voters who were offended by the president’s comment about Pennsylvanians’ clinging to their guns and their religion. It has a Democratic history, but it’s culturally conservative.”

Senator Toomey carried Cambria two years ago, and Republican Keith Rothfus, who narrowly lost his House race in 2010, is running strong against the county’s incumbent congressman, Democrat Mark Critz, a former Murtha staffer. Romney should also be helped by U.S. Senate candidate Tom Smith, a former coal executive from the region who is running countless TV ads about Obama’s “war on coal.”

Lancaster County

2008 result: McCain +12

2004 result: Bush +32

Eight years ago, President Bush won farm-dotted Lancaster County by a two-to-one margin. Four years later, McCain won easily, but Democrats closed the gap by 20 percentage points. Romney needs to be much closer to the Bush margin this time around. Lancaster County and neighboring York County make up the base of the Pennsylvania GOP. Running up solid totals here gives you some breathing room, especially if Philadelphia’s suburbs don’t turn completely red and the turnout in the western counties is less than expected.

Politically, Pennsylvania Dutch Country is often overlooked, but it is more populated than people think, with over 500,000 residents, and turnout here can change the entire dynamic of a Republican’s statewide effort. Back in April before the Republican primary, during a stop at a Lancaster event, Romney said, jokingly, “There are more Republicans in this room than I had in Massachusetts.” More recently, Paul Ryan has stumped in nearby Middletown, closer to Harrisburg, looking to stoke regional enthusiasm.

But Romney’s late entry into Pennsylvania makes turnout in Lancaster harder to predict. As Tom Murse, a columnist for the Intelligencer Journal, has observed, both Obama and McCain campaigned in Lancaster County, and “George W. Bush made a pair of campaign stops here” in 2004. But Romney hasn’t visited this deep-red county since the spring, so this critical GOP county has been out of the action for months. Looking to win the state, Romney must hope that local conservatives don’t mind his absence.

— Robert Costa is a political reporter for National Review.