Over the last week, China’s state media outlets have called the US government delusional, compared it to apes shouting on a river bank, and offered to teach the Americans a Chinese idiom: diandao heibai, “to invert black and white”, or deliberately distort the truth.

As trade tensions mount between the US and China, Beijing faces the difficult task of appealing to national pride to shore up confidence in the leadership while also keeping public anger in check.

As US-China ties have deteriorated over the last year, Chinese officials and state media have been relatively restrained. Official statements refer to “trade frictions” with the US, rather than a “trade war”, and have been careful not to name Donald Trump directly or criticise the country as a whole.

“They want to send the message that they are being firm, that they are in control, that China’s economy is healthy and capable of self-sufficiency,” said David Bandurski, co-director of the China Media Project, a research programme affiliated with the University of Hong Kong.

“I believe the thinking here is not to directly antagonise Trump, not to escalate and makes things too personal. Because at some point, for all the talk of self-reliance and preparing for a new ‘long march’ and so on, China wants to get back to the table,” he said.

After the breakdown of trade talks and US moves to list Huawei and potentially other Chinese companies on a trade blacklist, voices within Chinese state and private media are growing more strident.

An editorial in the People’s Daily on Wednesday accused the US of “bullyism”, while a bulletin on the state broadcaster CCTV said the US was “delusional” if it believed “technological bullying” could contain China. “This shows some American politicians are extremely narrow-minded and cannot tolerate the normal pursuit of development and progress of other countries,” the announcer said.

The harsher sentiments appear to be resonating with the public. Earlier in the week, a song written by a former Chinese official about the trade war, set to the tune of a fight song featured in an anti-Japanese wartime film, had been viewed thousands of times on WeChat.

A clip of a CCTV news segment from last week promising that China would “fight to the end” was one of the top viewed posts on the microblogging site Weibo. And last weekend, a CCTV film channel aired a series of documentaries about the Korean war, when Chinese and US forces clashed. “We are using movies to echo the current era,” the broadcaster said on its Weibo account on Saturday.

But Mao-era levels of mobilisation or overzealous nationalism could turn into something difficult for authorities to control. In 2012, anti-Japanese riots erupted across Chinese cities over rights to disputed islands in the East China Sea.

The CCTV segment from Wednesday night garnered more than 1,100 comments, with many commentators supporting a harder government line. “Less slogans, more real strength,” one said.

“For China’s leadership, nationalism is a very useful part of a coherent super-narrative about China’s return to greatness under the leadership of the party,” Bandurski said. “But the party is insistent on keeping the party at the very centre of national pride.

“Anti-Americanism could very easily become a force the party cannot control.”