GLENDALE - The San Francisco 49ers have struggled in the second half this season.
A week ago against Chicago, it was turnovers, mainly by quarterback Colin Kaepernick.
This time, penalties helped do the 49ers in and, yes, it was ugly.
Dominating early, the 49ers fell apart in the second half under a wave of penalties and undisciplined mistakes, leading to a 23-14 loss to the Arizona Cardinals on Sunday.
"We've got to do a better job - players and coaches - of not getting those penalties," 49ers coach Jim Harbaugh said.
Against the Bears, San Francisco blew a 13-point lead after Kaepernick threw two of his three interceptions in the fourth quarter and lost a fumble.
The 49ers (1-2) led Arizona 14-6 at halftime after two long scoring drives to open the game.
Once the second half started, San Francisco's offense sputtered and its defense began giving up big chunks of yards - much of it on penalties.
Arizona (3-0) scored on its first drive of the second half, moving 85 yards in seven plays for a 24-yard touchdown pass from Drew Stanton to John Brown.
The 49ers didn't have any penalties on that drive, but they had two big ones on the next one.
The first was an unnecessary-roughness call on linebacker Dan Skuta for hitting Stanton in the head while the quarterback was trying to slide. Next play, linebacker Patrick Willis was called for roughing the passer after hitting Stanton - a call the 49ers were furious about - to move the Cardinals 15 more yards closer to the end zone.
Arizona found it three plays later, when Stanton shook off the hits and Brown hooked up for another touchdown on a 24-yard pass over the middle to put the Cardinals up 20-14. "He's tough as nails," Arizona coach Bruce Arians said of Stanton.
San Francisco's offense got into the penalty act after that.
With the 49ers on Arizona's 12-yard line, Anquan Boldin was called for unnecessary roughness for head-butting an Arizona player. Three plays after that, right tackle Jonathan Martin was called for clipping, backing San Francisco up to the 34.
Making matters worse for the 49ers, Arizona's Tommy Kelly was able to get a hand up and block Phil Dawson's 45-yard field-goal attempt.
San Francisco later had a pass interference penalty to keep an Arizona drive alive and was flagged nine times for 107 yards overall. The 49ers have been outscored 52-3 in the second half this season, including 17-0 by Arizona.
"We have to come out of halftime with our mind right and stay focused, and not let penalties bother us," Skuta said. "We have to stay together."
The 49ers had hoped to take advantage of the Cardinals, who were playing with a backup quarterback for the second straight week and could potentially be distracted after backup running back Jonathan Dwyer was arrested on a domestic abuse charge earlier in the week.
San Francisco looked sharp early. With Kaepernick hurting the Cardinals with his arm and legs, the 49ers went on a pair of methodical, 80-yard scoring drives in the first half. Kaepernick capped the first one with a 2-yard touchdown pass to Michael Crabtree and Carlos Hyde scored on a 6-yard run in the second quarter.
San Francisco's defense held Stanton and the Cardinals pretty much in check during the first half, holding Arizona to a pair of field goals by Chandler Catanzaro.
Just about everything flip-flopped in the second half.
Arizona's offense started to hum behind Stanton, who played more confidently than the week before while throwing for 244 yards and two touchdowns on 18-of-33 passing.
The Cardinals' defense stiffened after some halftime adjustments, most of which centered on containing Kaepernick.
San Francisco's athletic quarterback hurt Arizona by keeping plays alive with his legs and rushing for 45 yards on nine carries. Arizona accounted for Kaepernick better in the second half, sacking him a couple of times and holding him to five yards on four carries.
Kaepernick also found little throwing room downfield in the second half, relegated to shorter to underneath throws to finish with 245 yards and a touchdown on 29-of-27 yards passing.
"I really can't say one thing," Kaepernick said of San Francisco's second-half struggles. "We just have to execute the way we should."