We know almost immediately that something is wrong in the world of Sam Foster (Ewan McGregor), the protagonist of “Stay.” He tells his girlfriend Lila (Naomi Watts) that he didn’t sleep last night because of the neighbors’ baby was crying, and Lila points out that the neighbors are 90 years old and don’t have a baby. Doh.

Sam is a psychiatrist who does some pro-bono work at a New York university. One of his colleagues, Beth (Janeane Garofalo), is having mental issues of her own, so Sam takes on one of her patients while she takes some time off. The patient is Henry Letham (Ryan Gosling), a depressed art student who predicts hail before it happens and sometimes knows what people are going to say before they say it, or at least seems to. He tells Sam that he’s going to commit suicide this Saturday at midnight.

As it happens, Lila is also an artist, and she once attempted suicide, too. Though Sam can’t tell her much about Henry for confidentiality reasons, she feels a kinship with him. She has just stopped taking her medication because she thinks it stifles her artistic ability. So now Sam has to worry about his girlfriend as well as his patient.

Someone needs to worry about Sam, too. As soon as he meets Henry, weird things start happening. He experiences deja vu regularly, with events and people seeming to overlap themselves. But in other scenes, away from Sam, we see Henry going through the same phenomena. Henry says his parents are dead, then thinks a colleague of Sam’s (played by Bob Hoskins) is his father, alive and well after all. In another scene, Sam thinks he has met Henry’s mother (Kate Burton), yet it is clear that she is a figment of his imagination, probably still dead like Henry said she was.

I hesitate to tell you which movies this reminds me of for fear of giving too much away, but it boils down to this: At least one of the characters is having serious trouble distinguishing between imagination and reality. In the end it is all revealed (more or less) and, as these things usually go, you are either delighted by the resolution or annoyed at how easily you predicted it.

This is David Benioff’s third screenplay, after “25th Hour” and “Troy.” I get the feeling he’s just horsin’ around. “Stay” is a basic “Twilight Zone”-inspired “What is reality?” brainteaser, a creative-writing exercise undertaken by a particularly gifted writer, like an Impressionist artist doing a paint-by-numbers.

That said, the potboiler screenplay has been prettied up with some striking visual compositions and symbolism. Some of it doesn’t turn out to mean anything, but it makes the film enjoyable to look at in the meantime.

Look at what director Marc Forster (“Monster’s Ball,” “Finding Neverland”) does with some of Henry and Sam’s conversations. In one, we cut back and forth between them as they speak, and since the men are facing the same direction (both in profile, looking to the right), the alternating shots look like photo-negatives of each other: Sam is in darkness, Henry is in light, but otherwise the shots are identical in composition.

In other parts of the film, when Sam and Henry are in two different locations, Forster will frame them in their shots identically — each standing in a doorway, each sitting in a chair, etc. — so that when he cuts from one scene to the other, we are momentarily tricked into thinking we’re seeing double before we realize it’s two different men who have been positioned on the screen in the same way.

This sort of thing doesn’t happen accidentally; Forster is playing tricks on purpose. Does it symbolize something? Is Sam and Henry’s connectedness relevant to the film’s psychology? Or are Forster, his cinematographer Roberto Schaefer and his editor Matt Chesse (both regular Forster cohorts) just enjoying themselves?

Probably some of each, actually. Other visual details are just as striking yet ultimately even more irrelevant. There are occasional glimpses of twins and triplets, or at least sets of people who are dressed identically. A majority of the film’s locations involve grids, squares, columns and other collections of straight lines; several scenes involve the descending of multiple staircases; there’s even a scene where a woman reads Hamlet’s lines in a play rehearsal! (Any movie that includes a scene from Shakespeare is doing so because it thinks that scene sheds thematic light on the rest of the film. Why a woman who normally plays Ophelia is reading Hamlet’s part, though, that’s up to you to decide.)

So while “Stay” is not innovative, it does offer an enjoyable puzzle for viewers who pay attention. It’s rare that movies are made with such devotion to detail, even if the details are more frivolous than significant. And who knows, maybe a second viewing would reveal them to be more significant than they appear. There must be SOME reason why Ewan McGregor’s pants are so short. Like I said, these things don’t happen accidentally.

B+ (1 hr., 39 min.; R, a fair amount of harsh profanity, some blood.)