Within less than two minutes, the first episode of HBO’s reimagined version of Perry Mason makes it very clear this show is going to be nothing like the legal procedural starring Raymond Burr that ran on CBS from 1957 to 1966 (and later as a series of TV movies from 1985 to 1993). Characters start dropping the F-word in the opening scene, and a ransom hand-off gone wrong ends with parents holding the corpse of their kidnapped baby, his eyes gruesomely sewn open. The title character (played by The Americans’ Matthew Rhys) isn’t yet a lawyer, but a cut-rate private investigator, who’s introduced tailing a movie star so he can snap salacious pictures of the guy performing oral sex with the aid of various foodstuffs.

Set in 1932, HBO’s Perry Mason turns out to be a long-winded origin story for a slightly more familiar version of the character, although creators Rolin Jones and Ron Fitzgerald make Perry far more troubled and morally complex than the righteous defense lawyer that Burr portrayed. Before the TV series, Perry was the lead character in 80-plus novels by Erle Stanley Garner, but neither the books nor the original show gave Perry much of a personal life or backstory. Jones and Fitzgerald take the opportunity to make Perry a haunted, broken man as the show begins, scraping by with meager cases and holding onto the family dairy farm where he now lives alone following a bitter divorce.

RELATED: Robert Downey Jr.'s Perry Mason Reboot Debuts First Trailer

His potential salvation comes from old friend E.B. Jonathan (John Lithgow), a slightly washed-up lawyer who’s been handed the high-profile case teased in the opening moments. Rich businessman Herman Baggerly (Robert Patrick) has put up the money for Jonathan to represent Baggerly’s illegitimate son Matthew Dodson (Nate Corddry) and Matthew’s wife Emily (Gayle Rankin), who’ve come under suspicion for the kidnapping and murder of their infant son Charlie. Jonathan hires Perry as his lead investigator, and the increasingly convoluted Dodson case takes over the entire eight-episode season.

The old Perry Mason might have been rigidly formulaic in its episodic stories, but the drawn-out single-season case is a scourge of modern TV storytelling, and the twists and turns of the Dodson case lose their thrill early on. The brief glimpses of Perry on other cases, both initially as he tracks the Fatty Arbuckle-like movie star and later as the series hints at future seasons, demonstrate the winning potential in the setting, characters and concept. However, the creators still slog through the Dodson storyline, slowly doling out clues and discoveries even after the audience is pretty clear on who the culprit is.

The Dodsons are connected to a showy revivalist church led by the charismatic Sister Alice (Orphan Black’s Tatiana Maslany), who’s a flawed, multilayered character but always seems a bit extraneous to the investigation. Sister Alice, partially inspired by real-life preacher Aimee Semple McPherson, is one example of the way Jones and Fitzgerald draw on the checkered history of 1930s Los Angeles, from the corrupt cops to the shady movie studios to the ongoing effects of the Great Depression. The golden hue gives the visuals a nostalgic tint, but the story is clear-eyed about the poverty, inequality and intolerance of the time period.

RELATED: HBO Max's Best Move Isn't the Snyder Cut... It's the Ghibli Collection

Perry himself is similarly complex, suffering from lingering PTSD after his experience in World War I and stubbornly refusing to conform to others’ expectations of him in respectable society. Rhys perfectly embodies the world-weary but ultimately upstanding detective, with his permanent stubble, his rumpled outfits and his unwavering code of personal ethics. The show is full of similarly great performances, including Juliet Rylance as Jonathan’s assistant Della Street (whom Perry Mason fans will recognize as Perry’s eventual assistant), Stephen Root as the ruthless, self-aggrandizing district attorney prosecuting the Dodson case, Shea Whigham as Perry’s salty fellow investigator Pete Strickland and Chris Chalk as another existing Perry Mason character, Paul Drake, who’s been reinvented as a black beat cop with unappreciated detective skills.

Like Perry, both Della and Drake slowly make their way into more familiar positions from the source material, and the show makes its way from the street to the courtroom, which is Perry’s natural habitat in his previous incarnations. Lithgow and Root are a delight to watch as the pair of grandstanding attorneys, bloviating for the press or the jury or just for each other. The season’s leisurely pace allows for rewarding explorations of the main characters’ personal lives, including Perry’s romance with his Latina neighbor Lupe (Veronica Falcón), who owns an adjacent airfield and is constantly offering to buy the Mason farm. Della has her own even more clandestine romance with a female "roommate," and she and Perry bond warily and then enthusiastically over their shared outsider status within the legal profession, offering plenty of potential for their professional partnership in future seasons.

At times Perry Mason gets too lost in its own self-seriousness, perhaps a holdover from when True Detective creator Nic Pizzolatto was set to be the showrunner (and Robert Downey Jr., now credited as a producer, would have been the star). The hour-long episodes could each be a few minutes shorter if they cut down on the characters’ moments of mournful staring into the middle distance, and some of the emotional heaviness doesn’t have the impact the creators seem to think it does. Perry Mason is best when it’s lively and sharp, with an appealingly grim sense of humor, just like its title character.

Starring Matthew Rhys, Juliet Rylance, John Lithgow, Chris Chalk, Shea Whigham and Tatiana Maslany, Perry Mason premieres Sunday on HBO at 9 p.m. ET/PT.

KEEP READING: How HBO's Run Sets Up a Fugitive-Filled Season 2