/* =========================================================
   文明：万世 —— 样式
   ========================================================= */
:root {
  /* 米色（默认主题） */
  --paper: #f4ecdc;
  --paper-2: #efe4d0;
  --panel: #fffdf7;
  --panel-2: #fbf5e8;
  --line: #d5c5a9;
  --line-2: #c0ad8d;
  --ink: #2e2417;
  --ink-2: #4e402c;
  --muted: #82714f;
  --accent: #a9622f;
  --accent-2: #c8853f;
  --gold: #b8891b;
  --red: #b23b2e;
  --green: #3f7d4e;
  --blue: #2f6690;
  --shadow: 0 2px 10px rgba(74, 55, 30, .12);
  --bg-glow1: rgba(255, 250, 235, .95);
  --bg-glow2: #fff8e6;
  --bg-glow3: #e9d9b6;
}

/* ---- 素白主题 ---- */
body.theme-white {
  --paper: #fafaf8;
  --paper-2: #f1f0ec;
  --panel: #ffffff;
  --panel-2: #f6f5f1;
  --line: #d9d6cf;
  --line-2: #c3bfb5;
  --ink: #21201d;
  --ink-2: #45413a;
  --muted: #6e675c;
  --accent: #a9622f;
  --accent-2: #c8853f;
  --shadow: 0 2px 10px rgba(0, 0, 0, .10);
  --bg-glow1: rgba(255, 255, 255, .95);
  --bg-glow2: #ffffff;
  --bg-glow3: #e9e6df;
}

