/* A single folio geometry for 风波 / 近侍 / 人物列表.
   The three stages show the same wooden backdrop and the same amount of frame.
   Their content scrolls INSIDE the fixed parchment, never the wood frame. */
html body[data-game='palace'] #game:is([data-page='investigation'],[data-page='attendant'],[data-roster-page='true'],[data-page='saves'],[data-page='family'],[data-page='sentiment']) > #tab-content.game-content .palace-ledger-folio {
 width:calc(100% - clamp(42px,7cqw,128px));
 max-width:1320px;
 min-width:0;min-height:0;
 flex:1 1 auto;box-sizing:border-box;
 margin:0 auto clamp(14px,3.4cqh,30px);
 padding:clamp(10px,1.5cqw,23px);
 border:1px solid #b394616f;border-radius:12px;
 background:rgba(255,248,233,.76);
 box-shadow:0 4px 18px #4f391d17,inset 0 0 12px #ffffff47;
 position:relative;isolation:isolate;overflow:hidden;
}
html body[data-game='palace'].game-shell #game[data-browse='true'][data-page='characters'][data-roster-page='true'] {
 display:block;position:relative;box-sizing:border-box;
 padding:clamp(10px,2cqh,24px) clamp(12px,2cqw,34px);
 color:#574535;
 background:linear-gradient(rgba(250,240,221,.1),rgba(250,240,221,.16)),
  var(--palace-quiet-folio-image) center / cover;
}
html body[data-game='palace'] #game[data-roster-page='true'] > :is(.game-hud,.game-background,[data-return-home]) {
 display:none;
}
html body[data-game='palace'].game-shell #game[data-page='characters'][data-roster-page='true'] > #tab-content.game-content.character-roster-page {
 position:relative;inset:auto;
 display:flex;flex-direction:column;gap:clamp(8px,1.5cqh,18px);
 box-sizing:border-box;width:100%;height:100%;max-height:none;
 margin:0;padding:0;overflow:hidden!important;
 color:#574535;background:none;border:0;border-radius:0;box-shadow:none;backdrop-filter:none;
}
#game[data-roster-page='true'] .character-roster-heading {
 display:flex;justify-content:flex-start;align-items:center;min-width:0;flex:none;
 gap:clamp(12px,2cqw,34px);padding-right:48px;
}
#game[data-roster-page='true'] .character-roster-heading > h2 {
 margin:0;font-size:calc((clamp(19px,2cqw,30px)) * var(--text-scale));line-height:1.4;color:#60472f;
}
#game[data-roster-page='true'] .character-roster-heading > button[data-browse-back] {
 flex:none;min-height:32px;margin:0;
 font-size:var(--font-body);
}
/* The folio owns the ornate corners. The inner columns are free to scroll. */
#game[data-page='investigation'] .clue-board-folio,
#game[data-roster-page='true'] .character-roster-folio {
 display:flex;flex-direction:column;gap:clamp(6px,1cqh,12px);
}
#game[data-page='investigation'] .clue-board-folio > .dossier-ornament,
#game[data-roster-page='true'] .character-roster-folio > .dossier-ornament {
 position:absolute;opacity:.24;z-index:0;pointer-events:none;
}
#game[data-page='investigation'] .clue-board-folio > .dossier-corner-top,
#game[data-roster-page='true'] .character-roster-folio > .dossier-corner-top {
 top:0;right:0;width:clamp(54px,9cqw,120px);
}
#game[data-page='investigation'] .clue-board-folio > .dossier-corner-bottom,
#game[data-roster-page='true'] .character-roster-folio > .dossier-corner-bottom {
 bottom:0;left:0;width:clamp(54px,9cqw,120px);
}
#game[data-page='investigation'] .clue-board-folio > .clue-board-scroll,
#game[data-roster-page='true'] .character-roster-folio > .character-roster-scroll {
 position:relative;z-index:1;
 flex:1 1 auto;min-height:0;min-width:0;
 overflow-x:hidden;overflow-y:auto;
 scrollbar-width:thin;scrollbar-color:#aa8a5955 transparent;
}
/* A single uninterrupted sheet: each part of the clue board becomes a subtle
   section, not another thick rounded parchment stacked on the first one. */
