Jack Dylan Grazer and Zachary Levi in Shazam!

The DC Comics universe gets its best movie since Wonder Woman with Shazam!, a fun—and surprisingly dark—blast of superhero fantasy. While a little sloppy at times, the movie works thanks to its central performances and warm-hearted core.

Zachary Levi is an excellent choice to play the title character; that character is the result of a 14-year-old boy being handed super powers by a wizard (Djimon Hounsou). That boy is Billy Batson (Asher Angel), a foster child in search of his real mom. When he yells “Shazam!” a lightning bolt blasts him in his melon, and he becomes the glorious, red-suited, white-caped superhero—but he still has a 14-year-old’s brain. This gives Levi the chance to do a Tom Hanks/Big sort of shtick, and he’s good at it.

Adults in a certain age group might remember the Shazam TV show from the 1970s. Batson would actually transform into Captain Marvel—not the Marvel Captain Marvel, but the DC Captain Marvel. (There’s a convoluted, legal history behind how Brie Larson eventually wound up playing a character named Captain Marvel. We won’t go into it here.) In the TV series, Billy got his powers from an animated Zeus and his family; it was a combination of live action and cartoon on Saturday mornings with your Frosted Flakes. It was actually kind of badass, but I digress.

The new Shazam (who goes by various names, including Captain Sparkle Fingers) gets coached by his superhero-obsessed sidekick and foster brother, Freddy (Jack Dylan Grazer). Freddy winds up being one of the big reasons this movie works, despite its flaws. Grazer employs the same kind of whip-smart line delivery that made him one of the more memorable kids running away from Pennywise in It.

As for those flaws: There are abrupt tonal shifts and subpar CGI—but it’s refreshing to see DC’s take on a comedic, shiny superhero after the gloomy blunders that were Man of Steel, Batman v Superman and Justice League, and the goofy bombast of Aquaman. Shazam! has some of the joy that’s missing from the latest Superman flicks.

Director David F. Sandberg is an interesting choice to helm what is essentially a family-fun blockbuster. Watch out: Sandberg directed the creepy horror films Lights Out and Annabelle: Creation, and horror does creep into a couple of genuinely frightening scenes. Sivana (Mark Strong), the film’s villain, is accompanied by monster personifications of the seven deadly sins, and they tend to bite people’s heads off and throw them through windows—making parts of Shazam! nightmare fuel for young children. As an adult, I appreciated the chance to be scared (even if the scares did feel slightly out of place), but I imagine some parents might sit shocked as monsters bite heads off. The scary stuff is countered by a sweet family message involving Billy and his foster home. Faithe Herman steals scenes as Darla, Billy’s blissfully optimistic little foster sister who will make you laugh and break your heart. Still, the violence is just short of R-rated, so be careful.

Some poor screenplay choices take the action to all-too-familiar places, like a convenience-store robbery and an attack at an amusement park. (“Uh oh, someone’s still up there in the Ferris wheel!”) Sivana doesn’t impress much as a bad guy. He’s serviceable, but nothing extraordinary.

Shazam! doesn’t feel like a DC movie, nor does it feel like a Marvel movie, for that matter (although it does use a Ramones song for its credits, as did Spider-Man: Homecoming; this actually bugged me a little bit). Batman and Superman live in the same universe as Shazam, but those parts aren’t filled at the moment. (Ben Affleck and Henry Cavill are out.) The movie still finds ways to include the characters that are fun nods, and maybe DC will do some legit crossovers in the future. I’m thinking they have at least one more Shazam! in them.

Shazam! is playing at theaters across the valley, in a variety of formats.