/* ============================================================
   《剑网三大富翁》样式 —— 宣纸卷轴风
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --paper: #f5eede;
  --ink: #3a2f25;
  --ink2: #6b5c4a;
  --gold: #b8860b;
  --red: #a63a2e;
  --line: #d8c9a8;
}
html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  background: radial-gradient(circle at 30% 20%, #fbf5e6 0%, #efe4cb 60%, #e6d7b5 100%);
  color: var(--ink);
  overflow: hidden;
}
.hidden { display: none !important; }
/* 动作处理中：锁定所有操作按钮，防连点/非回合误操作 */
body.busy #action-bar, body.busy .ast .ops, body.busy #players-bar, body.busy #assets-panel {
  pointer-events: none; opacity: .55;
}
.screen { height: 100vh; display: flex; align-items: center; justify-content: center; }

/* ---------- 通用 ---------- */
.btn {
  background: linear-gradient(#c9a44c, #a8842f);
  border: 1px solid #8a6a1e; color: #fff8ea;
  padding: 10px 22px; border-radius: 8px; font-size: 16px; cursor: pointer;
  font-family: inherit; letter-spacing: 2px; transition: transform .08s, box-shadow .15s;
  box-shadow: 0 2px 4px rgba(80,50,10,.25);
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 8px rgba(80,50,10,.3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.big { font-size: 20px; padding: 12px 40px; }
.btn.sm { padding: 4px 12px; font-size: 13px; }
.btn.ghost { background: none; border: 1px solid var(--ink2); color: var(--ink2); box-shadow: none; }
.btn.red { background: linear-gradient(#b5544a, #93362c); border-color: #7c2a22; }
.inp {
  border: 1px solid var(--line); background: #fffdf6; color: var(--ink);
  padding: 10px 14px; border-radius: 8px; font-size: 17px; outline: none; text-align: center;
}
.inp:focus { border-color: var(--gold); }
.sel {
  border: 1px solid var(--line); background: #fffdf6; color: var(--ink);
  padding: 9px 10px; border-radius: 8px; font-size: 14px; font-family: inherit;
}
.msg { color: var(--red); font-size: 14px; min-height: 20px; margin-top: 8px; text-align: center; }
.trait-tip { color: var(--ink2); font-size: 13px; line-height: 1.6; min-height: 20px; text-align: center; max-width: 340px; }
.trait-tip b { color: var(--gold); }
.tips { color: var(--ink2); font-size: 13px; line-height: 1.7; max-width: 360px; margin-top: 14px; text-align: center; }

/* ---------- 大厅 ---------- */
.lobby-box {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  background: rgba(255,252,242,.85); border: 1px solid var(--line);
  padding: 40px 56px; border-radius: 16px; box-shadow: 0 12px 40px rgba(90,60,20,.18);
}
.logo {
  font-size: 42px; letter-spacing: 8px; font-weight: 700;
  background: linear-gradient(#8a6a1e, #a63a2e);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.sub { color: var(--ink2); letter-spacing: 3px; }
.av-row { display: flex; gap: 12px; }
.av-pick {
  width: 64px; height: 64px; border-radius: 50%; border: 3px solid transparent;
  cursor: pointer; overflow: hidden; background: #efe4cb; position: relative;
  transition: transform .12s, border-color .12s;
}
.av-pick img { width: 100%; height: 100%; object-fit: cover; display: block; }
.av-pick span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 20px; color: #fff; }
.av-pick.sel { border-color: var(--gold); transform: scale(1.12); box-shadow: 0 0 0 2px #fff, 0 4px 10px rgba(0,0,0,.2); }
.join-row { display: flex; gap: 10px; }
.join-row .inp { width: 120px; }

/* ---------- 房间 ---------- */
.room-box {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  background: rgba(255,252,242,.85); border: 1px solid var(--line);
  padding: 36px 52px; border-radius: 16px; box-shadow: 0 12px 40px rgba(90,60,20,.18);
  min-width: 420px;
}
.room-code { font-size: 20px; letter-spacing: 2px; }
.room-code b { font-size: 34px; color: var(--red); margin: 0 8px; letter-spacing: 6px; }
.rplayers { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; min-height: 90px; }
.rplayer {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: #fffdf6; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px;
  min-width: 92px;
}
.rplayer img, .rplayer .avfb { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; }
.rplayer .avfb { display: flex; align-items: center; justify-content: center; color: #fff; font-size: 22px; background: #8a6a1e; }
.rplayer .nm { font-size: 14px; }
.rplayer .host { color: var(--gold); font-size: 12px; }
.rplayer.offline { opacity: .45; }
.host-tools { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* ---------- 对局布局（电脑横屏满幅） ---------- */
#scr-game { align-items: stretch; justify-content: center; padding: 12px; }
.game-wrap {
  display: grid; grid-template-columns: 240px minmax(0,1fr) 310px; gap: 12px;
  width: 100%; height: calc(100vh - 24px);
}
.players-bar {
  display: flex; flex-direction: column; gap: 8px; overflow-y: auto;
}
.pcard {
  background: rgba(255,252,242,.9); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; display: flex; align-items: center; gap: 10px; position: relative;
}
.pcard .pv { position: relative; flex-shrink: 0; line-height: 0; }
.pcard img, .pcard .avfb { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.pcard .avfb { display: flex; align-items: center; justify-content: center; color: #fff; font-size: 18px; background: #8a6a1e; }
.pcard .pno {
  position: absolute; right: -4px; bottom: -3px;
  width: 18px; height: 18px; border-radius: 50%;
  color: #fff; font-size: 11px; font-weight: 800; line-height: 15px; text-align: center;
  border: 1.5px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35);
}
.pcard .info { flex: 1; min-width: 0; }
.pcard .nm { font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard .cash { font-size: 17px; font-weight: 700; color: var(--gold); }
.pcard.dead { opacity: .4; text-decoration: line-through; }
.pcard.turn { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
.pcard .flag { font-size: 11px; color: var(--red); }
.assets-panel { background: rgba(255,252,242,.9); border: 1px solid var(--line); border-radius: 10px; padding: 10px; overflow-y: auto; }
.assets-panel h4 { font-size: 14px; color: var(--ink2); margin-bottom: 8px; letter-spacing: 2px; }
.ast {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 7px; font-size: 13.5px;
  background: #fffdf6;
}
.ast .t { font-weight: 700; }
.ast .dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.ast .ops { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.ast .ops button {
  font-size: 11px; padding: 2px 7px; border-radius: 5px; border: 1px solid var(--line);
  background: #f3ead2; cursor: pointer; color: var(--ink);
}
.ast .ops button:disabled { opacity: .35; cursor: not-allowed; }
.ast.mort { opacity: .55; }

/* ---------- 棋盘（正方形，取高与宽的较小者，居中） ---------- */
#board-box {
  position: relative; min-width: 0; min-height: 0;
  display: flex; align-items: center; justify-content: center;
}
#board-frame {
  position: relative;
  width: min(100%, calc(100vh - 24px));
  aspect-ratio: 1; height: auto;
}
#board {
  display: grid;
  grid-template-columns: repeat(13, minmax(0,1fr));
  grid-template-rows: repeat(13, minmax(0,1fr));
  width: 100%; height: 100%;
  background: rgba(255,252,242,.75);
  border: 2px solid #a8842f; border-radius: 8px;
  box-shadow: inset 0 0 0 1px var(--line), 0 8px 30px rgba(90,60,20,.15);
}
.cell {
  position: relative; border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  padding: 2px; overflow: hidden; background: #fffdf6; font-size: 11px; line-height: 1.15;
  text-align: center; color: var(--ink);
}
.cell .bar { position: absolute; top: 0; left: 0; right: 0; height: 14%; }
/* 色条朝棋盘内侧 */
.cell.pos-t .bar { top: auto; bottom: 0; }
.cell.side .bar { top: 0; bottom: 0; height: auto; width: 14%; }
.cell.side-l .bar { left: auto; right: 0; }
.cell.side-r .bar { right: auto; left: 0; }
/* 左右列：竖排文字（窄格专用） */
.cell.side { flex-direction: row; align-items: center; justify-content: center; gap: 2px; padding: 3px 2px; }
.cell.side .nm { writing-mode: vertical-rl; max-height: 90%; }
.cell.side .pr { writing-mode: vertical-rl; text-orientation: upright; letter-spacing: 0; }
.cell .nm { font-size: clamp(8px, 1.1vw, 13px); font-weight: 700; padding: 0 1px; }
.cell .pr { font-size: clamp(7px, .9vw, 11px); color: var(--ink2); }
.cell .own { position: absolute; top: 2px; right: 2px; width: 10px; height: 10px; border-radius: 50%; border: 1px solid #fff; }
.cell .hs { position: absolute; top: 1px; left: 2px; font-size: 9px; color: var(--red); letter-spacing: -1px; }
.cell.corner { background: #f3ead2; }
.cell.corner .nm { font-size: clamp(9px, 1.2vw, 14px); color: var(--red); }
.cell.corner .ic { font-size: clamp(14px, 2.4vw, 26px); margin-top: 6px; }
.cell.ev { background: #f7f1df; }
.cell.ev .ic { font-size: clamp(11px, 1.7vw, 18px); margin-top: 4px; }
/* 「轻功·再掷」格：淡青底 + 金边，一眼能认出来 */
.cell.ev.extra-cell {
  background: linear-gradient(160deg, #e6f7f0, #f7f1df);
  box-shadow: inset 0 0 0 1px #7fbfa4;
}
.cell.ev.extra-cell .nm { color: #1f6b52; }
.cell.mortgaged { background: repeating-linear-gradient(45deg, #fffdf6, #fffdf6 4px, #eee2c4 4px, #eee2c4 7px); }

/* ---------- 棋子 ---------- */
#tokens { position: absolute; inset: 0; pointer-events: none; }
/* 棋子：放大 + 玩家身份色描边 + 右下角座位号徽章，同格多人自动缩小错开 */
.tok {
  position: absolute; width: 6.4%; aspect-ratio: 1;
  transform: translate(-50%, -50%);
  z-index: 5; pointer-events: auto; cursor: default;
  transition: left .28s ease-in-out, top .28s ease-in-out, width .2s ease;
}
.tok .tav {
  width: 100%; height: 100%; border-radius: 50%; overflow: hidden; background: #fff;
  border: 3px solid var(--pc, #fff);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.9), 0 3px 9px rgba(0,0,0,.45);
}
.tok .tav img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tok .tav .avfb {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 11px; background: #8a6a1e;
}
.tok .tno {
  position: absolute; right: -1px; bottom: -1px;
  min-width: 17px; height: 17px; padding: 0 2px; border-radius: 9px;
  background: var(--pc, #c0392b); color: #fff;
  font-size: 11px; font-weight: 800; line-height: 14px; text-align: center;
  border: 1.5px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.45);
}
.tok .tnm {
  position: absolute; left: 50%; bottom: 100%; transform: translate(-50%, -6px);
  white-space: nowrap; background: rgba(26,21,12,.94); color: #fff;
  font-size: 11px; padding: 2px 8px; border-radius: 10px;
  border: 1px solid var(--pc); opacity: 0; transition: opacity .15s; pointer-events: none;
}
.tok:hover { z-index: 60 !important; }
.tok:hover .tnm { opacity: 1; }
/* 同格多人：缩小 + 由 JS 错位排布 */
.tok.grp { width: 4.3%; }
.tok.grp .tav { border-width: 2px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.9), 0 2px 6px rgba(0,0,0,.45); }
.tok.grp .tno { min-width: 14px; height: 14px; font-size: 9px; line-height: 11px; right: -2px; bottom: -2px; }
/* 同格 6 人以上：再缩小一档，10 人也不挤爆一格 */
.tok.grp2 { width: 3.1%; }
.tok.grp2 .tav { border-width: 1.5px; }
.tok.grp2 .tno { min-width: 12px; height: 12px; font-size: 8px; line-height: 9px; right: -3px; bottom: -3px; }
/* 当前行动者：金色脉冲光圈 */
.tok.act .tav { box-shadow: inset 0 0 0 2px rgba(255,255,255,.9), 0 0 0 2px var(--gold), 0 0 14px 3px rgba(201,160,60,.75); }
.tok.act::after {
  content: ""; position: absolute; inset: -9px; border-radius: 50%;
  border: 2px solid rgba(201,160,60,.95);
  animation: tokPulse 1.5s ease-out infinite; pointer-events: none;
}
@keyframes tokPulse {
  0% { transform: scale(.8); opacity: .95; }
  100% { transform: scale(1.22); opacity: 0; }
}
/* 自己的棋子：白金双环，永远最好找 */
.tok.me .tav { border-color: #fff; box-shadow: inset 0 0 0 2px var(--pc), 0 0 0 2.5px var(--gold), 0 3px 9px rgba(0,0,0,.5); }
.tok.dead { filter: grayscale(1); }

/* ---------- 中央信息区 ---------- */
#center {
  position: absolute; inset: 16% 17%; z-index: 4;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: linear-gradient(165deg, rgba(255,252,242,.96), rgba(247,236,211,.96));
  border: 2px solid var(--gold); border-radius: 12px;
  box-shadow: inset 0 0 0 1px var(--line), 0 8px 30px rgba(90,60,20,.18);
  padding: 12px 16px; overflow: hidden;
}
#center-title { font-size: 14px; letter-spacing: 5px; font-weight: 700; color: rgba(138,106,30,.55); }
#dice-area { display: flex; gap: 12px; }
.die {
  width: 50px; height: 50px; border-radius: 10px;
  background: linear-gradient(160deg, #fffdf6, #f2e8cf);
  border: 2px solid #8a6a1e;
  display: grid; place-items: center;
  box-shadow: 0 3px 8px rgba(80,50,10,.22), inset 0 1px 0 #fff;
}
.pips {
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  width: 100%; height: 100%; padding: 7px;
}
.pips b { display: flex; align-items: center; justify-content: center; }
.pips i {
  width: 10px; height: 10px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #4a4a4a, #1c1c1c);
}
.pips i.r { background: radial-gradient(circle at 35% 30%, #d95548, #9c2a20); }
#dice-owner { font-size: 13px; color: var(--ink2); letter-spacing: 1px; min-height: 18px; }
#dice-owner b { color: var(--red); }
.die.rolling { animation: shake .5s ease-in-out infinite; }
@keyframes shake {
  0%,100% { transform: rotate(0) scale(1); }
  25% { transform: rotate(-18deg) scale(1.1); }
  50% { transform: rotate(0) scale(.92); }
  75% { transform: rotate(18deg) scale(1.1); }
}
#turn-info {
  font-size: 14px; color: var(--ink2); text-align: center;
  background: rgba(184,134,11,.1); border: 1px dashed var(--gold);
  border-radius: 999px; padding: 6px 18px;
}
#turn-info b { color: var(--red); }
#action-bar { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
#action-bar .btn { padding: 7px 16px; font-size: 14px; }
#log-box {
  flex: 1; width: 100%; overflow-y: auto; font-size: 12px; color: var(--ink2);
  background: rgba(255,255,255,.45); border: 1px dashed var(--line); border-radius: 8px;
  padding: 7px 10px; line-height: 1.6;
}
#log-box .l b { color: var(--red); }
#log-box .l.card { color: #9a7410; }

/* ---------- 卡牌弹出 ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(30,20,10,.55); z-index: 50;
  display: flex; align-items: center; justify-content: center;
}
.card-pop {
  width: 320px; min-height: 200px; border-radius: 14px; padding: 26px;
  background: linear-gradient(160deg, #fff8e8, #f2e2b8);
  border: 2px solid var(--gold); box-shadow: 0 16px 50px rgba(0,0,0,.4);
  text-align: center; animation: cardIn .45s cubic-bezier(.2,1.4,.4,1);
}
@keyframes cardIn {
  0% { transform: perspective(700px) rotateY(90deg) scale(.6); opacity: 0; }
  100% { transform: perspective(700px) rotateY(0) scale(1); opacity: 1; }
}
#card-kind { font-size: 26px; letter-spacing: 6px; color: var(--red); font-weight: 700; margin-bottom: 12px; }
#card-text { font-size: 16px; line-height: 1.8; color: var(--ink); }

/* ---------- 交易 ---------- */
.trade-box {
  width: min(480px, 92vw); max-height: 86vh; overflow-y: auto;
  background: #fffdf6; border-radius: 14px; padding: 22px;
  border: 2px solid var(--gold);
}
.trade-box h3 { letter-spacing: 4px; margin-bottom: 14px; color: var(--red); text-align: center; }
.trade-row { margin-bottom: 10px; }
.trade-row label { display: block; font-size: 13px; color: var(--ink2); margin-bottom: 4px; }
.trade-row input[type=number] { width: 130px; }
.prop-checks { display: flex; flex-wrap: wrap; gap: 6px; }
.prop-checks label {
  display: inline-flex; align-items: center; gap: 3px; font-size: 12px;
  border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; background: #fff; cursor: pointer;
}
.trade-btns { display: flex; gap: 12px; justify-content: center; margin-top: 14px; }
#tradeask-detail { font-size: 14px; line-height: 2; }

/* ---------- toast ---------- */
#toast {
  position: fixed; top: 14%; left: 50%; transform: translateX(-50%);
  background: rgba(40,28,16,.88); color: #ffe9c2; padding: 10px 22px; border-radius: 24px;
  font-size: 15px; z-index: 99; pointer-events: none; opacity: 0; transition: opacity .3s;
}
#toast.show { opacity: 1; }

/* ---------- 测试区标识 ---------- */
#test-badge {
  position: fixed; top: 10px; right: 12px; z-index: 98;
  padding: 5px 14px; border-radius: 999px;
  font-size: 13px; letter-spacing: 3px; font-weight: 700; color: #fff;
  background: linear-gradient(180deg, #c0463a, #8f2a20);
  border: 1px solid #ff9a8a; box-shadow: 0 3px 10px rgba(0,0,0,.3);
  pointer-events: none; opacity: .92;
}

/* 桌面端专用，不做手机适配 */


/* ---------- 道具系统 ---------- */
.shop-list { max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.shop-row { display: flex; align-items: center; gap: 10px; background: rgba(122, 84, 40, .08); border: 1px solid rgba(122, 84, 40, .15); border-radius: 10px; padding: 8px 12px; }
.shop-row .si { font-size: 22px; width: 32px; text-align: center; flex: none; }
.shop-row .si.tnum { font-weight: 800; font-size: 18px; }
.shop-row .sd { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.shop-row .sd b { font-size: 14px; }
.shop-row .sd span { font-size: 12px; color: #8a7258; }
.bag-target-tip { font-size: 13px; color: #8a7258; padding: 2px 2px; }
.pcard .its { font-size: 12px; letter-spacing: 1px; color: #8a7258; }
.cell.shop-cell { background: linear-gradient(180deg, #fdf3dd, #f3e2b8); }
.cell.shop-cell .pr { color: #b3541e; font-weight: 700; }
