Molly’s Game, which marks the directorial debut of screenwriter, television creator, and playwright Aaron Sorkin, is based on the book of the same title by Molly Bloom, who, in the early 2000s when she was only in her mid-20s, found herself in rather extreme circumstances. Originally planning to be an Olympic skier, her path was diverted into the world of big-money poker, which she learned on the fly and soon came to dominate, first in Los Angeles and later in New York, by organizing and running what she described in the subtitle of her book as “the Most Exclusive, High-Stakes Underground Poker Game in the World.” This endeavor eventually landed her in hot water, as she was charged by the feds several times, first for engaging in illegal gambling and later for being involved in money laundering for the Russian mafia. Sorkin’s ambition is to cut through Molly’s media-fueled “Poker Princess” persona and frame her primarily as a victim—not one who is weak and helpless, but rather a woman who is strong, independent, intelligent, and resourceful and, through little fault of her own, became a victim of circumstance, caught up in the net intended to snare all the real criminals around her. Molly certainly had her flaws, and at least once she admitted to taking a rake (a percentage of the pot), which is illegal, but otherwise she was simply a determined entrepreneur who saw an opportunity and made the most of it.

Sorkin, who is best known as a writer of intense, rapid-fire dialogue usually shot like verbal machine-gun fire by alpha males, structures the film as a series of flashbacks narrated by Molly (Jessica Chastain), often as she is talking to her incredulous lawyer, Charlie Jaffey (Idris Elba). Jaffey is the film’s audience surrogate, as he initially understands Molly through the media hype that turned her into a caricature of infamy, but gradually comes to see her as a human being who is not only not a corrupt, scheming hustler, but actually someone with a clear ethical code and unwavering morality. Even when Molly has an opportunity to sell out others to protect herself, she refuses to do it out of a sense of obligation. Her book, which Jaffey reads and becomes a major bone of contention, helped her out financially, but not nearly as much as it could have if she had “named names” as the publisher wanted. Chastain plays Molly as a complex, fascinating enigma—a determined opportunist and wily entrepreneur of great ambition who nevertheless always saw the people around her first and foremost as people, which in the ruthless world in which she operated was a weakness that ultimately left her vulnerable. She makes tons of money and becomes a fixture in the kind of elite circles most people don’t even know exist, yet there is a core emptiness in her life that adds a poignancy to all the decadence. As Bloom recently said in an interview, “You’re as sick as your secrets, and my whole life was a secret.”

At its best, Molly’s Game takes us deep into an intriguing, hidden world that few if any of us will ever get to see. Sorkin makes the world of high-stakes poker games both engaging and understandable (as least as understandable as they need to be for his narrative purposes), and he wrings substantial pathos from the manner in which the players win and lose, with some of them being quite literally destroyed. The hubris is almost suffocating at times, and the amount of money changing hands is nothing less than obscene; part of the film’s sneaky appeal is the way it makes palpable just how decadent the wealthiest of the wealthy actually live (one player, unable to secure enough cash for the game, arrives with a multi-million-dollar painting from the wall of the gallery he runs as collateral). Molly’s initial poker game is played in the backroom of a famous Hollywood club and attracts businessmen, athletes, and actors, including the unnamed Player X (Michael Cera). Player X is the moral opposite of Molly, as he sees people not as people, but as marks, as pawns for his own amusement. Cera, who has so often played awkward, insecure characters, conveys a devilish sense of entitlement to do whatever he wants, and even as his presence at the game helps Molly financially, it always threatens to bring the whole house down. He is a true viper, even as he comes across like a gangly kid in an oversized sweatshirt.

At its worst, Molly’s Game sinks into pseudo-profound explanations for Molly’s engagement in this sordid world, most of which is driven by her vexed relationship with her father, Larry (Kevin Costner), a psychologist and professor who drove her and her brothers mercilessly in the attainment of success. The idea is that Molly is both running away from her domineering dad and also trying to one-up him and everything he and other powerful men represent, which would be fine except that all of that is eventually spelled out in a contrived scene late in the film in which Larry, long estranged from Molly, conveniently shows up and has a three-point “session” with her on a park bench. It’s gratingly obvious, and even though Chastain and Costner give it their all, it still feels forced. The scenes between Chastain and Elba are much better, as their sparring over Molly’s legal defense becomes a coded (and sometimes not-so-coded) way of talking about her life and how she’s lived it. When Molly’s Game works, it is because Sorkin not only makes tangible a unique and hidden world, but shows how Molly, always in the background watching, was both a puppet master and a puppet.