The neat trick of Gore Verbinski's Rango is the way it wraps some rather adult themes (and adult references) around a pretty basic kids' movie structure. The film follows the titular chameleon, voiced by Johnny Depp, as he falls out of a moving car and stumbles into the desert, where he encounters an adventure right out of a spaghetti western. The film is packed with hip references, like an early blink-and-you'll-miss-it Fear and Loathing in Las Vegas visual gag, and more notably the obvious influence of the Sergio Leone/Clint Eastwood "Man with No Name" trilogy. Those films loom large here, as Rango arrives in a dusty frontier town populated with various grizzled species of anthropomorphic animals. Rango, who inhabited a lively fantasy world to stave off loneliness in his small tank, now presents himself as a wandering mercenary hero, ready to help the townspeople, who are suffering from a drought that threatens to eliminate their water supplies. The plot combines the Leone films with, improbably, Roman Polanski's Chinatown and its schemes over water rights.

The plot, however, is not the film's strong point by any means. Despite the sophisticated reference points, the film's narrative is a bit of a jumble, and Verbinski leans too heavily on cliché when he's not nodding to his more venerable influences. When one mid-film action sequence devolves into a noisy, silly war film parody complete with "Ride of the Valkyries" — probably the most tired musical choice it's possible to make in a movie these days — it underscores how rapidly the film veers between clever pastiche and rote regurgitation.

It's easy to forgive and forget the more unimaginative stretches, however, when Verbinski packs the fringes of the film with such a wealth of visual wit and interesting ideas. When Rango first arrives in the desert, he encounters an armadillo (Alfred Molina) who has been run over on the highway but is somehow still alive and talking as though nothing has happened. This is especially disconcerting because there's a giant truck-tire-sized cutout in the animal's midsection, but the armadillo simply wants Rango to push the two halves of his body back together again. It's a disconcerting image, particularly for a movie supposedly made for kids, and an image that suggests the twin poles of surrealism and mortality that will serve as important motifs throughout the film.

Indeed, Rango is curiously obsessed with death. A trio of musical birds provide the vibrant, Morricone-esque soundtrack for the film, while also appearing onscreen as a Greek chorus narrating Rango's adventures. From the beginning, the birds suggest that this is going to be the story of the life and death of a hero, and they begin to seem strangely disappointed when the hero continually faces death and fails to die. At one point, the birds even deliver their grim predictions while hanging from nooses. The film's biggest threat, the tremendous, vicious Rattlesnake Jake (Bill Nighy), claims to come from Hell, and his fiery eyes and seeming willingness to kill suggests that there's some truth to the claim. The grislier aspects of the film sit uncomfortably against its sillier moments and its concensions to kids' movie conventions, like the plucky love interest (Isla Fisher) and the unbearably cutesy kid (Abigail Breslin) who does pretty much nothing and serves no purpose, throughout the movie, besides saying cute things in a cute voice and batting her huge eyes.

There's tension here, because the film sometimes seem to want to offer little more than this kind of predictable, jokey entertainment, but sometimes it seems to want to tell a much more serious story. It's a story about loneliness (on the personal level for the misfit Rango, a lifetime loner who creates his own entertainment with imaginary friends because he's never had real ones) and about the costs of modernization and the impotence of common people faced with powerful political and economic interests. The latter story, the big picture social story that's derived from the example of Chinatown, crops up periodically, most powerfully perhaps when Rango discovers the body of the town's bank manager, killed and cast aside in the rush for progress. Like all the best Westerns, this is a film about the West facing its end, about the push to tame the frontier. But the theme is never fleshed out very much, so that even at the end of the film, the exact nature of the plot cooked up by the film's obvious-from-the-start villain, the turtle mayor (Ned Beatty), is somewhat unclear, and he's left to spit out rote expositional dialogue to emphasize his villainy.

If the film's plot is sometimes less than coherent, broken up by embarassing digressions like the "Ride of the Valkyries" scene, Verbinski compensates with other pleasures. Rango's first night in the desert is visualized by a charmingly surrealist dream sequence populated by a talking windup goldfish and a disembodied Barbie torso, his only "friends" from his solitary existence. Later, in the film's best and most memorable scene, Rango actually meets the Man with No Name himself, a cartoonized Clint Eastwood (actually voiced by Timothy Olyphant) dressed in the distinctive poncho he wore in his Leone films. It's a wonderful meta moment, an explicit acknowledgment of Rango's affectionate tribute to the Leone/Eastwood collaborations. Eastwood's appearance provides a good example of the film's animation quality, too, since the caricature is instantly recognizable as the iconic actor, his face deeply lined and worn like a grizzled, aging Western hero, squinting and sneering as he dispenses advice to the tiny lizard he's inspired.

The animation is generally gorgeous in general. Not all of the character designs are as expressive and satisfying as the depictions of the Man With No Name and Rango himself, but the animation is unceasingly lovely, and all of the characters are textured and detailed so that they never seem like molded plastic (as, for example, the highly praised Pixar's human figures often do). There are plenty of visually sumptuous moments along the way, brief sequences where the action pauses to simply admire the scenery. A posse ride through the desert is particularly jaw-dropping, as the sunset desert scenery looks simultaneously realistic and colorfully stylized. The iconography of the Western is lovingly referenced in the visuals, from a shadowy figure appearing out of the shimmering heat haze of the desert to a group of riders galloping against the huge orange half-circle of the setting sun.

Rango is in many respects an interesting, if somewhat schizophrenic, work with the ambition to marry some big ideas to a rather conventional underlying structure. At its best, the film is visually dazzling, witty and a tribute worthy of the spaghetti Western influences it wears on its sleeve. At it's worst, it's cloying, overbearing kiddie fare, and those two sides of its personality are never quite resolved. Still, the film has enough ambition, smarts and style to make it a mostly enjoyable entertainment that occasionally reaches for something more.