Although it wasn’t the first movie to feature a character stuck in a never-ending time loop, the 1993 Bill Murray comedy Groundhog Day has become such a cultural touchstone that any movie with a similar premise inevitably draws comparisons to it. The makers of the hugely entertaining time loop romantic comedy Palm Springs are clearly aware of the baggage they’ve been stuck with, but like the creators of smartly crafted recent time loop stories Happy Death Day and Russian Doll, director Max Barbakow and screenwriter Andy Siara don’t shy away from the influence, even having their characters acknowledge that this highly unlikely scenario is somehow completely familiar.

“It’s one of those infinite time loop situations that you might have heard of,” slacker Nyles (Andy Samberg) tells fellow wedding guest Sarah (Cristin Milioti) when she ends up trapped with him, repeating the day of her sister’s wedding over and over again. As Palm Springs begins, Nyles is already an old pro at the whole time loop situation, having accidentally stumbled into a glowing cave in the desert outside the eponymous Southern California vacation town and been sucked into a vortex that causes him to wake up in the same place at the same time every day, stuck with his cheating girlfriend (Search Party’s Meredith Hagner) at the wedding of her friend Tala (Camila Mendes).

RELATED: Palm Springs Trailer Boasts Star-Studded Cast and Groundhog Day Vibes

Sarah is Tala’s sister and the wedding’s maid of honor, and she clearly would rather be anywhere else. After Nyles saves her from having to give a wedding speech that she hasn’t prepared, the two hit it off, and soon they’re alone in the desert, making out. But when a mysterious assailant shows up and starts firing arrows at Nyles, he crawls into that glowing cave to get away, and despite his admonitions to stay back, Sarah follows him. Suddenly she too is waking up to repeat the same day over again, and she is not happy about it.

What follows is in a lot of ways a typical and predictable romantic comedy, as Nyles and Sarah are at first at odds with each other and then form a genuine intimate connection, before pushing each other away and then coming back together in the final act, There’s even the movie’s equivalent of the last-minute rush to the airport, in this case a rush to the glowing cave. But Samberg and Milioti have fantastic chemistry, and it’s easy to see how these two misanthropes would delight in finding each other. The movie is at its best in the middle section when the characters are just delighting in each other’s company, waking up every day with smiles on their faces even though they’re stuck encountering the same people doing the same things.

RELATED: Spider-Man's J.K. Simmons Is Signed on for Multiple MCU Appearances

The filmmakers have fun with some of the activities recognizable from other time loop stories, including predicting what others will do before they do it (Nyles expertly mimics every dancer at the wedding) and going to extreme lengths to escape (Nyles tells a story of flying all the way to Equatorial Guinea before passing out and resetting the day back in Palm Springs). Barbakow and Siara pay more attention to the existential implications of the time loop than other creators have, engaging Nyles and Sarah in surprisingly meaningful debates about what their situation means from a philosophical perspective, and what their moral obligations are to the people around them, even though they’ll never experience the consequences of their actions.

There’s an undercurrent of darkness in the story of fellow wedding guest Roy (J.K. Simmons), a bitter distant relative who blames Nyles for his getting caught up in the time loop as well, and is the shadowy figure who’s shooting at Nyles at the beginning of the movie. Roy is like the Wile E. Coyote to Nyles’ Roadrunner, targeting him with periodic violence even though neither of them can die (“I’ve done a lot of suicides,” Nyles admits to Sarah). Roy eventually takes his own moral journey, adding an extra dimension to the genre that is usually about characters who are alone in their plight.

The fact that Nyles and Sarah are not alone is what makes the movie work, and keeps it from feeling like a retread of Groundhog Day or other time loop stories. When everything around them is rendered meaningless, they find meaning in each other, and Samberg and Milioti make that burgeoning romance feel genuine, even in the midst of such a bizarre situation. They’re sweet but never cloying; they're funny and goofy while remaining emotionally honest.

The movie loses some momentum, then, when it pulls them apart for an extended period in the third act, and while Milioti makes Sarah into a fully realized character, and there are occasional sequences told from her perspective, she still feels a bit secondary to Nyles in a way that throws off the balance when they aren’t together. But their eventual reunion is heartfelt and satisfying, and even the movie’s focus on the questionable science of the time loop reaches a rewarding conclusion. As Nyles and Sarah learn, just because you’ve seen something before doesn’t mean you can’t get new pleasures from it.

Starring Andy Samberg, Cristin Milioti, J.K. Simmons, Meredith Hagner, Camila Mendes, Tyler Hoechlin and Peter Gallagher, Palm Springs premieres Friday on Hulu and in select drive-in theaters.

KEEP READING: Crossing Swords Is a Vulgar, Unfunny Fantasy Comedy