Image copyright AP Image caption Harry Styles urged fans to boycott SeaWorld at a concert in San Diego, California

One Direction's Harry Styles sent SeaWorld's reputation plunging on social media when he urged concertgoers to boycott the chain of aquatic theme parks, research by the investment bank Credit Suisse suggests. Are young people turning en masse against the idea of animals in captivity?

"Does anybody like dolphins?", Styles shouted to fans in San Diego in July. The crowd roared: "Yes."

"Don't go to SeaWorld," the star responded.

It wasn't long before his comments - captured on their phones by hundreds of spectators, including Game of Thrones actress Maisie Williams - went viral on social media.

Very viral, according to Credit Suisse. It says there was a huge spike in online mentions of SeaWorld - which trains dolphins and killer whales to perform tricks in front of stadiums full of spectators - and a sharp increase in negative commentary.

Image copyright Credit Suisse

It wasn't just Styles. Allegations that a SeaWorld employee had acted as an undercover member of activist group Peta (People for the Ethical Treatment of Animals) also contributed to the negative commentary, according to the investment bank.

SeaWorld took rapid steps to minimise the bad publicity.

"Dear Harry, we've seen a concert clip of you urging your fans not to visit SeaWorld. We want you to know we love dolphins too. We care for the animals in our parks like we would our own family," the company wrote.

"We are committed to making sure their lives are enriching and they are continually engaged socially, mentally and physically. And, we also care for animals in the wild. We invite you to see for yourself, and then decide based on facts."

The company has taken a series of hits in recent years.

In August, SeaWorld Entertainment reported an 84% drop in earnings in the second quarter of 2015, compared to the same period in 2014, and a 2% drop in visitor numbers.

Chief executive Joel Manby blamed "the timing of Easter, record levels of rainfall in Texas and continued brand challenges in California" for the figures, although it said visitors were still flocking to SeaWorld in Florida.

A key moment for the company's fortunes came when the 2013 documentary Blackfish criticised its treatment of killer whales, or orcas, tracing the history of killer whales in captivity, up to the 2010 killing of SeaWorld trainer Dawn Brancheau by Tilikum, a five-tonne male.

Image copyright AP Image caption SeaWorld operates 11 theme parks in the US

The film also raised questions over the ethics of breeding programmes and practices such as the separation of calves from their mothers.

SeaWorld described the film as inaccurate, misleading and exploitative.

It said it had not captured a killer whale in the wild for 35 years and pointed out that according to the Association of Zoos and Aquariums, SeaWorld was "meeting or exceeding the highest standard of animal care and welfare of any zoological organisation in the world".

It also launched a SeaWorld Cares site, and has taken to releasing videos designed to reinforce how much the company cares for its animals.

But in the wake of the film's release, SeaWorld still saw ticket sales slide, some school children start petitions against class trips and musicians such as Willie Nelson and the Beach Boys cancel SeaWorld performances.

An #AskSeaWorld Twitter campaign which hoped to help rehabilitate its image in 2015 also backfired - with users asking when the park would close. SeaWorld said the Q&A was hijacked by "bots and bullies".

Image copyright Reuters Image caption Attendance at SeaWorld has declined in the wake of criticism of its treatment of whales

US advertising and public relations executive Marian Salzman isn't surprised by the continuous slide of SeaWorld's fortunes. Public opinion on animals in captivity has shifted, she says.

"We humanise all animals now. A video of bear cubs in New Jersey went viral last week. There was that big reaction to Cecil the lion. One in 12 or something Americans send their pet cards from holiday. Some even leave them voicemails," she says. "We project feelings on to animals, so we are projecting how we would feel in captivity."

Salzman is also critical of the company's advertisements, which are a turn-off for many Americans, she suggests.

"You have these teethy employees on TV talking about how they love the animals and 'nothing would happen on their watch'. There is no recognition of any captivity. It comes across as unwise, inauthentic, and feels fake-, saccharin and truly unbelievable.

"I've heard millennials say they don't like the ad - so maybe Harry Styles was part of that," she says.

Peta's senior vice-president Lisa Lange says celebrities can have a big influence on public opinion.

"Peta has worked with celebrities from day one. Someone like Harry Styles has a massive and loyal following - so he can really help move the needle. We've seen the same thing with Jane Birkin wanting Hermes to take her name off its crocodile bag after realising methods crocodile and alligator farms were using. It sends a strong message," she says.

SeaWorld has complained of being the victim of an "anti-zoo agenda" but Salzman thinks it's a cultural shift that goes beyond any organised campaign or celebrity broadside.

"I'm not sure SeaWorld's salvageable - it's that kind of business venture," she says. "We love animals and we love the wild and SeaWorld is the antithesis of wild."

Subscribe to the BBC News Magazine's email newsletter to get articles sent to your inbox.