/* ===== 三国：诸侯争霸 明亮写实国风 UI（金玉质感） ===== */
:root {
  /* 底色：明亮暖色（羊皮纸 / 宣纸 / 浅金） */
  --bg: #f3ecd9;
  --bg2: #ebe1c8;
  --panel: #fdf9ef;
  --panel2: #f6efdc;
  /* 金玉边框 */
  --border: #c8a25e;
  --border-light: #e3c88a;
  --gold: #b8862e;
  --gold-light: #e6c069;
  --gold-dark: #96651f;
  /* 点缀 */
  --red: #b03a2e;
  --green: #4f8a3a;
  --blue: #3d6f9e;
  /* 文字：深褐（浓墨） / 淡墨 */
  --text: #3b2f1e;
  --text-dim: #8a7a5c;
  --text-weak: #b0a285;
  /* 星级 */
  --star5: #c8861a;
  --star4: #8a5fd0;
  --star3: #4a7ba6;
  /* 字体：标题隶书 / 正文仿宋 */
  --serif: "LiSu", "STLiti", "KaiTi", "STKaiti", "SimSun", serif;
  --body-font: "FangSong", "STFangsong", "KaiTi", "STKaiti", "Microsoft YaHei", serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* hidden 属性优先级最高，防止被 display:flex 等覆盖 */
[hidden] { display: none !important; }

body {
  background:
    repeating-linear-gradient(45deg, rgba(180,140,80,0.03) 0 2px, transparent 2px 16px),
    radial-gradient(ellipse at 50% -10%, #fbf4e0 0%, #f1e7cd 45%, #e9ddbf 100%);
  color: var(--text);
  font-family: var(--body-font);
  font-size: 15px;
  user-select: none;
  overflow: hidden;
  height: 100vh;
}

#app { height: 100vh; display: flex; flex-direction: column; }

/* ===== 标题界面 ===== */
#title-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(214,169,78,.28) 0%, rgba(240,225,190,.18) 45%, transparent 70%),
    radial-gradient(ellipse at 50% 120%, #efe4c8 0%, #e6d8b8 70%);
}
body.has-title-art #title-screen {
  background-image:
    linear-gradient(rgba(250,243,224,.32), rgba(240,228,196,.55)),
    var(--title-bg);
  background-size: cover;
  background-position: center;
}
.title-box {
  text-align: center;
  padding: 56px 72px;
  border: 1px solid var(--border-light);
  background: linear-gradient(rgba(253,249,239,.88), rgba(246,239,220,.92));
  box-shadow:
    0 0 0 1px var(--gold-dark),
    0 0 50px rgba(180,134,46,.35),
    inset 0 1px 0 rgba(255,255,255,.7);
}
.game-title {
  font-size: 58px;
  letter-spacing: 14px;
  color: #8a5f1c;
  background: linear-gradient(180deg, #e8c06a 0%, #b8862e 45%, #8a5f1c 60%, #d9ae52 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 1px 0 rgba(255,255,255,.35), 0 3px 12px rgba(150,101,31,.25);
  font-family: var(--serif);
  font-weight: bold;
}
.title-sub {
  margin: 18px 0 42px;
  color: var(--text-dim);
  letter-spacing: 8px;
  font-size: 16px;
  border-top: 1px solid rgba(180,134,46,.4);
  border-bottom: 1px solid rgba(180,134,46,.4);
  padding: 10px 0;
}
.menu-buttons { display: flex; flex-direction: column; gap: 16px; align-items: center; }

.big-btn {
  min-width: 260px;
  padding: 14px 32px;
  font-size: 19px;
  letter-spacing: 8px;
  cursor: pointer;
  color: #4a3515;
  background: linear-gradient(180deg, #f6dd96 0%, #dfb45a 45%, #c8922e 55%, #ecd08a 100%);
  border: 1px solid #96651f;
  box-shadow: 0 3px 0 #96651f, 0 5px 14px rgba(150,101,31,.35), inset 0 1px 0 rgba(255,255,255,.6);
  font-family: var(--serif);
  transition: all .15s;
}
.big-btn:hover {
  background: linear-gradient(180deg, #ffe8aa 0%, #e8c06a 45%, #d4a94e 55%, #f6dd96 100%);
  color: #3b2f1e;
  box-shadow: 0 3px 0 #96651f, 0 0 22px rgba(200,150,50,.45), inset 0 1px 0 rgba(255,255,255,.7);
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #96651f; }

.load-slots { margin-top: 24px; display: flex; flex-direction: column; gap: 10px; }

/* ===== 顶栏 ===== */
#game-screen { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#topbar {
  display: flex;
  gap: 18px;
  align-items: center;
  padding: 8px 18px;
  background: linear-gradient(#faf4e3, #f1e7cd);
  border-bottom: 2px solid var(--border-light);
  box-shadow: 0 2px 8px rgba(150,101,31,.18);
  font-size: 13px;
  white-space: nowrap;
  overflow-x: auto;
}
#tb-faction {
  color: #8a5f1c;
  font-weight: bold;
  font-size: 17px;
  font-family: var(--serif);
  letter-spacing: 2px;
  text-shadow: 0 1px 0 rgba(255,255,255,.5);
}
.topbar-label { color: var(--text-dim); }

/* ===== 主区域 ===== */
#main-row { flex: 1; display: flex; min-height: 0; }

#screen-root {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  background:
    repeating-linear-gradient(0deg, rgba(180,140,80,0.025) 0 2px, transparent 2px 16px),
    radial-gradient(ellipse at 50% 0%, rgba(214,169,78,.12) 0%, transparent 55%);
}

#log-panel {
  width: 300px;
  flex-shrink: 0;
  border-left: 2px solid var(--border-light);
  background: linear-gradient(#fbf5e5, #f3ecd9);
  display: flex;
  flex-direction: column;
}
.log-header {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-light);
  color: #8a5f1c;
  letter-spacing: 3px;
  font-family: var(--serif);
  font-size: 15px;
  background: linear-gradient(#f6edd6, #f0e6cb);
}
#log-body { flex: 1; overflow-y: auto; padding: 8px 10px; font-size: 12px; line-height: 1.7; }
.log-item { margin-bottom: 6px; border-bottom: 1px dashed rgba(180,134,46,.35); padding-bottom: 4px; }
.log-item b { color: #8a5f1c; }

/* ===== 通用按钮 ===== */
.btn {
  display: inline-block;
  padding: 6px 14px;
  cursor: pointer;
  color: #4a3515;
  background: linear-gradient(#f6edd6, #ece0c0);
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 1px;
  transition: all .12s;
}
.btn:hover {
  background: linear-gradient(#fbf3e0, #f0e5c6);
  color: #8a5f1c;
  border-color: var(--gold);
  box-shadow: 0 0 8px rgba(200,150,50,.3);
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(180deg, #f2d384 0%, #d4a94e 50%, #c8922e 55%, #e8c877 100%);
  border-color: #96651f;
  color: #3b2f1e;
  box-shadow: 0 1px 3px rgba(150,101,31,.4), inset 0 1px 0 rgba(255,255,255,.55);
}
.btn-primary:hover { background: linear-gradient(180deg, #ffe8aa 0%, #e0b65c 50%, #d4a94e 55%, #f2d384 100%); color: #3b2f1e; }
.btn-danger { background: linear-gradient(#d88a7e, #b85a4a); border-color: #8a3d33; color: #fff8f5; }
.btn-small { padding: 3px 9px; font-size: 12px; }

/* ===== 面板 ===== */
.panel { margin-bottom: 14px; }
.panel-title {
  padding: 9px 14px;
  background: linear-gradient(#f6edd6, #ecdcc0);
  border: 1px solid var(--border-light);
  border-bottom: 2px solid var(--gold);
  color: #8a5f1c;
  letter-spacing: 3px;
  font-size: 15px;
  font-family: var(--serif);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.panel-body {
  border: 1px solid var(--border-light);
  background: linear-gradient(rgba(253,249,239,.94), rgba(246,239,220,.95));
  padding: 12px 14px;
  box-shadow: 0 3px 12px rgba(150,101,31,.15), inset 0 1px 0 rgba(255,255,255,.65);
}

/* 主界面（宫殿/朝堂）铺满整个画面，不留下方空白 */
.palace-panel, .court-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-bottom: 0;
}
.palace-panel .panel-body, .court-panel .panel-body { flex: 1; display: flex; flex-direction: column; }
.palace-panel .court-grid, .court-panel .court-grid { flex: 1; align-content: start; }

/* 宫殿内容区 + 底部导航栏（按钮放大、横向填满一行） */
.palace-content { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }
.palace-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 2px solid var(--border-light);
}
.palace-nav-btn {
  flex: 1;
  min-width: 108px;
  padding: 18px 6px;
  text-align: center;
  cursor: pointer;
  background: linear-gradient(180deg, #fbf3e0, #f0e3c2);
  border: 1px solid var(--border-light);
  color: #5a4420;
  font-family: var(--serif);
  font-size: 19px;
  letter-spacing: 3px;
  transition: all .15s;
  box-shadow: 0 2px 6px rgba(150,101,31,.18), inset 0 1px 0 rgba(255,255,255,.6);
}
.palace-nav-btn:hover {
  border-color: var(--gold);
  color: #8a5f1c;
  background: linear-gradient(180deg, #fff8e8, #f2dfae);
  box-shadow: 0 2px 6px rgba(150,101,31,.25), 0 0 14px rgba(214,169,78,.35), inset 0 1px 0 rgba(255,255,255,.7);
}

/* 宫殿主界面背景（文生图接入点，明亮覆盖层） */
body.has-palace-art .palace-hero {
  background-image:
    linear-gradient(rgba(250,243,224,.34), rgba(240,228,196,.5)),
    var(--palace-bg);
  background-size: cover;
  background-position: center 30%;
}
/* 朝堂背景（大殿内部） */
body.has-court-art .court-hero {
  background-image:
    linear-gradient(rgba(250,243,224,.36), rgba(240,228,196,.52)),
    var(--court-bg);
  background-size: cover;
  background-position: center 35%;
}

/* 势力色块 */
.swatch { display: inline-block; width: 14px; height: 14px; margin-right: 6px; vertical-align: -2px; border: 1px solid rgba(59,47,30,.4); }

/* ===== 势力卡片 ===== */
.faction-card { border: 1px solid var(--border-light); background: linear-gradient(rgba(253,249,239,.97), rgba(243,234,214,.98)); box-shadow: 0 3px 14px rgba(150,101,31,.22); }
.faction-banner { padding: 12px 14px; position: relative; }
.faction-name { font-size: 24px; letter-spacing: 6px; color: #8a5f1c; font-family: var(--serif); font-weight: bold; text-shadow: 0 1px 0 rgba(255,255,255,.5); }
.faction-ruler { font-size: 13px; color: #a8834a; margin-top: 2px; letter-spacing: 2px; }
.faction-stats { display: flex; gap: 10px; flex-wrap: wrap; padding: 8px 12px; background: rgba(180,134,46,.07); font-size: 13px; }
.faction-gens { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 12px 12px; }
.gen-chip {
  display: inline-block; padding: 2px 9px; border: 1px solid var(--border);
  background: rgba(255,255,255,.5); font-size: 12px; letter-spacing: 1px; border-radius: 2px;
}

/* 星级 */
.star5 { color: var(--star5); }
.star4 { color: var(--star4); }
.star3 { color: var(--star3); }
.star { letter-spacing: 1px; font-size: 12px; }

/* ===== 表格 ===== */
table.data-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.data-table th {
  background: linear-gradient(#f2e6c8, #e8d8b4);
  border: 1px solid var(--border);
  padding: 5px 6px;
  color: #8a5f1c;
  white-space: nowrap;
  font-weight: normal;
  letter-spacing: 1px;
}
.data-table td {
  border: 1px solid rgba(180,134,46,.4);
  padding: 5px 6px;
  text-align: center;
  white-space: nowrap;
  color: var(--text);
}
.data-table tr:nth-child(even) td { background: rgba(180,134,46,.05); }
.data-table tr:hover td { background: rgba(214,169,78,.14); }
.attr-high { color: #3f7d2a; }
.attr-mid { color: #a8781a; }
.attr-low { color: #b04a3a; }

/* ===== 朝堂按钮网格 ===== */
.court-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.court-btn {
  padding: 22px 10px;
  text-align: center;
  cursor: pointer;
  background: linear-gradient(180deg, #fbf3e0, #f0e3c2);
  border: 1px solid var(--border-light);
  font-size: 18px;
  letter-spacing: 4px;
  color: #5a4420;
  font-family: var(--serif);
  transition: all .15s;
  box-shadow: 0 2px 6px rgba(150,101,31,.18), inset 0 1px 0 rgba(255,255,255,.6);
}
.court-btn:hover {
  border-color: var(--gold);
  color: #8a5f1c;
  background: linear-gradient(180deg, #fff8e8, #f2dfae);
  box-shadow: 0 2px 6px rgba(150,101,31,.25), 0 0 16px rgba(214,169,78,.35), inset 0 1px 0 rgba(255,255,255,.7);
}
.court-btn .court-desc { display: block; font-size: 11px; color: var(--text-dim); letter-spacing: 1px; margin-top: 6px; font-family: var(--body-font); }

/* ===== 地图 ===== */
#map-wrap {
  display: inline-block;
  border: 2px solid var(--border-light);
  background: #e9e0c8;
  box-shadow: 0 4px 16px rgba(150,101,31,.25), inset 0 0 30px rgba(150,101,31,.12);
}
#map-canvas { display: block; cursor: crosshair; }
.map-side {
  width: 252px;
  background: linear-gradient(rgba(253,249,239,.96), rgba(243,234,214,.97));
  border: 1px solid var(--border-light);
  padding: 12px;
  font-size: 13px;
  line-height: 1.8;
  box-shadow: 0 3px 12px rgba(150,101,31,.18);
}
.map-side h3 { color: #8a5f1c; letter-spacing: 2px; margin-bottom: 6px; font-family: var(--serif); }

/* ===== 模态框 ===== */
#modal-mask {
  position: fixed; inset: 0;
  background: rgba(59,47,30,.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  backdrop-filter: blur(2px);
}
#modal-box {
  background: linear-gradient(#fdf9ef, #f4ead2);
  border: 1px solid var(--border-light);
  box-shadow: 0 0 0 1px var(--gold-dark), 0 0 0 4px rgba(253,249,239,.5), 0 10px 40px rgba(59,47,30,.4);
  padding: 22px 26px;
  max-width: 720px;
  max-height: 82vh;
  overflow-y: auto;
  min-width: 420px;
  color: var(--text);
}
#modal-box h3 { color: #8a5f1c; letter-spacing: 3px; margin-bottom: 14px; font-size: 17px; font-family: var(--serif); }

/* ===== 奏折 ===== */
.memorial { border-left: 3px solid var(--gold-dark); padding: 8px 12px; margin-bottom: 10px; background: rgba(214,169,78,.12); }
.memorial-choices { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* ===== 后宫 ===== */
.harem-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.harem-card {
  border: 1px solid var(--border-light);
  background: linear-gradient(#fbf3e0, #f0e3c2);
  padding: 10px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(150,101,31,.18);
}
.harem-card .name { color: #8a5f1c; font-size: 16px; letter-spacing: 2px; margin: 4px 0; font-family: var(--serif); }

/* 提示 */
.tip { color: var(--text-dim); font-size: 12px; }
.divider { border-top: 1px solid rgba(180,134,46,.4); margin: 10px 0; }
.row-flex { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.gold-text { color: #8a5f1c; }
.green-text { color: #3f7d2a; }
.red-text { color: #b04a3a; }
select, input[type=number], input[type=range] {
  background: #fdf9ef; color: var(--text);
  border: 1px solid var(--border); padding: 4px 6px;
  font-family: inherit; font-size: 13px;
}
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-thumb { background: #c9a86a; border: 2px solid #f0e6cb; border-radius: 6px; }
::-webkit-scrollbar-track { background: #f0e6cb; }
