SANTA CLARA, Calif. (AP)The San Francisco 49ers spent the past few weeks after clinching the NFC West chasing the No. 2 seed and an extra home game in the playoffs.

Now the 49ers (12-4) head into the regular-season finale against the Arizona Cardinals (4-12) on Sunday with a shot at earning the top seed and a coveted first-round bye.

”We’re obviously hoping for the perfect scenario,” defensive end Nick Bosa said. ”As you saw last week, there’s no easy opponent in this league. We have to win this game.”

Back-to-back losses by the Eagles have opened the door for the 49ers, who will earn the top seed with a win and another loss by Philadelphia.

San Francisco will be assured of the No. 2 seed and home field in the divisional round if the 49ers get there with either a win or a loss to Minnesota.

With the Vikings playing early Sunday, the Niners will start their game knowing the result of that game but their final fate won’t be known until after they play.

Shanahan said he doesn’t want to get updates on the Philadelphia game while the 49ers are playing, but figures he will likely see the score when he looks at the videoboard to watch replays.

”We’ll see how it plays out and we’ll see what the situation is,” Shanahan said. ”We would love to be the (No.) 1 seed, but right now we got the (No.) 2 seed and we want to make sure we at least stay the 2 seed. In order to do that, we need to win. Maybe if Minnesota lost before us, that wouldn’t be the case, but I’m counting on us having to win to get that. … To me, there’s only thing one thing that guys should be worried about and our team should be talking about and that is beating Arizona.”

The Niners will be facing a fourth-string quarterback with David Blough slated to get a second straight start ahead of Trace McSorley.

Kyler Murray and Colt McCoy are out with injuries and coach Kliff Kingsbury wants the chance to see Blough against San Francisco’s defense.

”Any time you’re in his position and you get a chance to go in real games and show what you can do, it’s huge,” Kingsbury said. ”Particularly against the best team in the NFC and the best defense in the league. It’s going to be a great challenge, but yeah, I’m excited for him to see how he handles that. It’s a tall task, that’s for sure.”

WATT’S FINALE

Defensive lineman J.J. Watt – one of the greatest defensive players in NFL history – will wrap up his stellar career Sunday.

The 12-year veteran spent his first 10 seasons with the Houston Texans and past two with the Cardinals. He was a three-time AP Defensive Player of the Year in 2012, 2014 and 2015.

Watt’s production waned in the back half of his career, mostly because of injuries. He has had a bit of a renaissance in his final season and his 10 + sacks are his most in a season since 2018.

Watt was a terrific on-field player, but also lauded for his off-field work. His community efforts were unmatched, highlighted by raising more than $40 million for Hurricane Harvey relief, which earned him the 2017 Walter Payton NFL Man of the Year Award.

PURDY GOOD

Rookie quarterback Brock Purdy is showing no signs of slowing.

Purdy has won his first four starts and has thrown at least two TD passes in five straight games for the longest streak by a Niners quarterback since 2001. Purdy’s 112.7 passer rating in his four starts since Jimmy Garoppolo went down with a broken foot leads the NFL in that span.

BIG FOOT

Matt Prater is 5 of 5 on field goals from at least 50 years over the past three weeks. He has made kicks from 50, 53, 55, 56 and 57 yards during that span.

Prater has made 71 field goals from at least 50 yards in his 16-year NFL career, which is 13 more than any other player in league history.

The two-time Pro Bowl selection is 22 of 25 on field goals this season and made all 16 of his extra points. This is his second season with the Cardinals. He also spent seven seasons with both Denver and Detroit.

WEATHER WORRIES

The Niners spent most of the week practicing in the rain as another big storm hit Northern California.

”I’m going to put plastic over my script and put a hood over my hat,” Shanahan said before the first practice of the week on Wednesday.

Shanahan said when he took over the Niners in 2017 he discussed possible options for leaving town in a storm like the team had done decades ago on occasion but it hasn’t been necessary.

”At least this is the time of year, where we’re not always going full speed, there’s no lightning so as long as you don’t mind getting wet, it’s just a distraction test,” he said. ”You never want it to rain on game day, but if you’re going to practice in it all week or if you know it’s going to rain on Sunday, you might as well practice in it.”

AP Sports Writer David Brandt contributed to this report

AP NFL: https://apnews.com/hub/nfl and https://twitter.com/AP-NFL