Neil Patrick Harris loves puzzles. He likes sports. He designed Box One, a single-player board game; He plays Wordle every day and consistently scores 3 points. An accomplished magician, he delights in magic tricks. Every issue of their newspaper, Wondercade, comes with a puzzle of some sort. His personality is fizz and bounce, with just a touch of shade. He tends to look like he’s up to something. something fun.

His home in the Hamptons, which I visited on a recent, absurdly perfect Sunday—had he somehow weathered the weather? — It’s full of jokes, lies and pranks, which start at the doormat and never stop. (There is, I’m reliably informed, an indoor slide.) The screened porch where we chatted was adorned with a giant Jenga set. Other games were crawling on nearby trolleys.

But the game Harris, 49, plays is the game of his own career. As a child star, prime-time prodigy Doogie Hauser, MD, he managed the transition to adult work with relative grace. And when he came out as gay, in a sunny statement released to the public, his career never shrank or faltered. He is now, if anything, even dearer. And her husband, David Burtka, the actor and cookbook author who came home to the kitchen to prepare carrots eight different ways, has become a symbol of gay domesticity.

While many actors face limited opportunities, Harris has worked in comedies, dramas, musicals. He has played heroes, villains, straight romantic leads, unrepentant libertines and, in his Broadway debut, “Hedwig and the Angry Inch,” a slip of a girl in communist East Berlin. As an in-demand awards show host, he plays a dashing, tuxedoed version of himself. In the Harold and Kumar films, he plays a different version, a hedonist who cavorts with strippers and rides unicorns.

“He is A unicorn,” said Pamela Fryman, a longtime friend and director who worked with Harris on “How I Met Your Mother.” “In every way possible.”

In Darren Starr and Jeffrey Richman’s eight-episode comedy “Uncoupled,” which debuts July 29 on Netflix, Harris tries a new trick that’s an old trick he hasn’t tried since his Doogie days: playing a part of someone he actually is. Feels close.

“It was like walking into a ‘Sliding Doors’ version of my own life,” he said of the role, referring to the 1998 film in which Gwyneth Paltrow’s lead character travels through an alternate future. “Not so close to the adult version of me.”

Harris stars as Michael, an elite real estate broker who is floored (sometimes literally, with many profanities) when his partner of 17 years, Colin (Tuke Watkins), leaves without warning or explanation. Throughout the series, Michael goes through stages of grief – denial, anger, bargaining, depression, acceptance. Sometimes he flips through them all during a text message thread made in the back of the cab.

Then again, it’s not all sadness. “I want to live this second version, what if I’m single in New York and have a Grindr account? Which, I don’t,” Harris said. “So it was kind of juicy and flexible as well.”

Starr and Richman did not write the pilot with any particular actor in mind. But when it came time to cast the show, they knew they wanted Harris. “Neil was our very, very, first choice,” the star said over a video call from France. (He was shooting “Emily in Paris” in Provence. Tough life.)

They wanted him for his talent and his looks, but also for his popularity, which they hoped would keep comedy from seeming out of place. (Are there still concerns about the appeal of gay romantic comedies post “Fire Island” and “Love, Simon”? Apparently there is.)

“He’s loved by a lot of people,” Starr said of Harris. “He’s very mainstream.” The creators wanted everyone to relate to Michael. “Straight and gay, male and female, everybody,” the star said. If Harris plays him, they will.

With Harris on board, they wrote the remaining episodes and revised those episodes into the pilot. Others who have worked with Harris have always told me: His gifts and his work ethic free those around him to do their best.

“He was more talented than I thought,” said Barry Sonnenfeld, showrunner of “A Series of Fortunate Events.” He helped create several song-and-dance numbers just for Harris. “How I Met Your Mother” also gave him a production number.

“It opens up your world in a way that you can write anything and it will deliver,” Fryman told me.

Harris doesn’t sing on “Uncoupled,” and he doesn’t dance alone. But he did some stunts of his own, including falling backwards off a mountain. And he balances deep sadness, bleak sex scenes and gross-out comedy with apparent ease.

“To basically be an actor that you could do anything to him, he inspired us to up our game, to give him the best material we could,” Starr said. “Because we know he can play.”

Harris describes himself to me as a technical actor, not an introspector; A craftsman, not a psychologist. (He wanted to be a stuntman at Universal Studios as a kid. He still wants to — hence the mountain story.) You can see that craft in his past roles, like Count Olaf, the costume-loving buddy in “A Series of Fortunate.” events,” or Barney, the lothario he played in “How I Met Your Mother” who can give a pointed pause in the middle of the word “famous” and somehow get away with it.

Harris also enjoys ridiculous personal charm and boyish good looks. He called those good-looking crutches and then corrected himself: “A strange albatross,” he said. But it is enough for some roles.

Michael wanted something more, something to combat the pratfalls and vomit-in-a-jacuzzi scene. So Harris did what he almost never does: He made the episode personal. He imagines coming home and his partner of 18 years, Burtka, has left him.

That act of imagination and the way he applied it to the role was “very revealing,” he said, “very vulnerable.” (About this time Burtka sneaks into the room and hands me a bag of garden produce, which sends me home on the bus, as if I’ve robbed several farm stands. He doesn’t seem to be going anywhere. )

Harris doesn’t often indulge in that kind of openness, perhaps because he spent much of his 20s carefully maintaining boundaries between his personal and professional life. He was constantly second-guessing himself, whether to cross his legs or not, how to hold his drink. He used to walk the red carpet separately from his date.

“I was suppressing my own freedom because I was afraid that I was going to give something away and someone might see through it,” he said. After he came out at 33, that changed. “I was definitely able to exhale more and just stand taller,” he said.

Friends also noticed. “I think he surprised,” said Brooks Ashmanskas, an “Uncoupled” co-star who has known Harris for nearly 20 years.

He has pushed some of those boundaries over the years. His 11-year-old twin sons have helped. “Because I’m a dad now, I’m very vulnerable around my kids,” he said. All of this allowed him to bring some personal fear and angst to the role.

But some boundaries remain. I asked him some questions about whether “Uncoupled” would make sense in terms of LGBTQ representation if he ever felt pressured to maintain a poster-boy persona. He responded in the most casual terms, but with such warmth and politeness that he never seemed particularly evasive. If he had more pointed or intimate answers, he kept them to himself.

He said, “I will be most successful in representing by maintaining an apolitical stance. “I want people to see me as a representative of positivity. I want them to see my work without prejudice.”

So this is another game of his. Watching “Uncoupled,” seeing that naked emotion, suggests a magician peels back the veil, showing how the trick is done. Is this, after all, the real Harris? But when magicians do this, it only complicates the trick. This onscreen vulnerability masks Harris’ other tools: his showmanship, that slightly insane work ethic (some of which he attributes — still! — to imposter syndrome) and a very busy brain calculating endless permutations of tone, gesture and expression. Then the cameras roll and he makes everything look easy.

“Part of his magic is the work he does; It’s behind that door,” Fryman told me. “He doesn’t need you to see that work. He needs you to sit in the audience and be overwhelmed by the performance.

In other words, Harris always has something. That afternoon in the Hamptons, he wore a snug, short-sleeve blue polo. Before I left, he pulled the cloth over his left bicep and showed me a fresh tattoo—a wizard’s hat with a rabbit peeking out. The rabbit holds three hearts for Burtka and his children. Then he put the sleeve back down.

“I’m a wizard too, and I believe in the wizard’s ethos,” he said. “Not everyone needs to know everything all the time.”