/* ---- 玄墨（深色）主题 ---- */
body.theme-dark {
  --paper: #1f1b16;
  --paper-2: #282319;
  --panel: #302a23;
  --panel-2: #38322a;
  --line: #4c443a;
  --line-2: #615748;
  --ink: #ede4d3;
  --ink-2: #cfc2a9;
  --muted: #a2957e;
  --accent: #c97a3d;
  --accent-2: #dd9755;
  --gold: #d4a72c;
  --red: #e06a5a;
  --green: #6fb37f;
  --blue: #6a9cc9;
  --shadow: 0 2px 12px rgba(0, 0, 0, .5);
  --bg-glow1: rgba(74, 62, 46, .55);
  --bg-glow2: #2b251e;
  --bg-glow3: #171310;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
/* 关闭 Android WebView / 移动浏览器的字体自动放大（font boosting）——
   Toy 端实测会把 12.5px 的帮助文字撑到 ~2 倍，布局全部失真 */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  overflow: hidden;
  font-size: 14px;
}
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ---------------- 主菜单 ---------------- */
#menu {
  position: fixed; inset: 0; overflow: hidden;
  display: flex; align-items: center; padding: 0 0 0 9vw;
  background:
    radial-gradient(900px 620px at 78% 34%, var(--bg-glow1) 0%, rgba(255, 250, 235, 0) 62%),
    radial-gradient(1100px 700px at 8% -18%, var(--bg-glow2) 0%, rgba(255, 248, 230, 0) 58%),
    radial-gradient(900px 520px at 92% 112%, var(--bg-glow3) 0%, rgba(233, 217, 182, 0) 58%),
    var(--paper);
}
#menu::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image:
    repeating-linear-gradient(60deg, rgba(160, 130, 85, .055) 0 1px, transparent 1px 26px),
    repeating-linear-gradient(-60deg, rgba(160, 130, 85, .055) 0 1px, transparent 1px 26px);
  mask-image: radial-gradient(70% 70% at 70% 45%, #000 0%, transparent 78%);
  -webkit-mask-image: radial-gradient(70% 70% at 70% 45%, #000 0%, transparent 78%);
}
.menu-inner {
  position: relative; z-index: 2; height: 100%; order: 1;
  flex: 0 1 auto; min-width: 0;   /* 窄横屏（Toy 等 ~1000px）允许收缩，防横向溢出 */
  display: flex; flex-direction: column; justify-content: center;
  max-width: 760px;
}
/* --- 右侧文明图鉴：六边形国土 --- */
.menu-plate {
  position: relative; z-index: 2; order: 2; flex: 0 0 auto;
  margin: 0 auto; --mp-accent: #a9622f;
  /* 中间留白随视口收缩，卡片始终居中于右侧空档 */
  width: min(36vw, 620px, 64vh, calc(91vw - 560px));
}
.mp-card {
  position: relative; padding: 13px 15px 11px; border-radius: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 18px 44px rgba(120, 96, 60, .13), 0 1px 0 rgba(255, 255, 255, .8) inset;
  transition: opacity .24s ease, transform .24s ease;
  cursor: pointer;
  backdrop-filter: blur(3px);
}
.mp-card::after {
  content: ''; position: absolute; inset: 5px; pointer-events: none; border-radius: 2px;
  border: 1px solid rgba(169, 98, 47, .12);
}
.mp-card.swapping { opacity: 0; transform: translateY(7px); }
.mp-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 10.5px; letter-spacing: 3px; color: var(--muted); padding-bottom: 8px;
}
.mp-tag { padding-left: 9px; position: relative; color: var(--ink-2); }
.mp-tag::before {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 11px; border-radius: 1px; background: var(--mp-accent); opacity: .75;
}
.mp-idx { letter-spacing: 1px; font-variant-numeric: tabular-nums; opacity: .85; }
.mp-map { position: relative; aspect-ratio: 1 / .86; }
.mp-map canvas { display: block; width: 100%; height: 100%; }
.mp-title {
  display: flex; align-items: baseline; gap: 8px; margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--line);
}
.mp-name {
  font-family: "Songti SC", Georgia, serif; font-size: 27px; letter-spacing: 5px;
  color: var(--ink); line-height: 1.1;
}
.mp-leader { margin-left: auto; font-size: 11.5px; color: var(--muted); letter-spacing: 1px; }
.mp-trait { margin-top: 7px; font-size: 11.5px; line-height: 1.62; color: var(--ink-2); }
.mp-trait b { color: var(--mp-accent); margin-right: 6px; letter-spacing: .5px; }
.mp-uni { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.mp-uni span {
  font-size: 10.5px; color: var(--ink-2); background: rgba(240, 230, 210, .7);
  border: 1px solid rgba(200, 182, 151, .7); border-radius: 3px; padding: 2px 6px;
}
.mp-uni i { font-style: normal; color: var(--muted); margin-right: 4px; }
.mp-cap { margin-top: 8px; font-size: 10.5px; color: var(--muted); letter-spacing: .8px; }
.mp-cap em {
  font-style: normal; margin-left: 12px; padding-left: 12px;
  border-left: 1px solid var(--line); color: var(--ink-2); opacity: .85;
}
.mp-foot { display: flex; align-items: center; gap: 10px; margin-top: 9px; }
.mp-hint { font-size: 10px; color: var(--muted); letter-spacing: 1px; white-space: nowrap; }
.mp-bar { flex: 1; height: 2px; border-radius: 2px; background: rgba(160, 140, 110, .2); overflow: hidden; }
.mp-bar i {
  display: block; height: 100%; width: 100%; background: var(--mp-accent); opacity: .65;
  transform: scaleX(0); transform-origin: left center;
}
@media (max-width: 1400px) {
  /* 窄屏时右上角的闲章会压到图鉴卡片上，直接收起来 */
  .menu-seal { display: none; }
}
@media (max-width: 1180px) {
  .mp-name { font-size: 23px; }
  .mp-trait { font-size: 11px; }
}
@media (max-width: 980px) { .menu-plate { display: none; } }
.menu-brand { margin-bottom: 34px; position: relative; width: max-content; max-width: 100%; }
.menu-seal {
  position: absolute; right: -116px; top: 19px; transform: rotate(-6deg);
  padding: 9px 13px; border: 2px solid var(--red); color: var(--red); border-radius: 5px;
  font-family: "Songti SC", serif; font-size: 14px; letter-spacing: 4px; opacity: .7;
}
.menu-brand h1 {
  margin: 0; font-family: "Songti SC", Georgia, serif; font-size: 62px; letter-spacing: 14px;
  color: var(--ink); text-shadow: 0 2px 0 rgba(255, 255, 255, .7);
}
.menu-brand .sub { color: var(--muted); letter-spacing: 7px; font-size: 12.5px; margin-top: 6px; }
.menu-brand .tagline {
  color: var(--ink-2); font-size: 13px; margin-top: 16px; letter-spacing: 1px;
  padding-left: 14px; border-left: 3px solid rgba(169, 98, 47, .45);
}
.menu-list { display: flex; flex-direction: column; gap: 9px; width: 430px; }
.menu-btn {
  display: block; text-align: left; width: 100%; padding: 12px 18px 12px 20px;
  background: rgba(255, 253, 247, .82); border: 1px solid var(--line);
  border-left: 3px solid rgba(169, 98, 47, .28); border-radius: 4px;
  transition: transform .16s, border-color .16s, background .16s, box-shadow .16s;
  backdrop-filter: blur(2px);
}
.menu-btn .k { display: block; font-size: 17px; font-weight: 700; letter-spacing: 4px; color: var(--ink); }
.menu-btn .d { display: block; font-size: 11.5px; color: var(--muted); margin-top: 3px; letter-spacing: .5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-btn:hover { transform: translateX(4px); border-left-color: var(--accent); background: #fffdf5; box-shadow: var(--shadow); }
.menu-btn.primary {
  background: linear-gradient(180deg, #b8722f, #96521f); border-color: #96521f; border-left-color: #7d4318;
  box-shadow: 0 5px 16px rgba(150, 82, 31, .26);
}
.menu-btn.primary .k { color: #fff8ec; }
.menu-btn.primary .d { color: rgba(255, 248, 236, .8); }
.menu-btn.primary:hover { filter: brightness(1.07); }
.menu-btn:disabled { opacity: .48; cursor: not-allowed; transform: none; box-shadow: none; }
.menu-btn .dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--red);
  margin-left: 7px; vertical-align: 6px; animation: pulse 1.8s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
.menu-foot {
  display: block; margin-top: 34px;
  color: var(--muted); font-size: 11.5px; letter-spacing: .5px;
}
.menu-foot .ver { opacity: .8; }

.ghost-btn {
  margin-left: auto; align-self: center; background: none; border: 1px solid var(--line-2);
  color: var(--ink-2); padding: 7px 14px; border-radius: 4px; font-size: 12.5px; letter-spacing: 1px;
}
.ghost-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--panel-2); }

/* 胜利条件选项 */
.vopt { position: relative; min-width: 150px; padding-right: 34px; }
.vopt::after {
  content: ''; position: absolute; right: 11px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; border-radius: 4px; border: 1.5px solid var(--line-2); background: #fff;
}
.vopt.on::after {
  content: '✓'; border-color: var(--accent); background: var(--accent); color: #fff;
  font-size: 11px; line-height: 13px; text-align: center; font-weight: 700;
}
.vopt.off { opacity: .55; }
.vopt .t { display: flex; align-items: center; gap: 6px; }

/* ---------------- 存档栏位 ---------------- */
.save-slots { display: flex; flex-direction: column; gap: 8px; }
.save-slot {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px;
  background: #fff; border: 1px solid var(--line); border-radius: 6px;
}
.save-slot.auto { background: #fdf7e9; border-color: var(--line-2); }
.save-slot .no {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 6px; display: grid; place-items: center;
  background: var(--panel-2); color: var(--accent); font-weight: 700; font-size: 14px; font-family: "Songti SC", serif;
}
.save-slot .no.auto { background: #ece0c8; font-size: 11px; letter-spacing: 0; }
.save-slot .info { flex: 1; min-width: 0; }
.save-slot .t1 { font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.save-slot .t1 .tagx {
  font-size: 10px; font-weight: 500; padding: 1px 6px; border-radius: 8px;
  background: #efe1c6; color: var(--ink-2);
}
.save-slot .t2 { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.save-slot .acts { display: flex; gap: 6px; flex: 0 0 auto; }
.save-slot .acts .act { padding: 5px 10px; font-size: 12px; }
.save-slot.empty { background: #fbf7ee; border-style: dashed; }
.save-slot.empty .t1 { color: var(--muted); font-weight: 500; }

/* ---------------- 游戏内菜单 ---------------- */
.gmenu-info { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 20px; margin-bottom: 14px; }
.gmenu-info .row { display: flex; gap: 8px; font-size: 12.5px; }
.gmenu-info .row span { color: var(--muted); min-width: 62px; }
.gmenu-info .row b { color: var(--ink); font-weight: 600; }
.gmenu-vic { display: flex; flex-wrap: wrap; gap: 6px; }
.gmenu-vic .vc {
  font-size: 11.5px; padding: 3px 9px; border-radius: 10px;
  background: #f1e6cf; color: var(--ink-2); border: 1px solid var(--line);
}
.gmenu-vic .vc.off { opacity: .42; text-decoration: line-through; }
.gmenu-acts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 16px; }
.gmenu-acts .act { padding: 11px; font-size: 13px; }

/* ---------------- 设置界面 ---------------- */
#setup {
  position: fixed; inset: 0; overflow-y: auto;
  background:
    radial-gradient(1200px 600px at 15% -10%, var(--bg-glow2) 0%, rgba(255, 248, 230, 0) 60%),
    radial-gradient(900px 500px at 90% 110%, var(--bg-glow3) 0%, rgba(240, 226, 198, 0) 55%),
    var(--paper);
  padding: 28px 32px 104px;
}
.setup-inner { max-width: 1240px; margin: 0 auto; }
/* 联机模式选择 / 联机大厅：与 #setup 同款的全屏滚动视图（否则 body overflow:hidden 时内容超高不可滚，
   底部的准备/开始按钮会落在折叠区外无法点击） */
#mpmode, #mp {
  position: fixed; inset: 0; z-index: 20; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background:
    radial-gradient(1200px 600px at 15% -10%, var(--bg-glow2) 0%, rgba(255, 248, 230, 0) 60%),
    radial-gradient(900px 500px at 90% 110%, var(--bg-glow3) 0%, rgba(240, 226, 198, 0) 55%),
    var(--paper);
  padding: 28px 32px 104px;
}
.brand { display: flex; align-items: flex-end; gap: 18px; border-bottom: 2px solid var(--line-2); padding-bottom: 16px; }
.brand h1 { margin: 0; font-size: 40px; letter-spacing: 8px; font-family: "Songti SC", Georgia, serif; font-weight: 700; }
.brand .sub { color: var(--muted); font-size: 13px; letter-spacing: 2px; padding-bottom: 8px; }
.brand .seal {
  margin-left: auto; padding: 8px 14px; border: 2px solid var(--red); color: var(--red);
  font-family: "Songti SC", serif; border-radius: 4px; font-size: 14px; letter-spacing: 3px; opacity: .85;
}
.setup-section { margin-top: 22px; }
.setup-section > h2 {
  font-size: 15px; letter-spacing: 3px; margin: 0 0 10px; color: var(--ink-2);
  display: flex; align-items: center; gap: 10px; font-weight: 600;
}
.setup-section > h2::before { content: ''; width: 4px; height: 15px; background: var(--accent); display: block; }
.setup-section > h2 span { color: var(--muted); font-weight: 400; letter-spacing: 0; font-size: 12px; }

.civ-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 10px; }
.civ-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 10px 11px;
  cursor: pointer; transition: .15s; position: relative; overflow: hidden;
}
.civ-card:hover { border-color: var(--accent-2); transform: translateY(-2px); box-shadow: var(--shadow); }
.civ-card.on { border-color: var(--accent); background: #fff8ea; box-shadow: 0 0 0 2px rgba(169, 98, 47, .18); }
.civ-card .stripe { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.civ-card .top { display: flex; align-items: baseline; gap: 6px; }
.civ-card .nm { font-size: 16px; font-weight: 700; letter-spacing: 1px; }
.civ-card .ld { font-size: 12px; color: var(--muted); }
.civ-card .tr { font-size: 11.5px; color: var(--accent); margin-top: 5px; font-weight: 600; }
.civ-card .ds { font-size: 11px; color: var(--ink-2); line-height: 1.45; margin-top: 3px; min-height: 30px; }
.civ-card .uu {
  display: flex; flex-wrap: wrap; gap: 3px 8px; margin-top: 6px;
  font-size: 10.5px; color: var(--ink-2); line-height: 1.4;
}
.civ-card .uu span {
  display: inline-flex; align-items: baseline; gap: 4px;
  padding: 1px 6px 1px 5px; background: #f6ead4; border-radius: 3px; max-width: 100%;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.civ-card .uu i {
  font-style: normal; font-size: 9px; color: var(--muted); letter-spacing: .5px;
}

.opt-row { display: flex; flex-wrap: wrap; gap: 8px; }
.opt {
  background: var(--panel); border: 1px solid var(--line); border-radius: 5px; padding: 8px 13px;
  cursor: pointer; min-width: 92px; transition: .12s;
}
.opt:hover { border-color: var(--accent-2); }
.opt.on { border-color: var(--accent); background: #fff7e8; box-shadow: inset 0 0 0 1px var(--accent); }
.opt .t { font-weight: 600; font-size: 13.5px; }
.opt .d { font-size: 11px; color: var(--muted); margin-top: 2px; line-height: 1.35; max-width: 190px; }
.mapopt { flex: 1 1 186px; max-width: 300px; }
.mapopt .d { max-width: none; }
.fixed-tag {
  display: inline-block; margin-left: 5px; font-size: 9.5px; padding: 0 4px;
  border-radius: 3px; background: #e8d6b4; color: #7a4a0d; vertical-align: 1px; font-weight: 400;
}
.setup-foot {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 12px max(32px, calc((100vw - 1240px) / 2));
  background: rgba(247, 240, 226, .98);
  border-top: 1px solid var(--line-2);
  box-shadow: 0 -6px 18px rgba(90, 70, 40, .07);
}
#startBtn {
  background: linear-gradient(180deg, #b8722f, #96521f); color: #fff8ec; border: none;
  padding: 14px 42px; font-size: 17px; letter-spacing: 6px; border-radius: 5px;
  box-shadow: 0 4px 14px rgba(150, 82, 31, .3);
}
#startBtn:hover { filter: brightness(1.06); }
#startBtn:disabled { opacity: .5; cursor: not-allowed; }
.hint { color: var(--muted); font-size: 12px; }
.seed-box { display: flex; gap: 8px; align-items: center; }
.seed-box input {
  width: 120px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 4px;
  background: var(--panel); color: var(--ink); font-family: inherit;
}

/* ---------------- 游戏主界面 ---------------- */
#game { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* —— 小地图（可在设置中开关） —— */
#minimap {
  position: absolute; left: 10px; bottom: 74px; z-index: 25;
  border: 1px solid var(--line-2); border-radius: 4px;
  opacity: .94; cursor: pointer; display: none;
  box-shadow: 0 3px 12px rgba(20, 26, 18, .3);
  touch-action: none;
}
body.mm-on #minimap { display: block; }
/* 手机 / 平板：小地图缩小，减少遮挡 */
@media (max-width: 980px) {
  #minimap { width: 132px; height: 99px; left: 8px; bottom: 66px; opacity: .88; }
}
/* —— 刘海 / 灵动岛规避：触屏横屏（非伪横屏）下左侧悬浮 UI 让出安全区 ——
   viewport-fit=cover 会把内容铺到刘海下面；force-rot 是旋转容器，安全区在 local 轴
   方向不同，另有坐标映射，不在此列。 */
@media (orientation: landscape) {
  body.touch-device:not(.force-rot) { --safe-l: env(safe-area-inset-left, 0px); }
  body.touch-device:not(.force-rot) #minimap { left: calc(8px + var(--safe-l, 0px)); }
}

#topbar {
  height: 58px; flex: 0 0 58px; display: flex; align-items: stretch;
  background: linear-gradient(180deg, var(--panel), var(--paper));
  border-bottom: 2px solid var(--line-2); box-shadow: 0 1px 4px rgba(90, 70, 40, .08);
  z-index: 20;
}
.tb-civ { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-right: 1px solid var(--line); }
.tb-emblem {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 15px; font-family: "Songti SC", serif;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .35);
}
.tb-civ .n { font-weight: 700; letter-spacing: 1px; }
.tb-civ .l { font-size: 11px; color: var(--muted); }

.tb-stats { display: flex; align-items: center; gap: 2px; padding: 0 8px; }
.stat { padding: 6px 12px; border-radius: 5px; min-width: 82px; text-align: center; }
.stat .k { font-size: 10.5px; color: var(--muted); letter-spacing: 1px; }
.stat .v { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .s { font-size: 10.5px; margin-left: 3px; font-weight: 500; }
.stat.gold .v { color: var(--gold); }
.stat.sci .v { color: var(--blue); }
.stat.cul .v { color: #8e44ad; }
.stat.turn .v { color: var(--accent); }
.pos { color: var(--green); }
.neg { color: var(--red); }

.tb-btns { margin-left: auto; display: flex; align-items: center; gap: 6px; padding: 0 14px; }
#btnToolsClose, #btnToolsSettings { display: none; }   /* 仅手机端展开面板时显示 */
.tbtn {
  background: var(--panel); border: 1px solid var(--line-2); color: var(--ink-2);
  padding: 7px 12px; border-radius: 5px; font-size: 12.5px; letter-spacing: 1px;
}
.tbtn:hover { background: #fff6e4; border-color: var(--accent-2); color: var(--accent); }
.tbtn .badge {
  display: inline-block; min-width: 15px; height: 15px; line-height: 15px; border-radius: 8px;
  background: var(--red); color: #fff; font-size: 10px; padding: 0 4px; margin-left: 4px;
}

#main { flex: 1; display: flex; min-height: 0; }
#mapWrap { position: relative; flex: 1; min-width: 0; overflow: hidden; background: #cdd6de; }
#map { display: block; width: 100%; height: 100%; cursor: grab; }
#map.dragging { cursor: grabbing; }

#legend { position: absolute; }
#legendClose {
  position: absolute; top: 2px; right: 4px;
  background: transparent; border: none; color: #93826a; cursor: pointer;
  font-size: 11px; line-height: 1; padding: 1px 3px; font-family: inherit;
}
#legendClose:hover { color: var(--red); }
.legend #legendClose, #legend span { display: block; }

table.rank th { cursor: default; }
table.rank th[data-act] { color: var(--accent); }
table.rank th[data-act]:hover { text-decoration: underline; }
.css-list { display: flex; flex-wrap: wrap; gap: 6px; }
.css-chip {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--line); border-radius: 14px; padding: 3px 10px;
  font-size: 11.5px; background: var(--panel);
}
.unit-bubble {
  background: linear-gradient(180deg, #44618c, #35507a); color: #fff;
  border: 1px solid #2c4258; border-radius: 16px;
  padding: 4px 11px; font-size: 11.5px; cursor: pointer; font-family: inherit;
  box-shadow: 0 2px 8px rgba(20, 30, 50, .35);
  display: flex; align-items: center; gap: 4px; white-space: nowrap;
}
.unit-bubble:hover { background: linear-gradient(180deg, #54739f, #42608d); }
.unit-bubble span { font-size: 13px; }

#mapOverlay { position: absolute; inset: 0; pointer-events: none; }
.map-tip {
  position: absolute; background: rgba(255, 253, 247, .96); border: 1px solid var(--line-2);
  border-radius: 5px; padding: 8px 11px; font-size: 12px; box-shadow: var(--shadow);
  max-width: 250px; line-height: 1.5; color: var(--ink);
}
.map-tip b { color: var(--accent); }

#side {
  width: 336px; flex: 0 0 336px; border-left: 2px solid var(--line-2);
  background: var(--panel-2); display: flex; flex-direction: column; min-height: 0;
}
#sideScroll { flex: 1; overflow-y: auto; }
.panel-sec { border-bottom: 1px solid var(--line); }
.panel-sec h3 {
  margin: 0; padding: 9px 14px; font-size: 12px; letter-spacing: 2px; color: var(--muted);
  background: #f4ebd9; border-bottom: 1px solid var(--line); font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.panel-body { padding: 11px 14px; }

.empty { color: var(--muted); font-size: 12.5px; line-height: 1.7; padding: 6px 2px; }

/* 单位面板 */
.unit-head { display: flex; gap: 11px; align-items: center; }
.unit-icon {
  width: 46px; height: 46px; border-radius: 8px; display: grid; place-items: center;
  font-size: 22px; background: #fff; border: 1px solid var(--line); flex: 0 0 46px;
}
.unit-name { font-size: 16px; font-weight: 700; }
.unit-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.hpbar { height: 7px; background: #e6dcc8; border-radius: 4px; overflow: hidden; margin-top: 5px; }
.hpbar > i { display: block; height: 100%; background: linear-gradient(90deg, #7cb342, #4c8c2b); }
.hpbar.low > i { background: linear-gradient(90deg, #e57373, #c62828); }
.kv { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 9px; font-size: 12px; }
.kv div span { color: var(--muted); }
.kv b { font-weight: 700; }

.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }
.act {
  background: #fff; border: 1px solid var(--line-2); border-radius: 5px; padding: 7px 11px;
  font-size: 12.5px; color: var(--ink-2);
}
.act:hover { background: #fff6e2; border-color: var(--accent-2); color: var(--accent); }
.act.primary { background: var(--accent); border-color: var(--accent); color: #fff8ec; }
.act.primary:hover { filter: brightness(1.08); color: #fff; }
.act:disabled { opacity: .45; cursor: not-allowed; }
.act.attack { border-color: #c95b4b; color: #a8342a; }
.act.attack:hover { background: #fdecea; }

/* 城市面板 */
.city-head { display: flex; align-items: flex-start; gap: 10px; }
.city-badge {
  width: 42px; height: 42px; border-radius: 6px; display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 17px; font-family: "Songti SC", serif;
}
.city-name { font-size: 17px; font-weight: 700; }
.city-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.yields { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-top: 10px; }
.y { background: #fff; border: 1px solid var(--line); border-radius: 4px; text-align: center; padding: 4px 2px; }
.y .n { font-size: 13px; font-weight: 700; }
.y .k { font-size: 9.5px; color: var(--muted); }
.prod-box { margin-top: 10px; background: #fff; border: 1px solid var(--line); border-radius: 5px; padding: 9px 10px; }
.prod-box .t { font-size: 12.5px; font-weight: 600; display: flex; justify-content: space-between; }
.prod-bar { height: 6px; background: var(--paper-2); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.prod-bar > i { display: block; height: 100%; background: linear-gradient(90deg, #d9a441, #b8722f); }

/* 建造队列 */
.q-list { margin-top: 6px; max-height: 208px; overflow-y: auto; padding-right: 1px; }
.qrow {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 5px; border-radius: 4px; background: #fdfbf6;
  border: 1px solid #f0e7d6; margin-bottom: 4px;
}
.qrow.top { background: var(--panel-2); border-color: #e8d3a8; }
.qrow .qn {
  flex: 0 0 17px; height: 17px; line-height: 17px; text-align: center;
  font-size: 10px; border-radius: 50%; background: var(--paper-2); color: var(--ink-2);
}
.qrow.top .qn { background: #b8722f; color: #fff; }
.qrow .qt { flex: 1; min-width: 0; font-size: 12px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.qrow .qt > b {
  font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 0 1 auto; max-width: 100%;
}
.qnow {
  flex: 0 0 auto; font-size: 9.5px; color: #b8722f; background: var(--panel-2);
  border: 1px solid #e8d3a8; border-radius: 3px; padding: 0 4px; line-height: 14px;
}
.q-buy { width: 100%; margin-top: 7px; }
.qrow .qp { font-size: 10px; color: var(--muted); }
.qrow .qb { flex: 0 0 100%; height: 3px; background: var(--paper-2); border-radius: 2px; overflow: hidden; margin-top: 1px; }
.qrow .qb > b { display: block; height: 100%; background: linear-gradient(90deg, #d9a441, #b8722f); }
.qbtns { display: flex; gap: 2px; flex: 0 0 auto; }
.qbtn {
  width: 20px; height: 20px; padding: 0; border: 1px solid var(--line); background: #fff;
  border-radius: 4px; font-size: 11px; line-height: 1; color: var(--ink-2); cursor: pointer;
}
.qbtn:hover { background: var(--panel-2); border-color: var(--accent-2); color: var(--accent); }
.qbtn.del:hover { background: #fdecea; border-color: #d99; color: var(--red); }
.q-hint { font-size: 10.5px; color: var(--muted); margin-top: 4px; }
.qtag {
  display: inline-block; font-size: 9px; padding: 0 3px; border-radius: 3px;
  background: #b8722f; color: #fff; vertical-align: 1px;
}

/* 边界扩张 / 金币购地 */
.border-box { margin-top: 10px; background: #fff; border: 1px solid var(--line); border-radius: 5px; padding: 8px 10px; }
.border-box .t { font-size: 12px; display: flex; justify-content: space-between; gap: 8px; color: var(--ink-2); }
.border-box .t span:first-child { font-weight: 600; }
.prod-bar.culture > i { background: linear-gradient(90deg, #b79bd6, #7d5fa8); }
.act.bt-buy { width: 100%; margin-top: 8px; }
.act.bt-buy.on { background: var(--panel-2); border-color: var(--accent-2); color: var(--accent); }
.act.bt-buy.poor { color: var(--muted); }
.buy-hint { margin-top: 6px; font-size: 11px; line-height: 1.6; color: var(--muted); }

.tabs { display: flex; gap: 4px; margin: 10px 0 8px; }
.tab {
  flex: 1; text-align: center; padding: 6px; border: 1px solid var(--line); background: #fff;
  border-radius: 4px; font-size: 12px; color: var(--muted);
}
.tab.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.itemlist { max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.item {
  display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-bottom: 1px solid #f0e7d6; cursor: pointer;
}
.item:last-child { border-bottom: none; }
.item:hover { background: var(--panel-2); }
.item .ic { font-size: 15px; width: 20px; text-align: center; }
.item .nm { flex: 1; font-size: 12.5px; }
.item .nm small { display: block; color: var(--muted); font-size: 10.5px; font-weight: 400; }
.item .cost { font-size: 11.5px; color: var(--accent); font-weight: 600; white-space: nowrap; }
.item.dis { opacity: .45; cursor: not-allowed; }
.item.cur { background: var(--panel-2); }

/* 日志 */
#logList { max-height: 320px; overflow-y: auto; font-size: 12px; line-height: 1.55; }
.logrow { padding: 5px 2px; border-bottom: 1px dashed #eadfc9; color: var(--ink-2); }
.logrow:last-child { border-bottom: none; }
.logrow .t { color: var(--muted); font-size: 10.5px; margin-right: 5px; }
.logrow.war { color: #a8342a; }
.logrow.wonder { color: #996b00; font-weight: 600; }
.logrow.era { color: #7b3fa0; }
.logrow.tech { color: #2f6690; }
.logrow.diplo { color: #2c6e4f; }
.logrow.warn { color: #b06a1f; }

/* 底部 */
#bottom {
  position: absolute; right: 352px; bottom: 18px; display: flex; align-items: center; gap: 10px; z-index: 12;
}
#nextTurn {
  background: linear-gradient(180deg, #3f7d4e, #2f6440); color: #f2fff4; border: none;
  padding: 13px 26px; font-size: 15px; letter-spacing: 3px; border-radius: 6px;
  box-shadow: 0 4px 14px rgba(47, 100, 64, .32);
}
#nextTurn:hover { filter: brightness(1.08); }
#nextTurn.busy { background: linear-gradient(180deg, #a9622f, #8a4c22); }
#nextTurn.done { background: linear-gradient(180deg, #8d8578, #746c60); box-shadow: none; cursor: default; opacity: .75; }
.turnhint {
  background: rgba(255, 253, 247, .94); border: 1px solid var(--line-2); border-radius: 5px;
  padding: 8px 12px; font-size: 12px; color: var(--ink-2); box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 8px;
}
.turnhint #turnHintClose {
  background: transparent; border: none; color: var(--muted); cursor: pointer;
  font-size: 12px; padding: 0 2px; line-height: 1; font-family: inherit;
}
.turnhint #turnHintClose:hover { color: var(--red); }
body.hint-off #bottom .turnhint { display: none; }

/* 弹窗 */
#modalRoot { position: fixed; inset: 0; z-index: 60; display: none; }
#modalRoot.on { display: block; }
.modal-mask { position: absolute; inset: 0; background: rgba(48, 38, 24, .45); }
.modal {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(1080px, 92vw); max-height: 88vh; background: var(--panel); border-radius: 8px;
  border: 1px solid var(--line-2); box-shadow: 0 18px 50px rgba(50, 34, 12, .3);
  display: flex; flex-direction: column; overflow: hidden;
}
.modal.narrow { width: min(720px, 92vw); }
.modal.wide { width: min(1500px, 96vw); }
.modal-head {
  display: flex; align-items: center; padding: 13px 18px; border-bottom: 2px solid var(--line-2);
  background: linear-gradient(180deg, var(--panel), #f7eeda);
}
.modal-head h2 { margin: 0; font-size: 17px; letter-spacing: 3px; font-family: "Songti SC", serif; }
.modal-head .sub { color: var(--muted); font-size: 12px; margin-left: 12px; }
.modal-head .x {
  margin-left: auto; border: none; background: none; font-size: 22px; color: var(--muted); line-height: 1;
}
.modal-head .x:hover { color: var(--red); }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot { padding: 10px 18px; border-top: 1px solid var(--line); background: #f9f2e3; font-size: 12px; color: var(--muted); }

/* 科技树 */
.techwrap { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.techcol { flex: 0 0 196px; }
.techcol h4 {
  margin: 0 0 8px; font-size: 12px; letter-spacing: 2px; text-align: center; padding: 5px; border-radius: 4px;
  background: #efe3cc; color: #6a5636; font-weight: 600;
}
.tech {
  border: 1px solid var(--line); border-radius: 5px; padding: 7px 9px; margin-bottom: 7px;
  background: #fff; font-size: 12px; cursor: pointer; position: relative;
}
.tech:hover { border-color: var(--accent-2); background: var(--panel); }
.tech.owned { background: #eef6ec; border-color: #a9cca6; }
.tech.owned::after { content: '✓'; position: absolute; right: 7px; top: 6px; color: #4c8c2b; font-weight: 700; }
.tech.cur { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--panel-2); }
.tech.locked { opacity: .45; cursor: not-allowed; }
.tech .n { font-weight: 600; font-size: 12.5px; }
.tech .c { color: var(--muted); font-size: 10.5px; margin-top: 2px; }
.tech .d { color: var(--ink-2); font-size: 10.5px; margin-top: 3px; line-height: 1.4; }
.tech .prog { height: 3px; background: #eee3cd; border-radius: 2px; margin-top: 5px; overflow: hidden; }
.tech .prog i { display: block; height: 100%; background: var(--blue); }

/* 市政 & 政策 */
.gov-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.gov {
  border: 1px solid var(--line); border-radius: 6px; padding: 8px 11px; background: #fff; cursor: pointer; min-width: 128px;
}
.gov.on { border-color: var(--accent); background: #fff7e7; box-shadow: inset 0 0 0 1px var(--accent); }
.gov.locked { opacity: .45; cursor: not-allowed; }
.gov.cooling { opacity: .62; }
.gov .cd {
  float: right; font-style: normal; font-weight: 400; font-size: 10px;
  padding: 0 4px; border-radius: 3px; background: #efe3c8; color: #8a6a44;
}
.gov .n { font-weight: 700; font-size: 13px; }
.gov .s { font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.gov .b { font-size: 10.5px; color: var(--accent); margin-top: 3px; line-height: 1.35; }
.slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.slot {
  border: 1px dashed var(--line-2); border-radius: 5px; padding: 7px; min-height: 74px; background: var(--panel);
}
.slot .h { font-size: 10.5px; color: var(--muted); letter-spacing: 1px; margin-bottom: 5px; }
.slot .p {
  background: var(--panel-2); border-radius: 3px; padding: 3px 5px; font-size: 10.5px; margin-bottom: 3px;
  display: flex; justify-content: space-between; gap: 4px; cursor: pointer;
}
.slot .p:hover { background: #eddbb9; }
.policy-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 7px; }
.pol {
  border: 1px solid var(--line); border-radius: 5px; padding: 7px 9px; background: #fff; cursor: pointer; font-size: 11.5px;
}
.pol:hover { border-color: var(--accent-2); background: var(--panel); }
.pol.on { border-color: var(--accent); background: #fff6e3; }
.pol.locked { opacity: .45; cursor: not-allowed; }
.pol .n { font-weight: 600; font-size: 12.5px; }
.pol .n small { font-weight: 400; color: var(--muted); font-size: 10px; margin-left: 4px; }
.pol .d { color: var(--ink-2); font-size: 10.5px; margin-top: 2px; line-height: 1.4; }

/* 外交 */
.dip-list { display: flex; flex-direction: column; gap: 8px; }
.dip {
  border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; background: #fff;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.dip .em {
  width: 34px; height: 34px; border-radius: 50%; color: #fff; display: grid; place-items: center;
  font-weight: 700; font-family: "Songti SC", serif; flex: 0 0 34px;
}
.dip .info { flex: 1; min-width: 150px; }
.dip .nm { font-weight: 700; font-size: 13.5px; }
.dip .st { font-size: 11px; color: var(--muted); margin-top: 2px; }
.dip .att { font-size: 11px; margin-top: 3px; }
.dip .ops { display: flex; gap: 5px; flex-wrap: wrap; }

/* 排行 */
table.rank { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.rank th { text-align: left; padding: 7px 8px; border-bottom: 2px solid var(--line-2); color: var(--muted); font-weight: 600; font-size: 11.5px; }
table.rank td { padding: 7px 8px; border-bottom: 1px solid #f0e6d3; }
table.rank tr.me { background: var(--panel-2); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

/* 提示条 */
#toasts { position: fixed; left: 50%; top: 72px; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast {
  background: rgba(46, 36, 22, .92); color: #fdf6e8; padding: 9px 18px; border-radius: 20px; font-size: 13px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .22); animation: tin .3s ease-out;
}
.toast.good { background: rgba(47, 100, 64, .94); }
.toast.bad { background: rgba(150, 52, 40, .94); }
.toast.warn { background: rgba(140, 96, 30, .94); }
@keyframes tin { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.victory {
  text-align: center; padding: 26px 10px;
}
.victory h1 { font-family: "Songti SC", serif; font-size: 40px; letter-spacing: 10px; margin: 0 0 8px; color: var(--accent); }
.victory p { color: var(--ink-2); font-size: 14px; line-height: 1.8; }

.help h3 { margin: 18px 0 6px; font-size: 14px; color: var(--accent); letter-spacing: 2px; }
.help p, .help li { font-size: 12.5px; line-height: 1.75; color: var(--ink-2); }
.help ul { margin: 4px 0; padding-left: 20px; }
.help code { background: var(--panel-2); padding: 1px 5px; border-radius: 3px; font-size: 11.5px; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #d3c3a6; border-radius: 5px; }
::-webkit-scrollbar-track { background: var(--paper); }

/* 矢量小图标（面板内的单位/改良图标） */
img.gl { vertical-align: -3px; display: inline-block; }
.unit-icon img.gl { vertical-align: 0; }
.item .ic img.gl { display: block; margin: 0 auto; }

/* 同格多对象切换条 */
.osw {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin: 0 0 8px; padding-bottom: 7px;
  border-bottom: 1px dashed var(--line);
}
.osw-btn {
  font-size: 11.5px; line-height: 1.5;
  padding: 2px 9px; border-radius: 11px;
  border: 1px solid var(--line-2);
  background: var(--panel); color: var(--ink-2);
  transition: background .12s, color .12s, border-color .12s;
}
.osw-btn:hover { background: var(--paper-2); border-color: var(--accent-2); }
.osw-btn.on {
  background: var(--ink-2); border-color: var(--ink-2); color: #fff8e8;
  font-weight: 600;
}
.osw-hp { margin-left: 5px; font-size: 10px; opacity: .7; }

/* 窄屏：压缩顶栏，避免按钮溢出 */
@media (max-width: 1280px) {
  .tb-civ { padding: 0 10px; gap: 7px; }
  .stat { min-width: 64px; padding: 6px 6px; }
  .stat .v { font-size: 14px; }
  .tb-btns { padding: 0 8px; gap: 4px; }
  .tbtn { padding: 7px 8px; font-size: 12px; letter-spacing: 0; }
  #side { width: 300px; flex: 0 0 300px; }
}

/* =========================================================
   文明百科
   ========================================================= */
#codex {
  position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column;
  background:
    radial-gradient(1100px 620px at 12% -12%, var(--bg-glow2) 0%, rgba(255, 248, 230, 0) 60%),
    radial-gradient(900px 520px at 96% 108%, #efe1c5 0%, rgba(239, 225, 197, 0) 58%),
    var(--paper);
}
.cx-bar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 20px;
  padding: 14px 26px; border-bottom: 1px solid var(--line-2);
  background: rgba(247, 240, 226, .94); box-shadow: 0 1px 0 rgba(255, 255, 255, .6) inset;
}
.cx-bar .ghost-btn { margin: 0; }
.cx-brand { display: flex; align-items: baseline; gap: 14px; }
.cx-brand h1 {
  margin: 0; font-family: "Songti SC", Georgia, serif; font-size: 25px; letter-spacing: 8px; color: var(--ink);
}
.cx-brand .sub { color: var(--muted); font-size: 11.5px; letter-spacing: 1px; }
.cx-legend { margin-left: auto; display: flex; gap: 16px; font-size: 11px; color: var(--muted); letter-spacing: .5px; }
.cx-legend b {
  color: var(--ink-2); font-weight: 600; padding: 1px 5px; border: 1px solid var(--line-2);
  border-radius: 3px; background: var(--panel); margin-right: 4px;
}

.cx-wrap { flex: 1; display: flex; min-height: 0; }
.cx-side {
  flex: 0 0 228px; overflow-y: auto; padding: 12px 11px 28px;
  border-right: 1px solid var(--line); background: rgba(252, 246, 234, .72);
}
.cx-side-h { font-size: 10.5px; letter-spacing: 3px; color: var(--muted); padding: 2px 7px 9px; }
.cx-civ {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; color: var(--ink);
  padding: 6px 8px; margin-bottom: 3px; background: none; border: 1px solid transparent;
  border-radius: 5px; transition: background .13s, border-color .13s;
}
.cx-civ:hover { background: var(--panel); border-color: var(--line); }
.cx-civ.on { background: var(--panel-2); border-color: var(--line-2); box-shadow: inset 2px 0 0 var(--c); }
.cx-civ-c {
  flex: 0 0 24px; width: 24px; height: 24px; border-radius: 4px; display: grid; place-items: center;
  background: var(--c); color: #fff8ec; font-family: "Songti SC", serif; font-size: 13px; opacity: .93;
}
.cx-civ-t { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.cx-civ-t b { font-size: 13.5px; letter-spacing: 1px; }
.cx-civ-t i { font-style: normal; font-size: 10.5px; color: var(--muted); }
.cx-civ-n {
  margin-left: auto; font-size: 10px; color: var(--muted); opacity: .55;
  font-variant-numeric: tabular-nums;
}

.cx-main { flex: 1; min-width: 0; overflow-y: auto; padding: 20px 26px 70px; }
.cx-inner { max-width: 1160px; margin: 0 auto; }

/* 文明抬头 */
.cx-top {
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: 15px;
  padding-bottom: 13px; border-bottom: 2px solid var(--line-2);
}
.cx-crest {
  flex: 0 0 52px; width: 52px; height: 52px; border-radius: 6px; display: grid; place-items: center;
  background: var(--c); color: #fff8ec; font-family: "Songti SC", serif; font-size: 25px;
  box-shadow: 0 6px 16px rgba(90, 70, 40, .17);
}
.cx-hd { flex: 1; min-width: 230px; }
.cx-h1 { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.cx-h1 h2 {
  margin: 0; font-family: "Songti SC", Georgia, serif; font-size: 29px; letter-spacing: 4px; color: var(--ink);
}
.cx-leader { font-size: 12px; color: var(--muted); letter-spacing: 1px; }
.cx-trait { margin-top: 5px; font-size: 12.5px; line-height: 1.62; color: var(--ink-2); }
.cx-trait b { color: var(--c); margin-right: 7px; letter-spacing: .5px; }

.cx-quick { flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: 7px; margin-top: 11px; }
.cx-qk {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  padding: 6px 11px; min-width: 104px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 5px; color: var(--ink);
  transition: background .13s, border-color .13s, transform .13s;
}
.cx-qk:hover { background: var(--panel-2); border-color: var(--accent-2); transform: translateY(-1px); }
.cx-qk i { font-style: normal; font-size: 9.5px; letter-spacing: 1px; color: var(--muted); }
.cx-qk b { font-size: 12.5px; letter-spacing: .5px; }
.cx-qk em { font-style: normal; font-size: 9.5px; color: var(--accent); opacity: .85; }
.cx-qk.static { background: transparent; border-style: dashed; cursor: default; }
.cx-qk.static:hover { transform: none; background: transparent; border-color: var(--line); }

/* 时代标签 */
.cx-eras {
  display: flex; gap: 2px; margin: 15px 0 0; border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none;
}
.cx-eras::-webkit-scrollbar { display: none; }
.cx-era {
  position: relative; display: flex; align-items: baseline; gap: 6px; white-space: nowrap;
  padding: 9px 15px 10px; background: none; border: none; color: var(--muted);
  transition: color .13s;
}
.cx-era b { font-size: 13.5px; font-weight: 600; letter-spacing: 1px; }
.cx-era i { font-style: normal; font-size: 10px; opacity: .6; font-variant-numeric: tabular-nums; }
.cx-era:hover { color: var(--ink-2); }
.cx-era.on { color: var(--ink); }
.cx-era.on b { color: var(--accent); }
.cx-era.on::after {
  content: ''; position: absolute; left: 11px; right: 11px; bottom: -1px; height: 2px; background: var(--accent);
}

/* 工具条 + 概览 */
.cx-tools { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 14px 0 12px; }
.cx-modes { display: inline-flex; border: 1px solid var(--line-2); border-radius: 5px; overflow: hidden; }
.cx-mode {
  padding: 5px 13px; font-size: 11.5px; background: var(--panel); border: none; color: var(--muted);
  letter-spacing: .5px;
}
.cx-mode + .cx-mode { border-left: 1px solid var(--line); }
.cx-mode.on { background: #f6e7cd; color: var(--ink); font-weight: 600; }
.cx-tip { font-size: 11px; color: var(--muted); }

.cx-ov {
  display: flex; flex-wrap: wrap; align-items: center; gap: 18px;
  padding: 12px 16px; margin-bottom: 20px; border: 1px solid var(--line); border-radius: 6px;
  background: linear-gradient(180deg, var(--panel), #fbf4e6);
}
.cx-ov-t { flex: 1; min-width: 250px; }
.cx-ov-t b { font-family: "Songti SC", serif; font-size: 16px; letter-spacing: 3px; color: var(--ink); }
.cx-ov-t p { margin: 5px 0 0; font-size: 12px; line-height: 1.6; color: var(--ink-2); }
.cx-ov-n { display: flex; gap: 18px; }
.cx-ov-n span { text-align: center; font-size: 10.5px; color: var(--muted); letter-spacing: 1px; }
.cx-ov-n b { display: block; font-size: 18px; color: var(--accent); font-variant-numeric: tabular-nums; }

/* 区块 */
.cx-sec { margin-bottom: 22px; }
.cx-sec > header { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; }
.cx-sec h3 {
  margin: 0; display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600; letter-spacing: 3px; color: var(--ink-2);
}
.cx-sec h3::before { content: ''; width: 4px; height: 14px; background: var(--accent); }
.cx-sec .cx-n { font-size: 10.5px; color: var(--muted); letter-spacing: 1px; }
.cx-sec .cx-hint { margin-left: auto; font-size: 10.5px; color: var(--muted); }
.cx-empty { font-size: 11.5px; color: var(--muted); padding: 6px 2px 10px; }
.cx-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(274px, 1fr)); gap: 8px; }

/* 卡片 */
.cx-card {
  display: flex; gap: 10px; padding: 10px 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  transition: border-color .13s, box-shadow .13s;
}
.cx-card:hover { border-color: var(--accent-2); box-shadow: var(--shadow); }
.cx-ic {
  flex: 0 0 30px; width: 30px; height: 30px; border-radius: 4px; display: grid; place-items: center;
  background: #f6ecd8; font-size: 16px; line-height: 1;
}
.cx-tx { flex: 1; min-width: 0; }
.cx-row { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.cx-nm { font-size: 13px; letter-spacing: .5px; }
.cx-sp { margin-left: auto; font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.cx-kind {
  font-size: 9.5px; color: var(--accent); border: 1px solid rgba(169, 98, 47, .3);
  border-radius: 3px; padding: 0 4px; white-space: nowrap;
}
.cx-badge {
  font-size: 9.5px; color: #fff8ec; background: var(--accent); border-radius: 3px;
  padding: 0 5px; letter-spacing: 1px; white-space: nowrap;
}
.cx-eratag {
  font-size: 9.5px; color: var(--ink-2); background: #f1e5cf; border-radius: 3px; padding: 0 4px;
  white-space: nowrap;
}
.cx-ds { margin-top: 4px; font-size: 11px; line-height: 1.55; color: var(--ink-2); }
.cx-ft { margin-top: 5px; font-size: 10.5px; color: var(--muted); }
.cx-stats { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.cx-stats span { font-size: 10px; background: var(--panel-2); border-radius: 3px; padding: 1px 5px; color: var(--ink-2); }

/* 国策卡 */
.cx-civic { border-left: 3px solid rgba(169, 98, 47, .32); }
.cx-civic .cx-nm { color: var(--accent); }
.cx-unl {
  display: grid; grid-template-columns: auto auto 1fr; gap: 6px; align-items: baseline;
  margin-top: 5px; font-size: 11px;
}
.cx-unl i {
  font-style: normal; font-size: 9.5px; color: var(--muted);
  border: 1px solid var(--line-2); border-radius: 3px; padding: 0 4px; white-space: nowrap;
}
.cx-unl b { font-size: 11.5px; font-weight: 600; }
.cx-unl span { color: var(--ink-2); line-height: 1.45; }

/* 科技条 */
.cx-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cx-chip {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 4px 9px; font-size: 11px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
}
.cx-chip em { font-style: normal; font-size: 9.5px; color: var(--accent); opacity: .8; }
.cx-chip b { font-weight: 600; }
.cx-chip i { font-style: normal; font-size: 10.5px; color: var(--muted); }

.cx-note { margin-top: 4px; font-size: 11px; color: var(--muted); line-height: 1.6; }

@keyframes cxhl {
  0%, 100% { box-shadow: 0 0 0 0 rgba(169, 98, 47, 0); }
  30% { box-shadow: 0 0 0 3px rgba(169, 98, 47, .26); }
}
.cx-card.hl { animation: cxhl 1.25s ease-out 2; border-color: var(--accent-2); }

@media (max-width: 1120px) {
  .cx-side { flex-basis: 196px; }
  .cx-main { padding: 16px 18px 64px; }
  .cx-grid { grid-template-columns: repeat(auto-fill, minmax(246px, 1fr)); }
  .cx-brand .sub { display: none; }
}
@media (max-width: 880px) {
  #codex { overflow-y: auto; }
  .cx-wrap { flex-direction: column; min-height: 0; }
  .cx-side {
    flex: none; display: block; overflow: visible;
    border-right: none; border-bottom: 1px solid var(--line);
    padding: 8px 10px 9px; background: rgba(252, 246, 234, .92);
  }
  .cx-side-h { display: none; }
  #codexCivList { display: flex; gap: 5px; overflow-x: auto; padding-bottom: 2px; }
  .cx-civ { width: auto; flex: none; margin: 0; padding: 4px 8px; white-space: nowrap; }
  .cx-civ-n, .cx-civ-t i { display: none; }
  .cx-main { overflow: visible; }
  .cx-legend { display: none; }
  .cx-sec .cx-hint { display: none; }
}

/* ===== 联机大厅 ===== */
.mp-note {
  font-size: 12.5px; line-height: 1.8; color: var(--ink-2);
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 10px 14px;
}
.mp-note code { background: #f3e9d4; padding: 1px 5px; border-radius: 3px; font-size: 11.5px; }
.mp-row { display: flex; gap: 8px; margin-top: 8px; max-width: 420px; }
.mp-row input {
  flex: 1; padding: 9px 12px; border: 1px solid var(--line); border-radius: 6px;
  font-size: 13.5px; font-family: inherit; background: #fff; color: var(--ink);
}
.mp-row input:focus { outline: none; border-color: var(--accent); }
.mp-players { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; font-size: 12.5px; }
.mp-player {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px;
}
.mp-player b { font-weight: 600; }
.mp-status { margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.civ-card.taken { opacity: .45; cursor: not-allowed; }
.civ-card .n { display: flex; align-items: baseline; justify-content: space-between; gap: 4px; }
.civ-card .mp-owner {
  font-style: normal; font-size: 10.5px; color: #7a5c28; background: #f3e9d4;
  border-radius: 3px; padding: 0 5px; white-space: nowrap;
}

/* ===== 房间制联机 ===== */
.room-list { display: flex; flex-direction: column; gap: 8px; }
.room-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 10px 14px;
}
.room-row.full { opacity: .6; }
.room-row .rr-main { flex: 1; }
.room-row .rr-main b { font-size: 14px; }
.room-row .rr-main small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.room-row .rr-tag { font-size: 11.5px; color: var(--ink-2); white-space: nowrap; }
.rm-settings {
  display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px;
}
.rm-settings label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); }
.rm-settings select {
  padding: 5px 8px; border: 1px solid var(--line); border-radius: 5px;
  font-family: inherit; font-size: 12.5px; background: #fff; color: var(--ink);
}
.rm-settings select:focus { outline: none; border-color: var(--accent); }
.rm-settings .vchk { display: inline-flex; align-items: center; gap: 3px; margin-left: 8px; font-size: 12px; }
.ready-tag {
  font-size: 10.5px; padding: 0 5px; border-radius: 3px;
  background: #e5f0dc; color: #4a7028; border: 1px solid #c3d9ae;
}


/* ================= 手机端适配（≤980px 或小屏触屏设备） ================= */
/* 侧栏开关按钮：桌面隐藏 */
.tb-sidebtn { display: none; }

#rotateHint {
  display: none;
}
#rhRotate.primary { background: var(--accent); color: #fff; border-color: var(--accent); margin-bottom: 10px; }

/* —— CSS 强制横屏（iOS 等不支持方向锁的设备）：旋转全部顶层容器 —— */
body.force-rot #menu,
body.force-rot #codex, body.force-rot #game, body.force-rot #modalRoot, body.force-rot #toasts,
body.force-rot #achieve, body.force-rot #achToastWrap {
  position: fixed; inset: auto;          /* 先清除原定位，再设置旋转后的盒子 */
  top: var(--rot-y, 0px); left: var(--rot-x, 100vw);
  width: var(--rot-w, 100vh); height: var(--rot-h, 100vw);
  transform: rotate(90deg); transform-origin: 0 0;
  max-width: none; max-height: none;
}
/* iOS 伪横屏锁滚：旋转层的布局盒（旋转前）在视口外，Safari 会把页面撑出四向滚动区+滚动条 */
html.force-rot, html.force-rot body {
  overflow: hidden !important;
  overscroll-behavior: none;
}
html.force-rot body {
  position: fixed !important;
  top: 0 !important; left: 0 !important;
  width: 100% !important; height: 100% !important;
}
body.force-rot #rotateHint { display: none !important; }

@media (max-width: 980px) {
  /* —— 竖屏：提示旋转（可点按钮强行继续） —— */
  #rotateHint.shown,
  #rotateHint:not(.off) {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    position: fixed; inset: 0; z-index: 999;
    background: linear-gradient(160deg, var(--paper), #eaddc2);
    text-align: center; padding: 30px;
  }
  #rotateHint.off { display: none !important; }
  .rh-icon { font-size: 64px; animation: rhTilt 1.6s ease-in-out infinite; }
  @keyframes rhTilt {
    0%, 20% { transform: rotate(0); }
    50%, 70% { transform: rotate(-90deg); }
    100% { transform: rotate(-90deg); }
  }
  .rh-t { font-size: 22px; font-weight: 700; margin: 14px 0 6px; color: var(--ink); }
  .rh-d { font-size: 13px; color: var(--muted); margin-bottom: 22px; }
  #rhIgnore {
    padding: 9px 22px; border: 1px solid var(--line-2); border-radius: 6px;
    background: #fff; color: var(--ink-2); font-size: 13px; font-family: inherit;
  }

  /* —— 触控基础 —— */
  button, .opt, .civ-card, .item { touch-action: manipulation; }
  #map { touch-action: none; }

  /* —— 主菜单压缩 —— */
  .menu-inner { padding-left: 6vw !important; max-width: none !important; }
  #menu .menu-brand h1 { font-size: 40px !important; }
  #menu .menu-brand .sub { font-size: 12px !important; }
  .menu-btn { padding: 10px 16px !important; }
  .menu-btn .k { font-size: 16px !important; }
  .menu-btn .d { font-size: 11px !important; }
  .menu-foot { font-size: 10px !important; }
  .menu-plate { display: none !important; }   /* 国土图鉴在手机上让位 */

  /* —— 设置 / 大厅：单列排布 —— */
  .setup-inner { padding: 12px 14px 40px !important; }
  .setup-section h2 { font-size: 14px !important; }
  .setup-section h2 span { display: block; font-weight: 400; }
  .opt-row { gap: 8px !important; }
  .opt { flex: 1 1 46% !important; max-width: none !important; padding: 8px 10px !important; }
  .civ-grid { grid-template-columns: repeat(3, 1fr) !important; gap: 7px !important; }
  .civ-card { padding: 7px 9px !important; }
  .civ-card .n { font-size: 12.5px !important; }
  .civ-card .l { font-size: 10px !important; }
  .room-list .room-row { padding: 8px 10px !important; }
  .mp-note { font-size: 11.5px !important; }

  /* —— 游戏内：顶栏压缩 —— */
  #topbar { height: 46px; flex: 0 0 46px; }
  .tb-sidebtn {
    display: flex; align-items: center; justify-content: center;
    width: 44px; flex: 0 0 44px; border: 0; border-right: 1px solid var(--line);
    background: transparent; font-size: 18px; color: var(--ink-2);
  }
  .tb-civ { padding: 0 8px !important; gap: 6px !important; }
  .tb-civ .tb-emblem { width: 28px !important; height: 28px !important; font-size: 14px !important; }
  .tb-civ .n { font-size: 12.5px !important; }
  .tb-civ .l { font-size: 10px !important; display: none; }
  .tb-stats { gap: 0 !important; overflow-x: auto; }
  .stat { padding: 0 8px !important; }
  .stat .k { font-size: 9px !important; }
  .stat .v { font-size: 13px !important; }
  .stat .s { font-size: 9px !important; }
  .topbtn, .tbtn { padding: 5px 8px !important; font-size: 11px !important; }

  /* —— 游戏内：侧栏改为抽屉 —— */
  #side {
    position: absolute; top: 46px; bottom: 0; right: 0; z-index: 40;
    width: min(78vw, 300px); flex: none;
    transform: translateX(100%); transition: transform .22s ease;
    box-shadow: -4px 0 14px rgba(60, 40, 20, .18);
  }
  body.side-open #side { transform: none; }
  #btnSide { color: var(--accent); }
  body.side-open #btnSide { background: var(--panel-2); }

  /* —— 底部回合条 —— */
  #bottom { padding: 6px 10px !important; }
  #bottom .turnhint { font-size: 10.5px !important; }
  #nextTurn { padding: 9px 18px !important; font-size: 14px !important; }

  /* —— 弹窗 —— */
  .modal { width: 94vw !important; max-width: 94vw !important; max-height: 88vh !important; }
  .modal-body { max-height: 62vh !important; }
  .toast { font-size: 11.5px !important; }
}
@media (max-width: 980px) and (orientation: landscape) {
  /* 横屏时隐藏旋转提示 */
  #rotateHint { display: none !important; }
  .rh-icon { display: none; }

  /* 横屏矮屏：主菜单整体压缩到一屏内 */
  #menu .menu-brand { margin-bottom: 12px !important; }
  #menu .menu-brand h1 { font-size: 26px !important; }
  #menu .menu-brand .sub { font-size: 10px !important; }
  #menu .menu-brand .tagline { display: none !important; }
  #menu .menu-brand .menu-seal { display: none !important; }
  .menu-list { gap: 4px !important; }
  .menu-btn { padding: 5px 12px !important; border-radius: 5px !important; }
  .menu-btn .k { font-size: 12.5px !important; }
  .menu-btn .d { font-size: 9px !important; }
  .menu-foot { display: none !important; }
  #legend { display: none !important; }   /* 左下角图例与回合提示重叠，手机上隐藏 */
}

/* ================= CSS 强制横屏（body.force-rot）专用布局 =================
   旋转容器内坐标映射：局部宽(x)=100vh(视觉纵向)，局部高(y)=100vw(视觉横向)。
   规则：旋转后的元素 width 用 vh、height/max-height 用 vw；
   视觉“底部固定条” = 局部坐标系右侧(right:0)的竖向条，flex 用 column-reverse 保持 DOM 顺序。 */

/* —— 屏幕容器不滚动，由旋转后的内部内容滚动 ——
   #mpmode/#mp 外壳必须不透明：iOS Safari 对「旋转 fixed 层 + display 切换」的重绘有残影 bug，
   透明外壳会把上一屏（主菜单）透出来。 */
body.force-rot #setup, body.force-rot #mpmode, body.force-rot #mp {
  position: fixed; inset: 0; z-index: 30;
  overflow: hidden; padding: 0;
  background:
    radial-gradient(1200px 600px at 15% -10%, var(--bg-glow2) 0%, rgba(255, 248, 230, 0) 60%),
    radial-gradient(900px 500px at 90% 110%, var(--bg-glow3) 0%, rgba(240, 226, 198, 0) 55%),
    var(--paper);
}
body.force-rot #setup .setup-inner,
body.force-rot #mpmode .setup-inner,
body.force-rot #mp .setup-inner {
  position: absolute; top: 0; left: 100vw;
  width: 100vh; height: 100vw;
  max-width: none; margin: 0;
  transform: rotate(90deg); transform-origin: 0 0;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 12px 96px 22px 16px !important;   /* 右侧留出视觉底栏厚度 */
  box-sizing: border-box;
}

/* —— 设置页底栏：不再旋转，直接用视觉横向固定底栏（与桌面一致），
   地图种子 + 开始游戏常驻底部，任何屏幕高度都完整可见 —— */
body.force-rot .setup-foot {
  position: fixed;
  top: 0; left: 96px;   /* rotate(90) 后落位 buffer 左缘竖条 = 横屏底部 */
  width: 96px; height: 100vw;
  right: auto; bottom: auto;
  transform: rotate(90deg); transform-origin: 0 0;
  /* JS 注入：top=innerHeight-96, left=innerWidth（实测像素，避开 iOS 动态 vh） */
  flex-direction: column-reverse; flex-wrap: nowrap;
  align-items: stretch; justify-content: flex-start;
  gap: 10px; padding: 10px 8px;
  border-top: none;
  border-left: 1px solid var(--line-2);
  box-shadow: -6px 0 18px rgba(90, 70, 40, .07);
  box-sizing: border-box;
}
body.force-rot #startBtn {
  writing-mode: vertical-rl; text-orientation: upright;
  letter-spacing: 7px; font-size: 15px; padding: 12px 0;
  width: 100%; box-sizing: border-box; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
}
body.force-rot .seed-box { flex-direction: column-reverse; gap: 6px; align-items: stretch; width: 100%; }
body.force-rot .seed-box .hint { text-align: center; font-size: 10px; }
body.force-rot .seed-box input { width: 100%; padding: 6px 6px; font-size: 12px; box-sizing: border-box; text-align: center; }
body.force-rot .seed-box .tbtn { width: 100%; padding: 5px 0; }
body.force-rot #setupHint { display: none; }   /* 底栏放不下长提示 */

/* —— 文明选择：force-rot 下为文档流内区块（与桌面同构，随页面一起滚动） ——
   旋转坐标：column-reverse 让 DOM 首位（详情卡）落在视觉左侧；
   必须显式限高（视觉宽度预算=100vw-底栏62-边距），否则百分比失效铺满全屏；
   列表卡片沿 local y 横排、wrap 沿 local x（即视觉向下）翻行，overflow-x 即视觉纵向滚动。 */
body.force-rot #civPickSection .civ-select {
  flex-direction: row;   /* local x = 横屏横向：左详情 / 右列表，与桌面完全同构 */
  height: clamp(320px, calc(100vw - 150px), 520px);   /* local y = 横屏高度（100vw 稳定可靠） */
  gap: 10px;
}
body.force-rot #civPickSection .civ-detail {
  flex: 0 0 38%; position: static; min-height: 0; align-self: stretch;
  padding: 12px 14px; overflow-y: auto; box-sizing: border-box;
}
body.force-rot #civPickSection .civ-list-wrap {
  flex: 1; min-height: 0; max-height: none; height: auto;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 8px; box-sizing: border-box;
}
body.force-rot #civPickSection .civ-list-wrap .civ-grid {
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
  gap: 7px !important;
}
body.force-rot #civPickSection .civ-list-wrap .civ-card { min-height: 60px; min-width: 0; padding: 6px 9px !important; }
body.force-rot #civPickSection .civ-list-wrap .civ-card .nm { font-size: 12.5px !important; }
body.force-rot #civPickSection .civ-list-wrap .civ-card .ld { font-size: 10.5px !important; }
body.force-rot #civPickSection .civ-list-wrap .civ-card .tr { font-size: 10px !important; margin-top: 3px !important; }
body.force-rot #setup .civ-detail .cd-emblem { width: 30px; height: 30px; font-size: 15px; margin-bottom: 4px; }
body.force-rot #setup .civ-detail .cd-name { font-size: 15px; letter-spacing: 1px; }
body.force-rot #setup .civ-detail .cd-leader { font-size: 11px; margin-bottom: 6px; }
body.force-rot #setup .civ-detail .cd-trait { padding: 1px 0 1px 7px; margin-bottom: 6px; }
body.force-rot #setup .civ-detail .cd-trait b { font-size: 11.5px; }
body.force-rot #setup .civ-detail .cd-trait p { font-size: 10.5px; }
body.force-rot #setup .civ-detail .cd-rows > div { margin-top: 5px; font-size: 10.5px; line-height: 1.5; }
/* 覆盖层方案的遗留全部废弃：顶栏/收起态不再使用 */
body.force-rot #setup .setup-section h2 span { display: none !important; }
/* 伪横屏下品牌大标题会变成整条竖排浪费一整列 —— 收纳成紧凑小条，只留返回按钮 */
body.force-rot #setup .brand { display: block; padding-bottom: 8px; margin-bottom: 8px; }
body.force-rot #setup .brand h1,
body.force-rot #setup .brand .sub,
body.force-rot #setup .brand .seal { display: none !important; }
body.force-rot #setup .brand .ghost-btn { padding: 7px 12px; font-size: 11.5px; }

/* —— 弹窗：宽用 vh、高用 vw —— */
body.force-rot .modal { width: min(1080px, 92vh) !important; max-width: min(1080px, 92vh) !important; max-height: 88vw !important; }
body.force-rot .modal.narrow { width: min(720px, 78vh) !important; max-width: min(720px, 78vh) !important; }
body.force-rot .modal.wide { width: min(1500px, 96vh) !important; max-width: min(1500px, 96vh) !important; }
body.force-rot .modal-body { max-height: none !important; flex: 1 1 auto; min-height: 0; }
body.force-rot .modal { height: auto; }
body.force-rot .modal-head { padding: 10px 14px; }
body.force-rot .modal-head h2 { font-size: 15px; }
body.force-rot .modal-body { padding: 10px 12px; }
body.force-rot .modal-foot { padding: 8px 12px; }

/* —— 弹窗内网格：适配 ~100vh 宽的旋转容器 —— */
body.force-rot .civ-grid { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)) !important; gap: 8px !important; }
body.force-rot .civ-card { padding: 7px 9px !important; }
body.force-rot .civ-card .nm { font-size: 13.5px !important; }
body.force-rot .civ-card .ds { min-height: 0 !important; }
body.force-rot .opt-row { gap: 7px !important; }
body.force-rot .opt { flex: 1 1 170px !important; max-width: 320px !important; min-width: 0 !important; }
body.force-rot .mapopt { flex: 1 1 200px !important; max-width: 300px !important; }
body.force-rot .policy-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
body.force-rot .civic-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
/* 强制横屏下小地图放本地左上（物理右上），避开左下的提示卡片 */
body.force-rot #minimap { top: 8px; left: 8px; bottom: auto; }
/* 触屏端（非强制横屏）弹窗才用 94vw；强制横屏沿用 vh 宽度 */
body.touch-device:not(.force-rot) .modal { width: 94vw !important; max-width: 94vw !important; }
/* 触屏端：侧栏为抽屉，底栏不再为常驻侧栏留白；按钮文字不折行 */
body.touch-device #bottom { right: 10px !important; }
body.touch-device #nextTurn, body.touch-device #btnNextUnit { white-space: nowrap; }
/* 手机端：顶栏功能按钮收纳为「⋯」展开面板 */
@media (max-width: 980px) {
  #topbar { position: relative; }
  .tb-btns { display: none !important; }
  body.tools-open .tb-btns {
    display: flex !important; flex-direction: column; align-items: stretch;
    position: absolute; right: 6px; top: 52px; z-index: 60;
    /* top 52px：整体下移，避开 Toy 等平台容器悬浮在右上角的关闭 ✕（约 44px 高） */
    background: var(--panel); border: 1px solid var(--line-2); border-radius: 6px;
    padding: 8px; gap: 6px; box-shadow: var(--shadow);
  }
  body.tools-open .tb-btns .tbtn { white-space: nowrap; }
  body.tools-open #btnTopSettings { display: none !important; }
  #btnTools { display: flex !important; color: var(--accent); }
  #btnToolsClose, #btnToolsSettings { display: block !important; }
}
body.force-rot .slots { grid-template-columns: repeat(4, 1fr); gap: 6px; }
body.force-rot .gov-row .gov { min-width: 110px; }
body.force-rot .techcol { flex: 0 0 178px; }
body.force-rot .setup-section { margin-top: 14px; }

/* —— 主菜单：压缩到旋转后的一屏内 —— */
body.force-rot .menu-inner { padding-left: 4vw !important; }
body.force-rot #menu .menu-brand { margin-bottom: 12px !important; }
body.force-rot #menu .menu-brand h1 { font-size: 26px !important; letter-spacing: 5px; }
body.force-rot #menu .menu-brand .sub { font-size: 10px !important; }
body.force-rot #menu .menu-brand .tagline { display: none !important; }
body.force-rot #menu .menu-brand .menu-seal { display: none !important; }
body.force-rot .menu-list { gap: 4px !important; }
body.force-rot .menu-btn { padding: 5px 12px !important; border-radius: 5px !important; }
body.force-rot .menu-btn .k { font-size: 12.5px !important; }
body.force-rot .menu-btn .d { font-size: 9px !important; }
body.force-rot .menu-foot { display: none !important; }

/* —— 联机大厅 —— */
body.force-rot .civ-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)) !important; }

/* —— 百科：侧栏变窄 —— */
body.force-rot .cx-side { width: 30vh; flex: 0 0 30vh; }
body.force-rot .cx-bar { padding: 8px 12px; }
body.force-rot .cx-brand h1 { font-size: 16px !important; }
body.force-rot .cx-legend { display: none; }

/* ---- 文明选择：左右两栏（左详情 / 右滚动列表） ---- */
.civ-select { display: flex; gap: 14px; align-items: stretch; }
.civ-detail {
  flex: 0 0 330px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 6px; padding: 16px 18px; align-self: flex-start; position: sticky; top: 0;
  min-height: 500px; box-sizing: border-box;   /* 锁定高度：切换文明时页面不跳动 */
}
.civ-detail .cd-emblem {
  width: 46px; height: 46px; border-radius: 6px; color: #fff; font-size: 23px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; margin-bottom: 8px;
}
.civ-detail .cd-name { font-size: 21px; font-weight: 700; letter-spacing: 2px; }
.civ-detail .cd-leader { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.civ-detail .cd-trait { border-left: 3px solid var(--accent); padding: 2px 0 2px 10px; margin-bottom: 12px; }
.civ-detail .cd-trait b { font-size: 13.5px; }
.civ-detail .cd-trait p { margin: 2px 0 0; font-size: 12px; color: var(--ink-2); line-height: 1.55; }
.civ-detail .cd-rows > div { margin-top: 9px; font-size: 12px; line-height: 1.5; }
.civ-detail .cd-rows span { color: var(--muted); }
.civ-detail .cd-rows p { margin: 2px 0 0; line-height: 1.5; }
.civ-list-wrap {
  flex: 1; min-width: 0; max-height: 520px; min-height: 500px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 6px; padding: 10px;
  background: var(--panel); box-sizing: border-box;
}
.civ-list-wrap .civ-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.civ-list-wrap .civ-card .ds, .civ-list-wrap .civ-card .uu { display: none; }
.civ-list-wrap .civ-card { min-height: 76px; height: auto; padding: 10px 12px; overflow: visible; }
.civ-list-wrap .civ-card .nm { font-size: 15px; }
.civ-list-wrap .civ-card .ld { font-size: 12px; }
.civ-list-wrap .civ-card .tr { font-size: 12px; margin-top: 6px; }
@media (max-width: 980px) {
  .civ-select { flex-direction: column; }
  .civ-detail { flex: none; position: static; min-height: 0; }
  .civ-list-wrap { max-height: 320px; min-height: 0; }
  .civ-list-wrap .civ-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)) !important; }
}

/* ---- 选项卡统一：一排尽量铺满、高度一致 ---- */
#setup .opt-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 8px;
}
#setup .opt-row .opt {
  min-width: 0 !important;
  max-width: none !important;
  flex: none !important;
  min-height: 72px;
}
#setup .opt-row .opt .d { max-width: none !important; }

/* ---- 文明列表卡片统一大小 ---- */
.civ-list-wrap .civ-card { height: 52px; display: flex; flex-direction: column; justify-content: center; }
.civ-list-wrap .civ-card .top { display: flex; gap: 6px; align-items: baseline; min-width: 0; }
.civ-list-wrap .civ-card .nm,
.civ-list-wrap .civ-card .ld,
.civ-list-wrap .civ-card .tr {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.civ-list-wrap .civ-card .top .nm { flex: 0 1 auto; }
.civ-list-wrap .civ-card .top .ld { flex: 1 1 auto; text-align: right; }

/* ---- 编年史 ---- */
.chron { max-height: 55vh; overflow-y: auto; padding-right: 4px; }
.chron-era {
  text-align: center; font-size: 12.5px; letter-spacing: 3px; font-weight: 700;
  margin: 14px 0 8px; opacity: .85;
}
.chron-row {
  display: flex; gap: 10px; padding: 5px 8px; margin-bottom: 4px;
  background: var(--panel); border-radius: 4px; font-size: 12.5px;
  align-items: baseline;
}
.chron-year { flex: 0 0 78px; color: #9a8460; font-size: 11.5px; text-align: right; white-space: nowrap; }
.chron-text { flex: 1; line-height: 1.5; }

/* ---- 主题切换按钮 & 编年史按钮（桌面也可见） ---- */
#btnChronicle {
  display: flex; align-items: center; justify-content: center;
  width: 44px; flex: 0 0 44px; border: 0; border-right: 1px solid var(--line);
  background: transparent; font-size: 18px; color: var(--ink-2);
}
#btnChronicle:hover, #btnTheme:hover { background: var(--panel-2); }
#btnTheme {
  background: transparent; border: 1px solid var(--line); border-radius: 5px;
  color: var(--ink-2); font-size: 13px; padding: 3px 8px;
}
#menuTheme {
  position: absolute; top: 16px; right: 18px; z-index: 5;
  background: var(--panel); border: 1px solid var(--line); border-radius: 5px;
  color: var(--ink-2); font-size: 12.5px; padding: 5px 10px;
}
#menuTheme:hover { border-color: var(--accent-2); }

/* ---- 市政研究：整齐网格 ---- */
.civic-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 8px;
}
.civic-grid .pol { min-width: 0 !important; height: 100%; box-sizing: border-box; }

/* ================= force-rot iOS 视口修正与主菜单一屏化 =================
   iOS Safari 的 100vh 是含工具栏的大视口，旋转容器会比可视区高出 ~180px 导致内容上下被裁；
   用 dvh/dvw（动态视口）修正，老浏览器回退 vh/vw。 */
@supports (width: 100dvh) {
  body.force-rot #menu, body.force-rot #codex, body.force-rot #game,
  body.force-rot #modalRoot, body.force-rot #toasts,
  body.force-rot .setup-inner {
    width: 100dvh !important;
    height: 100dvw !important;
  }
  body.force-rot .setup-foot {
    top: calc(100dvh - 96px) !important;
  }
}

/* —— force-rot 主菜单：与 PC 端一致的双栏布局（左菜单 / 右文明图鉴） ——
   旋转容器内：横向空间 = 100vh（长边），纵向空间 = 100vw（短边），
   因此横向尺寸用 vh、纵向尺寸用 vw 表达。 */
body.force-rot #menu {
  display: flex !important;
  align-items: center !important;
  padding: 0 4vh 0 3vh !important;
  gap: 2.5vh;
}
body.force-rot .menu-inner {
  position: relative !important;
  inset: auto !important;
  order: 1;
  flex: 0 0 auto;
  height: 100% !important;
  max-width: none !important;
  width: auto !important;
  display: flex !important;
  flex-direction: column !important;
  /* 内容超出时顶部对齐 + auto 外边距；不做滚动区（与图鉴卡同层级贴背景，由 JS 缩放适配） */
  justify-content: flex-start !important;
  align-items: stretch !important;
  padding: 2vw 0 !important;
  overflow: visible !important;
  box-sizing: border-box !important;
}
body.force-rot .menu-inner > :first-child { margin-top: auto !important; }
body.force-rot .menu-inner > :last-child { margin-bottom: auto !important; }
body.force-rot .menu-brand {
  margin-bottom: 2.4vw !important;
  width: auto !important;
  text-align: left;
}
body.force-rot .menu-brand h1 {
  font-size: clamp(19px, 6.2vw, 30px) !important;
  letter-spacing: 5px !important;
  line-height: 1.15 !important;
}
body.force-rot .menu-brand .sub { font-size: clamp(9px, 2.6vw, 11px) !important; letter-spacing: 3px !important; }
body.force-rot .menu-brand .tagline { font-size: clamp(8.5px, 2.3vw, 10px) !important; }
body.force-rot .menu-brand .menu-seal { font-size: clamp(9px, 2.4vw, 11px) !important; }
body.force-rot .menu-list {
  width: auto !important;
  max-width: 100% !important;
  gap: clamp(3px, 1.4vw, 7px) !important;
}
body.force-rot .menu-btn {
  padding: clamp(4px, 1.5vw, 9px) clamp(10px, 3vw, 16px) !important;
  border-radius: 6px !important;
}
body.force-rot .menu-btn .k { font-size: clamp(12px, 3.1vw, 15px) !important; letter-spacing: 3px !important; }
body.force-rot .menu-btn .d { font-size: clamp(9px, 2.2vw, 11px) !important; margin-top: 2px !important; }
/* 右侧文明图鉴卡：横向预算 = 100vh - 菜单列，纵向预算 = 100vw */
body.force-rot .menu-foot {
  display: flex !important;    /* 恢复被矮屏隐藏的存档信息：伪横屏下由内容缩放保证放得下 */
  flex-wrap: wrap;
  gap: 6px 14px !important;
  margin-top: 2vw !important;
  font-size: clamp(8.5px, 2.2vw, 10.5px) !important;
}
body.force-rot .menu-plate {
  order: 2;
  flex: 1 1 auto;
  display: block !important;   /* 覆盖窄屏媒体查询的隐藏：旋转后横向空间由 100vh（长边）提供 */
  margin: 0 auto !important;
  width: min(30vh, 300px, calc(100vh - 430px)) !important;
  min-width: 170px;
}
body.force-rot .mp-name { font-size: clamp(16px, 4.6vw, 22px) !important; letter-spacing: 3px !important; }
body.force-rot .mp-trait { font-size: clamp(9.5px, 2.4vw, 11px) !important; line-height: 1.5 !important; margin-top: 5px !important; }
body.force-rot .mp-title { margin-top: 7px !important; padding-top: 7px !important; }
body.force-rot .mp-uni { margin-top: 6px !important; gap: 4px !important; }
body.force-rot .mp-uni span { font-size: 9.5px !important; padding: 1px 5px !important; }
body.force-rot .mp-cap { font-size: 9.5px !important; margin-top: 5px !important; }
body.force-rot .mp-head { font-size: 9.5px !important; padding-bottom: 5px !important; }
body.force-rot .mp-foot { margin-top: 6px !important; }
/* 极矮屏幕（横屏浏览器窗口矮）时图鉴让位，保菜单完整 */
@media (max-height: 340px) {
  body.force-rot .menu-plate { display: none !important; }
  body.small-land .menu-plate { display: none !important; }
}

/* —— 原生横屏矮视口（Toy 容器横屏 ~872x393 等）主菜单一屏化 ——
   无 CSS 旋转，但内容超高且图鉴被 980px 媒体查询隐藏 → 与 force-rot 同款双栏：
   菜单列顶部对齐（子块真实范围可测，供 JS 缩放）+ 图鉴卡显示（JS 同步缩放）。 */
body.small-land #menu {
  padding: 0 4vh 0 6vh !important;
  gap: 2.5vh;
}
body.small-land .menu-inner {
  height: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: flex-start !important;
  align-items: stretch !important;
  padding: 2vh 0 !important;
  overflow: visible !important;
  box-sizing: border-box !important;
}
body.small-land .menu-inner > :first-child { margin-top: auto !important; }
body.small-land .menu-inner > :last-child { margin-bottom: auto !important; }
body.small-land .menu-plate {
  order: 2;
  flex: 0 1 auto;
  display: block !important;   /* 覆盖 980px 媒体查询的隐藏：Toy 横屏也要右侧国家介绍 */
  margin: 0 auto !important;
  width: clamp(240px, 30vw, 340px) !important;   /* 随视口加宽：过窄会让国名竖排、文字拥挤 */
  min-width: 240px;
}
/* 菜单列收窄（描述文字超宽自动省略号），把横向空间让给图鉴卡 */
body.small-land .menu-list { width: 340px !important; max-width: 100% !important; }
/* 国土图压扁 + 竖向间距收紧：降低卡片自然高度 → 减小 JS 缩放损耗，卡片视觉更宽 */
body.small-land .mp-map { aspect-ratio: 1 / 0.74; }
body.small-land .mp-title { margin-top: 7px !important; padding-top: 7px !important; }
body.small-land .mp-uni { margin-top: 6px !important; }
body.small-land .mp-cap { margin-top: 6px !important; }
body.small-land .mp-foot { margin-top: 6px !important; }

/* —— small-land 设置页：文明选择保持 左详情 / 右列表（与桌面同构） ——
   否则 980px 媒体查询把 .civ-select 压成上下堆叠，矮横屏上详情占满首屏、列表沉底 */
body.small-land #civPickSection .civ-select {
  flex-direction: row;
  height: clamp(280px, calc(100vh - 110px), 460px);
  gap: 10px;
}
body.small-land #civPickSection .civ-detail {
  flex: 0 0 38%; position: static; min-height: 0; align-self: stretch;
  padding: 12px 14px; overflow-y: auto; box-sizing: border-box;
}
body.small-land #civPickSection .civ-list-wrap {
  flex: 1; min-width: 0; min-height: 0; max-height: none; height: auto;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 8px; box-sizing: border-box;
}
body.small-land #civPickSection .civ-list-wrap .civ-grid {
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
  gap: 7px !important;
}
body.small-land #civPickSection .civ-card { min-height: 60px; min-width: 0; padding: 6px 9px !important; }
body.small-land #civPickSection .civ-card .nm { font-size: 12.5px !important; }
body.small-land #civPickSection .civ-card .ld { font-size: 10.5px !important; }
body.small-land #civPickSection .civ-card .tr { font-size: 10px !important; margin-top: 3px !important; }
body.small-land #setup .civ-detail .cd-emblem { width: 30px; height: 30px; font-size: 15px; margin-bottom: 4px; }
body.small-land #setup .civ-detail .cd-name { font-size: 15px; letter-spacing: 1px; }
body.small-land #setup .civ-detail .cd-leader { font-size: 11px; margin-bottom: 6px; }
body.small-land #setup .civ-detail .cd-trait { padding: 1px 0 1px 7px; margin-bottom: 6px; }
body.small-land #setup .civ-detail .cd-trait b { font-size: 11.5px; }
body.small-land #setup .civ-detail .cd-trait p { font-size: 10.5px; }
body.small-land #setup .civ-detail .cd-rows > div { margin-top: 5px; font-size: 10.5px; line-height: 1.5; }
/* —— small-land 底栏压缩：按钮减半、栏高压半（原 padding 12px+按钮 14px/17px 是桌面尺寸） —— */
body.small-land .setup-foot { padding: 5px 14px !important; gap: 12px; flex-wrap: nowrap !important; }
body.small-land #startBtn { padding: 6px 20px; font-size: 13px; letter-spacing: 3px; box-shadow: 0 2px 8px rgba(150, 82, 31, .25); flex: none; }
body.small-land .seed-box { flex: none; }
body.small-land .seed-box input { width: 92px; padding: 5px 8px; font-size: 12px; }
body.small-land .seed-box .tbtn { padding: 4px 10px; }
body.small-land #setupHint { font-size: 10.5px; flex: 1 1 0; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ================= 触屏设备（平板 UA 伪装 PC，按输入能力识别） =================
   关键：#map 必须 touch-action:none，否则浏览器把单指拖动当页面滚动吞掉 */
body.touch-device button,
body.touch-device .opt,
body.touch-device .civ-card,
body.touch-device .item,
body.touch-device .menu-btn { touch-action: manipulation; }
body.touch-device #map { touch-action: none; }

/* 平板竖屏时给出横屏提示（可忽略继续） */
@media (orientation: portrait) {
  body.touch-device #rotateHint {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    position: fixed; inset: 0; z-index: 999;
    background: linear-gradient(160deg, var(--paper), #eaddc2);
    text-align: center; padding: 30px;
  }
}
body.touch-device #rotateHint.off { display: none !important; }
@media (orientation: landscape) {
  body.touch-device #rotateHint:not(.off) { display: none !important; }
}
body.touch-device .rh-icon { font-size: 64px; animation: rhTilt 1.6s ease-in-out infinite; }
@keyframes rhTilt {
  0%, 20% { transform: rotate(0); }
  50%, 70% { transform: rotate(-90deg); }
  100% { transform: rotate(-90deg); }
}
body.touch-device .rh-t { font-size: 22px; font-weight: 700; margin: 14px 0 6px; color: var(--ink); }
body.touch-device .rh-d { font-size: 13px; color: var(--muted); margin-bottom: 22px; }
body.touch-device #rhRotate { background: var(--accent); color: #fff; border-color: var(--accent); margin-bottom: 10px; }
body.touch-device #rhIgnore { padding: 9px 22px; border: 1px solid var(--line-2); border-radius: 6px; background: #fff; color: var(--ink-2); font-size: 13px; font-family: inherit; }

/* 游戏内：顶栏压缩 + 抽屉侧栏（与手机端一致，保证触摸可操作） */
body.touch-device #topbar { height: 46px; flex: 0 0 46px; }
body.touch-device .tb-sidebtn {
  display: flex; align-items: center; justify-content: center;
  width: 44px; flex: 0 0 44px; border: 0; border-right: 1px solid var(--line);
  background: transparent; font-size: 18px; color: var(--ink-2);
}
body.touch-device .tb-civ { padding: 0 8px !important; gap: 6px !important; }
body.touch-device .tb-civ .tb-emblem { width: 28px !important; height: 28px !important; font-size: 14px !important; }
body.touch-device .tb-civ .n { font-size: 12.5px !important; }
body.touch-device .tb-civ .l { font-size: 10px !important; display: none; }
body.touch-device .tb-stats { gap: 0 !important; overflow-x: auto; }
body.touch-device .stat { padding: 0 8px !important; }
body.touch-device .stat .k { font-size: 9px !important; }
body.touch-device .stat .v { font-size: 13px !important; }
body.touch-device .stat .s { font-size: 9px !important; }
body.touch-device .topbtn, body.touch-device .tbtn { padding: 5px 8px !important; font-size: 11px !important; }
body.touch-device #side {
  position: absolute; top: 46px; bottom: 0; right: 0; z-index: 40;
  width: min(60vw, 340px); flex: none;
  transform: translateX(100%); transition: transform .22s ease;
  box-shadow: -4px 0 14px rgba(60, 40, 20, .18);
}
body.touch-device.side-open #side { transform: none; }
body.touch-device #btnSide { color: var(--accent); }
body.touch-device.side-open #btnSide { background: var(--panel-2); }
body.touch-device #bottom { padding: 6px 10px !important; }
body.touch-device #bottom .turnhint { font-size: 10.5px !important; }
body.touch-device #nextTurn { padding: 9px 18px !important; font-size: 14px !important; }
body.touch-device .modal { width: 94vw !important; max-width: 94vw !important; }
body.touch-device .modal-body { max-height: 70vh !important; }

/* —— force-rot 百科：文明选择改为视觉顶部的紧凑横排（拖动滚动，占面积极小） ——
   旋转坐标映射：cx-side 是 local 左侧窄列（flex-basis 即视觉条高），
   内部 chip 沿 local y 排列 → 视觉上成一横排；overflow-y 即视觉横向拖动。
   chip 用 flex-grow 沿条长弹性摊满：内容不足一屏时拉伸填满（不留空白），
   超出一屏时按自然尺寸滚动。 */
body.force-rot .cx-side {
  flex: 0 0 88px !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: flex-start;
  gap: 5px;
  overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 7px 5px !important;
}
body.force-rot .cx-side-h { display: none !important; }   /* 「选择文明」标题省掉 */
body.force-rot .cx-civ {
  flex: 1 0 auto !important;        /* 沿条长（local y）吸收剩余空间 */
  min-height: 56px;
  max-height: 120px;
  flex-direction: column;           /* 徽记在上、名字在下（local） */
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: auto !important;
  padding: 5px 4px !important;
  margin: 0 !important;
}
body.force-rot .cx-civ-c { flex: 0 0 26px; width: 26px; height: 26px; font-size: 14px; border-radius: 5px; }
body.force-rot .cx-civ-t { align-items: center; text-align: center; }
body.force-rot .cx-civ-t b { font-size: 12.5px !important; letter-spacing: 0 !important; line-height: 1.2; }
body.force-rot .cx-civ-t i { display: none !important; }  /* 领袖名省掉 */
body.force-rot .cx-civ-n { display: none !important; }    /* 城市数省掉 */
body.force-rot .cx-civ.on { box-shadow: inset 0 0 0 1px var(--line-2), inset 2px 0 0 var(--c); }

/* —— 联机观战模式：只读 —— */
body.spec-mode #side { pointer-events: none; opacity: .82; }
body.spec-mode #bottom .turnhint { color: var(--muted); }

/* —— 设置弹窗板块选项卡 —— */
.set-tab { padding: 5px 16px; border-radius: 5px; border: 1px solid var(--line); background: transparent; color: var(--ink-2); font-size: 12.5px; }
.set-tab.cur { background: var(--accent); color: #fff; border-color: var(--accent); }
.set-sec small { line-height: 1.5; }

/* —— 单位动作面板：屏幕左侧竖排（无底框，仅按钮本身） ——
   定位收敛到样式表（原为 JS 内联 left:10px）：calc 接 safe-area 变量，
   触屏横屏下自动让出灵动岛/刘海（--safe-l 由上面的媒体查询定义） */
#unitBubbles {
  position: absolute; left: calc(10px + var(--safe-l, 0px)); top: 50%;
  transform: translateY(-50%); display: flex; flex-direction: column; gap: 6px;
  pointer-events: auto; z-index: 14;
}
#unitBubbles .unit-bubble { justify-content: flex-start; }

/* —— 回合上限滑条（Unciv 式） —— */
.tl-slider { display: flex; align-items: center; gap: 10px; width: 100%; padding: 4px 6px; }
.tl-label { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.tl-btn {
  width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line-2);
  background: var(--panel); color: var(--ink); font-size: 15px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto; font-family: inherit;
}
.tl-btn:hover { background: var(--panel-2); }
.tl-edit { font-size: 13px; }
.tl-val { font-size: 14px; min-width: 44px; text-align: center; color: var(--ink); }
#tlRange { flex: 1; accent-color: var(--accent); height: 6px; cursor: pointer; min-width: 120px; }
body.force-rot #setup .setup-section h2 span { display: none !important; }

/* —— AI 阵容席位 —— */
.ai-slot.rand { border-style: dashed; }

/* ==================== 成就系统 ==================== */
.menu-pair { display: flex; gap: 10px; width: 100%; }
.menu-pair .menu-btn { flex: 1 1 0; min-width: 0; }

#achieve {
  position: fixed; inset: 0; z-index: 60; overflow: hidden;
  display: flex; flex-direction: column;
  background:
    radial-gradient(70% 70% at 70% 45%, transparent 0%, transparent 78%),
    linear-gradient(160deg, var(--paper), #eaddc2),
    repeating-linear-gradient(-60deg, rgba(160, 130, 85, .055) 0 1px, transparent 1px 26px);
}
#achieve.hidden { display: none; }
.ach-wrap { flex: 1; overflow-y: auto; padding: 0 4vw 44px; }
.ach-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 18px; }
.ach-tab {
  padding: 6px 14px; border: 1px solid var(--line-2); border-radius: 999px;
  background: rgba(255, 253, 247, .55); font-family: inherit; font-size: 12.5px;
  color: var(--ink-2); cursor: pointer;
}
.ach-tab.cur { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.ach-card {
  border: 1px solid var(--line-2); border-radius: 8px; padding: 12px 14px;
  background: rgba(255, 253, 247, .6);
}
.ach-card.got {
  border-color: #b08a3e; background: linear-gradient(160deg, #fdf6e3, #f7ecd2);
  box-shadow: 0 2px 10px rgba(150, 110, 40, .12);
}
.ach-name {
  font-weight: 700; font-size: 14px; color: var(--ink);
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.ach-card:not(.got) .ach-name { color: var(--muted); }
.ach-tick { color: #9a7b2d; font-style: normal; }
.ach-desc { font-size: 12px; margin-top: 4px; line-height: 1.6; color: var(--ink-2); }
.ach-card:not(.got) .ach-desc { color: var(--muted); }
.ach-prog { position: relative; height: 6px; background: rgba(0, 0, 0, .08); border-radius: 4px; margin-top: 9px; }
.ach-prog i { position: absolute; left: 0; top: 0; bottom: 0; background: #b08a3e; border-radius: 4px; }
.ach-prog span { position: absolute; right: 0; top: 8px; font-size: 10px; color: var(--muted); }

#achToastWrap { position: fixed; inset: 0; z-index: 1200; pointer-events: none; }
#achToast {
  position: absolute; top: 14px; left: 14px; pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(160deg, #2e2a22, #3c352a); color: #f3ead6;
  border: 1px solid #b08a3e; border-radius: 10px; padding: 10px 26px 10px 14px;
  max-width: 340px; box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
  transform: translateX(-120%); opacity: 0; transition: transform .35s ease, opacity .35s ease;
}
#achToast.show { transform: none; opacity: 1; }
.ach-t-badge {
  width: 38px; height: 38px; border-radius: 6px; flex: 0 0 auto;
  background: #b08a3e; color: #fff; display: flex; align-items: center;
  justify-content: center; font-weight: 700; font-size: 12px; text-align: center; line-height: 1.1;
}
.ach-t-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ach-t-txt b { font-size: 13px; }
.ach-t-txt span { font-size: 11px; opacity: .8; }
.ach-t-x {
  position: absolute; top: 4px; right: 8px; background: none; border: 0;
  color: #cfc6b2; font-size: 15px; cursor: pointer; font-family: inherit;
}

/* 结算：本局新解锁成就 */
.vic-ach {
  margin-top: 16px; padding: 12px 14px; border: 1px solid #b08a3e; border-radius: 8px;
  background: linear-gradient(160deg, #fdf6e3, #f7ecd2); text-align: left;
  max-height: 220px; overflow-y: auto;
}
.vic-ach-h { font-weight: 700; font-size: 13px; color: #7a5b1e; margin-bottom: 8px; }
.vic-ach-row { padding: 5px 0; border-bottom: 1px dashed rgba(150, 110, 40, .25); }
.vic-ach-row:last-child { border-bottom: 0; }
.vic-ach-row b { display: block; font-size: 13px; color: var(--ink); }
.vic-ach-row span { font-size: 11.5px; color: var(--ink-2); }

/* =========================================================
   玄墨主题：硬编码浅色表面修正
   大量组件底色写死为白色/米白（浅色主题专用），深色主题下
   继承的浅色文字（--ink/--ink-2）落在浅底上不可读 → 统一翻深。
   ========================================================= */
/* —— 主菜单按钮（用户首报问题：浅 parchment 底 + 浅字） —— */
body.theme-dark .menu-btn { background: rgba(48, 42, 35, .86); }
body.theme-dark .menu-btn:hover { background: #3a332b; }
/* —— 通用按钮 / 小按钮 / 标签页 —— */
body.theme-dark .act { background: var(--panel-2); }
body.theme-dark .qbtn { background: var(--panel-2); }
body.theme-dark .qbtn.del:hover { background: rgba(224, 106, 90, .16); border-color: var(--red); }
body.theme-dark .tab { background: var(--panel-2); }
body.theme-dark .itemlist { background: var(--panel); }
body.theme-dark .border-box { background: var(--panel); }
/* —— 城市面板 —— */
body.theme-dark .y { background: var(--panel-2); }
body.theme-dark .unit-icon { background: var(--panel-2); }
body.theme-dark .map-tip { background: rgba(35, 30, 25, .96); }
/* —— 科技 / 政体 / 政策 / 外交 —— */
body.theme-dark .tech { background: var(--panel); }
body.theme-dark .tech.owned { background: rgba(111, 179, 127, .12); border-color: rgba(111, 179, 127, .4); }
body.theme-dark .tech.owned::after { color: var(--green); }
body.theme-dark .gov { background: var(--panel); }
body.theme-dark .gov.on { background: rgba(201, 122, 61, .14); }
body.theme-dark .dip { background: var(--panel); }
body.theme-dark .slot .p:hover { background: var(--panel-2); }
/* —— 文明卡选中 / 存档栏位 —— */
body.theme-dark .civ-card.on { background: rgba(201, 122, 61, .14); }
body.theme-dark .save-slot { background: var(--panel); }
body.theme-dark .save-slot.auto { background: rgba(201, 122, 61, .10); }
body.theme-dark .save-slot .no.auto { background: rgba(201, 122, 61, .20); }
/* —— 输入框 / 下拉 —— */
body.theme-dark .mp-row input,
body.theme-dark .rm-settings select,
body.theme-dark .rh-d input,
body.theme-dark input[type="text"], body.theme-dark input[type="number"], body.theme-dark input[type="password"],
body.theme-dark select, body.theme-dark textarea { background: var(--panel-2); color: var(--ink); }
body.theme-dark .seed-box input { background: var(--panel-2); color: var(--ink); }
body.theme-dark #rhIgnore { background: var(--panel-2) !important; color: var(--ink-2) !important; }
/* —— 成就页 —— */
body.theme-dark .ach-tab { background: rgba(48, 42, 35, .6); }
body.theme-dark .ach-card { background: rgba(48, 42, 35, .66); }
body.theme-dark .ach-card.got { background: linear-gradient(160deg, rgba(201, 122, 61, .16), rgba(180, 135, 27, .10)); }
body.theme-dark .ach-tick { color: var(--gold); }
body.theme-dark .vic-ach-h { color: var(--gold); }
body.theme-dark .chron-year { color: var(--muted); }
/* —— 彩色文字在深底上提亮（日志分类 / 攻击按钮 / 城市文化值等） —— */
body.theme-dark .logrow.war { color: #e88a7a; }
body.theme-dark .logrow.wonder { color: #e5b93f; }
body.theme-dark .logrow.era { color: #b58ae0; }
body.theme-dark .logrow.tech { color: #7fb2e0; }
body.theme-dark .logrow.diplo { color: #7fc79a; }
body.theme-dark .logrow.warn { color: #e0a04a; }
body.theme-dark .act.attack { color: #e88a7a; border-color: #a05446; }
body.theme-dark .stat.cul .v { color: #b98ae0; }
body.theme-dark .tech .n { color: var(--ink); }
body.theme-dark .menu-btn.primary { background: linear-gradient(180deg, #b8722f, #96521f); border-color: #96521f; }
/* —— 弹窗头/脚（硬编码浅渐变与浅底） —— */
body.theme-dark .modal-head { background: var(--panel) !important; }
body.theme-dark .modal-foot { background: var(--panel-2); border-top-color: var(--line); }
body.theme-dark .modal-mask { background: rgba(0, 0, 0, .55); }
/* —— 图鉴特性标签 / 设置底栏 / 回合提示 / 百科侧栏 —— */
body.theme-dark .mp-uni span { background: rgba(72, 63, 52, .85); border-color: rgba(97, 87, 72, .8); }
body.theme-dark .setup-foot { background: rgba(31, 27, 22, .97); }
body.theme-dark .turnhint { background: rgba(48, 42, 35, .94); }
body.theme-dark .cx-side { background: rgba(40, 35, 25, .72); }
