/* Desktop-first layout audit, mobile landscape pass.
   The PC master CSS (rhythm.css + location-overlay.css) is unchanged.
   All offsets are measured from the fitted 16:9 main stage (cqw/cqh),
   rather than the device viewport or a set of fixed PC pixel values. */
html[data-mobile-device='true'] body[data-game='palace'].game-shell {
 --stage-top-gap:clamp(7px,1.25cqh,12px);
 --stage-edge-gap:clamp(8px,1.05cqw,18px);
 --stage-content-top:clamp(46px,8.6cqh,76px);
 --stage-bottom-gap:clamp(8px,1.8cqh,18px);
}

/* Expanded residence menu destinations: the PC panel below a slim top bar.
   Keep the existing menu contents and scroll; do not switch to a full screen
   overlay when the phone's CSS viewport height is below 500px. */
/* 宫中人物与宫中纪事 share a near-edge large paper;
   none inherit the generic mobile information panel's 46px top band. */
html[data-mobile-device='true'] body[data-game='palace'].game-shell #game.game-page:is([data-page='settings'],[data-page='saves'],[data-page='debug']) > #tab-content.game-content:not(.character-detail-page) {
 inset:var(--stage-content-top) var(--stage-edge-gap) var(--stage-bottom-gap);
 top:var(--stage-content-top);
 right:var(--stage-edge-gap);
 bottom:var(--stage-bottom-gap);
 left:var(--stage-edge-gap);
 min-width:0;
 min-height:0;
 overflow:auto;
 padding:clamp(8px,1.25cqw,14px);
 box-sizing:border-box;
}
html[data-mobile-device='true'] body[data-game='palace'].game-shell #game.game-page:not([data-page='home']):not([data-page='arrange']) > [data-return-home],
html[data-mobile-device='true'] body[data-game='palace'].game-shell #game.game-page[data-page='saves'] > [data-page-back] {
 top:var(--stage-top-gap);
 left:var(--stage-edge-gap);
 margin:0;
 min-height:clamp(28px,4.4cqh,36px);
 padding:4px 9px;
}
/* Right-hand date/information stays in a compact header strip, rather than
   consuming one-third of the shorter phone viewport. */
html[data-mobile-device='true'] body[data-game='palace'].game-shell #game.game-page:not([data-page='home']):not([data-page='arrange']) > .game-hud {
 top:var(--stage-top-gap);
 left:clamp(123px,21cqw,180px);
 right:var(--stage-edge-gap);
 width:auto;
 max-height:clamp(38px,10cqh,62px);
 min-height:0;
 gap:5px;
 align-items:flex-start;
 justify-content:flex-end;
 overflow-x:auto;
 overflow-y:hidden;
 padding:0;
}
html[data-mobile-device='true'] body[data-game='palace'] #game.game-page:not([data-page='home']):not([data-page='arrange']) > .game-hud .hud-clock {
 padding:4px 7px;
 line-height:1.25;
}
html[data-mobile-device='true'] body[data-game='palace'] #game.game-page:not([data-page='home']):not([data-page='arrange']) > .game-hud .hud-updates button {
 min-height:28px;
 width:auto;
 margin:0;
 padding:3px 6px;
}

/* In the "人物" and "我的面板" detail views, keep the desktop's
   three-part relationship row, rather than the legacy <700px two-row mode. */
html[data-mobile-device='true'] body[data-game='palace'] #game:is([data-page='character'],[data-page='panel']) .character-detail-page .relationship-row {
 grid-template-columns:3.2em minmax(74px,1fr) minmax(5.5em,auto);
 gap:clamp(4px,.9cqw,10px);
}
html[data-mobile-device='true'] body[data-game='palace'] #game:is([data-page='character'],[data-page='panel']) .character-detail-page .relationship-meter,
html[data-mobile-device='true'] body[data-game='palace'] #game:is([data-page='character'],[data-page='panel']) .character-detail-page .relationship-label {
 grid-column:auto;
}
html[data-mobile-device='true'] body[data-game='palace'] #game:is([data-page='character'],[data-page='panel']) .character-detail-page .relationship-label {
 text-align:right;
}

