The Nice Guys opens with a shot of the Hollywood sign in 1977, dilapidated and covered with graffiti. While modern film nerds look back at that era as a kind of Golden Age, the Los Angeles of The Nice Guys is a place that has lost its luster. The town is swimming in smog and porn; it is literally and metaphorically dirty from top to bottom. The crumbling Hollywood sign is historically accurate, but it also makes a convenient symbol, not just of the place as it was, but as it still is — particularly at this time of year, when everything is based on something else and it sometimes feels like the studios are remaking movies that were just released a few weeks earlier.

The Nice Guys is a throwback to an earlier era, when big movies could still have strange little touches and lots of edge. In structure, it’s a buddy cop movie, although neither of the title characters are actually cops. Holland March (Ryan Gosling) works as a private eye; his daughter Holly (Angourie Rice) claims he’s the world’s worst detective. He’s also an exceptional drunk and a passable con man, who mostly spends his days fleecing old ladies. He’s hired to track down a girl named Amelia (Margaret Qualley), who in turn hires an underworld enforcer named Jackson Healy (Russell Crowe) to get March off her tail. When the two meet for the first time, Healy breaks March’s arm. When they meet again,  Healy hires March to help him find Amelia, and get to the bottom of a mystery that also involves the recent death of a famous porn star and air pollution in Los Angeles.

This swirl of sin and secrets comes from writer-director Shane Black, the man who wrote Lethal Weapon and The Last Boy Scout, and directed Kiss Kiss Bang Bang and Iron Man 3. If he didn’t invent the buddy cop genre, he certainly codified most of its tropes. Black’s latest feature carries forward that tradition, and reworks many of his favorite themes: Unlikely heroes forced into doing good deeds, the seedy side of Los Angeles, precocious kid sidekicks, vast criminal conspiracies, and a Christmastime setting (the better to accentuate the protagonists’ feelings of loneliness and isolation).

These days, most buddy cop movies are knowing self-parodies like the 21 Jump Street franchise. But Black isn’t interested in making fun of the genre’s clichés, and the way he writes these characters, with freshness and attitude, they don’t feel like clichés. (He also delivers a really compelling mystery where so many recent buddy cop movies treat their stories as an afterthought to focus on the banter and stunts.) It helps that he’s got a terrific cast, and a lead pairing in Gosling and Crowe who can handle Black’s snappy dialogue and play off each other with the kind of fractious chemistry this type of movie demands.

Black made his bones as a writer, but he’s matured into a very solid action director. The Nice Guys’ final frenetic setpiece in, around, and above a Los Angeles car show, is easily the sharpest, funniest, and most exciting finale of any movie this year, and even with different sets of characters squaring off against each other in different places simultaneously, the geography of everything is always easy to follow. Even though Black’s best known for his bickering repartee, he knows when to use restraint; note the way he treats Healy’s drinking issues, or explains Holly’s interest in detective work with some careful set decorating (her collection of Nancy Drew novels sits in a place of honor, on a shelf separate from the rest of her books).

I rewatched a bunch of Shane Black’s work before my interview with him last week, and what surprised me most about it — and what separates it from so many crummy knockoffs — is how dark and bleak it gets at times. Filmmakers looked at Black’s buddy comedies, copied the wisecracks and the action, and wound up with a lot of derivative, forgettable junk. Black’s best movies stand the test of time because they have real pathos along with real humor. In the first Lethal Weapon, Martin Riggs is suicidally depressed; the conspiracy at the heart of The Long Kiss Goodnight is so disturbing it’s become a favorite of 9/11 truthers. There’s a joke in the final scene of The Nice Guys that might be the saddest and darkest gag I’ve ever ever laughed out loud at. It’s so funny, but it’s so sad too.

Black’s general atmosphere of resigned melancholy fits perfectly with The Nice Guys and its portrait of sleazy 1970s Los Angeles, the ideal setting for a filmmaker interested in faded dreams and broken dreamers. Perhaps there’s something about those themes that really resonates with Black. Back in 1987, his work felt cutting edge. Now it feels like a welcome return to the past, when big action movies were filled with flawed human beings who bled and suffered, and cracked jokes so they wouldn’t burst into tears.