/* 《城迹》测试版样式：布局与结构。配色/主题变量在 theme.css（美术），颜色编码对应设计文档「九、颜色编码」。 */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  background-image: radial-gradient(circle at 20% 0%, #f7f3ea 0%, var(--bg) 60%);
  color: var(--ink);
  font-size: 14px;
  min-height: 100vh;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
#app { padding: 12px 12px 40px; max-width: 960px; margin: 0 auto; }
h1, h3 { margin: 0 0 8px; }
h3 { margin-top: 18px; font-size: 13px; color: var(--muted); font-weight: 700; letter-spacing: .04em; }
button { font-family: inherit; cursor: pointer; }

/* ---------- 开始界面 ---------- */
.start { text-align: center; padding: 24px 0; min-height: calc(100vh - 60px); display: flex; flex-direction: column; justify-content: center; }
.start .logo { font-size: 30px; font-weight: 800; letter-spacing: .06em; }
.start .logo-sub { color: var(--muted); margin: 6px 0 28px; font-size: 13px; }
.set-block { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 0 auto 14px; max-width: 460px; box-shadow: 0 2px 10px rgba(0,0,0,.04); }
.set-block > .lab { font-size: 12px; color: var(--muted); font-weight: 700; margin-bottom: 10px; text-align: left; }
.opt-row { display: flex; gap: 8px; flex-wrap: wrap; }
.opt-row.cities { display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 1fr; gap: 8px; }
.opt-row.cities .city-opt { flex: initial; }
.opt {
  flex: 1 1 80px; padding: 10px; border-radius: 10px; border: 1.5px solid var(--line);
  background: #fff; font-size: 14px; font-weight: 600; color: #555;
}
.opt.on { border-color: var(--accent); background: #fff7e2; color: #7a5a00; }
.city-opt { flex: 1 1 130px; text-align: left; padding: 10px 12px; }
.city-opt .cname { font-weight: 700; }
.city-opt .cdesc { font-size: 11px; color: var(--muted); font-weight: 400; margin-top: 3px; line-height: 1.4; }
.big-btns { display: flex; flex-direction: column; gap: 10px; max-width: 460px; margin: 22px auto 0; }
.btn-primary { padding: 14px; border: none; border-radius: 12px; background: var(--accent); color: #fff; font-size: 16px; font-weight: 700; box-shadow: 0 4px 14px rgba(184,134,11,.3); }
.btn-sec { padding: 11px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; font-size: 14px; font-weight: 600; color: #555; }

/* ---------- 顶栏 ---------- */
.topbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.topbar .title { font-size: 20px; font-weight: 800; letter-spacing: .1em; }
.topbar .meta { color: var(--muted); font-size: 12px; }
.topbar .spacer { margin-left: auto; }
.tbtn { border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 5px 10px; font-size: 12px; color: #555; }
.tbtn.on, .btn-sec.on { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700; }
#app .tbtn.on, #app .btn-sec.on, #app .act.on { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700; }
.volrange { flex: 1 1 auto; min-width: 90px; }
.infobar { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; margin: 10px 0 2px; }
.infobar .meta { color: var(--muted); font-size: 12px; }
.infobar .hint { margin: 0 0 0 auto; }

.status {
  margin: 12px 0; padding: 11px 14px; border-radius: 12px;
  background: #fff5da; border: 1px solid #f0dfae;
  font-weight: 700; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.status .grow { flex: 1; }

/* ---------- 卡牌 ---------- */
.row { display: flex; flex-wrap: wrap; gap: 10px; }
/* ---------- 卡牌（内联 SVG 卡框 + 类型色底；完整 150×200 / 缩略 105×140） ---------- */
.card, .card.compact {
  position: relative; border: none; border-radius: 8px; overflow: hidden; background: transparent;
}
.card { width: 150px; height: 200px; }
.card.compact { width: 105px; height: 140px; border-radius: 7px; }
.face { position: absolute; top: 0; left: 0; right: 0; bottom: 0; }
.fr { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: block; }
.content { position: absolute; top: 0; left: 0; right: 0; bottom: 0; z-index: 2; }
.typetag {
  position: absolute; z-index: 3; top: 4%; left: 4%; padding: 0 6px; height: 20px; line-height: 20px;
  border-radius: 7px; background: rgba(255,255,255,.92); border: 1px solid rgba(0,0,0,.28);
  font-size: 10px; font-weight: 800; color: #2f2b24;
}
.card.compact .typetag { height: 16px; line-height: 16px; font-size: 9px; padding: 0 5px; }
.art { position: absolute; left: 3.6%; right: 3.6%; top: 4%; height: 43%; background-size: cover; background-position: center; border-radius: 6px; }
.card.compact .art { left: 4.1%; right: 4.1%; top: 3.3%; height: 59.5%; }
.artIcons { position: absolute; top: 6%; right: 5%; display: flex; gap: 3px; align-items: center; }
.card.compact .artIcons { top: 5%; right: 4%; }
.artIcons .chip {
  width: 18px; height: 18px; padding: 0; border-radius: 9px; text-align: center; line-height: 18px;
  font-size: 10px; box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.card.compact .artIcons .chip { width: 15px; height: 15px; line-height: 15px; font-size: 8px; }
.artIcons .chip em { font-style: normal; font-size: 8px; margin-left: 1px; }
.txt { position: absolute; left: 5%; right: 5%; top: 49.3%; height: 35%; display: flex; flex-direction: column; overflow: hidden; }
.info { position: absolute; left: 5.5%; right: 5.5%; top: 65.7%; height: 31%; display: flex; flex-direction: column; justify-content: center; overflow: hidden; }
.pubcell { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pubacts { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; width: 100%; }
.pubacts .act { padding: 2px 8px; font-size: 11px; }
.card .nm { font-weight: 800; font-size: 13px; line-height: 1.25; color: #26241f; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card.compact .nm { font-size: 10px; }
.card .meta { font-size: 12px; font-weight: 700; color: #3a3730; margin-top: 4px; }
.card.compact .sub { font-size: 9px; font-weight: 700; color: #3a3730; margin-top: 2px; }
.card .eff { font-size: 11px; line-height: 1.4; color: #333026; margin-top: 4px; overflow: hidden; }
.bar { position: absolute; left: 3.6%; right: 3.6%; top: 86.7%; height: 9.3%; display: flex; gap: 4px; align-items: center; justify-content: flex-end; }
.bar:empty { display: none; }
.bar .act { border: 1px solid rgba(0,0,0,.16); background: rgba(255,255,255,.8); border-radius: 7px; padding: 1px 7px; font-size: 10px; font-weight: 700; color: #3a3730; }
.bar .act:active { background: rgba(255,255,255,.95); }
/* 底条左侧斜体描述（文案在策划写区 src/content/cards.js；与右侧操作按钮共用底条） */
.card .desc { flex: 1 1 auto; min-width: 0; margin-right: auto; font-size: 9px; font-style: italic; color: #59544b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 卡图（data-art 分类 → 图片）规则在 theme.css（美术写区） */
.card-name { font-weight: 700; font-size: 13px; }
.card-id { font-size: 10px; opacity: .85; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.chip { display: inline-block; padding: 1px 7px; border-radius: 10px; color: #fff; font-size: 12px; font-weight: 700; }
.chip.population { background: var(--population); }
.chip.economy { background: var(--economy); }
.chip.tech { background: var(--tech); }
.chip.culture { background: var(--culture); }
.tag { display: none; }
.act { border: 1px solid var(--line); background: #fbf9f4; border-radius: 8px; padding: 5px 9px; font-size: 12px; font-weight: 600; color: #4a463f; }
.act:active { background: #efe9dc; }

/* ---------- 玩家面板 ---------- */
.grid-opps { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.pcard {
  flex: 1 1 200px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--card); padding: 10px; border-left-width: 5px;
}
.pcard.human { border-color: var(--accent); }
.pcard.active { box-shadow: 0 0 0 2px #f2d98a; }
.pcard.city-SH { border-left-color: #d4af37; }
.pcard.city-BJ { border-left-color: #c0392b; }
.pcard.city-CD { border-left-color: #17a2a2; }
.pcard.city-SZ { border-left-color: #9aa2ab; }
.pname { font-weight: 700; display: flex; justify-content: space-between; align-items: baseline; }
.pstat { color: var(--muted); font-weight: 600; font-size: 12px; }
.board { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.mini { font-size: 11px; background: #f1eee6; border-radius: 7px; padding: 2px 6px; color: #333; }
.keptrow { margin-top: 4px; align-items: center; }
.keptlab { font-size: 10px; color: var(--muted); font-weight: 700; }
.mini.kept { border: 1px dashed rgba(0,0,0,.22); }
.mini .act { margin-left: 4px; padding: 1px 6px; font-size: 11px; }
.empty { color: var(--muted); font-size: 13px; }

/* ---------- 政策槽 / 预告区 ---------- */
.slot { flex: 1 1 150px; border: 1.5px dashed var(--line); border-radius: 10px; background: var(--card); padding: 8px 10px; }
.slot-hd { font-size: 12px; font-weight: 700; }
.slot .meta { color: var(--muted); font-size: 11px; margin-top: 2px; }
.slot.fc-done { border-style: solid; background: #f4f1e8; }

/* ---------- 日志 / 统计 ---------- */
.log { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; max-height: 240px; overflow: auto; }
.log div { font-size: 12px; color: #4a463f; padding: 3px 0; border-bottom: 1px dashed #f0ece2; }
.logcard { color: var(--accent); border-bottom: 1px dashed currentColor; cursor: pointer; }
.log div:last-child { border-bottom: none; }
.stats { margin-top: 12px; padding: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; font-size: 12px; color: #4a463f; line-height: 1.7; }
.results { margin: 0; padding-left: 22px; }
.results li { margin: 6px 0; font-weight: 700; font-size: 15px; }

/* ---------- 设置界面 ---------- */
.set-row { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.set-label { flex: 1; font-weight: 600; }
.set-desc { font-size: 11px; color: var(--muted); }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button { width: 34px; height: 34px; border: 1px solid var(--line); background: #fff; border-radius: 9px; font-size: 18px; line-height: 1; color: #555; }
.set-val { min-width: 34px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.set-row.locked { background: #f3f0e8; color: var(--muted); }
.set-row.locked .set-label { font-weight: 500; }
.lock-note { max-width: 460px; margin: 0 auto 14px; padding: 10px 12px; background: #fff3d6; border: 1px solid #f0dfae; border-radius: 10px; font-size: 12px; color: #7a5a00; font-weight: 600; }

/* ---------- 详情浮层 ---------- */
.card, .mini, .slot, .pcard {
  cursor: pointer;
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
}
.hint { font-size: 11px; color: var(--muted); margin: 8px 0; }
/* 兼容旧 WebView：不用 inset 简写 */
.overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.backdrop { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(20,18,14,.5); }
.modal { position: relative; width: 100%; max-width: 340px; max-height: 82vh; overflow: auto; background: var(--card); border-radius: 16px; box-shadow: 0 16px 44px rgba(0,0,0,.35); }
.cardbig { position: relative; z-index: 1; transform: scale(1.6); }
.modal-top { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; color: #fff; font-weight: 700; text-shadow: 0 1px 2px rgba(0,0,0,.25); }
.modal-body { padding: 10px 14px; }
.drow { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px dashed #f0ece2; font-size: 13px; }
.drow:last-child { border-bottom: none; }
.dlab { flex: 0 0 76px; color: var(--muted); font-weight: 600; }
.dval { flex: 1; color: var(--ink); line-height: 1.5; }
.modal-btns { padding: 10px 14px 14px; }
.modal-btns .btn-sec { width: 100%; }

/* ---------- 布局重排 ---------- */
.pcard.own { flex: 1 1 100%; }
.scene { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
/* 等宽等高网格，避免 flex 换行后落单项被拉满导致尺寸不一 */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); grid-auto-rows: 1fr; gap: 10px; justify-items: center; }
.grid-cards .card { width: 150px; }
.grid-compact { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; align-items: start; }
.grid-compact .card { width: 100%; max-width: 105px; }
.grid-slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); grid-auto-rows: 1fr; gap: 8px; }
.grid-slots .slot { flex: initial; }
.grid-slots .empty { grid-column: 1 / -1; }
.lab2 { font-size: 11px; color: var(--muted); font-weight: 700; margin-bottom: 5px; }
.logwrap { margin-top: 18px; }
.logwrap > summary { font-size: 13px; color: var(--muted); font-weight: 700; cursor: pointer; padding: 6px 0; outline: none; }
.note { font-size: 12px; color: var(--muted); margin: 8px 0; }

/* ---------- 设置分类 ---------- */
.cat-list { display: flex; flex-direction: column; gap: 8px; max-width: 520px; margin: 0 auto; }
.cat-row { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: inherit; }
.cat-name { font-weight: 700; font-size: 15px; }
.cat-count { margin-left: 8px; font-size: 11px; font-weight: 700; color: #fff; background: var(--accent); border-radius: 8px; padding: 1px 7px; }
.cat-desc { font-size: 12px; color: var(--muted); }
.cat-lock { margin-left: 8px; font-size: 11px; font-weight: 700; color: #b07b00; background: #fff2cf; border-radius: 8px; padding: 1px 7px; }
