NEW YORK — Initially, it looked like the Phillies had a chance. In the top of the eighth inning, Nick Castellanos launched an Adam Ottavino fastball 381 feet to left-center field for a three-run home run that gave the Phillies a one-run lead over the Mets Sunday night.

Johan Camargo, who was on third base, jogged home and waited for his teammate at home plate to give Castellanos a hug and a high five. And then, in the bottom of the eighth, Camargo made a diving stop at short to rob Mark Canha of a sure hit, gunning it to first base, while he was off balance, to record the out.

It looked like the Phillies were bringing their energy again — something that they have seemed to be lacking over the past few days. But then they squandered it. After a 1-2-3 inning from Seranthony Domínguez in the eighth, Corey Knebel came in for the ninth and allowed a first-pitch home run to newly called-up Nick Plummer, who had precisely one plate appearance (0-for-1) and had appeared in three major league games going into Sunday.

The Phillies went down easily in the top of the 10th inning, only getting on base via an intentional walk of Bryce Harper. And then Knebel allowed a walk-off double to Eduardo Escobar to give the Mets their 5-4 win. It was the Phillies’ second walk-off loss of the seven-game road trip that started in Atlanta.

“I mean, getting walked off twice in games we should have won, it’s always tough,” Harper said. “Losing games in any situation [is tough], but situations like that, where it’s big homer, big homer, and you lose, it’s crushing. That’s just how it is. But at the same time, we’ve got to forget about this one. Move on to tomorrow and be ready to go.

“I keep saying it, but we’ve got to be ready to go. We’ve got to play. We’ve got to keep going, we’ve got to keep grinding. We can’t be happy about losses ... we’ve got to stay as even-keeled as we can. We can’t get too high, we can’t get too low. And like I say, we play a full season for a reason. But at the same time, we’ve got to go. We’ve got to play.”

When the Phillies embarked on the road trip, it seemed to come at the perfect time. They have hit better on the road than at Citizens Bank Park this season, and were coming off a homestand in which they’d lost four of six. But then they went to Atlanta and dropped two of four to the Braves. And then they went to New York and were swept in three games by the Mets.

The Phillies are now 21-27. They are 10½ games out of first place in the NL East. Things are unlikely to get easier at home. They start a three-game set against the San Francisco Giants on Monday, and a three-game set against the Los Angeles Angels on Friday.

Their loss on Sunday night was just more of what we’ve been seeing over the past few games. They made sloppy defensive mistakes. In the bottom of the first inning, with runners on first and third, Francisco Lindor hit a ball to first base. Rhys Hoskins made a faulty throw to Camargo at second base, and Camargo threw it wide and low to catcher J.T. Realmuto at the plate. No outs were recorded on that play, and the Mets scored their first run.

» READ MORE: Kyle Gibson reminds the lifeless-looking Phils the season’s still young and they should have fun playing the game

The Phillies’ offense didn’t capitalize on the few opportunities it did have. While down 3-0 in the top of the third inning, they loaded the bases with no outs. Alec Bohm grounded into a double play that plated a run. Harper was walked, then Castellanos struck out to end the inning. It was the best shot they’d have at doing any real damage to Mets starter Chris Bassitt, and they got just one run out of it.

After a bumpy first inning when the Mets scored three runs, the Phillies got a solid performance from their starter, Zack Wheeler, and they didn’t back it up. After a lifeless seven innings, Castellanos gave them a come-from-behind lead, and they didn’t protect it. And after losing 10 of their last 14 games, they still don’t appear to have any answers as to how this happened.

“It’s extremely frustrating,” said manager Joe Girardi. “I mean, it’s what it is. Castellanos gets that huge hit on an 0-2 pitch, and then unfortunately Corey got too much of the plate and the kid hit it out. It’s tough, when you’re tied and you’ve got to try to control and ... it stinks.

“You’ve got to fight. You can see, there’s fight in there. Look at the hit that Castellanos gets. Look at the walk that Bohm gets. There’s fight. It’s just, we’ve got to stop shooting ourselves in the foot. We’ve got to stop making mistakes.”

Girardi was asked whether he was worried about his job security. He said he was not.

“I’m don’t worry about my job,” said Girardi, who is in the third and final year of his contract. “I’m never worried about my job. I don’t worry about my job. I’ve got to do my job, it’s the business of being a manager. I don’t worry about it.”

Wheeler struggles, then shines

Wheeler ran into trouble as soon as Luis Guillorme stepped up to the plate for the first at-bat of the night. The Mets’ second baseman hit a double, and they started to pile on. By the end of the first inning, Wheeler had allowed three runs and a walk, and thrown 32 pitches. Only one of of the runs was earned, due to the Hoskins throwing error.

“I didn’t look it as the defense let me down,” Wheeler said. “[The Mets] had some luck on their side, some weak hits and balls just put in the right places. And I’ve just got to get us out of that a little quicker, I pride myself on that kind of stuff. Picking my guys up and limiting the damage. I wish I would have cut that down a little quicker. Obviously we saw what happened, so I kind of beat myself up a little bit about that.”

After the first inning, Wheeler cruised. He said he didn’t change anything in his approach, but clearly something was working for him. He allowed only two walks (including one intentional walk), one hit, and one hit-by-pitch over his final five innings of work.