Eighty years ago, he was more popular than Superman; his comic books outsold those of the man of steel. The hero dubbed “Captain Marvel” in 1939 looked to be invincible. But he turned out to be vulnerable to a form of kryptonite known as lawyers. Because of an excessively close resemblance to Superman, the copyright was transferred to DC Comics. Since then, the character has been in and out of the deep freeze and was renamed so as to stay on the good side of Marvel Comics’ attorneys. In the meantime, Marvel created a new Captain of its own. But deep down, the superhero today known as “Shazam” remains the same: a boy with magical powers.

“Shazam!” is the seventh film set in DC’s cinematic universe. Even though the plots of all seven pictures unfold in the same fictional world, it’s clear that “Shazam!” represents another step in the process of breaking away from the legacy of Zack Snyder. The director of “Man of Steel,” “Batman v Superman” and “Justice League” set the tone for a darker and grimmer universe than that conjured up by the competition at Marvel.

Snyder’s films all made money, but “Wonder Woman” and “Aquaman” were attempts to depart from the depressive, pessimistic vision in favor of more optimistic, colorful, even lighthearted movies. Both were commercial successes, and the Swedish director David F. Sandberg continues the same line with “Shazam!” in an effort to return the superheroes to their 1930s roots as an empowerment fantasy for children.

The veteran hero who arrives on the big screen is Billy Batson, played by Asher Angel (from “Andi Mack”), who is far from being childlike or naive. At age 14 and without parents or a home, he is a sad product of the American welfare system, having been moved from one foster family to another. The acerbic, courageous Billy refuses to accept the fact that his mother has abandoned him, and escapes from every home he’s placed in to search for her. His determination to rehabilitate his broken family leaves him unable to connect with any alternative family. Along the way, he arrives at a home run by the affable Victor and Rosa Vazquez. Having grown up in foster homes themselves, they decided to raise sweet foster children from across the spectrum.

Billy’s pattern of behavior – from foster home to escape – undergoes a change with the aid of an old, worn-out magician named Shazam (acronym of Solomon, Hercules, Atlas, Zeus, Achilles and Mercury) who wants to retire and has been looking for a worthy heir for decades. It’s not clear why, but he decides that Billy is the one and only person who can become the new Shazam and do battle against the forces of evil, which are gaining momentum. This is the first, and unexciting, part of the film, but it’s short and leaves more than enough room to deal with the next stage in the hero’s life. The shift is accompanied by a new narrative thrust that breathes life into the characters.

The origin story of a typical superhero almost always comes with a scene or two in which he gets acquainted with his new powers. What is usually only a side dish becomes the main course in “Shazam!” In contrast to other heroes, who wear a mask to hide their identity, Billy’s power makes it possible to shout the magician’s name and instantly become an adult attired in a red suit and a white cloak, played by Zachary Levi (“Chuck”).

Seen through the eyes of Billy and his new foster brother and friend Freddy, this is also the most meaningful and enjoyable part of the film. The disabled Freddy, a fan of Superman and an expert on superheroes, accompanies Billy in an entertaining process of trial and error in which they try to understand what he’s capable of doing, decide the name he should adopt and – first things first – buy beer and visit a strip club. Still, he’s a child in a man’s body.

Because they document everything and upload it to YouTube, the villain, played by Mark Strong, also hears about the new hero. Together with seven demons that represent the seven deadly sins, he is out to steal Billy’s powers. The conflict between a magical hero and demons that represent sins is drawn from religious mythologies, but “Shazam!” actually devotes less time to constructing a mythology than a typical superhero film.

A breath of fresh air

With a budget a bit short of $100 million, this is the most inexpensive production to date in the DC universe. (By comparison, “Justice League” cost around $300 million.) Sandberg, the director, successfully avoids competing with Batman and Superman for the heart of the audience, which is used to seeing cities, countries and whole worlds destroyed every summer and Christmas.

The film is set in a big city, Philadelphia, but the action includes small, modest arenas of combat. Visually, “Shazam!” is certainly less impressive than many superhero movies, particularly when it comes to special effects, but it offers in compensation something more unusual: creativity, emotion and satisfaction. In the world of Marvel and DC, heroes and villains that function within certain proportions are a breath of fresh air.

The deliberate conceptual choice of having the action and the special effects serve the story, and not the other way around, suffuses the whole film. The obvious inspiration is from “Big,” starring Tom Hanks, and includes various forms of tribute, notably to the walking piano in the earlier picture. In addition, “Shazam!” is rife with the kind of childlike enthusiasm that is disappearing from DC and Marvel movies. The secret of the charm of “Big,” which was directed by Penny Marshall 31 years ago, in which a boy fulfills a wish to become an adult, lies in the basic yearning of every child for independence, alongside anxiety at the responsibility that comes with it. Although Shazam has superpowers that recall an upgraded Superman – he flies, is immune to bullets, spits lightning – those are not his most attractive powers.

Billy’s ability to become an adult whenever he shouts “Shazam” is also his most enjoyable power. All he needs is one word and he’s no longer an underappreciated kid. He’s not a ward of any guardian, doesn’t go to sleep early and never stops consuming sugar. It’s easy to forget how helpless and deprived of freedom children are in the world of adults, and how deep their urge for independence runs – it takes priority over every superhero fantasy. Billy and Freddy naturally enjoy discovering and utilizing the rest of the former’s powers, including in school, but here, too, there is a greater purpose at work. The accelerated and imposed maturation of the abandoned Billy, and in fact of all the children under the care of the Vazquez family, forces him to part with the conservative idea of a family. At the same time, it also provides a moral for every child in a regular family: With independence comes great responsibility, as family is transformed from something that is self-evident into an act of conscious choice. For children, too.

With a redefinition of the concept of family at the heart of the plot and propelling the narrative, the result is a movie packed with action but also fraught with intimacy. With seriousness, but also with funny moments. “Shazam!” is an exception in the present world of superheroes, which move between gloomy pessimism and empowering optimism, but is almost always wrapped in abysmal seriousness. With its shift of viewpoint, “Shazam!” offers a satisfying fantasy for children, an entertaining tale for parents and also one of the most felicitous superheroes of the era.