Written by Gerwig and her partner, Noah Baumbach, the movie introduces Barbie on yet another perfect day in Barbie Land, in which dolls played by humans exist in what resembles a toyland gated community. There, framed by a painted mountain range, Barbie and a diverse group of other Barbies rule, living in homes with few exterior walls. With their flat roofs, clean lines and pink décor — a spherical TV, Eero Saarinen-style tulip table and chairs — the overarching look evokes the era when Barbie first hit the market. It’s very Palm Springs circa 1960, an aesthetic that could be called bubble-gum midcentury modern.

Gerwig has fun in Barbie Land, and in her role as a friendly playmate, she works hard to ensure you do too. She takes you for a leisurely spin, cranks the tunes, stages some old-school, Hollywood-style musical numbers and brings in those eternal sidekicks, the Kens (with a scene-stealing Ryan Gosling chief among them). The production design (Sarah Greenwood) and costumes (Jacqueline Durran) offer ticklish pleasure but also underscore this place’s artificiality. Barbie, et al., are of our world and not, existing in a plasticky paradise that proves less hospitable when she begins having un-Barbie thoughts and experiences: She thinks of death, and then her feet, which are molded to fit high heels, go flat.

This change to Barbie’s body is played for laughs — the other Barbies are horrified — but it’s crucial to the plot and to Gerwig’s intentions. Once Barbie’s feet touch the ground, she seeks advice from a misfit version of the doll (the invaluable Kate McKinnon), who prescribes Birkenstocks and a trip to the real world. Soon, Barbie — with Ken riding shotgun — journeys into something like reality; that they land in Los Angeles reads like a puckish joke. There, Barbie is astonished to discover sexism, and Ken is delighted to discover patriarchy, contrapuntal revelations that generate further comedy and something like enlightenment.

Gerwig handles the transition between realms smoothly, but even in this bouncy, happy movie, reality proves a bummer. It’s amusing when Barbie points out a billboard filled with women, mistaking them for the Supreme Court because that’s what the court looks like in Barbie Land, just with more pink. She learns how wrong she was, which is to Gerwig’s point. But the weight of our world, emblematized at least for this viewer by the real Court’s overturning of Roe v. Wade, proves unbearably heavy. However politically sharp, the gag is an unpleasant reminder of all the profoundly unfunny ways in which this world, with its visible and invisible hands, tries to control women, putting them into little boxes.

Mattel has long tried to reconcile Barbie with the real world. The toy’s origins lie with Ruth Handler, a founder of Mattel who wanted to make a doll for girls like her daughter, Barbara. Handler found her inspiration in Europe with an adult-looking German doll called Bild Lilli that Mattel reconfigured. Some buyers pushed back: “The idea of a doll with breasts was not received well,” Handler said in a 1994 Lilith magazine interview.