/* ===== v6：固定视口与诸侯争霸工作台 ===== */
:root { --footer-h: 24px; }
html, body { width:100%; height:100%; overflow:hidden !important; }
body { min-width:0; }
#app { height:calc(100dvh - var(--footer-h)); min-height:0; }
#history-note { height:var(--footer-h); display:grid; place-items:center; color:#77694f; background:#eee3c8; border-top:1px solid rgba(150,101,31,.25); font:12px/1.2 var(--body-font); letter-spacing:1px; }
#game-screen, #main-row, #screen-root { min-height:0; }
#screen-root { overflow:hidden; padding:10px; display:grid; grid-template-rows:minmax(0,1fr) auto; }
#screen-root > .panel, #screen-root > .v6-page { min-height:0; height:100%; overflow:hidden; }
.panel-body { min-height:0; overflow:auto; }
.v6-page { display:grid; grid-template-rows:auto minmax(0,1fr); background:rgba(251,246,232,.96); border:1px solid var(--border-light); box-shadow:var(--shadow); }
.v6-heading { min-height:60px; display:flex; align-items:center; justify-content:space-between; padding:9px 16px; border-bottom:1px solid var(--line); background:linear-gradient(#fbf5e4,#efe0be); }
.v6-heading h2 { margin:2px 0 0; color:#58380e; font:700 24px var(--serif); letter-spacing:4px; }
.v6-scroll { min-height:0; overflow:auto; padding:14px; overscroll-behavior:contain; }
.court-tabs { height:48px; display:grid; grid-template-columns:repeat(12,minmax(52px,1fr)) auto; gap:4px; padding:5px; overflow-x:auto; background:linear-gradient(#f7eed8,#e7d3a9); border:1px solid var(--border); border-top:0; box-shadow:0 -4px 15px rgba(60,40,15,.08); }
.court-tabs button { min-width:58px; padding:5px 7px; border:1px solid rgba(151,105,33,.35); background:#fff9e9; color:#4e3b22; cursor:pointer; font:700 13px var(--body-font); white-space:nowrap; }
.court-tabs button:hover { color:#fff; background:var(--jade); }
.court-tabs .court-home { color:#fff; background:var(--cinnabar); }
.weekly-limit { display:inline-flex; align-items:center; padding:4px 9px; color:#145c51; background:#e2f0e8; border:1px solid rgba(36,117,106,.35); border-radius:2px; font:700 12px var(--body-font); }
.court-summary { display:grid; grid-template-columns:repeat(4,minmax(150px,1fr)); gap:10px; }
.system-card { min-height:86px; display:flex; flex-direction:column; align-items:flex-start; justify-content:center; gap:6px; padding:13px; color:#3d311f; background:#fffaf0; border:1px solid var(--line); cursor:pointer; text-align:left; }
.system-card b { color:#65420e; font-size:17px; letter-spacing:2px; }
.system-card span { color:#76664d; font:12px/1.45 var(--body-font); }
.system-card.primary { background:linear-gradient(135deg,#fff4ca,#e8c66f); border-color:#aa7621; }
.system-card:hover { border-color:var(--jade); box-shadow:inset 4px 0 var(--jade); }
.scene-banner { min-height:86px; margin-bottom:13px; display:flex; align-items:center; gap:16px; padding:16px 20px; color:white; border:1px solid rgba(255,255,255,.3); box-shadow:0 8px 20px rgba(40,25,10,.18); }
.scene-banner b { font:700 25px var(--serif); letter-spacing:5px; }
.scene-banner span:not(.weekly-limit) { flex:1; line-height:1.6; }
.visit-scene { background:linear-gradient(110deg,#547d4c,#b07f35); }
.prison-scene { background:linear-gradient(110deg,#272b34,#695132); }
.scene-banner .weekly-limit { color:#fff; background:rgba(255,255,255,.14); border-color:rgba(255,255,255,.5); }
.action-grid { display:grid; grid-template-columns:repeat(4,minmax(170px,1fr)); gap:10px; }
.action-grid article, .target-grid article, .city-manage-grid article { padding:13px; background:#fffaf0; border:1px solid var(--line); box-shadow:0 4px 12px rgba(50,35,15,.07); }
.action-grid article.active { border-color:var(--jade); box-shadow:inset 4px 0 var(--jade); }
.action-grid h3, .target-grid h3, .city-manage-grid h3 { margin-bottom:7px; color:#65420e; letter-spacing:2px; }
.action-grid p, .target-grid p, .city-manage-grid p, .page-note { margin-bottom:10px; color:#71634c; line-height:1.6; }
.target-grid, .city-manage-grid { display:grid; grid-template-columns:repeat(3,minmax(210px,1fr)); gap:10px; }
.case-list, .army-list, .delegate-list { display:grid; gap:9px; }
.case-list article, .army-list article, .delegate-list article { display:flex; align-items:center; justify-content:space-between; gap:14px; padding:12px 14px; background:#fffaf0; border:1px solid var(--line); }
.case-list h3, .army-list h3, .delegate-list h3 { color:#5b3b12; }
.case-list span { color:#7c6b50; }
.city-manage-grid header, .meter-row, .route-summary { display:flex; justify-content:space-between; gap:12px; align-items:center; }
.city-manage-grid header b { color:var(--jade); }
.meter-row { margin:9px 0; padding:7px; background:#f0e6cd; }
.relation-grid { display:grid; grid-template-columns:repeat(4,minmax(150px,1fr)); gap:8px; }
.relation-grid article { display:grid; gap:4px; padding:10px; background:#fffaf0; border:1px solid var(--line); }
.relation-grid span { color:var(--jade); }
.relation-grid small { color:#76664d; }
.route-summary, .rule-strip { margin-bottom:12px; padding:10px 13px; background:#edf5e9; border-left:4px solid var(--jade); }
.rule-strip { display:flex; justify-content:space-around; gap:12px; }
.section-title { margin:15px 0 9px; color:#65420e; letter-spacing:3px; }
.training-list { display:grid; grid-template-columns:repeat(3,minmax(210px,1fr)); gap:8px; }
.training-list article { display:grid; grid-template-columns:1fr auto; align-items:center; gap:5px 10px; padding:10px; background:#fffaf0; border:1px solid var(--line); }
.training-list article div { grid-column:1/-1; display:flex; gap:4px; }
.training-list article div button { flex:1; padding:4px; background:#f2e4c5; border:1px solid var(--line); cursor:pointer; }
.emperor-btn { display:block; margin:18px auto 5px; }
.army-create { display:grid; grid-template-columns:1fr 1fr 1.2fr auto; gap:8px; margin-bottom:12px; }
.army-create select, .army-create input, .custom-difficulty input, .setting-row select { min-height:36px; padding:5px 8px; border:1px solid var(--line); background:#fffdf7; }
.chronicle { position:relative; display:grid; gap:0; padding-left:20px; }
.chronicle:before { content:""; position:absolute; left:7px; top:8px; bottom:8px; width:2px; background:var(--gold); }
.chronicle article { position:relative; display:grid; grid-template-columns:100px 70px 1fr; gap:10px; padding:9px 12px; border-bottom:1px solid var(--line); }
.chronicle article:before { content:""; position:absolute; left:-17px; top:16px; width:9px; height:9px; border-radius:50%; background:var(--cinnabar); }
.chronicle time { color:#806329; }
.chronicle p { user-select:text; }
.encyclopedia { display:grid; grid-template-columns:repeat(2,1fr); gap:10px; }
.encyclopedia details { padding:12px 14px; background:#fffaf0; border:1px solid var(--line); }
.encyclopedia summary { color:#62400f; font-weight:700; cursor:pointer; }
.encyclopedia p { margin-top:8px; color:#6e604a; line-height:1.7; user-select:text; }
.palace-quick { display:flex; gap:7px; flex-wrap:wrap; margin-top:10px; }
.harem-expansion { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin:12px; }
.harem-expansion div { padding:9px; display:grid; gap:4px; background:#fff5e7; border:1px solid var(--line); }
.tactic-picker { margin:10px 0; display:grid; grid-template-columns:repeat(2,1fr); gap:6px; }
.tactic-picker > b { grid-column:1/-1; color:#65420e; }
.tactic-picker label { display:grid; grid-template-columns:auto 1fr; gap:2px 7px; padding:7px; border:1px solid var(--line); cursor:pointer; }
.tactic-picker small { grid-column:2; color:#76664d; }
.difficulty-modal { box-sizing:border-box; width:min(1080px,calc(100vw - 28px)); height:min(650px,calc(100dvh - 28px)); max-width:none !important; max-height:none !important; overflow:hidden !important; padding:18px 20px !important; }
.difficulty-layout { width:100%; height:100%; min-width:0; min-height:0; display:grid; grid-template-columns:220px minmax(0,1fr); gap:14px; }
.difficulty-layout aside { display:grid; grid-template-rows:repeat(5,1fr); gap:7px; }
.difficulty-card { display:flex; justify-content:center; align-items:center; padding:12px; color:#554226; background:#f8efd9; border:1px solid var(--line); cursor:pointer; }
.difficulty-card b { font-size:18px; letter-spacing:3px; }
.difficulty-card.active { color:white; background:linear-gradient(120deg,var(--jade),var(--jade-dark)); border-color:var(--jade-dark); }
#difficulty-detail { min-width:0; min-height:0; overflow:hidden; padding:18px 22px; background:#fffaf0; border:1px solid var(--line); }
#difficulty-detail h2 { margin:5px 0 12px; color:#5c3c10; font:700 29px var(--serif); letter-spacing:5px; }
#difficulty-detail > p { line-height:1.7; color:#6f6049; }
.difficulty-values { display:grid; grid-template-columns:repeat(4,1fr); gap:8px; margin:15px 0; }
.difficulty-values div { padding:10px; text-align:center; background:#f2e5c6; border:1px solid var(--line); }
.difficulty-values span, .difficulty-values b { display:block; }
.difficulty-values b { margin-top:4px; color:var(--jade-dark); font-size:19px; }
.ai-behavior { min-height:58px; padding:10px 12px; background:#edf5e9; border-left:4px solid var(--jade); }
.custom-difficulty { display:grid; gap:8px; margin:12px 0; }
.custom-difficulty label { display:grid; grid-template-columns:85px 1fr 48px; gap:8px; align-items:center; }
.custom-difficulty output { text-align:right; color:var(--jade-dark); font-weight:700; }
.save-transfer h4 { margin-bottom:6px; }
.file-btn { position:relative; overflow:hidden; }
.file-btn input { position:absolute; inset:0; opacity:0; cursor:pointer; }

@media (max-width:1180px) {
  #log-panel { width:245px; }
  .court-tabs { grid-template-columns:repeat(12,minmax(49px,1fr)) auto; }
  .court-tabs button { min-width:50px; padding-inline:4px; font-size:12px; }
  .court-summary { grid-template-columns:repeat(3,1fr); }
  .action-grid { grid-template-columns:repeat(3,1fr); }
  .target-grid, .city-manage-grid { grid-template-columns:repeat(2,1fr); }
  .relation-grid { grid-template-columns:repeat(3,1fr); }
}
@media (max-height:760px) {
  #topbar { min-height:36px; padding-block:5px; }
  #screen-root { padding:6px; }
  .v6-heading { min-height:50px; padding-block:5px; }
  .v6-heading h2 { font-size:21px; }
  .v6-scroll { padding:9px; }
  .court-tabs { height:43px; padding:4px; }
  .system-card { min-height:70px; padding:9px; }
  .scene-banner { min-height:68px; padding:10px 15px; }
}
@media (max-width:860px) {
  #app, #game-screen { height:calc(100dvh - var(--footer-h)) !important; min-height:0 !important; }
  #main-row { display:grid !important; grid-template-columns:minmax(0,1fr) 190px; min-height:0; }
  #screen-root { min-height:0 !important; overflow:hidden !important; padding:5px !important; }
  #log-panel { width:auto !important; max-height:none !important; border-left:2px solid var(--border-light) !important; border-top:0 !important; }
  .court-tabs { overflow-x:auto; display:flex; }
  .court-tabs button { min-width:58px; }
  .court-summary, .action-grid, .relation-grid { grid-template-columns:repeat(2,minmax(145px,1fr)); }
  .target-grid, .city-manage-grid, .training-list { grid-template-columns:1fr; }
  .difficulty-modal { width:calc(100vw - 16px); height:calc(100dvh - 16px); padding:10px !important; }
  .difficulty-layout { grid-template-columns:150px minmax(0,1fr); gap:8px; }
  .difficulty-values { grid-template-columns:repeat(2,1fr); }
}
@media (max-width:620px) and (orientation:portrait) {
  #main-row { grid-template-columns:1fr; }
  #log-panel { display:none; }
  .court-summary, .action-grid { grid-template-columns:1fr; }
  .case-list article, .army-list article, .delegate-list article { align-items:flex-start; flex-direction:column; }
  .army-create { grid-template-columns:1fr 1fr; }
  .encyclopedia { grid-template-columns:1fr; }
  .difficulty-layout { grid-template-columns:1fr; grid-template-rows:54px minmax(0,1fr); }
  .difficulty-layout aside { grid-template-columns:repeat(5,minmax(0,1fr)); grid-template-rows:1fr; gap:4px; overflow:hidden; }
  .difficulty-card { min-width:0; padding:4px; }
  .difficulty-card b { font-size:12px; letter-spacing:0; }
}
@media (max-height:520px) {
  .difficulty-modal { width:calc(100vw - 12px); height:calc(100dvh - 12px); padding:7px !important; }
  .difficulty-layout { grid-template-columns:138px minmax(0,1fr); gap:7px; }
  .difficulty-layout aside { grid-template-rows:repeat(5,1fr); gap:4px; }
  .difficulty-card { padding:4px; }
  .difficulty-card b { font-size:13px; letter-spacing:1px; }
  #difficulty-detail { padding:7px 10px; }
  #difficulty-detail .eyebrow { font-size:10px; }
  #difficulty-detail h2 { margin:1px 0 3px; font-size:20px; }
  #difficulty-detail > p { line-height:1.35; margin:3px 0; font-size:11px; }
  .difficulty-values { grid-template-columns:repeat(4,1fr); gap:4px; margin:5px 0; }
  .difficulty-values div { padding:4px; font-size:10px; }
  .difficulty-values b { margin-top:1px; font-size:14px; }
  .ai-behavior { min-height:0; padding:4px 7px; }
  .custom-difficulty { gap:3px; margin:4px 0; }
  .custom-difficulty label { grid-template-columns:68px 1fr 40px; gap:5px; font-size:11px; }
  .custom-difficulty input { min-height:22px; padding:0; }
  #difficulty-detail .big-btn { min-height:30px; padding:4px 14px; }
}
