As Latvian rescue workers searched Friday for bodies in the rubble of a supermarket collapse that killed dozens, speculation about the cause focused on a garden and a playground being installed on the grass- and gravel-covered roof.

The death toll from the Thursday evening rush-hour roof collapse at the Maxima supermarket in Latvia’s capital had risen to at least 51, including three firefighters, police said.

Police opened a criminal investigation into the cause of the tragedy at the award-winning building — once vaunted as a place where high-rise residents could step out of their homes, stroll along a shady garden and pick up a couple of items for dinner.

Riga Mayor Nils Usakovs told reporters that large bags of construction materials and soil were left on a weak spot on the roof and could have caused the collapse. It had rained for days, leading to speculation that the soil had become soaked and weighed down.

Deputy Mayor Andris Ameriks said that several reinforced steel beams fell over at once, which might indicate that engineers failed to properly calculate load pressure on the roof. He blamed budget cuts for a lack of construction controls.

An enormous crater-like hole gaped in the supermarket’s roof, while building materials were still stacked on the remaining sections.

It was the largest tragedy for the Baltic state since it regained independence from the Soviet Union in 1991. Latvia’s government declared three days of mourning starting today.

At least 35 people were injured, 28 of them hospitalized, including 10 firefighters struck just as they entered the unstable building, emergency medical officials said.

The store was filled with shoppers when an enormous section of the roof caved in. Two hours later, while rescue workers searched for survivors, a second and larger section of roof caved in, trapping and killing firefighters.

Nina Kameneva, a retiree who lives on the seventh floor of an apartment building overlooking the supermarket, said she and her husband were in the kitchen when the first collapse occurred about 4:45 p.m. on Thursday — producing a jolt so powerful it shook their building.

She said they both rushed out onto their balcony, from where they saw survivors trying to scramble out of the store through a cloud of dust.

“It felt like an earthquake,” Kameneva said. She added that “they loaded so much material on that roof over the past two weeks that I simply don’t understand.”

Maxima executive Gintars Jasinks confirmed reports Friday that fire alarms went off approximately a half-hour before the collapse, but he told reporters that no one was evacuated because there was no indication of a fire. It was not clear if there was a connection or whether construction work could have triggered the alarm.

State Police spokesman Toms Sadovskis said rescuers hoped to complete the search for survivors by this morning.

About 5,300 square feet of the roof collapsed, the rescue service estimated, destroying large sections of the store’s high walls and nearly all its front windows.

Several large construction cranes gingerly hauled metal slabs and other debris from the central hole, while bulldozers cleared paths into the store.

The Baltic News Service quoted two company executives as saying that the retailer planned to pay compensation to employees and shoppers involved in the disaster, including costs of treatment and funeral services.

Latvia’s economy underwent a steep decline, with output collapsing 23 percent over 2008-2010. Unemployment reached 25 percent and the country had to borrow billions of dollars to prevent a bankruptcy.