The Phillies needed a win Tuesday in the worst way, and for a brief moment, in the bottom of the ninth with two outs, they had a chance to get one. Bryson Stott, who had entered the game when Jean Segura left with a broken finger, roped a double down the left field line.

Batting in that spot was a tough task for Stott, who came into the game with an 0-for-13 streak. But the rookie delivered. Unfortunately for the Phillies, Nick Castellanos grounded out and the game went into extra innings.

» READ MORE: Phillies pitching coach says bullpen needs to get ahead in counts and improve its mindset

The Giants scored in the 10th on a fielding error by reliever Jeurys Familia. But the Phillies stayed alive on a two-out RBI single by Alec Bohm. In the top of the 11th, Donovan Walton hit an RBI double and Joc Pederson piled on the damage with a two-run homer off Andrew Bellatti. The Phils couldn’t come back from that and were handed a 7-4 loss at Citizens Bank Park.

It was the Phillies’ fifth loss in a row and their 12th loss in 16 games. They are now 21-29 and are 12½ games out of first place in the NL East.

“June has to be better,” manager Joe Girardi said. “These last two weeks have been really frustrating for our club. We’ve had a lot of tough losses. Last two, the way we lost extra innings … it’s been really tough. We’ve had opportunities to win, we just haven’t been able to do it.”

Scoring with RISP remains an issue

In the fourth inning, with one out and the bases loaded, J.T. Realmuto hit a potential double-play grounder to shortstop Walton. Realmuto beat the throw to first and was ruled safe. But the second-base umpire, Junior Valentine, intervened and said Rhys Hoskins was guilty of an illegal slide to try to break up the double play, which meant the inning was over and the run was taken off the board.

Girardi challenged the call, and it was overturned to give the Phillies a 1-0 lead. Of course, scoring a run in what would have been a fairly routine double play was better than scoring no runs at all. But the Phillies certainly didn’t capitalize on their opportunities to score with runners in scoring position in that inning.

“There’s been a lot of close games, and we just ended up on the other side of it,” left fielder Kyle Schwarber said. “And it’s unfortunate. Obviously, we’re not trying to go out there and not get the job done. I will tell you that the preparation is there. It’s unbelievable, the due diligence of who is on the mound, what do we have to do on defense, things like that. It’s not like we’re showing up at 6 o’clock, going out there for a 7 o’clock game.

“I think that’s what is overseen. We’ve just got to keep going. Learn about today, learn about yesterday, and let it go. And we’ve got to come for the next game and try to salvage the series tomorrow. And then we move on to the next one.”

They encountered a similar situation in the fifth inning. Johan Camargo singled and Schwarber walked to put runners on first and second with one out. But Segura struck out and Bryce Harper grounded out to end the inning. In the sixth inning, the Phillies loaded the bases with no outs and had to settle for two runs to tie the game, 3-3.

Ranger Suárez struggles with his command again

Suárez has not looked himself since May 14, when he allowed three earned runs over seven innings pitched with one walk and six strikeouts. Since then, he’s struggled to throw strikes. Tuesday night’s outing was no exception. Suárez exited the game after 4⅓ innings, having allowed five hits and three walks, with five strikeouts. He was charged with two earned runs. He threw 100 pitches over that span, and only 58 of them were strikes.

A mixed performance from the bullpen

The Phillies entered the fifth inning with a 1-0 lead — a tenuous lead, at best — but lost it after Suárez ran into trouble. Right-hander Nick Nelson relieved him with one out and runners on first and second, and proceeded to allow a walk, a double and a sacrifice fly to score three runs.

Nelson bounced back with a 1-2-3 inning in the sixth and a strikeout to start the seventh. Connor Brogdon had a good outing, allowing only one hit through one inning of work. Seranthony Domínguez came in with one out in the eighth inning and induced two pop outs, and had a 1-2-3 inning in the ninth.

From there, it got ugly. Starting the 10th with the runner on second, Familia allowed a walk, three hits and a run, which was unearned due to his error. And Bellatti came in after him, and gave up the three critical runs in the top of the 11th to seal the Giants’ win.

Castellanos heating up

With a double on Tuesday, Castellanos now has a six-game hitting streak. He’s batting .310/.333/.621 over his last seven games.

Segura leaves with fractured finger

In the seventh inning, Segura was squaring up to bunt and the pitch hit both his bat and his right hand. He was taken out of the game and Stott finished his at-bat. Girardi said an X-ray revealed that Segura has a fracture in his right index finger. He was scheduled to get a CT scan on Wednesday. The team doesn’t know who will fill in for him at second base yet; it’s possible that Didi Gregorius, who is on a rehab assignment at triple-A Lehigh Valley, could come up early.

» READ MORE: Phillies push back on criticism of organization’s hotel plan for minor leaguers