Midway through the first episode of The Deuce, premiering on HBO Sunday night, Candy (Maggie Gyllenhaal), a veteran sex worker, explains to a nervous teenage client whose encounter with her has ended prematurely why he can’t try again without paying for it. “It doesn’t seem fair,” the boy complains, evolving from shy nervousness to nasty petulance in a blink. Candy asks what his father does, and when the teenager replies that he owns a car dealership, she issues a free lesson in the principles of work. If his father sells a car, she explains, “he doesn’t give the easy customer two cars for the price of one, right? This is my job, Stewart.”

It’s a scene that’s characteristic of David Simon. Candy, distilling the tenets of capitalism from micro to macroeconomics, could be Stringer Bell lecturing street dealers on supply and demand. And The Deuce, like The Wire, is about infinitely more than the industry it’s profiling—in this case, sex in 1970s Times Square rather than drugs in early-aughts Baltimore. There are familiar faces, too (the kick from seeing Cheese and Chris Partlow in bell-bottoms would be worth the HBO subscription alone). But it’s in the scope of its story and the complexity of its characters that The Deuce (created by Simon and George Pelecanos) comes the closest to Simon’s earlier masterpiece. It’s about the sex trade, but also about the weirdness of human sexuality; there are Mafiosi gangsters, and corrupt cops, and selfish journalists, and new pornographers. The playing field is different but the game—and the rules—are the same.

That’s not to say it’s perfect. The eight episodes that make up the first season are clear preamble for the main story to be told later, a maddening hallmark of streaming shows that appears to be catching on with episodic TV. The fact that James Franco plays not one primary character but two—twin brothers Vincent and Frankie Martino—feels intended to make some kind of point about duality and nature/nurture that’s presumably being saved for a subsequent season. Visually, though, the show is richer than anything Simon’s done before, thanks in large part to Michelle MacLaren, the Breaking Bad and Game of Thrones alumna who directed the first and last episode. Painstakingly, with everything from typography to body hair, the show recreates 1971 Midtown Manhattan in all its seamy, squalid disorder.

The 90-minute pilot, made available to stream in August, is maybe the series’s finest episode, setting up the manifold characters and their various arcs with a structure that loosens considerably later on. In the first scene, a drunken man in a bar cajoles the woman he’s sitting with to “give me something I can’t get at home”—an early explanation for the thriving prostitution industry in the stretch of 42nd Street known as “the Deuce.” Vincent (James Franco), the bartender, works double shifts in bars on both sides of the river to support his feckless wife (Zoe Kazan) and their two children. He’s further beleaguered by his twin brother Frankie (also Franco), a profligate gambler who’s distinguishable from Vincent only in his gum chewing and his radiant, jittery douchebag energy.

Thanks to his night job in a Korean restaurant near Times Square, Vincent is well acquainted with the pimps, panderers, and professionals who work nearby: C.C. (Gary Carr), a genial smooth-talker; Larry (Gbenga Akinnagbe), a surlier but more conflicted individual; Rodney (Method Man/Clifford Smith); Reggie Love (Tariq “Black Thought” Trotter); and Gentle Richie (Matthew James Ballinger), the lone white guy, a hippie prone to spouting aphorisms about capitalism. The men engage in banter about politics and business (Nixon, Rodney and Larry agree in one scene, is a pimp himself), and they physically and emotionally abuse their stables of women, from the budding reader Darlene (Show Me a Hero’s Dominique Fishback) to the deceptively savvy newcomer Lori (Emily Meade).

Just as The Wire manipulated prurient curiosity about drug dealers in decaying Baltimore communities to slyly make points about social inequity and injustice, The Deuce relies on a titillating subject—sex for sale—to hook viewers. But the sex on display is anything but arousing. The show (like the recent Hulu drama Harlots) navigates a complicated path between showing the reality of sex work and somehow keeping the action from being impossibly depressing. It’s as often funny as it’s brutal, and yet the two modes don’t undermine each other. Candy’s initiation into the world of porn, for example, is a money shot that involves cold Campbell’s potato soup and a Macgyvered pumping device.

There are labyrinthine plots and subplots involving an honest cop, Officer Alston (Lawrence Gilliard Jr., a.k.a. D’Angelo Barksdale), an ambitious reporter (Natalie Paul), an outspoken NYU student (Margarita Levieva), and a Mafia capo (Michael Rispoli) who engages Vincent and Frankie in his bid to clean up Times Square—by moving the street action into lucrative indoor parlors. Franco, who directs the third episode, anchors the action, making Vincent plausibly decent, although possessing some less obvious flaws. But it’s Gyllenhaal, as Candy, who takes the series to a different level. She’s luminous onscreen, exuding Candy’s washed-out, sluggish demeanor, her world-weariness, and the unexpected energy she derives from making films—not as a star, but as a creator. In many of her scenes, Candy is seen by viewers as a reflection looking into a mirror, ostensibly tweaking her makeup or covering bruises, but the image that comes across is of someone trying to really perceive what she’s become.

Before agreeing to play Candy, Gyllenhaal reportedly asked for some influence over her character, and it’s her scenes that take the show in its most explicitly feminist direction. Simon and Pelecanos seem to have realized, too, that a show about the sex trade needs to have a strong female point of view. (“We realized, to try to do the story, two middle-aged straight guys, it just wasn’t going to work with just us,” Pelecanos told UpRoxx’s Alan Sepinwall.) There’s a riotous scene in the diner where the women disgust their pimps by talking about their periods, but there’s also a deeply rooted sympathy for the reality, the tedium, and the danger of their daily lives. The Deuce is unfailingly candid and thoughtful about misogyny, and the legion forms in which it manifests.

This narrative nuance is all wrapped up in an aesthetic that’s part Taxi Driver, part Super Fly. The gaudy ostentatiousness of the era helps communicate Simon’s point that the core of the sex industry is exploitation, and it filters from top to bottom, with hardly anyone empowered. Vincent persuades his waitresses to wear leotards to bring in business; Candy seduces shy actresses to get a better take; the mobsters give the women safer environments to work in so they can take a cut of their labor. In the final episode, Lori observes Linda Lovelace (Heather Cole), starry-eyed, and imagines the promise and liberation of porn’s golden age. The kicker is that Simon, and his viewers, really know what happened next.