KANSAS CITY, Mo. — There was a Polar Bear Grand Slam Plan.

This is the underappreciated aspect of the amazin’ Mets rookie. Pete Alonso has a plan for everything and works hard to achieve success.

His bases-loaded, majestic fly ball deep into the stands hugged the right-field line and foul pole in the seventh inning at Kauffman Stadium on Saturday night. The ball was ruled foul, but there was a crew chief review — and with the game tied and an Alonso error having helped the Royals to get their only run against Jacob deGrom, this was the time for atonement for the first baseman.

So while the umpires huddled along the first base line, Alonso stayed locked in on submarining left-hander Tim Hill.

Asked afterward if the blast, which would have been his 40th homer and an NL rookie record, looked fair or foul, Alonso smiled and said:

“Only God knows. I don’t know. It could have been fair, it could have been foul. Honestly, usually I have a pretty good look at it, but I had no idea.

“I left it up to the replay and they thought it was foul.’’

Noted Mickey Callaway, “He actually came over and said, ‘Was it fair? Was it fair?’ [Todd] Frazier was like: ‘Stay locked in! Stay locked in!’ It was awesome. It was the approach that Pete took that made him successful. He was trying to stay in the middle of the field.’’

The ball was ruled foul. Alonso had to get back in the box with two outs and the bases loaded. Here is where his plan came to fruition.

“I kind of put myself in a mental state that they were going to call it foul,’’ Alonso explained. “Then if they called it fair, I would have gladly taken a fake swing and jogged around the bases.’’

The count went to 2-2. A crucial mistake was made by the Royals. After the long foul, second baseman Whit Merrifield was shifted three steps toward first base.

Alonso got jammed, but got enough muscle on the swing to hit the ball back up the middle. Merrifield made a sliding stop, but it was too late. Two runs scored when his throw was cut off at the mound, the Mets went up 3-1 and came away with a 4-1 victory over the Royals, a win they had to have after losing four of five.

In the fourth inning, Alonso picked up the error on Jorge Soler’s ball to first that brought Alex Gordon in from third and gave the Royals a 1-0 lead.

“I try and make up for it,’’ Alonso said of the error. “I didn’t think it was routine because the ball was capped and when a ball that gets cued off the bat like that it is really difficult to make a play. Next time I got to do better. I should have had that one. With guys on base I felt this was a chance for redemption, and I thought I did a good job.’’

He did. He stayed on that pitch from Hill thanks in part to an old college roommate who happened to be a funky sidewinding lefty pitcher.

“His name was Kirby Snead,’’ Alonso said. “Played a lot of inter-squad against him.’’

Here is your batting tip of the day against funky pitchers: “You have to find that window — wherever it is — and I kind of picked a spot, and that spot was his knee because he is almost scraping his knuckles on the pitchers mound, so I just had my eyes focused on his knee and that is where the ball came from.’’

The two RBIs gave him 93, the most by a Met since David Wright had 93 in 2012.

In the ninth inning, Alonso doubled, his 65th extra-base hit to lead all rookies. With Fernando Tatis Jr. done for the season with a back issue, Alonso figures to be the NL Rookie of the Year.

“It sucks to get hurt,’’ Alonso said of the young Padres superstar. “I’ve been hurt before in my career. It’s unfortunate. I wish him a speedy recovery. What he has done this year is remarkable, especially for a 20-year-old guy.’’

Alonso was quick to praise other rookie candidates, but he is on the way to that award. His plan is succeeding.