Our reservation was for 9 p.m., and it was my wife's birthday, so we ducked into a swanky hotel bar for a cocktail first.

On the wall, a neon sign flickered: "Of all the gin joints in all the towns in all the world, she walks into mine."

This was Casablanca. We were getting close.

Drinks done, we jumped into a red "petit taxi," as they're still called in this former French protectorate in Morocco, and made our way down dusty, palm-lined streets to Rick's Cafe. Two tall guards waved us past heavy wooden doors, and another bowed with a flourish as he pulled aside a curtain.

And there it was.

"It's smaller than I thought," I whispered to my wife.

"It's beautiful," she said.

Rick's Cafe, of course, is the re-creation of something that never was: Rick's Cafe Americain, the smoky, intrigue-filled nightclub built in 1942 on a Warner Bros. sound stage for Casablanca, the timeless Hollywood film of love, betrayal, and schmaltz in the terrible early days of World War II.

I'd first seen the film as a boy. My mother had pulled me out of school for the afternoon, correctly figuring that I'd learn more from Humphrey Bogart and Ingrid Bergman than from algebra class. Today, I know infinitely more about the film than I do about  polynomials. I've seen it countless times over the years, most recently aboard our Air France flight en route to Casablanca — and to Rick's.

Kathy Kriger, a retired U.S. diplomat, opened Rick's in 2004 after renovating a dilapidated Moroccan home with a huge interior courtyard, betting that it would draw an international clientele eager to mix nostalgia with fine food and jazz. She died this past July, but Rick's lives on.

Rick's is period piece meant to evoke the 1940s. The brassy saxes from Glenn Miller's "In the Mood" played on a soundtrack as we entered. The host quickly led us under arches and past cedar screens to a private table by a wall. A beaded table lamp flickered while stenciled brass lanterns and strategically placed potted palms sent soft shadows dancing around the room. It felt intimate, even a bit glamorous.

Rashid, our fez-topped waiter, recommended the roast duck and lamb shank with couscous. (All anyone eats in the picture is caviar, but the menu at Rick's is more egalitarian.) By then, the pianist had started his set and soon enough began playing  "As Time Goes By."

Dooley Wilson memorably sang it in the film (but did not actually play it because he was a drummer), but this was keyboards only. And unlike in the film, the piano was a baby grand, not an upright. But enough trivia. The room briefly hushed in quiet  appreciation.

After a dry martini, I wandered up a winding tiled staircase near the entrance. It led to a balcony with more tables, on this night filled with what appeared to be Chinese tourists. French couples clustered in a nearby lounge where the film was silently showing with subtitles  on a widescreen TV  — apparently on an endless loop — and two well-dressed couples were smoking and drinking Champagne at the roulette table.

Gambling is legal in Morocco — you're shocked, shocked, right? — but this table was covered with glass. A pile of chips lay on No. 22 because, well, you know.

By the time our food arrived, a Cuban chanteuse and a Venezuelan percussionist had taken over, belting out fado-like torch songs, and the café came alive as we savored our meal. More red wine, sweet mint tea, and a sumptuous lava cake later, I went  in search of Issam Chabaa, the piano player and Rick's longtime manager. We quickly retired to the marble-topped bar, grabbing leather stools at one end.

Originally from the Moroccan capital Rabat, Chabaa is 53, with a dapper mustache, a goatee, and the polite but jaded manner of a proper saloon keeper. He made it clear that he has a bemused view of the cafe's popularity.

"People don't come for the food," he said. "They come for the theme. They come for the dream. It's a fantasy for some people. It means so much to them to be here. It still surprises me."

There's a downside to running a nightclub based, in large part, on a mirage. Forget, for a moment, the racial prejudice and implied sexual misconduct in the film. Patrons grouse that Chabaa doesn't wear a white dinner jacket, that he refuses to lead them in singing "La Marseillaise," and even that he isn't black.

"When it's a dream, anything different is a problem," he said. "It puts the bar very high for us."

Recently, he said, an older Mexican fan showed up. "He said he'd wanted to come to Rick's since he was 15. I said, 'We weren't here when you were 15.' He said, 'You've always been here in my mind.' "

Social media are full of protests by tourists who were turned away at the door because they showed up in shorts (or short skirts) and sandals. But Chabaa defends the dress code  as a way to maintain the ambience — and the illusion.

"Some people get mad," he said. "They say, 'But these are $200 designer jeans,' and I say, 'I'm sorry, but they're still torn jeans.' We try not to be too rigid. But if someone sits down wearing flip-flops and a T-shirt, we get complaints from other customers."

He said that he'd only once seen Casablanca — the film that is playing in that upstairs lounge on an apparent endless loop — and that he wasn't that impressed.

"I don't know what the big deal is with that movie," Chabaa said with a shrug. "I don't know what makes it so special. It's efficient, it's a good love story, it's exotic. But it's so cliched."

His favorite films? Morocco and Garden of Allah, two Marlene Dietrich classics from the 1930s.

After a moment's reflection, I assured Chabaa that if he opened a gin joint for either of those, I'd try them too.

     Rick's Café: rickscafe.ma.  Daily, noon to 3 p.m. for lunch,  6:30 p.m. to 1 a.m. for dinner; reservations suggested. The dress code is detailed under the Rick's Café tab and then the About Us section.