The coins aren't gained, they are set aside. And you start with 7 coins.
Honestly, I guess we could try to calculate the odds of each move depending on his choice number, but I feel it to be too tiring a task. Let's take 3, it's an average number and go from it.
He has chosen 5. So, we lose 2 gold coin (we have 5 remaining), and he turns 5 of his 7 coins to tail.
During the recovery phase, he recovers one coin, so he has 3 unturned coins and 4 tails.
He is limited to playing 1 or 2, while we can play 1-4 (we can't play all of our unturned coins at once).
If we play 4, our maximum, and he plays 1, he loses. He'd lose 3 coins, all of his. So he is basically obliged to play 2 to avoid lose (he can't know that we won't play 4). And actually, since there is a chance for him to lose, let's play 4.
He plays 2, as we expected. So he loses two coins -- he is now left with 1 unturned, 4 tails. We turn four of our coins, so we have 1 unturned, 4 turned. During recovery, we but turn one coin each, so he has 2 unturned, 3 tails, while we have 2 unturned, 3 tails. We have a similar hand.
The section informs us that since we have only two unturned coin each, we are limited to play 1 each, resulting in a draw, and after the next recovery we each have 3 heads and two tails. We can play 1 or 2.
I play 2, and he plays 2. After recovering, Kief comments on my ability as I "prevent him from gaining ground". Somehow.
We both have 4 heads and 1 tail. Since another drow would give us both 5 heads, we'd be in a similar position to the starting position, but with each 5 coins instead of 7. I chose 3 coins. He chose three coins.
Both both have 5 coins. He again compliments me on him having to lose ground. I am as baffled right now than when I was 12.
I'll just quote the section there:
Grandmaster Kief watches you with an inscrutable smile. Well done, he says at last. You are an implacable opponent. I concede a draw, and this is not something I do lightly. A reward for your valiant efforts, then..." and he proceeds to give us an Ice Jewel.
Apparently, we don't get a say in whether we accept the draw, or if the game is finished. I am really puzzled. He then casts a spell to teleport us further into the dungeon.
Honestly, I can't say if it's something other than chance at guessing his first move. Flipping through the section, there is a way to beat him, but I don't know how we are supposed to pass this puzzle. If someone has some kind of explanation...