Bitcoin rallies amid risk-on market mood after dip below $40