#game[data-page='investigation'] .clue-board-folio .clue-paper {
 margin:0 0 clamp(8px,1.4cqh,16px);padding:clamp(7px,1.1cqw,14px) 0 clamp(9px,1.4cqh,16px);
 background:none;border:0;border-bottom:1px solid rgba(163,132,82,.22);
 border-radius:0;box-shadow:none;backdrop-filter:none;
}
#game[data-page='investigation'] .clue-board-folio .clue-paper:last-child {
 border-bottom:0;margin-bottom:0;
}
#game[data-page='investigation'] .clue-board-folio .clue-paper > .dossier-ornament {
 display:none;
}
@media (orientation:landscape) and (max-height:450px) {
 html body[data-game='palace'] #game:is([data-page='investigation'],[data-page='attendant'],[data-roster-page='true'],[data-page='saves'],[data-page='family'],[data-page='sentiment']) > #tab-content.game-content .palace-ledger-folio {
  width:calc(100% - clamp(28px,5cqw,78px));
  margin-bottom:clamp(8px,2cqh,14px);
  padding:clamp(7px,1cqw,14px);
 }
 html body[data-game='palace'] #game[data-roster-page='true'] {
  padding:7px 10px;
 }
 #game[data-roster-page='true'] .character-roster-heading > h2 {
  font-size:var(--font-heading);
 }
}

/* 存读档 uses the same wooden backdrop and decorated paper as 近侍/风波.
   A deliberately smaller folio keeps all six slots inside one scrollable sheet. */
