:root {
  --bg: #eef1ea;
  --card: #ffffff;
  --ink: #1d1d1f;
  --ink-2: #6e6e73;
  --ink-3: #a1a1a6;
  --line: rgba(0, 0, 0, .08);
  --blue: #0071e3;
  --blue-soft: rgba(0, 113, 227, .08);
  --radius: 18px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 0, 0, .05);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }

body {
  background: linear-gradient(160deg, #f4f7f1 0%, #e9eee6 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro SC", "SF Pro Text", "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
.app { min-height: 100vh; display: flex; flex-direction: column; }

/* 顶栏 */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px;
  background: rgba(255, 255, 255, .72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: baseline; gap: 10px; font-weight: 600; font-size: 17px; letter-spacing: .2px; }
.brand small { font-size: 10px; letter-spacing: 2.5px; color: var(--ink-3); font-weight: 500; }
.topbar-actions { display: flex; gap: 8px; }
.tbtn { padding: 7px 14px; border-radius: 999px; font-size: 13px; background: rgba(0, 0, 0, .05); transition: .2s; }
.tbtn:hover { background: rgba(0, 0, 0, .09); }
.tbtn.on { background: var(--blue); color: #fff; }

/* 布局 */
.stage {
  flex: 1; display: flex; gap: 22px; padding: 22px;
  align-items: flex-start; justify-content: center; flex-wrap: wrap;
}

/* ---------- 地图 ---------- */
.board-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 24px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .04), 0 16px 40px rgba(60, 70, 50, .08);
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.board {
  position: relative;
  width: min(78vh, 800px); aspect-ratio: 1 / 1;
  border-radius: 16px; overflow: hidden;
  background: #f2f4ee;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .05);
}
#mapSvg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#mapSvg .tile { cursor: pointer; }
#mapSvg .tile:hover rect { filter: brightness(.965); }

/* 岔路选路面板：贴在地图外侧下方，不遮挡棋盘 */
.branch-panel {
  display: none; flex-direction: column; gap: 6px;
  padding: 12px 14px; border-radius: 16px;
  background: linear-gradient(165deg, #ffffff, #f4f5f1);
  border: 1px solid var(--line);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .05), 0 14px 30px rgba(60, 70, 50, .1);
  animation: slideUp .22s cubic-bezier(.2, .9, .3, 1.1);
}
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.bp-head { font-size: 12px; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.bp-head small { font-weight: 400; color: var(--ink-3); font-size: 11px; }
.branch-opt {
  border: 1.5px solid var(--line); border-radius: 12px; padding: 8px 11px;
  background: #fff; cursor: pointer; transition: .16s;
}
.branch-opt:hover { transform: translateX(2px); box-shadow: 0 2px 10px rgba(0, 0, 0, .07); }
.bo-title { font-size: 12px; font-weight: 700; letter-spacing: .5px; margin-bottom: 2px; }
.bo-path { font-size: 11.5px; line-height: 1.55; color: var(--ink-2); }

/* 状态条：位于地图外侧下方，不遮挡棋盘 */
.board-msg {
  padding: 10px 14px;
  border-radius: 14px;
  background: linear-gradient(165deg, #ffffff, #f4f5f1);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .8);
  font-size: 12.5px; line-height: 1.45; color: var(--ink-2);
  text-align: center; min-height: 20px;
}

/* 骰盅（地图左侧独立一列） */
.board-wrap { display: flex; gap: 14px; align-items: flex-start; }
.dice-tray {
  width: 112px; flex: 0 0 112px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 15px 12px 13px;
  border-radius: 18px;
  background: linear-gradient(165deg, #ffffff, #f3f4ef);
  border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 10px 26px rgba(60, 70, 50, .07);
}
.tray-title { font-size: 10px; letter-spacing: 2.6px; color: var(--ink-3); font-weight: 600; }
.dicerow { display: flex; gap: 9px; justify-content: center; flex-wrap: wrap; }
.die {
  width: 42px; height: 42px; border-radius: 12px; background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 5px 14px rgba(0, 0, 0, .07);
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  padding: 6px;
}
.die.roll { animation: shake .45s ease; }
@keyframes shake {
  0% { transform: rotate(0) translateY(0); }
  30% { transform: rotate(140deg) translateY(-6px); }
  60% { transform: rotate(260deg) translateY(2px); }
  100% { transform: rotate(360deg) translateY(0); }
}
.pip { width: 8px; height: 8px; border-radius: 50%; background: var(--ink); align-self: center; justify-self: center; }
.dice-total { font-size: 15px; font-weight: 600; letter-spacing: -.3px; color: var(--ink); min-height: 22px; }
.tray-tip { font-size: 10px; color: var(--ink-3); line-height: 1.35; text-align: center; }
.dice-tray .tbtn { width: 100%; text-align: center; }

/* 棋子 */
#tokens { position: absolute; inset: 0; z-index: 6; pointer-events: none; }
.token {
  position: absolute; width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
  transform: translate(-50%, -50%);
  transition: left .26s cubic-bezier(.3, .8, .3, 1), top .26s cubic-bezier(.3, .8, .3, 1);
}
.token.tiny { width: 11px; height: 11px; border-width: 1.5px; }
.token.active { box-shadow: 0 0 0 3px rgba(255, 255, 255, .85), 0 2px 8px rgba(0, 0, 0, .4); z-index: 9 !important; }

/* ---------- 侧栏 ---------- */
.panel { width: 330px; flex: 0 0 330px; display: flex; flex-direction: column; gap: 14px; }
.pcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.pcard h3 { margin: 0 0 10px; font-size: 11px; letter-spacing: 1.6px; color: var(--ink-3); font-weight: 600; }

.turn-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.avatar { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; font-size: 14px; }
.avatar.sm { width: 24px; height: 24px; flex: 0 0 24px; font-size: 11px; }
.turn-head .nm { font-size: 16px; font-weight: 600; }
.cash { font-size: 26px; font-weight: 600; letter-spacing: -.5px; }
.cash .y { font-size: 14px; color: var(--ink-3); font-weight: 400; margin-right: 2px; }

.btnrow { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.bigbtn { flex: 1 1 40%; padding: 11px 12px; border-radius: 12px; background: var(--blue); color: #fff; font-size: 14px; font-weight: 500; transition: .18s; }
.bigbtn:hover:enabled { background: #0077ed; }
.bigbtn:disabled { background: #d2d2d7; cursor: not-allowed; }
.bigbtn.ghost { background: rgba(0, 0, 0, .05); color: var(--ink); }
.bigbtn.ghost:hover:enabled { background: rgba(0, 0, 0, .09); }
.bigbtn.warm { background: #ff9500; color: #fff; }

.hintbox { margin-top: 10px; font-size: 12px; color: var(--ink-2); background: var(--blue-soft); border-radius: 10px; padding: 9px 11px; line-height: 1.45; }
.hintbox.warn { background: rgba(255, 149, 0, .12); }

.player-row { display: flex; align-items: center; gap: 10px; padding: 8px 9px; border-radius: 11px; transition: .2s; margin-bottom: 3px; }
.player-row.active { background: var(--blue-soft); box-shadow: inset 0 0 0 1px rgba(0, 113, 227, .25); }
.player-row.dead { opacity: .4; }
.player-row .nm { flex: 1; font-size: 13px; font-weight: 500; }
.player-row .sub { font-size: 10px; color: var(--ink-3); font-weight: 400; }
.player-row .amt { font-size: 13px; font-weight: 600; letter-spacing: -.2px; }
.tag { font-size: 9px; padding: 2px 6px; border-radius: 6px; background: rgba(0, 0, 0, .06); color: var(--ink-2); margin-left: 4px; }
.pbar { margin-top: 4px; height: 4px; border-radius: 3px; background: rgba(0, 0, 0, .07); overflow: hidden; }
.pbar span { display: block; height: 100%; border-radius: 3px; transition: width .3s ease; }

/* 净资产分布图 */
.worth-row { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.worth-row.dead { opacity: .4; }
.wr-name { flex: 0 0 74px; font-size: 11.5px; color: var(--ink-2); display: flex; align-items: center; gap: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wr-name i { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }
.wr-bar { flex: 1; height: 12px; border-radius: 6px; background: rgba(0, 0, 0, .06); display: flex; overflow: hidden; }
.w-seg { height: 100%; transition: width .3s ease; }
.w-seg.cash { opacity: 1; }
.w-seg.prop { opacity: .42; background-image: repeating-linear-gradient(45deg, rgba(255, 255, 255, .55) 0 3px, transparent 3px 6px); }
.wr-val { flex: 0 0 52px; text-align: right; font-size: 11.5px; font-weight: 600; letter-spacing: -.2px; }
.chart-legend { display: flex; gap: 14px; margin-top: 8px; font-size: 10.5px; color: var(--ink-3); }
.chart-legend span { display: flex; align-items: center; gap: 5px; }
.lg { width: 18px; height: 8px; border-radius: 4px; background: var(--ink-3); }
.lg.cash { background: #8e8e93; }
.lg.prop { background: #8e8e93; opacity: .42; background-image: repeating-linear-gradient(45deg, rgba(255, 255, 255, .55) 0 3px, transparent 3px 6px); }

.asset { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 9px; font-size: 12px; cursor: pointer; transition: .15s; }
.asset:hover { background: rgba(0, 0, 0, .045); }
.asset .swatch { width: 5px; height: 20px; border-radius: 3px; flex: 0 0 5px; }
.asset .an { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset .meta { color: var(--ink-3); font-size: 11px; }
.asset.mortgaged .an { text-decoration: line-through; color: var(--ink-3); }
.empty-tip { font-size: 12px; color: var(--ink-3); padding: 6px 2px; }

.log { max-height: 190px; overflow: auto; font-size: 12px; line-height: 1.65; color: var(--ink-2); }
.log div { padding: 3px 0; border-bottom: 1px dashed rgba(0, 0, 0, .06); }
.log div:last-child { border: none; }

/* ---------- 弹窗 ---------- */
.mask {
  position: fixed; inset: 0; background: rgba(30, 40, 30, .28);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
  animation: fade .2s;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #fff; border-radius: 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
  width: min(430px, 100%); padding: 24px; animation: pop .26s cubic-bezier(.2, .9, .3, 1.1);
  max-height: 88vh; overflow: auto;
}
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
.modal h2 { margin: 0 0 4px; font-size: 19px; font-weight: 600; }
.modal .desc { font-size: 13px; color: var(--ink-2); margin-bottom: 16px; }
.deed { width: min(340px, 100%); }
.deed .strip { height: 12px; border-radius: 8px 8px 0 0; margin: -24px -24px 16px; }
.deed .group { font-size: 11px; letter-spacing: 1.5px; color: var(--ink-3); margin-bottom: 14px; }
.rent-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-bottom: 14px; }
.rent-table td { padding: 5px 0; border-bottom: 1px solid var(--line); }
.rent-table td:last-child { text-align: right; font-weight: 600; }
.rent-table tr.em td { color: var(--blue); }
.modal .foot { font-size: 11px; color: var(--ink-3); margin-top: 12px; text-align: center; }
.card-flash {
  border-radius: 14px; padding: 18px; margin-bottom: 16px; font-size: 14px; line-height: 1.6;
  background: linear-gradient(160deg, #f7faf5, #eef3ea); border: 1px solid var(--line); text-align: center;
}
.card-flash .kind { font-size: 10px; letter-spacing: 2px; color: var(--ink-3); margin-bottom: 8px; }
.rules { font-size: 13px; color: var(--ink-2); line-height: 1.75; max-height: 60vh; overflow: auto; }
.rules b { color: var(--ink); }

/* 岔路选线 */
.branches { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.branch-row {
  border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px;
  background: linear-gradient(160deg, #fbfcf9, #f3f5f0);
}
.branch-row .bn { font-size: 11px; letter-spacing: 1px; color: var(--ink-3); margin-bottom: 3px; }
.branch-row .bp { font-size: 12.5px; line-height: 1.6; color: var(--ink); }
.risk { color: #e8453c; font-weight: 600; }
.own { color: #34c759; font-weight: 700; }
.free-to-buy { color: #0071e3; }

.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%);
  background: rgba(29, 29, 31, .92); color: #fff; padding: 11px 20px; border-radius: 999px;
  font-size: 13px; z-index: 80; opacity: 0; pointer-events: none; transition: .28s;
  backdrop-filter: blur(10px); max-width: 80vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }

/* ---------- 联机大厅 ---------- */
.lobby {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: linear-gradient(160deg, rgba(244, 247, 241, .96), rgba(232, 238, 229, .96));
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  overflow: auto;
}
.lb-card {
  width: min(430px, 100%);
  background: #fff; border: 1px solid var(--line); border-radius: 26px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .05), 0 26px 60px rgba(60, 70, 50, .14);
  padding: 26px 24px 22px; animation: pop .28s cubic-bezier(.2, .9, .3, 1.1);
}
.lb-title { font-size: 22px; font-weight: 600; letter-spacing: -.4px; text-align: center; }
.lb-title .code { letter-spacing: 6px; color: var(--blue); font-size: 26px; }
.lb-sub { font-size: 12px; color: var(--ink-3); text-align: center; margin: 6px 0 18px; line-height: 1.55; }
.lb-field { margin-bottom: 12px; }
.lb-field input, .lb-code {
  width: 100%; padding: 11px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: rgba(0, 0, 0, .03);
  font-size: 14px; font-family: inherit; color: var(--ink); outline: none; transition: .18s;
}
.lb-field input:focus, .lb-code:focus { border-color: rgba(0, 113, 227, .5); background: #fff; }
.lb-code { text-align: center; letter-spacing: 8px; font-weight: 600; text-transform: uppercase; }
.lb-row { display: flex; gap: 10px; margin-bottom: 10px; }
.lb-row .bigbtn { flex: 1; }
.lb-msg { min-height: 18px; font-size: 12px; color: var(--ink-2); text-align: center; margin-top: 8px; }
.lb-msg.bad { color: #e8453c; }
.lb-foot { margin-top: 14px; font-size: 10.5px; color: var(--ink-3); text-align: center; }
.lb-seats { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 14px; }
.lb-seat {
  display: flex; align-items: center; gap: 8px; padding: 8px 11px;
  border-radius: 11px; background: rgba(0, 0, 0, .035); font-size: 13px;
}
.lb-seat.off { opacity: .45; }
.lb-seat.ai { background: rgba(0, 0, 0, .02); }
.lb-seat .dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 10px; }
.lb-seat .sn { flex: 1; font-weight: 500; }
.lb-seat .st { font-size: 10.5px; color: var(--ink-3); }
.lb-empty { font-size: 12px; color: var(--ink-3); text-align: center; padding: 10px; }
.lb-ai {
  display: flex; align-items: center; gap: 10px; font-size: 13px;
  padding: 9px 12px; border-radius: 12px; background: rgba(0, 0, 0, .035); margin-bottom: 12px;
}
.lb-ai small { color: var(--ink-3); font-size: 11px; margin-left: auto; }
.lb-ai b { min-width: 18px; text-align: center; }
.mini {
  width: 26px; height: 26px; border-radius: 9px; background: rgba(0, 0, 0, .06);
  font-size: 15px; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.mini:hover { background: rgba(0, 0, 0, .1); }

.room-chip {
  display: inline-flex; align-items: center; padding: 6px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 500; background: var(--blue-soft); color: var(--blue);
  white-space: nowrap;
}
.tag.me { background: var(--blue); color: #fff; }

@media (max-width: 1180px) {
  .board-wrap { flex-direction: column; align-items: center; }
  .dice-tray {
    width: min(94vw, 620px); flex: none; flex-direction: row; flex-wrap: wrap;
    justify-content: center; align-items: center; gap: 14px; padding: 12px 14px;
  }
  .dice-tray .tbtn { width: auto; padding: 7px 16px; }
  .tray-tip { width: 100%; }
}
@media (max-width: 1080px) {
  .stage { flex-direction: column; align-items: center; gap: 16px; }
  .panel { width: min(800px, 100%); flex: none; }
  .board { width: min(94vw, 620px); }
}
