Missing schoolgirl Shannon Matthews had been drugged and tethered in the flat where she was found, a court has heard.
Shannon's mother, Karen Matthews, and Michael Donovan are on trial over the nine-year-old's disappearance in West Yorkshire in February this year.
They deny kidnap, false imprisonment and perverting the course of justice.
Leeds Crown Court heard the plan had been for Mr Donovan to eventually release Shannon and "find" her in a local market and claim reward money.
Prosecutor Julian Goose, QC, said officers who found the youngster also found a set of written rules restricting her movements in the flat.
Medical tests revealed she had been fed temazepam tablets and travel sickness pills to subdue her during the 24 days she was incarcerated.
And a looped strap tied to a roof beam had been used to restrain Shannon, allowing her limited access around the flat when Mr Donovan went out.
Police who called at Mr Donovan's flat looking for Shannon initially got no answer, but neighbours said he was in, and they had heard a child.
Shannon was found inside one half of the base of a double bed and Mr Donovan in the other half.
Opening the case, Mr Goose told the court Ms Matthews, 33, had raised the alarm about her daughter's disappearance on 19 February.
He said it was part of a "wicked and dishonest plan" to kidnap the girl devised by her mother and Mr Donovan.
Ms Matthews was widely seen on television making impassioned pleas for her daughter's safe return - but all the time she knew exactly where she was, the court heard.
Mr Goose added that Mr Donovan had tricked Shannon into his car on her way home from a school swimming trip.
He then kept Shannon "drugged, subdued and hidden from the public" and bought newspapers featuring the investigation.
The prosecution said Karen Matthews took part in a "wicked" plan
The court heard that the pair plotted to claim the £50,000 reward money put up by the press for the youngster's return.
Mr Donovan later told police the plan was to release Shannon in Dewsbury market and he would then "discover her".
The disappearance of Shannon, now 10, became one of the highest-profile missing person inquiries ever seen in the UK.
The court heard the cost of the search, the biggest-ever conducted by West Yorkshire Police involving 300 officers, was almost £3.2m.
Within a half-mile radius of where Shannon was last seen, 1,800 premises were searched and extensive house-to-house inquiries were conducted.
Three-quarters of all the UK's specially-trained police dogs were brought in to assist in the search.
More than 800 CCTV tapes and computer hard drives were examined and 41 other areas were searched outside the half-mile radius of Moorside Road, including operations in Cumbria and Nottinghamshire.
"Karen Matthews even gave deliberately misleading lines of inquiry to the police," Mr Goose told the court.
Mr Goose said she even gave officers one address where she said she had been told by a clairvoyant that Shannon might be found.
Ms Matthews, of Moorside Road, Dewsbury, West Yorkshire, and Mr Donovan, of Lidgate Gardens, Batley Carr, deny all the charges.
The case continues.