Superhero Shazam first appeared in comic books nearly 80 years ago. The character has weathered a long, complicated history, rife with lawsuits and name changes. The only thing that has remained the same is his bright red suit emblazoned with a huge gold lightning bolt.

“Shazam!” is the first big-budget blockbuster for the character, and the filmmakers have stayed true to its essence — combining his childlike 1940s gee-whiz enthusiasm with a postmodern sense of irreverence, creating a film that is delightfully playful and sharply self-aware.

Lovably nerdy “Chuck” star Zachary Levi packed on the muscle to play Shazam, who shares a lot of qualities with that other DC star, Superman. They both have super speed and strength, the ability to fly, a strong jaw, the same haircut and even a secret identity. But Shazam’s alter ego doesn’t have the gravitas of Clark Kent. Rather, deep within the body of this brawny superhero lie the mind and heart of a kid, 14-year-old Billy Batson (Asher Angel).

As a world-building origin story, “Shazam!” has a lot of heavy lifting to do. Written by Henry Gayden and Darren Lemke (who collaborated on TV’s “Zombie Roadkill”), the film often feels stuffed with overwrought mysticism (Djimon Hounsou in a frizzy wizard beard trapped in a cave of ghouls imbues Billy with his powers) and bogged down by melodramatic back stories for Billy and his nemesis, supervillain Thaddeus Sivana (Mark Strong).

The tragic personal histories offer plenty of motivation for the characters, but they’re somewhat shoddily written and bloat the two-plus-hour running time.

Ultimately, the myth-building distracts from what makes the film so fun: the charming dynamic between Shazam and his smart-aleck, superhero-obsessed foster brother Freddy (“It” breakout star Jack Dylan Grazer), as well as the rest of their quirky band of foster siblings.

The movie truly takes off when Levi is in the picture. His Shazam is goofy and innocent; amazed by and barely in control of his own powers. Levi’s infectious, big-kid energy makes him a great candidate for a remake of “Big.” (We’re not the only ones who think so; there’s even a reference to the 1988 Tom Hanks classic.)

But one can’t help but feel that Levi’s cheery Billy is out of step with Angel’s performance, who operates in a much darker tone, portraying Billy as a tormented, disaffected foster kid searching futilely for his family. He might be pure of heart, but it takes him a while to realize that’s what he wants.

Director David F. Sandberg’s career has been on an amazing rocket to the top. He went from helming the low-budget, high-concept 2016 horror flick “Lights Out” to 2017’s “Annabelle: Creation,” to being behind the wheel of this massive studio superhero property in only about three years.

While the movie sometimes loses its way in a cloud of CGI, Sandberg gives the film room to breathe, letting the humorous moments land, never losing sight of the characters or sense of place (Philadelphia) that offer real texture and personality. He also lets the film be exceptionally dark, violent and funny at the same time, managing to keep the tonal swings within reason.

While the story of “Shazam!” may be unwieldy at times, Levi and his kid co-stars make this new (to us) superhero just so gosh darn appealing that it’s hard to resist making room in our hearts for one more.