html body[data-game='palace'].game-shell #game[data-browse='true'][data-page='saves'] {
 display:block;position:relative;box-sizing:border-box;
 /* Shift the whole heading and folio together without crowding their controls. */
 padding:clamp(4px,.6cqh,8px) clamp(12px,2cqw,34px) clamp(22px,4.2cqh,44px);
 color:#574535;
 background:linear-gradient(rgba(250,240,221,.1),rgba(250,240,221,.16)),
  var(--palace-quiet-folio-image) center / cover;
}
html body[data-game='palace'] #game[data-page='saves'] > :is(.game-hud,.game-background,[data-return-home]) {display:none;}
html body[data-game='palace'].game-shell #game[data-browse='true'][data-page='saves'] > #tab-content.game-content.save-page {
 position:relative;inset:auto;display:flex;flex-direction:column;
 gap:clamp(8px,1.5cqh,18px);box-sizing:border-box;
 width:100%;height:100%;min-width:0;min-height:0;max-height:none;
 margin:0;padding:0;overflow:hidden;
 grid-column:auto;grid-row:auto;
 color:#574535;background:none;border:0;border-radius:0;
 box-shadow:none;backdrop-filter:none;
}
/* Override the legacy mobile browse inset which forced a large empty top band. */
html[data-mobile-device='true'] body[data-game='palace'].game-shell #game.game-page[data-browse='true'][data-page='saves'] > #tab-content.game-content.save-page {
 position:relative;inset:auto;top:auto;right:auto;bottom:auto;left:auto;
 width:100%;height:100%;padding:0;overflow:hidden;
}
:is(#game[data-page='saves'],.unified-save-dialog) .save-page-heading {
 display:flex;align-items:center;justify-content:flex-start;flex:none;
 gap:clamp(12px,2cqw,34px);padding-right:48px;min-width:0;margin:0;
}
:is(#game[data-page='saves'],.unified-save-dialog) .save-page-heading > h2 {
 margin:0;font-size:calc((clamp(19px,2cqw,30px)) * var(--text-scale));line-height:1.4;color:#60472f;
}
:is(#game[data-page='saves'],.unified-save-dialog) .save-page-heading > button {
 flex:none;width:auto;margin:0;min-height:32px;font-size:var(--font-body);
}
html body[data-game='palace'] :is(#game[data-page='saves'],.unified-save-dialog) > #tab-content.game-content .save-page-folio {
 display:flex;flex-direction:column;
 width:min(84cqw,1080px);max-width:calc(100% - clamp(12px,3cqw,50px));
 margin:0 auto clamp(12px,2.6cqh,26px);
 padding:clamp(12px,1.65cqw,24px);
}
:is(#game[data-page='saves'],.unified-save-dialog) .save-page-folio > .dossier-ornament {
 position:absolute;z-index:0;opacity:.22;pointer-events:none;
}
:is(#game[data-page='saves'],.unified-save-dialog) .save-page-folio > .dossier-corner-top {
 top:0;right:0;width:clamp(54px,9cqw,120px);
}
:is(#game[data-page='saves'],.unified-save-dialog) .save-page-folio > .dossier-corner-bottom {
 bottom:0;left:0;width:clamp(54px,9cqw,120px);
}
:is(#game[data-page='saves'],.unified-save-dialog) .save-page-scroll {
 position:relative;z-index:1;flex:1 1 auto;min-width:0;min-height:0;
 overflow-x:hidden;overflow-y:auto;overscroll-behavior:contain;
 scrollbar-width:thin;scrollbar-color:#aa8a5955 transparent;
 padding:0 clamp(2px,.5cqw,7px) clamp(6px,1.2cqh,14px) 0;
}
:is(#game[data-page='saves'],.unified-save-dialog) .save-page-scroll > h3.dossier-section-heading {
 display:flex;align-items:center;gap:clamp(5px,.75cqw,10px);
 margin:0 0 clamp(5px,1cqh,10px);font-size:var(--font-section);
 font-weight:600;line-height:1.4;color:#694b2e;letter-spacing:.06em;
}
:is(#game[data-page='saves'],.unified-save-dialog) .save-page-scroll > h3.dossier-section-heading:not(:first-child) {
 margin-top:clamp(12px,2cqh,20px);
}
:is(#game[data-page='saves'],.unified-save-dialog) .save-page-scroll .dossier-heading-flower {
 width:clamp(20px,2.6cqw,36px);height:clamp(18px,3.4cqh,30px);
}
:is(#game[data-page='saves'],.unified-save-dialog) .save-page-scroll .dossier-heading-line {
 height:1px;flex:1;min-width:8px;background:linear-gradient(90deg,#b3946177,#b3946118);
}
:is(#game[data-page='saves'],.unified-save-dialog) .save-page-scroll .dossier-heading-end {
 width:clamp(22px,3.5cqw,45px);height:clamp(12px,2cqh,20px);
}
:is(#game[data-page='saves'],.unified-save-dialog) .save-slot-grid {
 display:grid;grid-template-columns:repeat(3,minmax(0,1fr));
 gap:clamp(8px,1.3cqw,16px);
}
:is(#game[data-page='saves'],.unified-save-dialog) .save-slot {
 display:flex;flex-direction:column;justify-content:space-between;gap:clamp(7px,1cqh,12px);
 min-width:0;box-sizing:border-box;padding:clamp(10px,1.35cqw,17px);
 margin:0;border:1px solid rgba(151,117,74,.34);border-radius:9px;
 background:rgba(255,252,245,.46);box-shadow:inset 0 1px rgba(255,255,255,.35);
}
:is(#game[data-page='saves'],.unified-save-dialog) .save-slot-auto {
 flex-direction:row;align-items:center;gap:clamp(12px,2cqw,24px);
 background:rgba(252,245,227,.62);
}
:is(#game[data-page='saves'],.unified-save-dialog) .save-slot-info {min-width:0;flex:1;}
:is(#game[data-page='saves'],.unified-save-dialog) .save-slot h3 {
 margin:0 0 clamp(5px,.8cqh,10px);
 font-size:var(--font-heading);line-height:1.4;color:#65492f;
}
:is(#game[data-page='saves'],.unified-save-dialog) .save-meta {
 display:flex;flex-direction:column;gap:2px;min-height:0;margin:0;
 font-size:var(--font-note);line-height:1.5;color:#6c5944;
 overflow-wrap:anywhere;
}
:is(#game[data-page='saves'],.unified-save-dialog) .save-meta strong {font-weight:600;color:#59432e;}
:is(#game[data-page='saves'],.unified-save-dialog) .save-meta p {margin:0;color:#8b755d;}
:is(#game[data-page='saves'],.unified-save-dialog) .save-meta small {opacity:1;color:#8b755d;font-size:var(--font-note);}
:is(#game[data-page='saves'],.unified-save-dialog) .save-slot-actions {
 display:flex;align-items:center;flex-wrap:wrap;gap:clamp(5px,.7cqw,9px);min-width:0;
}
/* Keep the shared save controls compact even inside #intro's full-width story-button rules. */
:is(#game[data-page='saves'],.unified-save-dialog) .save-slot-actions > button {
 flex:0 1 auto;width:auto;min-width:clamp(55px,5.5cqw,76px);
 min-height:clamp(32px,4.5cqh,40px);
 padding:5px clamp(8px,.9cqw,12px);margin:0;
 font-size:var(--font-body);line-height:1.35;text-align:center;
 border:1px solid rgba(140,108,70,.39);border-radius:7px;
 background:linear-gradient(180deg,rgba(255,253,247,.94),rgba(247,237,217,.85));
 color:#59432c;box-shadow:0 1px 3px rgba(65,48,29,.06);
 cursor:pointer;
}
:is(#game[data-page='saves'],.unified-save-dialog) .save-slot-actions > button:hover:not(:disabled) {
 background:#fffaf0;border-color:rgba(132,92,46,.6);
}
:is(#game[data-page='saves'],.unified-save-dialog) .save-slot-actions > button:focus-visible {
 outline:2px solid #8d6545;outline-offset:2px;
}
:is(#game[data-page='saves'],.unified-save-dialog) .save-slot-actions > small {
 color:#806c55;font-size:var(--font-note);line-height:1.5;
}
@media (orientation:landscape) and (max-height:500px) {
 html body[data-game='palace'] :is(#game[data-page='saves'],.unified-save-dialog) > #tab-content.game-content .save-page-folio {
  width:min(88cqw,1080px);max-width:calc(100% - 10px);
  padding:clamp(8px,1.2cqw,15px);margin-bottom:clamp(6px,1cqh,12px);
 }
 :is(#game[data-page='saves'],.unified-save-dialog) .save-slot-grid {grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;}
 :is(#game[data-page='saves'],.unified-save-dialog) .save-slot {padding:8px 10px;gap:6px;}
 :is(#game[data-page='saves'],.unified-save-dialog) .save-slot-auto {padding:9px 12px;}
 :is(#game[data-page='saves'],.unified-save-dialog) .save-page-scroll > h3.dossier-section-heading:not(:first-child) {margin-top:9px;}
}
@media (orientation:portrait) and (max-width:700px) {
 :is(#game[data-page='saves'],.unified-save-dialog) .save-slot-grid {grid-template-columns:1fr;}
 :is(#game[data-page='saves'],.unified-save-dialog) .save-slot-auto {align-items:stretch;flex-direction:column;}
 html body[data-game='palace'] :is(#game[data-page='saves'],.unified-save-dialog) > #tab-content.game-content .save-page-folio {
  width:94%;max-width:94%;
 }
}


/* Shared folio sidebar — 宫务、我的谋划、家书 */
/* A quiet binding line and a small gold flower turn the three navigations into
   one consistent chapter index. The corner decoration belongs to the folio,
   so these buttons deliberately do not add a second framed card. */
#game:is([data-page='investigation'],[data-page='family']) .folio-side-tabs {
 position:relative;isolation:isolate;display:flex;flex-direction:column;
 align-items:stretch;min-width:0;
 gap:clamp(6px,.85cqh,11px);
 margin:0;
 padding:clamp(8px,1.2cqh,14px) clamp(6px,1cqw,13px) clamp(9px,1.3cqh,16px) clamp(13px,1.5cqw,20px);
 border:0;
 background:transparent;
}
#game[data-page='investigation'] .folio-side-tabs {
 border-right:1px solid rgba(159,121,75,.2);
}
#game:is([data-page='investigation'],[data-page='family']) .folio-side-tabs::before {
 content:"";position:absolute;
 top:clamp(4px,.6cqh,8px);bottom:clamp(8px,1.2cqh,14px);
 left:clamp(4px,.5cqw,7px);width:1px;
 background:linear-gradient(180deg,rgba(180,141,85,.04),rgba(158,110,52,.57) 23%,rgba(158,110,52,.43) 76%,rgba(180,141,85,.03));
 pointer-events:none;
}
#game:is([data-page='investigation'],[data-page='family']) .folio-side-tabs::after {
 content:"";position:absolute;bottom:clamp(6px,.9cqh,11px);
 left:clamp(1px,.26cqw,4px);
 width:7px;height:7px;border-radius:50%;
 border:1px solid rgba(168,126,71,.38);
 background:radial-gradient(circle,rgba(185,146,84,.46) 0 27%,transparent 34%);
 pointer-events:none;
}
#game:is([data-page='investigation'],[data-page='family']) .folio-side-tabs > button {
 position:relative;z-index:1;display:flex;align-items:center;justify-content:flex-start;
 gap:clamp(5px,.8cqw,11px);
 width:100%;min-width:0;min-height:clamp(38px,5.5cqh,51px);
 margin:0;padding:clamp(7px,1cqh,11px) clamp(7px,.85cqw,12px);
 border:1px solid transparent;border-left:2px solid transparent;
 border-radius:3px 7px 7px 3px;
 box-shadow:none;background:transparent;color:#765e43;
 text-align:left;white-space:normal;
 font-family:inherit;font-size:var(--folio-menu-font,var(--font-body));font-weight:500;
 letter-spacing:.045em;line-height:1.35;
 cursor:pointer;
 transition:background .16s ease,border-color .16s ease,box-shadow .16s ease,color .16s ease;
}
#game:is([data-page='investigation'],[data-page='family']) .folio-side-tabs .folio-menu-flower.dossier-ornament {
 display:block;position:static;inset:auto;flex:none;
 width:clamp(13px,1.5cqw,21px);height:clamp(13px,1.8cqh,21px);
 max-width:none;max-height:none;object-fit:contain;
 opacity:0;transform:scale(.84);pointer-events:none;
 transition:opacity .16s ease,transform .16s ease;
}
#game:is([data-page='investigation'],[data-page='family']) .folio-side-tabs .folio-menu-label {
 flex:1 1 auto;min-width:0;overflow-wrap:normal;
}
#game:is([data-page='investigation'],[data-page='family']) .folio-side-tabs > button[aria-pressed='true'] {
 color:#51391f;font-weight:600;
 border-color:rgba(161,119,63,.27);
 border-left-color:#a77b41;
 background:linear-gradient(100deg,rgba(211,174,112,.33) 0%,rgba(241,220,185,.42) 57%,rgba(255,250,240,.24) 100%);
 box-shadow:inset 0 1px rgba(255,254,246,.65),0 2px 7px rgba(94,61,31,.055);
}
#game:is([data-page='investigation'],[data-page='family']) .folio-side-tabs > button[aria-pressed='true'] .folio-menu-flower {
 opacity:.92;transform:scale(1);
}
#game:is([data-page='investigation'],[data-page='family']) .folio-side-tabs > button:hover:not([aria-pressed='true']) {
 color:#654727;border-color:rgba(168,123,65,.12);
 background:rgba(235,217,185,.3);
}
#game:is([data-page='investigation'],[data-page='family']) .folio-side-tabs > button:hover:not([aria-pressed='true']) .folio-menu-flower {
 opacity:.53;transform:scale(.93);
}
#game:is([data-page='investigation'],[data-page='family']) .folio-side-tabs > button:focus-visible {
 outline:2px solid #967042;outline-offset:2px;
}
#game[data-page='investigation'] .folio-side-tabs .clue-mine-count {
 flex:none;min-width:1.35em;padding:1px 4px;
 border-radius:3px;background:rgba(167,126,72,.075);
 color:#947b5e;font-size:var(--font-note);font-weight:400;text-align:center;
}
#game[data-page='investigation'] .folio-side-tabs > button[aria-pressed='true'] .clue-mine-count {
 background:rgba(255,252,243,.47);color:#775938;
}
@container (max-width:780px) {
 #game[data-page='investigation'] .folio-side-tabs {
  padding-left:13px;padding-right:6px;gap:5px;
 }
 #game[data-page='investigation'] .folio-side-tabs > button {
  min-height:34px;gap:5px;padding:6px 5px;
  letter-spacing:0;
 }
 #game[data-page='investigation'] .folio-side-tabs .folio-menu-flower.dossier-ornament {
  width:13px;height:14px;
 }
 #game[data-page='investigation'] .folio-side-tabs .clue-mine-count {padding:0 3px;}
}
@media (orientation:landscape) and (max-height:450px) {
 #game:is([data-page='investigation'],[data-page='family']) .folio-side-tabs {
  gap:4px;padding-top:5px;padding-bottom:7px;
 }
 #game:is([data-page='investigation'],[data-page='family']) .folio-side-tabs > button {
  min-height:33px;padding:5px 7px;
 }
}

