A wealthy stock trader sacrificed safety for secrecy before a fire killed a man who was helping him dig a network of tunnels for a nuclear bunker beneath his Maryland home, a prosecutor said Wednesday at the start of the millionaire's murder trial.

But a defense attorney for 27-year-old Daniel Beckwitt told jurors the deadly fire that killed his client's friend was an accident, not a crime.

"Secrecy does not equate to lack of safety," Beckwitt's lawyer, Robert Bonsib, said during the trial's opening statements.

Beckwitt is charged with second-degree murder and involuntary manslaughter in the September 2017 death of 21-year-old Askia Khafra. The two men met online, and Beckwitt had invested money in a company Khafra was trying to launch as he helped Beckwitt dig the tunnels.

Firefighters found Khafra's charred, naked body in the basement when they entered the home in Bethesda, a suburb of Washington, D.C. A hole in the basement floor led them to the tunnels where Khafra worked for days at a time.

Montgomery County prosecutor Marybeth Ayres said Beckwitt created a "death trap" in his family's home, with mounds of trash blocking Khafra's escape. The hoarding conditions in the house were so extreme that trash and clutter mostly covered the floors and nearly reached the ceiling in spots, Ayres said.

"You had to hike over this garbage to get out," she told jurors.

Bonsib said Khafra was a willing participant in the project. He showed jurors a "selfie" photograph that Khafra posted on social media, showing him in the tunnels.

"He was proud of what he was doing, and he was promoting it to his friends," Bonsib said.

Prosecutors have described Beckwitt as a skilled computer hacker who had a paranoid fixation on a possible nuclear attack by North Korea. In 2016, Beckwitt spoke at a hacker convention using the alias "3AlarmLampscooter" and wearing a fire-resistant suit and visor that obscured his face. Another prosecutor, Doug Wink, has said Beckwitt was teaching his audience how to make thermite bombs to destroy computer data "in order to get away with hacking."

Beckwitt had been digging the tunnels for years and took extraordinary measures to keep his project a secret. He tried to trick Khafra into thinking they were digging the tunnels in Virginia instead of Maryland by having him don "blackout glasses" before taking him on a long drive. Beckwitt also used internet "spoofing" to make it appear they were digging in Virginia.

A hole in the concrete basement floor led to a shaft that dropped down 20 feet (6 meters) into tunnels that branched out roughly 200 feet (60 meters) in length. The tunnels had lights, an air circulation system and a heater.

Khafra slept and ate in the tunnels. He urinated and defecated into a bucket Beckwitt lowered into the tunnels. He used "wet wipes" to clean himself because he didn't have access to a shower.

"Yes, he agreed to go because he was a dreamer, he was a little bit naive and he ignored red flags," Ayres said.

Hours before the fire broke out in the basement, Khafra texted Beckwitt to warn him it smelled like smoke in the tunnels. Ayres said Beckwitt didn't respond for more than six hours before telling Khfra that there had been a "major electrical failure." Instead of getting Khafra out of the tunnels, Beckwitt told him that he "just switched it all over to another circuit," the prosecutor added.

"The theme of this case is secrecy over safety at all costs," Ayres said.

Bonsib said Beckwitt screamed for help from neighbors after the fire broke out and risked his own safety in a failed attempt to rescue his friend from the blaze. The defense attorney also noted that Beckwitt's father owned the house, and he said his client's parents had created the hoarding conditions.

"He was the functional equivalent of a tenant," Bonsib said.

Bonsib told jurors they will hear testimony from another man who had helped Beckwitt dig tunnels before Khafra. Bonsib said the witness will give a far more positive description of living conditions in the tunnels than prosecutors have provided.