Why it works
White's queen has been hovering around the kingside since 6.Qh5, and castling feels like the natural way to get out of its sights. But 8...O-O?? castles straight into the battery: 9.Bh6! attacks g7 together with the queen, 9...g6 is forced to stop mate, and 10.Bxf8 collects the exchange. The dark squares around the king were indefensible the moment the rook committed to f8.
Refutation
8...g5! is the move castling should have waited for: the pawn physically closes the c1–h6 diagonal, so Bh6 never comes. It looks loosening, but the engine keeps Black within half a pawn — and only then is ...O-O safe. Note the finish is a win of the exchange, not a rout: engine +1.7 with some dark-square compensation for Black.