/* Compact, read-only usage estimate shared by the saved-game folio and dialogs. */
:is(#game[data-page='saves'],.unified-save-dialog) .save-storage-summary {
 flex:none;max-width:100%;margin:0;padding:0 clamp(3px,.6cqw,9px);
 font-size:var(--font-note);line-height:1.35;color:#79634c;
}

/* Save modal in an active scene reuses exactly the regular six-slot folio. */
html body[data-game='palace']:is(.game-shell,.frame-opening) :is(#game,#intro) .unified-save-dialog {
 position:fixed;inset:0;box-sizing:border-box;margin:auto;
 width:min(94cqw,1080px);height:min(91cqh,720px);
 max-width:94vw;max-height:92svh;min-height:0;overflow:hidden;
 padding:clamp(8px,1.4cqw,20px);
 border:1px solid #a48962;border-radius:12px;
 color:#574535;background:#f4ecdc;
 box-shadow:0 14px 48px rgba(23,20,13,.35);
}
html body[data-game='palace']:is(.game-shell,.frame-opening) :is(#game,#intro) .unified-save-dialog::backdrop {background:rgba(24,24,22,.56);}
html body[data-game='palace']:is(.game-shell,.frame-opening) :is(#game,#intro) .unified-save-dialog > #tab-content.game-content.save-page {
 position:relative;inset:auto;display:flex;flex-direction:column;
 gap:clamp(7px,1.2cqh,14px);box-sizing:border-box;
 width:100%;height:100%;min-width:0;min-height:0;
 margin:0;padding:0;overflow:hidden;
 color:#574535;background:none;border:0;box-shadow:none;
}
html body[data-game='palace']:is(.game-shell,.frame-opening) :is(#game,#intro) .unified-save-dialog > #tab-content.game-content .save-page-folio {
 flex:1 1 auto;min-height:0;border:1px solid #b394616f;
 border-radius:12px;background:rgba(255,248,233,.76);
 box-shadow:0 4px 18px #4f391d17,inset 0 0 12px #ffffff47;
 position:relative;isolation:isolate;overflow:hidden;
}
