/* ═══════════════════════════════════════════════════════════
 * 千里通波 · 前端样式（中式宣纸风 · 浅色主题）
 * 配色取意：宣纸底 / 墨字 / 朱砂（人类·强调）/ 墨绿（AI）/ 赭金（高亮）
 * ═══════════════════════════════════════════════════════════ */
:root {
  --paper:   #F4EFE3;   /* 宣纸底 */
  --paper2:  #FFFCF4;   /* 卡片面 */
  --paper3:  #EDE6D6;   /* 凹陷区 */
  --ink:     #2C2A26;   /* 墨字 */
  --ink2:    #6E685A;   /* 淡墨 */
  --ink3:    #9A9282;   /* 极淡 */
  --line:    #D9D1BE;   /* 边框 */
  --line2:   #C6BDA6;
  --cinnabar:#A8402F;   /* 朱砂：人类/强调 */
  --cinnabar2:#C25441;
  --jade:    #2E5D4F;   /* 墨绿：AI */
  --gold:    #B8862B;   /* 赭金：高亮 */
  --gold2:   #E0B458;
  --shadow:  0 1px 3px rgba(60,50,30,.10), 0 4px 12px rgba(60,50,30,.06);
  --r:       8px;
  --font-song: "Songti SC","SimSun","STSong",serif;
  --font-kai:  "Kaiti SC","KaiTi","STKaiti",serif;
  --font-hei:  -apple-system,"PingFang SC","Microsoft YaHei","Segoe UI",sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-hei);
  background:
    radial-gradient(circle at 18% 12%, rgba(184,134,43,.05), transparent 42%),
    radial-gradient(circle at 82% 88%, rgba(46,93,79,.05), transparent 42%),
    var(--paper);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── 总布局：三栏 + 顶栏 + 底栏 ── */
.app {
  display: grid;
  grid-template-columns: 290px minmax(0,1fr) 312px;
  grid-template-rows: auto minmax(0,1fr) auto;
  grid-template-areas:
    "header header header"
    "public board  player"
    "log    log    log";
  height: 100vh;
  gap: 8px;
  padding: 8px;
}