/* Shared ordinary location frame: 御苑(garden), 凤仪宫(queen-palace),
   太医院(medical), 永寿宫(dowager-palace), 文澜阁(archive).
   All keep the PC placement model: upper-left navigation + place name,
   upper-right clock, left-side people, right-side actions. */
html[data-mobile-device='true'] body[data-game='palace'].game-shell #game[data-page='arrange'] > .location-nav {
 left:var(--stage-edge-gap);
 top:var(--stage-top-gap);
 gap:clamp(3px,.5cqw,6px);
 max-width:54%;
}
html[data-mobile-device='true'] body[data-game='palace'] #game[data-page='arrange'] .location-nav > button {
 min-height:clamp(28px,4.2cqh,36px);
 padding:4px 7px;
 line-height:1.25;
}
html[data-mobile-device='true'] body[data-game='palace'].game-shell #game[data-page='arrange'] > .game-hud {
 top:var(--stage-top-gap);
 right:var(--stage-edge-gap);
 left:auto;
 width:max-content;
 max-width:40%;
 /* The clock and combined notices remain scrollable on short landscape screens. */
 max-height:clamp(146px,42cqh,220px);
 gap:3px;
 align-items:flex-end;
 overflow-x:hidden;
 overflow-y:auto;
}
/* Only the right-hand HUD scrolls; the combined notice stays readable. */
html[data-mobile-device='true'] body[data-game='palace'] #game[data-page='arrange'] .game-hud > .home-formal-events {
 flex:none;
 width:max-content;
 max-width:100%;
 min-width:0;
}
html[data-mobile-device='true'] body[data-game='palace'] #game[data-page='arrange'] .hud-clock {
 padding:4px 7px;
 line-height:1.25;
}
html[data-mobile-device='true'] body[data-game='palace'] #game[data-page='arrange'] .hud-clock > strong {
 line-height:1.3;
 white-space:normal;
}
html[data-mobile-device='true'] body[data-game='palace'] #game[data-page='arrange'] .hud-clock > small {
 line-height:1.35;
 white-space:normal;
}
html[data-mobile-device='true'] body[data-game='palace'] #tab-content.location-stage:is([data-location-id='garden'],[data-location-id='queen-palace'],[data-location-id='medical'],[data-location-id='dowager-palace'],[data-location-id='archive'],[data-location-id='palace-path'],[data-location-id='water-pavilion']) > .location-actions {
 min-height:0; overflow-x:hidden;
}
/* Menu level 1 and level 2 retain PC's column and interaction. On mobile
   rows are shorter and the submenu is scrollable, never cropped at bottom. */
html[data-mobile-device='true'] body[data-game='palace'] #tab-content.location-stage .location-action-groups {
 gap:clamp(4px,.8cqh,8px);
 overflow-y:auto;
 justify-content:center;
}
html[data-mobile-device='true'] body[data-game='palace'] #tab-content.location-stage .location-action-groups > .location-group-button {
 flex:none;
 width:100%;
 min-height:clamp(30px,5.7cqh,42px);
 margin:0;
 padding:4px 8px;
 line-height:1.3;
 white-space:normal;
}
html[data-mobile-device='true'] body[data-game='palace'] #tab-content.location-stage .location-actions-submenu {
 justify-content:flex-start;
 overflow:auto;
 padding-right:2px;
}
html[data-mobile-device='true'] body[data-game='palace'] #tab-content.location-stage .location-action-submenu-head {
 gap:5px;
 padding:2px 0 4px;
 margin-bottom:5px;
}
html[data-mobile-device='true'] body[data-game='palace'] #tab-content.location-stage .location-actions-submenu > button,
html[data-mobile-device='true'] body[data-game='palace'] #tab-content.location-stage .location-actions-submenu > .game-action button {
 min-height:30px;
 margin:2px 0;
 padding:4px 7px;
 line-height:1.3;
}
/* Short-stage scheduled hints stay near the PC-equivalent upper-left zone. */
html[data-mobile-device='true'] body[data-game='palace'] #tab-content.location-stage > .scheduled-notice {
 top:clamp(65px,20cqh,145px);
 left:var(--stage-edge-gap);
 width:38%;
 max-height:26%;
 overflow:auto;
}
