In Woody Allen’s bittersweet 1985 romantic comedy The Purple Rose of Cairo, a Depression-era housewife escapes her miserable existence by escaping to the movies. One day, to her delight and confusion, her favorite movie character walks off the screen and into the theater. It’s a fantasy that only lasts so long—he’s eventually coaxed back into his own world, leaving the housewife alone at the movies—and yet the final scene shows her sitting in the darkness, contented, gazing up at the glamorous people on screen. Allen was asked if he was ever tempted to shoot a happy ending to Purple Rose. His response—“This is the happy ending”—is both typical of the filmmaker’s glass-half-empty philosophy and insight about human nature. Even when our fantasies let us down, we crave them, if only for the brief respite they give us from everyday life.

La La Land is as delightful and magical as you’ve heard—a big, joyful celebration of old-school Hollywood musicals—but it’s also smarter, tougher, and sadder than its moonstruck trailer might suggest. With his third feature, writer-director Damien Chazelle (Whiplash) has crafted a ravishing ode to the possibilities of love and dreams, but like Allen, he understands that we can’t live up there on screen. We are tragically stuck in our own world.

Emma Stone, who’s never been better, is Mia, an aspiring actress living in Los Angeles. One day, she meets Sebastian (Ryan Gosling), a dedicated, struggling jazz pianist who hates the way the city disrespects its musical history by tearing down old clubs and replacing them with tacky theme restaurants. At first, the two don’t get along—she doesn’t like jazz, and he thinks she’s just another flighty actress—but their flirtatious bond develops into something deeper. Because La La Land fills its first half with glorious song-and-dance numbers, their relationship develops through a series of widescreen, Technicolor sequences where, sometimes literally, the pair floats through the heavens.

The original songs, with music from Justin Hurwitz and lyrics by Benj Pasek and Justin Paul, are an absolute delight, conjuring up a nostalgic glow that avoids cynicism or soulless pastiche. Dancing With the Stars choreographer Mandy Moore gives Stone and Gosling a lively energy in their dance routines, making them appear polished without being perfect. Chazelle’s dialogue and plotting feel contemporary, but the musical sequences are a balance of now and then; the characters fall in love in a Hollywood netherworld where an impossibly romantic Los Angeles is the backdrop and everyone can have the job of their dreams if they just wish hard enough.

This balancing act can be incredibly difficult for a director—make a film that’s too reverent and it feels like a dull homage, too snarky and it curdles in its hipness—but for the most part Chazelle confidently walks the line. La La Land invites us to recognize that this L.A. is far from reality, but it wants us to put that fact aside for a moment and allow ourselves to be swept away by the youthful optimism of its characters.

Stone and Gosling are so effortless in their roles that the movie’s invitation is easy to accept. In her best performances, Stone has always seemed timeless, but irreverent; her characters can’t quite accept the manufactured reality inherent to being in the movies. But that wised-up sensibility never undercuts Stone’s loveliness, and that’s especially true of her portrayal of Mia, who has suffered through years of bad auditions but has held onto the notion that, eventually, she’s going to break through to stardom.

Likewise, Gosling has operated in a public sphere in which he’s practically more meme than man. Here, he seems slightly removed from the neon artificiality of the city. Sebastian hates L.A.’s disposable culture, but Gosling undercuts that disgust with palpable vulnerability. His character is as much a dreamer as Mia is, except he’s a little older and a little further down the road in his aggravation.

If La La Land’s first half is a buoyant salute to love, musicals, and optimism, the film’s second half takes the movie in a different direction, which is best not to spoil. It’s not that La La Land features a blindsiding plot twist, but its rather that Chazelle slowly starts to shift toward a realistic examination of how careers and relationships often conflict through no fault of either person.

Chazelle provides a wiser, more believable glimpse into the artist’s struggle to maintain his or her integrity than he did in Whiplash, which, for all its actorly pyrotechnics, was eventually bogged down by its ultra-macho battle between pupil and teacher. The stakes are just as high in La La Land. While the film would appear to be less grounded in reality, it feels truer to the compromises we all must face if we decide to live in our fantasies instead of putting them aside for a more conventional life.

La La Land isn’t the first musical to question the genre’s escapism—Chazelle has acknowledged a debt to The Umbrellas of Cherbourg—but its resolution feels like an apt way of reconciling its characters’ romantic and professional dreams. Like The Purple Rose of Cairo, La La Land arrives at the most plausible of happy endings for Mia and Sebastian. Some audience members won’t feel that way, though, and that’s Chazelle’s point. Los Angeles is a city full of possibilities, that’s part of its immense appeal, but eventually, possibilities require choices. Mia and Sebastian make theirs—then they learn how to live with them.

Grade: A-

Grierson & Leitch write about the movies regularly for the New Republic and host a podcast on film. Follow them on Twitter @griersonleitch or visit their site griersonleitch.com.