As a GM I believe in rewarding good tactics and plans on the part of the PCs. To me things feel more real when a valid solution is able to solve the problem. This sometimes means that challenges are easily overcome or that an adventure ends soon after it started, but in the long haul, I think those are good things, not bad. But, just as the players are rewarded for their cunning, I assume they live in a world inhabited by equally clever opponents. Once in a while the tables are turned and I put a lot of effort into the evil schemes of my NPCs.
One rule of thumb I abide by, since as the GM I have a serious advantage over the players, is I imbed several 'outs' for the players. I'll usually include a couple of opportunities to detect some crack or clue about the scheme, as well as a couple of opportunities to prevent the schemes from reaching fruition.
And when I say schemes, I mean the kinds of intricate plans that are designed by a very intelligent foe to trick, mislead and get the party to play right into their hands. These are things that really hit below the belt and wake the party up. When you reward clever thinking sometimes it leads players to believe they can't be outwitted, and I think every once in a while they need to face a truly worthy adversary on that front.
As an example, recently in my Blood of the Demon Moon Cult Campaign, the party, who had been on a steady ascension to power, were sidetracked when a powerful and clever martial hero named Yang Tuo decided to get revenge for a friend they had murdered, and also sought to stop them from enacting their evil plans (the party in this campaign could be described as evil and cruel). When the party killed his friend Kang, they took a Jade Turtle he was carrying. It was worth a lot of money but they didn't inspect it enough to discern its true nature. Kang came into possession of it because it once contained the imprisoned spirits of a cursed town. After he freed them, he was taking the turtle to its original creator, an Immortal of Iron Sky Realm.
It just so happened the party had been planning a tournament to help grow their prestige, and they were in need of a nice prize. They decided the Jade Turtle was ideal and announced it would be given to the winner of the competition.
Yang Tuo realized because the turtle was now empty after Kang freed the spirits inside, it could once again be used to imprison people if he learned the original ritual that had been cast on it. He mastered a ritual and improved it, then went to compete in the tournament. He planned to win it, then complete the final mudras of the ritual once he had it (or use trickery if he didn't win). If Yang Tuo did not win, he knew he'd probably only get one chance to grab the turtle and use its powers before they became suspicious of him.
Yang ended up making it to the final match, but was ultimately beat by a Player Character named Chen. Because the PCs were recruiting muscle and were impressed by Yang Tuo's performance, they invited him to join their group for a good wage. He convinced them he would and asked if he could handle the Jade Turtle telling them he only competed so he could see it for himself, that once would be enough. When the party agreed and handed it over, they fell right into his trap. He tapped the turtle and imprisoned them.
The end result was the party was imprisoned for about 2-3 months of time before they escaped (due to time moving slower on the inside of the turtle). This is a pretty good example of the kind of scheme I will occasionally deploy against a party when they attract powerful enemies.
Another recent example occurred in my Secret of Je Valley Campaign. The party had been trying forever to find a way to kill the Glorious Emperor, but he was protected by demonic warriors called Yao, who have their hearts ripped out and placed in boxes (which makes them immortal, regenerative and loyal). In order to kill him, they needed to find the heart boxes and destroy them, so he has less protection. This played right into the hands of a nefarious official who also wanted the Emperor Dead so he could get his hands on a magical artifact that would help him restore the demon emperor (both campaigns have been dealing with this threat, but from two very different angles). When the heroes finally found the heart boxes, the official put his plan into action and sent an assassin against the emperor.
Again, I think it is always important to insert opportunities for players to learn about the schemes. In the second case, the party got a bit suspicious and lingered in town well after they destroyed the heart boxes. Because they took time to spy on the official, they saw him send out the assassin and were able to follow him and learn of his plans. So every wicked scheme can be cracked if the players are sufficiently vigilant or clever.
When using wicked schemes like this, it is very important not to railroad and let the dice fall where they may. There might be points where, once a certain line is crossed, there is very little the players can do (for example once Yang Tuo tapped the Jade Turtle, he enacted a powerful magic that couldn't be stopped). But along the way, he shouldn't protect NPCs on their path to outwit the party. Again, in each fight Yang Tuo participated in in the tournament, I rolled the dice and let the results stand. Ultimately he ended up losing the final match, which nearly ruined his ploy. He basically had that one last card to play, and the party was in a good enough mood that it worked. Otherwise, it might not have happened. My view was, things should have been able to go either way.