Scottish ministers axed the universal winter fuel payment as a "direct consequence" of the UK government's decision to stop the benefit, a court has heard.