21...d5 was the panic-move mistake that did Black in (I'm thinking exf6 for White followed by Rxd5+! looks more hurtful) .....though this is a very tough position for black to hold ... Kd8 feels safe but after Bh4, Black is dead.
Maybe c6 first and then run the king out of harms way with Kd8, Kc7? (regardless if White plays Bh4 or opens the center with exf5?)
What was the time control and how much time did black have on the clock here?
Especially around move 19, I wonder if black had better to defend his position after me blundering and saccing two pieces for two pawns. Or