Usually when we say a movie “goes off the rails,” that’s not good — but in the wickedly amusing suburban mom comedy/thriller “A Simple Favor,” the more bat-bleep crazy things get, the more fun we have.

Imagine “The Girl on the Train” with a sense of humor. (Lord knows we needed one just to make it through that lurid debacle.) Thanks to the stylish direction by Paul Feig, a whip-smart screenplay by Jessica Sharzer (adapting Darcey Bells’ novel) and performances that pop from the screen, “A Simple Favor” is a sharp-edged delight.

It’s the dark comedic flavor baked into the increasingly outlandish plot ingredients that keeps our interest and often has us laughing, even when there’s some pretty serious business transpiring — for example, murder.

Director Feig sets the tone with a sleek and cool opening credits sequence set to a French pop tune. Then we meet mommy video blogger Stephanie Smothers (Anna Kendrick), who thanks her viewers for inquiring about Stephanie’s best friend, who has gone missing five days earlier.

This leads to one of the many flashbacks in the film — some taking us back just a few weeks, others diving deep into the past to reveal some big, big, big, I mean HUGE, secrets about certain key players in the unfolding drama.

So. Turns out “Stephanie Smothers” is an appropriate name for this Energizer Bunny of a single mom, who hovers like a chatty helicopter over her little boy Miles (Joshua Satine), dominates the volunteer sign-up sheets at Miles’ school and is the target of jealous and catty barbs from the other parents.

Miles has become fast friends with a boy named Nicky (Ian Ho). They want a play date, yay! Stephanie says they’ll have to ask Nicky’s mother — and that’s the cue for Nicky’s mother Emily (Blake Lively) to emerge from her luxury car in the rain, looking for all the world like a fashion superhero with her pricey shoes and her tailored suit and her movie-star beauty.

This could be the beginning of an uneven friendship.

MORE FROM RICHARD ROEPER

In campy horror film ‘Slice,’ Chance the Rapper fits right in with witty cast
‘Peppermint’ flavored with stylish action, nasty revenge cliches

In the blink of an eye and the mix of a martini (or three), the nerdy Stephanie is drawn into the sophisticated Emily’s world.

Stephanie is dazzled by Emily’s incredible house and amazing personal style (Emily is the head of public relations for a famous designer in Manhattan). She is blown away by Emily’s blunt, foul-mouthed honesty, as Emily explain she’s house-poor, she’s bored out of her mind by life in suburban Connecticut and her dashing writer husband Sean (Henry Golding) hasn’t published a word in the 10 years since his smash hit debut novel.

The energy and the rhythm and the cadence of the exchanges between Kendrick and Lively are a real thing to behold — especially as we come to learn more about Stephanie and Emily. (Let’s just say they’re both harboring secrets, and they’re both capable of shocking the other.)

Fashion PR exec Emily (Blake Lively) carries a veneer of sophistication in "A Simple Favor."

Fashion PR exec Emily (Blake Lively) carries a veneer of sophistication in “A Simple Favor.” | LIONSGATE

When Emily goes missing, Stephanie sets aside the baking lessons and the helpful parenting tips in favor of recapping the case and asking her (ever-increasing numbers of) subscribers for help.

Frustrated with the local authorities — who suspect husband Sean might have had a hand in Emily’s disappearance — Stephanie turns amateur sleuth, digging deep into Emily’s past to unearth clues as to what really happened.

To say it’s complicated would be to undersell the meaning of complicated.

Kendrick sinks her teeth into the juicy role of Stephanie and delivers one of the best performances of her career. One minute, Stephanie is legitimately just about the best mom one could hope for — to her own son and to Emily’s boy when Emily disappears. Next thing we know, Stephanie is looking out for Stephanie and only Stephanie, in a big way.

Lively hits all the right notes as a femme fatale who is clearly a deeply troubled person beneath the bravado and the wild stories and the veneer of sophistication — and yet has a way of getting people to do exactly what she wants them to do. She’s like a 21st century Hitchcock blonde. We don’t have to discover Emily is bad news because she pretty much announces she’s bad news from the start, but we can understand why Sean has stayed with Emily through all the arguments and lies, and how Stephanie could be thrilled to become Emily’s BFF.

At times we can only laugh at how ridiculous “A Simple Favor” becomes — but that’s OK, because the film has beat us to the punch and is inviting us to have fun with it.

Invitation accepted.

‘A Simple Favor’

1⁄2

Lionsgate presents a film directed by Paul Feig and written by Jessica Sharzer, based on the novel by Darcey Bells. Rated R (for sexual content and language throughout, some graphic nude images, drug use and violence). Running time: 116 minutes. Opens Friday at local theaters.