THOUSAND OAKS, Calif. - It was college night at a country-music bar in the third-safest city in America. Inside, people were line dancing. Outside, a man in black clothing approached the door.

He shot the security guard with a .45-caliber handgun.

Then he went inside.

In the next few minutes, the gunman - identified by police as 28-year-old Ian David Long - killed 11 other people in the Borderline Bar & Grill, including a sheriff's sergeant who rushed in to stop him.

For many of those inside, there was a grim benefit to being young in America during an age of massacres: They knew exactly what this was, and they knew exactly what to do, in the way that past generations knew how to hide from tornadoes or nuclear bombs.

"They ran out of back doors, they broke windows, they went through windows, they hid up in the attic, they hid in the bathroom," Ventura County Sheriff Geoff Dean said. "Unfortunately, our young people, people at nightclubs, have learned that this may happen. They think about that."

Witnesses said some victims stayed, protecting friends, and in doing so sacrificed their lives.

The carnage added Thousand Oaks to the seemingly endless list of American cities that have experienced a mass shooting. The violence came just days after 11 people were gunned down in a Pittsburgh synagogue, months after 17 students and staff were massacred in a Parkland, Florida, high school, and a year after rampages at a Las Vegas country music festival and in a Sutherland Springs, Texas, church took the lives of a combined 84 people.

At least one survivor of the Las Vegas shooting was in the bar Wednesday - again trying to enjoy country music while on a night out - his second mass shooting in 13 months.

Like in Las Vegas and in Sutherland Springs, the shooter in California died of an apparent suicide before providing any explanation for the attack. At the Borderline on Wednesday, Long was found dead inside an office at the bar.

Witnesses said Long did not utter a word to explain why he had chosen this place, this night, these people, this obscene and wasteful end.

When asked by a reporter what it looked like inside the venue, Dean responded: "Like hell."

On Thursday, police identified the deceased officer as Sgt. Ron Helus, a 29-year veteran of the Ventura force. Family members identified several other victims, many of whom were in their late teens or early 20s.

Cody Coffman was 22. His father, Jason Coffman, said Thursday that he had last spoken to his son as the younger man left for the night.

"I said, don't drink and drive," Jason Coffman recalled, his voice breaking with emotion. "The last thing I said was, 'Son, I love you.' "

Police said that as many as 15 other people were injured in the attack, mostly with cuts from diving under tables. At least one suffered a nonfatal gunshot wound.

Police said they weren't sure why the gunman, who lived in nearby Newbury Park, California, was drawn to the bar.

Long grew up in the area, played high school varsity baseball, and joined the Marine Corps in 2008, the year he graduated. He served as a machine-gunner in Afghanistan from November 2010 to June 2011 and became a corporal two months later. He left the Marine Corps in 2013, and attended California State University at Northridge between 2013 and 2016 and did not graduate.

A former roommate said that Long was quiet and prone to unusual behavior - like dancing alone in his garage to "trance" music, a kind of electronic dance music.

In recent years, police said they had "several contacts" with Long, mostly for minor events including traffic accidents. In April, deputies were called to the home Long shared with his mother for a reported disturbance, Dean said. Neighbors described that incident as looking like a standoff, with police cars blocking the street and officers taking cover with rifles.

"They went to the house, they talked to him," Dean said. "He was somewhat irate, acting a little irrationally. They called out our crisis intervention team, our mental health specialist, who met with him, talked to him and cleared him."

On Wednesday evening, there were at least 100 people inside the Borderline bar - which describes itself as Ventura County's largest country dance hall and live music venue. The city of 130,000, northwest of Los Angeles, was ranked "third safest," based on FBI crime data.

Many of the patrons were drawn by the "college country night" promotion. Six off-duty police officers from other agencies were inside, Dean said. It appeared they were there as patrons, not working paid security details.

It was 11:20 p.m. Pacific time. Chris Brown's "Turn Up the Music" was blaring on the dance floor.

David Anderson, 23, of Newbury Park, had survived the mass shooting at the Route 91 Harvest country music festival in October 2017 that killed 58 in Las Vegas. After that, when he went out, he liked to keep his eyes on the door.

Looking at the door Wednesday, he saw Long enter.

"I knew exactly what it was, the moment it was," Anderson said.

"He took two to three steps in, and his stance and the way that he was aiming at everyone was very uniform and you could tell he had training," Anderson said. "And basically it was like slow motion. I watched the gun."

Anderson estimated that the gunman fired 10 to 15 times.

"It was a very stern, straight-faced, focused face," he said. "Didn't say anything."

In the bar, people dived for cover, or began to run.

"It was sheer panic," said Teylor Whittler, 19, who was inside the venue at the time. "I ran to the side. We all dog-piled on top of each other. I kept getting stomped on. Just trampled."

She said she ran to the back door, where people crowded during a pause in the gunfire. "And then, all of a sudden, a couple of guys started running to the back door and said, 'Get up, he's coming.' "

Witnesses described the shooter as standing over 6 feet tall and wearing dark clothing. Police said Long had a pistol with an extended magazine, meaning it could hold more ammunition than a standard clip.

Some hid under a pool table as the shooter emptied his gun and then paused to reload. Some threw bar stools through a window and escaped.

"At first I thought it was robbery," said Sarah Deson, 19. "A smoke bomb then went off and Cody was yelling 'everyone get down.' He then told me to run for he front door because the shooter had moved further into the bar. I ran fast - so fast - all the way across the street to a gas station. Then I heard the second round of shots."

Rochelle Hammons, 24, said she heard a volley of shots before she was able to flee.

"All of a sudden we heard four shots, you know, 'bang, bang, bang, bang.' Everyone got down on the floor. Everyone ducked and covered each other," she said. "As everyone crouched down on the floor, I figured that my only chance would be to run out to the nearest exit. I saw the nearest exit, and I ran out as fast as I could."

From inside her car, she saw a police officer arrive, she said. She rolled down her window and told him there was an active shooter inside.

"You've got to hurry, you've got to get in there," she urged him.

Nearby, Helus was in his patrol car, talking to his wife, when he got the call. He told her he loved her before hanging up and moving toward the bar.

Police said Helus arrived about 11:22 p.m. On the scene, according to radio traffic obtained by the Daily Beast, he reported finding one person down outside. He told the dispatcher he was outside an entrance with two California Highway Patrol officers.

"I'm going in," Helus said, according to the radio calls. Inside, the gunman shot Helus several times.

"He died a hero," said Dean, the sheriff, with his voice cracking, "because he went in to save lives."