A password will be e-mailed to you.

If you’ve seen Toy Story 3, there’s a remarkable moment at the climax. After fending off the villain, the entire gang of toys is plunged into the incinerator of a garbage dump, slowly sinking with the thrash towards a fiery hell mouth. Stripped of every last option, they all join hands and prepare to face the inevitable. Toy Story 3 being a “kids” movie, they are of course saved at the last instant.

It’s a remarkable sequence, not just for its aesthetic darkness, but for its profound emotional and artistic depth. For a moment, the film shakes loose the shackles of its genre and our cinematic and cultural pretensions, and lays bare how soul-rendingly fragile and insignificant we sentient beings are in the face of the universe’s capacity for destruction.

Wreck-It Ralph inches up on equaling that moment in Toy Story 3 not once, but twice. And like Toy Story 3, both times it must veer aside at the last moment and zig zag to its pre-ordained happy ending. But in doing so it betrays its own internal logic.

That logic is set up like so: Wreck-It Ralph (John C. Reilly) is the hulking, ham-fisted villain of the arcade game Fix-It Felix. In a blatant call-out to Donkey Kong, Ralph sits atop a building, smashing things and raining down destruction, while the player, as Felix (Jack McBrayer), must repair the damage. If Felix is successful, the building’s tenants all happily congregate on the roof to toss Ralph off and into the mud.

The film has a lot of creative fun building the interior world of the games. The characters all dutifully play out their respective roles in a kind of stage performance. After hours, they take public transit through the electrical wires to visit other games, carrying out a pleasant neighborly existence. There are hick-ups: “Be careful when traveling outside your game,” warns a public service announcement. “If you die outside your game, you don’t regenerate.

Wreck-It Ralph has a lot of clever asides like that. Characters from older arcade games, while beautifully animated, move in the herky-jerky style reminiscent of 8-bit animation. Those whose games have been unplugged and decommissioned are left to beg homeless in the transit system’s grand central station. A game called “Tapper” is the community’s local watering hole. And in Pac-Man there’s a group therapy session for the arcade’s villains — Bowser from Mario Bros., Zangief and M. Bison from Street Fighter, and the ghosts from Pac-Man all put in appearances.

Those sessions are an outlet for Ralph to pour out his weariness and frustration with the “bad guy” role into which he’s been shoehorned. He lives in the game’s dump, consigned to a rote manual labor day after day. The other characters in his game fail to differentiate Ralph from his job, treating him with trepidation or outright contempt. They shower adoration on Felix who, like many sunny one-percenters, is blissfully unaware of his own good fortune or the injustice under which Ralph suffers.

After Ralph’s decision to crash an anniversary party for Felix goes horribly wrong, Ralph goes AWOL. Convinced that winning a “medal” (another call-out to the old arcade games) will finally earn him the respect of his peers, Ralph sneaks his way into a military sci-fi first-person shooter populated by monstrous cybugs. He successfully snags a medal, but just as quickly gets diverted into a racing game — “Sugar Rush,” a Mario Kart clone where the bulk of the film plays out — where he loses it to Vanellope (Sarah Silverman).

A young mischievous girl, Vanellope is also a “glitch,” a character with damaged code, which has made her an outcast in the Sugar Rush community. She longs to enter the game’s race, and Ralph’s medal is her ticket to the big time. After initially butting heads, she and Ralph realize their goals are mutually complementary and join forces. Meanwhile, Felix sets out to track Ralph down, and teams up with Calhoun (Jane Lynch), a commander from the first-person shooter. One of the cybugs escaped with Ralph into the world of Sugar Rush, a subplot that could spell doom for everyone.

There’s a great deal that’s good here. The film is beautifully animated, and the early and climactic sequences involving the cybugs are unusually dark and intense for the genre. (Unlke myself, viewers bringing their kids will probably not rate this as a positive.) The villain (voiced by Alan Tudyk) undergoes a transformation at the end, reminiscent of Gary Oldman’s fate in Lost In Space, that’s genuinely visually unnerving. The movie knows its cultural inheritance, and throws out plenty of asides to warm the hearts of game nerds, as well as substantive character development. Both Ralph and Felix’s characteristics turn out to be critical plot devices, and the fact that if you die outside your game you die permanently becomes a central point of drama. All the performances are good, but Silverman is the one who truly stands out. She makes use of the nihilistic bad girl act that frames her comedy routines, but then burrows beneath it to find the deep emotional wounds that inevitably drive such an act.

The script is a bit haphazard. After a creative opening act, the middle lags, but the third act comes roaring back with a blizzard of surprising story turns and ironic moral twists. We learn that Felix is in some ways as frustrated with the limits of his role as is Ralph; that Ralph’s abandonment of the Fix-It Felix game has placed it in danger of being decommissioned and all its players rendered homeless; and Ralph himself is eventually forced into the same paternalistic role he has fought against in others, trying to talk Vanellope into accepting her fate and her lowly status for the greater good.

Which brings us, finally, back to those two moments I mentioned. I won’t go into details. But the first moment, at the start of the third act, briefly raises the possibility that a happy ending will be impossible. If Ralph takes one course, he will betray everything he stands for. If he takes the other, it may end in the destruction of Sugar Rush’s world and Vanellope’s death. The logic of the impasse is so pitiless it took my breath away. The second moment comes at the climax, when it looks like matters could possibly be set right, but only after unthinkable sacrifice. As with Toy Story 3, both these sequences are visually realized in ways that further enhance the sense of impending doom, conjuring in equal measures terror, dread and awe.

To Wreck-It Ralph’s credit, the way it wriggles out of these challenges are not cheats. They emerge naturally from previous plot points, and the pay-offs are genuine. But Toy Story 3 was able to get away with this because its brush with the apocalyptic, while clarifying and thematic, was not integral to its plot. Wreck-It Ralph does not have that out. The two times when it leans out to peer down into the abyss emerge naturally from its characters’ central thematic dilemmas. Both Ralph and Vanellope are pressing against the limits of fate, their own natures, and the great structural forces of existence. They are quite literally engaged in an assault on reality itself.

We embrace happy endings in movies because most movies are upfront fantasy, with no pretensions towards deep meaning. (This is also what makes unearned happy endings so grating.) Wreck-It Ralph makes the mistake of briefly lifting up the hood and taking a look at existence as it is actually lived — with its inescapable traps, impossible choices, cruel ironies, and final oblivion. Once you’ve acknowledged that reality, your story can only end in one of two ways: Tragedy and destruction, or utter, total salvation. And since the film isn’t looking to found a new religion, the second option is a no-go.

It also means your story can’t embrace the optimistic notions of happy endings or a just world without taking the path of Ayn Rand and the modern GOP — which is to straight up embrace the subjugation of the weak and the rule of the strong as a positive moral good. It doesn’t take too much work to read into Wreck-It Ralph’s conclusion a pernicious political message; one that encourages the poor and working class to accept their lot while leaving the one-percent in peace to roll happily in their good fortune. Justice is not needed, merely acceptance and neighborliness.

Look, I get it. It’s a kids movie. And Wreck-It Ralph is well-made entertainment. It does the hard work to invest in its characters so that we care even as its plot surrenders to genre conventions. But the film opens a door that briefly hints at greatness. It’s also a door it can’t turn away from without betraying its own integrity.