/* ── 顶栏 ── */
.header {
  grid-area: header;
  display: flex; align-items: center; gap: 16px;
  background: linear-gradient(90deg, var(--paper2), #FBF7EC);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 8px 16px;
  box-shadow: var(--shadow);
}
.title {
  font-family: var(--font-kai);
  font-size: 22px; font-weight: 700; letter-spacing: 2px;
  color: var(--cinnabar);
  white-space: nowrap;
}
.title .sub { font-size: 11px; color: var(--ink3); letter-spacing: 1px; font-family: var(--font-hei); margin-left: 6px; }
.phase-track { display: flex; gap: 4px; align-items: center; }
.phase-pill {
  font-family: var(--font-song); font-size: 12px;
  padding: 3px 10px; border-radius: 12px;
  border: 1px solid var(--line2); color: var(--ink3); background: var(--paper3);
  white-space: nowrap;
}
.phase-pill.active { background: var(--cinnabar); color: #fff; border-color: var(--cinnabar); font-weight: 700; }
.phase-pill.done { background: var(--jade); color: #dfeee7; border-color: var(--jade); }
.header .spacer { flex: 1; }
.round-badge {
  font-family: var(--font-song); font-size: 13px; color: var(--ink2);
  border-left: 2px solid var(--line2); padding-left: 14px; white-space: nowrap;
}
.turn-badge {
  font-size: 12px; padding: 4px 12px; border-radius: 14px; font-weight: 700;
  background: var(--gold2); color: #5a4413; border: 1px solid var(--gold); white-space: nowrap;
}

/* ── 通用面板 ── */
.panel {
  background: var(--paper2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-h {
  font-family: var(--font-kai); font-size: 13px; font-weight: 700; letter-spacing: 1px;
  color: var(--ink); padding: 7px 12px;
  background: var(--paper3); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 6px;
}
.panel-h .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cinnabar); }
.panel-b { padding: 10px 12px; }

/* ── 左栏：公共区 ── */
.public { grid-area: public; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.depot-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.depot {
  border: 1px solid var(--line); border-radius: 6px; background: var(--paper2);
  padding: 5px 6px; min-height: 56px;
}
.depot-h { display: flex; align-items: center; gap: 4px; margin-bottom: 4px; }
.depot-num {
  width: 18px; height: 18px; border-radius: 50%; flex: none;
  background: var(--jade); color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.depot-goods { font-size: 10px; color: var(--ink2); }
.tile-chips { display: flex; flex-wrap: wrap; gap: 3px; }

/* 板块小片 */
.chip {
  font-family: var(--font-song); font-size: 10px; line-height: 1.15;
  padding: 2px 5px; border-radius: 4px; border: 1px solid rgba(0,0,0,.14);
  white-space: nowrap; display: inline-flex; align-items: center; gap: 2px;
}
.chip .n { font-weight: 700; opacity: .8; }

.nightmarket { display: flex; flex-wrap: wrap; gap: 4px; }
.goods-pile { display: flex; gap: 3px; flex-wrap: wrap; }
.die-row { display: flex; align-items: center; gap: 8px; }
.die {
  width: 34px; height: 34px; border-radius: 7px; flex: none;
  background: linear-gradient(145deg,#fff,#EFE7D6);
  border: 1px solid var(--line2); box-shadow: inset 0 -2px 3px rgba(0,0,0,.06);
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; font-weight: 700; color: var(--cinnabar); font-family: var(--font-song);
}
.die.white { color: var(--jade); }
.die-lbl { font-size: 11px; color: var(--ink2); }

/* ── 中栏：疆域 + 行动 ── */
.board-area { grid-area: board; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.board-panel { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.board-svg-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 6px; min-height: 0; overflow: hidden; }
#board-svg { width: 100%; height: 100%; max-height: 100%; }

.hex-cell { cursor: default; transition: filter .12s; }
.hex-bg { stroke: rgba(90,80,60,.30); stroke-width: 1; }
.hex-cell.legal { cursor: pointer; }
.hex-cell.legal .hex-bg { stroke: var(--gold); stroke-width: 2.6; }
.hex-cell.legal:hover .hex-bg { stroke: var(--cinnabar2); stroke-width: 3.2; filter: brightness(1.04); }
.hex-num { font-family: var(--font-song); font-size: 11px; fill: var(--ink3); text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.hex-tile { font-family: var(--font-song); font-size: 10.5px; fill: var(--ink); text-anchor: middle; dominant-baseline: central; pointer-events: none; font-weight: 700; }
.hex-sub { font-size: 8px; fill: var(--ink2); text-anchor: middle; pointer-events: none; }
@keyframes pulse { 0%,100%{ opacity:1 } 50%{ opacity:.55 } }
.hex-cell.legal .hex-bg { animation: pulse 1.4s ease-in-out infinite; }

/* 行动区 */
.actions-panel { flex: none; }
.action-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.act-btn {
  font-family: var(--font-hei); text-align: left; cursor: pointer;
  border: 1px solid var(--line2); border-radius: 7px;
  background: linear-gradient(180deg,#fff,#F6F1E5);
  padding: 7px 11px; min-width: 132px; flex: 1 1 132px;
  display: flex; align-items: center; gap: 8px;
  transition: all .12s; color: var(--ink);
}
.act-btn:hover { border-color: var(--cinnabar); background: linear-gradient(180deg,#fff,#FBEFEB); transform: translateY(-1px); box-shadow: 0 3px 8px rgba(168,64,47,.16); }
.act-btn .ico {
  width: 26px; height: 26px; border-radius: 6px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-kai); font-size: 15px; font-weight: 700; color: #fff;
}
.act-btn .txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.act-btn .t1 { font-size: 12.5px; font-weight: 600; }
.act-btn .t2 { font-size: 10.5px; color: var(--ink2); }
.ico.take{background:var(--jade)} .ico.place{background:var(--cinnabar)} .ico.sell{background:var(--gold)}
.ico.worker{background:#7A6A4F} .ico.market{background:#5B6E8C}
.hint {
  font-family: var(--font-kai); font-size: 13px; color: var(--cinnabar);
  padding: 8px 4px; letter-spacing: .5px;
}
.hint.cell::before { content:"◈ "; }

/* ── 右栏：玩家面板 ── */
.player-area { grid-area: player; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.pcard { border: 1px solid var(--line); border-radius: 7px; background: var(--paper2); padding: 8px 10px; }
.pcard.human { border-color: var(--cinnabar); box-shadow: 0 0 0 1px var(--cinnabar) inset; }
.pcard.active { background: linear-gradient(180deg,#FFFDF6,#FBF3E4); }
.pcard-h { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.pname { font-family: var(--font-kai); font-size: 14px; font-weight: 700; }
.pname.human { color: var(--cinnabar); }
.pname.ai { color: var(--jade); }
.ptag { font-size: 10px; padding: 1px 6px; border-radius: 8px; background: var(--paper3); color: var(--ink2); border: 1px solid var(--line); }
.pvp { margin-left: auto; font-family: var(--font-song); font-size: 18px; font-weight: 700; color: var(--gold); }
.pvp small { font-size: 10px; color: var(--ink3); font-weight: 400; }
.pstats { display: flex; gap: 10px; flex-wrap: wrap; font-size: 11.5px; color: var(--ink2); margin-bottom: 5px; }
.pstats b { color: var(--ink); font-family: var(--font-song); font-size: 13px; }
.prow { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.prow .lbl { font-size: 10.5px; color: var(--ink3); width: 30px; flex: none; }
.passive-tags { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 5px; }
.ptag-passive { font-size: 9.5px; padding: 1px 5px; border-radius: 4px; background: #EFE7F2; color: #6B4A78; border: 1px solid #DCC9E2; }

/* 顺位轨 */
.order-track { display: flex; gap: 3px; align-items: center; }
.order-slot {
  width: 22px; height: 22px; border-radius: 5px; border: 1px dashed var(--line2);
  display: flex; align-items: center; justify-content: center; font-size: 10px; color: var(--ink3);
  background: var(--paper3); position: relative;
}
.order-slot .occ { width: 16px; height: 16px; border-radius: 4px; background: var(--jade); color:#fff; font-weight:700; display:flex;align-items:center;justify-content:center; font-size:10px; }
.order-slot .occ.human { background: var(--cinnabar); }

/* ── 底栏：日志 + 控制 ── */
.log-area { grid-area: log; display: flex; gap: 8px; min-height: 96px; max-height: 130px; }
.log-panel { flex: 1; display: flex; flex-direction: column; }
.log-body { flex: 1; overflow-y: auto; padding: 6px 12px; font-size: 11.5px; color: var(--ink2); font-family: var(--font-song); }
.log-body div { padding: 1px 0; border-bottom: 1px dotted rgba(0,0,0,.05); }
.log-body .hl { color: var(--cinnabar); }
.ctrl-panel { flex: none; width: 230px; display: flex; flex-direction: column; }
.ctrl-body { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; }
.btn {
  font-family: var(--font-hei); font-size: 12.5px; cursor: pointer;
  border: 1px solid var(--line2); border-radius: 6px; padding: 7px 10px;
  background: linear-gradient(180deg,#fff,#F4EEE0); color: var(--ink); transition: all .12s;
}
.btn:hover:not(:disabled) { border-color: var(--cinnabar); color: var(--cinnabar); }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg,var(--cinnabar2),var(--cinnabar)); color: #fff; border-color: var(--cinnabar); }
.btn.primary:hover:not(:disabled) { color:#fff; filter: brightness(1.06); }
.btn-row { display: flex; gap: 6px; }
.btn-row .btn { flex: 1; }
.seed-row { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--ink2); }
.seed-row input { width: 90px; padding: 3px 6px; border: 1px solid var(--line2); border-radius: 4px; font-family: var(--font-song); font-size: 12px; background:#fff; }

/* 终局遮罩 */
.overlay {
  position: fixed; inset: 0; background: rgba(40,34,24,.55);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  backdrop-filter: blur(2px);
}
.overlay-card {
  background: var(--paper2); border-radius: 12px; padding: 28px 36px; min-width: 340px;
  box-shadow: 0 12px 48px rgba(0,0,0,.3); border: 1px solid var(--line2); text-align: center;
}
.overlay-card h2 { font-family: var(--font-kai); font-size: 26px; color: var(--cinnabar); margin-bottom: 4px; letter-spacing: 2px; }
.overlay-card .win-sub { font-size: 12px; color: var(--ink2); margin-bottom: 16px; }
.rank-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.rank-row { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-radius: 7px; background: var(--paper3); font-size: 13px; }
.rank-row.me { background: #FBEFEB; border: 1px solid var(--cinnabar); }
.rank-row .pos { font-family: var(--font-song); font-weight: 700; color: var(--gold); width: 22px; }
.rank-row .nm { font-family: var(--font-kai); font-weight: 700; }
.rank-row .sc { margin-left: auto; font-family: var(--font-song); font-size: 16px; font-weight: 700; }

.hidden { display: none !important; }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ── 窄屏：单列堆叠 ── */
@media (max-width: 1080px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto auto;
    grid-template-areas: "header" "board" "public" "player" "log";
    height: auto; min-height: 100vh;
  }
  .board-svg-wrap { min-height: 320px; }
  .log-area { flex-direction: column; max-height: none; }
  .ctrl-panel { width: auto; }
}
