In the darkness, down the twisting stone tunnels and through the murky water, they awaited an uncertain future. Outside, under the skies of a modern planet, cameras and bystanders and a rapt global audience of many millions looked toward the remote hills of northern Thailand, connected by cables and satellites and wireless signals and gadgets in their pockets. For two weeks and more this went on.

We have barely a hint of what the past 18 days were like for the 12 young Thai soccer players and their coach. But for the rest of us, watching from afar as an uneasy planet’s media juggernaut beamed us live shots and the unknowable was revealed drip by tantalizing drip, we knew one thing: It was hard to look away. Particularly when these two words were splattered across the world’s websites and mobile apps in impactful typefaces: “WATCH LIVE.”

Were they even alive at all in there after so many days? Probably not. And yet they were. Could we get a glimpse? There they were, captured on video, waving tentatively to what had fast become their public. Could they be pulled out, through water that rose and fell and threatened to rise again? That question, drawn out for so many days as the clock ticked menacingly, found its answer Tuesday with a resounding yes.

“We really needed something to cheer for right now. We needed some positivity. We needed a good headline that could carry the day,” says Daryl Van Tongeren, an associate professor of psychology at Hope College in Michigan who studies how humans build meaning in their lives.

“People started believing, like a snowball rolling down a hill: ‘Maybe they WILL get out,’” he said.

First, the obvious. These were children who did nothing wrong, and we love tales of innocents. Plus, it was easy to conclude for several days that they’d met their end prematurely and unfairly. When they did not — when children not unlike those in our own lives had a fighting chance at being OK — many eyes locked in on the story.

At that point, the saga was also fueled by hope, and by a possibility of a good outcome — both elements of any memorable human tale.

There are other reasons this particular story was so captivating, though. They cast light on some things about ourselves and about the strange forces — sometimes wonderful and sometimes destructive — that shape our lives in a modern media society.

___

THE STORYLINE COULDN’T HAVE BEEN MORE HOLLYWOOD.

It’s become cliche to compare the real world to showbiz (“It was like something out of a movie,” so many witnesses to disaster say). But even bearing that in mind, it would have been impossible to craft a Hollywood treatment that felt more cinematic.

For several decades in the American film industry during the 20th century, a production code made sure that the bad guys couldn’t win and that bad things couldn’t be shown. What’s less known is that the code discouraged ambiguity and subtly encouraged sharp, distinctive resolutions to plotlines — something that came to be known as the “Hollywood ending” and endures to this day.

That’s what we got Tuesday out of northern Thailand — a satisfying, all-tied-up-in-a-bow Hollywood ending, the kind that would make a reality-TV producer salivate.

“This sets the framework for what we expect from a great story,” says Roscoe Scarborough, a sociologist at Franklin & Marshall College in Pennsylvania who studies first responders and reality television.

“Any action movie follows this script. Thinking they’re dead but they’re alive. A race against time and the odds to get them out,” says Scarborough, who is also a firefighter. “It’s a cultural product that we understand. But this is a real-life version.”

___

TECHNOLOGY HELPED SAVE THEM.

Our world today is utterly consumed with technology — witness the ability to witness a lot of this event on television and mobile devices — but also increasingly uneasy with the way it affects our lives and landscapes.

So to look at such a remote area and watch a good outcome unfold because of smart uses of technology, from the pumping effort that drained water out of the cave to the carefully calibrated oxygen tanks used in extracting the kids, illuminated the ways technology can encourage our humanity rather than whittle away at it.

___

SOMEONE SACRIFICED EVERYTHING.

In any epic narrative, something precious is lost. In this case, that was 38-year-old Saman Gunan, the Thai Navy SEAL who died in the cave late last week during rescue efforts.

This happens often in rescue efforts: People who die heroically trying to help others become martyrs who are seen as the best of us. The highest-profile example in recent years: the firefighters and police officers who died helping people on Sept. 11, 2001.

It’s pretty obvious that our media-consuming world needs some news that couldn’t possibly be contentious or political. This story deftly managed that.

The enemies were diffuse — nature and the ticking clock. There was no backstory of refugees or immigration or gun control or economic disparity. There were, to most of the world watching, no politics whatsoever.

Additionally, their 2014 military coup notwithstanding, Thais are generally quiet participants in the global community for the most part.

Thus, not much to argue about.

___

IT UNFOLDED GRADUALLY, AND TIME WAS OF THE ESSENCE.

Serial narratives have been around for a while after their ascent in print form during the 1800s and as “cliffhangers” like “The Perils of Pauline” or “Flash Gordon” during cinema’s early days. Their calculus: They give you some of the story but leave you anticipating more. Serial podcasts and TV season finales carry on that tradition today.

In the case of the cave saga, a series of inflection points kept turning attention back to northern Thailand. The effect, said one observer, felt like the tiny rush you get when people, one after another, like your Facebook post or Instagram photo.

And over it all hung a ticking clock. Would the waters rise again? Would oxygen run out? Would rescuers beat the countdown?

In the end, this strange summer saga in Thailand was the kind of story that a modern, media-consuming human is literally conditioned through life to consume.

It takes its place among similar underground sagas that entranced the planet — the trapped Copiapó miners (Chile, 2010); the Quecreek mining disaster (Pennsylvania, 2002), 18-month-old Jessica McClure trapped in a well (Texas, 1987); and the first such event covered by modern media, the trapping and subsequent cave death of Floyd Collins (Kentucky, 1925), where coverage featured radio bulletins and, in the spirit of the age, a popular ballad recorded on acetate disc.

Sounds antique and distant, right? But in the end it’s the same. No matter how much the decades pass or the technology progresses, we do the same thing: We watch, we wonder, and we hope for a happy ending. And then we move on.

This time, though, in this contentious season of humanity, we can do it with a smile.

___

Ted Anthony, director of digital innovation for The Associated Press, was the AP’s director of Asia-Pacific news from 2014 until earlier this year.