A standard setting phrase in Chinese historical fiction and palace dramas (
宫廷剧) — think 《
甄嬛传》 (Empresses in the Palace) or 《
延禧攻略》 (Story of Yanxi Palace).
宫 alone usually refers to imperial residences (
故宫 Forbidden City);
宫中 places the action 'inside' that world.