When do I have to trash my hidden card? After showdown end or after my only unit killed?
It depends on whether a Showdown is still running.
Your hidden card trashes when you lose control of the battlefield (Rule 323.7). That timing changes based on context:
- Outside a Showdown/Combat (Open State, no chain): the moment your last unit is killed, you lose control in the following cleanup and the hidden card goes to the trash — there's no window to flip it (Rules 187.4.c, 323.6).
- During a Showdown/Combat: the battlefield is Contested, so you keep control even with zero units. Your hidden card stays put and you can still flip it as a Reaction. It only trashes when the Showdown fully resolves and you still control no units there (Rule 466.5.c).
One caveat: if a Deathknell or other trigger from your dying unit creates a chain, that opens a window to play the hidden card before control is lost. Otherwise, outside of combat, a killed last unit is "checkmate" for your hidden.