Democratic presidential nominee Hillary Clinton takes a picture with the traveling press group before boarding her campaign plane in White Plains, N.Y., before Election Day.

Nov. 7, 2016 Democratic presidential nominee Hillary Clinton takes a picture with the traveling press group before boarding her campaign plane in White Plains, N.Y., before Election Day. Melina Mara/The Washington Post

A look at Hillary Clinton’s final 24 hours on the campaign trail.

A look at Hillary Clinton’s final 24 hours on the campaign trail.

A look at Hillary Clinton’s final 24 hours on the campaign trail.

Hillary Clinton looked very happy as she closed her hectic final day of campaigning here in the wee hours of Tuesday to the shouts and cheers of an excited hometown band of supporters, neighbors and staff.

“I believe that she will win,” the crowd chanted as Clinton and her husband, former president Bill Clinton, shook hands on an airport tarmac in bitter cold.

Clinton did, too — as her relaxed, confident posture throughout her final day on the trail Monday had revealed. She grinned as she and President Obama clasped hands. She smiled softly as her husband slung his arm around her on the campaign plane, before the champagne was popped. She danced and clapped as Bruce Springsteen sang at one rally and Lady Gaga at another.

Yet for all the trappings of a winning campaign in view that day, atop all the polling and predictions favoring Clinton, there were signs of trouble in those final hours.

She campaigned in Pennsylvania twice on that last day, adding a morning rally in Pittsburgh to a long-planned evening showstopper in Philadelphia alongside Obama and first lady Michelle Obama.

That was a testament to the crucial importance of Pennsylvania, the biggest prize among the states in the Northeast and industrial Midwest where Republican Donald Trump had drawn closer in the polls as Election Day approached.

She ended up losing Pennsylvania and both of the other states she visited on the final day — Michigan and North Carolina. All were states where she had held seemingly durable leads two or three weeks before.

The campaign appeared confident headed into the last week, despite the shifting ground; the last day’s schedule was designed with feel-good events to juice up turnout.

Although that rally at Independence Mall in Philadelphia was originally intended to close out the evening, the campaign at the last minute added a midnight rally in Raleigh, N.C. And Clinton found herself being asked by aides to do quickie radio interviews with black radio shows such as the “Rise and Grind Morning Show” on WUSL in Philadelphia, with hosts Mina Saywhat, Mikey Dredd and Muthaknows.

At the outdoor get-out-the-vote rally in Pittsburgh on that sparkling fall afternoon, Clinton framed the election as a referendum on the future and the character of America.

Much of the contest had been about the character of Clinton and her opponent. Clinton’s attacks on Trump as unfit for the presidency, usually made by turning his own words against him, had largely supplanted regular acknowledgment of the economic and political anxieties that many Americans were feeling.

That was true on the eve of the election, too. The campaign knew that voters were turning away in disgust. But her attempt to reframe a relentlessly negative contest in optimistic terms was still, ultimately, about Trump — and it fell short.

“Our core values are being tested in this election, and I know that people are frustrated. A lot of people feel left out and left behind. There’s fear, even anger in our country,” she said.

From the back of the crowd then came a shouted protest that sounded like “Vote Trump!” Clinton kept talking.

“But I’ve gotta say, anger is not a plan, my friends.”

Next up was Grand Rapids, Mich., a majority-white city where the target audience was largely moderate women. Obama was dispatched on an emergency mission to rally young people in Ann Arbor, Mich. Clinton aides originally hoped to send Obama to Detroit to rally black voters, but they decided against it for fear of disrupting a police funeral that day.

Clinton had spent little time in Michigan until the final week, when Trump had nearly tied her there. And the rescue mission came too late. In the end, although Clinton won Detroit’s Wayne County in a landslide, she underperformed Obama there by 78,000 votes — vastly more than her statewide losing margin of roughly 11,000.

“We are already great, but we can be greater, and we will be greater,” Clinton said in Grand Rapids.

“I love our country. I believe in the American people, and I know there is nothing we cannot do when we make up our minds,” she said.

Trump was also in Grand Rapids on his final campaign day, reflecting the momentum he claimed — rightly — was swinging his way in states that had voted for Democrats for president for a generation.

“We’re hours away from a once-in-a-lifetime change,” Trump said then.

The emotional heart of Clinton’s last day was a stunning tableau of Americana laid out before Independence Hall in Philadelphia on a crisp, clear evening. A giddy crowd of 33,000 sang along as Springsteen opened with “Thunder Road.”

He also played “Long Walk Home,” an elegy for hollowed-out small-town America, the kinds of places that always used to vote Democratic.

Obama and Michelle Obama, whom the Clinton campaign considered their best weapon against Trump among women and young black voters, both delivered rousing tributes to Clinton. Bill Clinton kept his fond remarks short.

It was clearly designed as the capstone to the long campaign, a celebration meant to urge Pennsylvania voters out to the polls the next morning with a smile.

So it was somewhat jarring when the campaign added a hastily arranged midnight rally in Raleigh to the schedule.

The slapdash affair in a gymnasium at North Carolina State University was a happy occasion. Lady Gaga’s acoustic performance was luminous, Clinton shimmied on stage and the screaming crowd was ecstatic.

Trouble might have been in the air, though. Clinton badly needed black voters in North Carolina, and the crowd was overwhelmingly white. When Chelsea Clinton asked how many had already voted early, nearly everyone enthusiastically raised a hand — meaning few in the crowd were left to energize. The event itself was held too late — it was after 1 a.m. when Clinton spoke — to get much media attention.

“I just can’t wait to raise both my hands with all of you in a few hours,” Chelsea Clinton said, grinning. It had been her job during the campaign to speak before college audiences on her mother’s behalf.

“I think I’m the most excited person in my family, but my dad may be just as excited,” she said. “I am fiercely, fiercely, fiercely proud to be my mother’s daughter, and I’m also really proud to be my father’s daughter.”

Her parents beamed.

Finally, on the last flight aboard her blue and white “Stronger Together” campaign plane from Raleigh home to the small airport here near her home in Chappaqua, Clinton mingled and laughed with staffers in full view of reporters.

As reporters called out to Bill Clinton, urging him to come to the separate press cabin to talk, he jokingly cupped a hand to his ear, pretending not to hear. Hillary Clinton smiled happily and leaned into his shoulder.

They were having a lovely time, at ease in the expectation that while the election would be close, she would win.

Champagne was poured for all, to celebrate the final flight and the end of the campaign.

On the spur of the moment, Clinton, her husband and a group of staffers filmed a “mannequin challenge” video on board. The videos of people in still-life poses are an Internet sensation, and Clinton gamely joined in alongside rock singer Jon Bon Jovi, who had hitched a ride on the plane after performing in Raleigh.

“Don’t stand still. Go vote today,” the campaign video urged.

For Clinton, not enough people did.