Margaret Thatcher's ­government imagined rounding up and imprisoning Scottish nationalists in the event of a possible nuclear war, previously secret official documents show.

Whitehall officials from the Ministry of Defence and the Foreign Office considered the fictional "Free Caledonia" group a threat to national security.

The papers, released under the 30-year rule, set out details of a 1983 "war game" in which top civil servants played the part of Mrs Thatcher and ministers during an imaginary nuclear showdown.

Officials envisioned an address to the nation by the Queen in which she refers to her father King George's wartime radio broadcasts, and reveals her son Andrew is fighting on the front line.

Secret documents have previously shown Mrs Thatcher's government was concerned about Scottish separatist groups.

Papers from 1980 released three years ago revealed fears army and naval bases could be at risk from Scottish nationalists after the 1979 devolution referendum.

A number of Scottish groups were listed alongside the IRA and INLA as potential terror threats, while chiefs warned Mrs Thatcher there was evidence extremist Scottish nationalists were trying to get weapons and explosives.

The document mentioned the Scottish National Liberation Army (SNLA), which in 1983 sent letter-bombs to Margaret Thatcher and the Princess of Wales.

The fictional war game revolved around a country called Orange, imagined to have elected a hard-line leadership in June 1982.

The files, never before made public, show officials imagined Orange had bombed UK military targets on March 4 1983, leading to a declaration of war.

The same day, the papers note, "police have rounded up Free Caledonia separatists".

They also show that 24,000 army reservists were called up and food rationing was introduced.

Under the scenario, cabinet ministers were also given guidance on the use of nuclear weapons.

By March 2 Orange had ­withdrawn from peace talks and invaded an imaginary country called "ArmourFleet". The next day Orange Bloc forces launch attacks on Denmark, West Germany, Italy Norway and Turkey.

The exercise also reveals civil service concerns about how the press would deal with the escalating emergency. They imagine the Sun newspaper reporting that if war was declared, every prisoner in Britain's jails – including murderers and rapists – would be released.

The day war breaks out a memo from the Paymaster General even considers press censorship, but concludes there are too few staff to enforce it.

During the Queen's address she recalls listening to her father speaking to the nation during Second World War.

"I have never forgotten the sorrow and the pride I felt as my sister and I huddled around the nursery wireless set listening to my father's inspiring words on that fateful day in 1939," officials imagined her saying.

"Not for a single moment did I imagine that this solemn and awful duty would one day fall to me. We all know that the dangers facing us today are greater by far than at any time in our long history.

"The enemy is not the soldier with his rifle nor even the airman prowling the skies above our cities and towns but the deadly power of abused technology.

"But whatever terrors lie in wait for us all the qualities that have helped to keep our freedom intact twice already during this sad century will once more be our strength.

She adds: "My message to you therefore is simple. Help those who cannot help themselves, give comfort to the lonely and the homeless and let your family become the focus of hope and life to those who need it. As we strive together to fight off the new evil let us pray for our country and men of goodwill wherever they may be. God Bless you all."

By March 6 officials imagine a million refugees across the UK as people flee cities. Orange also starts chemical attacks against land forces and has its nuclear weapons at "advanced readiness"

On March 8 the Sun uses a picture of Prince William with the words: "Keep him safe Charlie: we shall be needing him."

The same day the UK announces it is about to use "nuclear weapons of limited yield against military targets in countries of the Orange bloc, excluding Orange itself.

"This solemn decision was taken as a defensive measure in the face of unprovoked military aggression."

The next day, civil servants envision, the Orange leader asks for peace talks without preconditions.