After her husband leaves her—apparently to run off with his secretary—Terry Wolfmeyer (Joan Allen) is left with four daughters between the ages of 15 and 22. The Upside of Anger is about reconstituting one’s existence when mostly what you feel is fury and the desire to retreat. It’s also about the unanticipated directions life can take when it seems to have reached a dead end.

It’s far from a perfect movie. Writer-director Mike Binder was the force behind the HBO comedy series The Mind of the Married Man, and some of the episodes in this film bring out his gimmicky sitcom side. Some sequences fall flat, and the sententious voice-over that frames the picture—spoken by Terry’s youngest, Popeye (Evan Rachel Wood), who’s preparing a video project for a high school class—seems to belong to some other picture altogether. But The Upside of Anger is one of the few recent American movies about family life that neither sentimentalizes its subject nor condescends to viewers. It’s inspiritingly messy and open-hearted.

One of the two gifts Binder brings to the big screen is a love of shifting tones. Big dramatic set pieces often splinter into farce, or a situation that seems headed for melodrama suddenly boomerangs. That’s true, for example, of the climactic scene in Popeye’s relationship with a sensitive schoolmate (winningly played by Dane Christensen). This subplot is one of the movie’s unexpected pleasures—it doesn’t develop in any way we can predict.

Binder’s other gift is for directing actors. The talented Joan Allen’s repertoire of thin-blooded, repressed women has become something of a liability: no matter how good she is at getting the temperature of these characters, the performance seems repetitive. But here she gets to display a wider emotional range. One of Terry’s first responses to her husband’s abandonment is to drink too much, and Allen’s raucousness is believable as well as being a great relief. I’d forgotten how good she can be at revealing the pockets of conflicting emotions in a character.

When Terry’s daughter Emily (radiant Keri Russell, of TV’s Felicity), who wants to be a dancer, develops a mysterious stomach ailment and winds up in the hospital, Terry goes to the hospital in a panic. Their relationship is the thorniest of all Terry’s connections with her kids, and her terror over the girl’s health doesn’t prevent her from falling back into her old tones with Emily—bossy, pedantic, insistent. It’s a wonderful scene.

All four of Terry’s daughters are gorgeous and distinctive, and Binder gets fine performances out of all the actresses, including Erika Christensen (she was Michael Douglas’s addict daughter in Traffic) as Andy and Alicia Witt as the eldest, Hadley, who shocks her mom by getting engaged to a college beau Terry hasn’t even heard of. Binder himself shows up as Shep Goodman, a deejay at a local station with a yen for women half his age who hires Andy and then begins sleeping with her, throwing another wrench into Terry’s plans for her family.

The movie’s trump card is Kevin Costner’s portrayal of Denny Davies, the neighbor and onetime baseball star who romances Terry. Costner does the kind of loose, lived-in acting that normally only appears when he gets to work with Ron Shelton (who directed him in Bull Durham and Tin Cup). And the role is a marvelous one. Denny has a radio show (he and Shep are co-workers) that trades off his celebrity but exasperates listeners because he refuses to discuss baseball. He spends most of the rest of his time drunk and stoned. Costner slips effortlessly inside Denny’s sozzled, cozy rhythms, and he’s so hilarious that you don’t imagine this character is going to be anything but a charming reprobate, a clown.

Reversing our expectations for Denny is Binder’s best surprise; as the movie goes on, the character grows and blossoms. His engagement with the Wolfmeyer women causes a vision of his own life to take shape. The movie is ostensibly about Terry, but Denny’s character is the emotional core.