/* ============================================================
   大富翁 · 环游中国 —— 桌面绿呢 + 米纸棋盘
   ============================================================ */
:root {
  --felt: #2c4237;
  --felt-deep: #223429;
  --paper: #f3ead9;
  --paper-2: #e9ddc6;
  --ink: #383126;
  --ink-2: #7a7060;
  --line: rgba(56, 49, 38, .18);
  --accent: #c05b4d;
  --gold: #c9a227;
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  --font-display: Georgia, "Times New Roman", "Songti SC", STSong, SimSun, serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 800px at 50% -10%, rgba(255, 255, 255, .06), transparent 60%),
    var(--felt);
  color: var(--ink);
  min-height: 100vh;
  min-height: 100svh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button { font-family: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.btn {
  border-radius: 10px;
  font-size: 15px;
  letter-spacing: .2em;
  text-indent: .2em;
  padding: 12px 18px;
  transition: transform .15s ease, background .2s, color .2s, border-color .2s;
}
.btn:active { transform: scale(.97); }
.btn-solid {
  border: none;
  background: var(--accent);
  color: #fdf6ea;
}
.btn-solid:hover { background: #a94b3e; }
.btn-line {
  border: 1.5px solid var(--line);
  background: transparent;
  color: var(--ink-2);
}
.btn-line:hover { border-color: var(--ink-2); color: var(--ink); }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; transform: none; }

/* ============================================================
   大厅
   ============================================================ */
.lobby {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px calc(24px + var(--safe-b));
}
.lobby-card {
  width: min(100%, 360px);
  background: var(--paper);
  border-radius: 18px;
  padding: 40px 34px 34px;
  text-align: center;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .6);
  animation: rise .5s ease;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}
.lobby-dice { font-size: 40px; letter-spacing: 6px; color: var(--ink); }
.lobby-dice .d-a { display: inline-block; animation: tumble 4s ease-in-out infinite; }
.lobby-dice .d-b { display: inline-block; color: var(--accent); animation: tumble 4s ease-in-out infinite reverse; }
@keyframes tumble {
  0%, 100% { transform: rotate(-8deg); }
  50%      { transform: rotate(10deg) translateY(-3px); }
}
.lobby-card h1 {
  font-family: var(--font-display);
  font-size: 38px;
  font-weight: 600;
  letter-spacing: .18em;
  text-indent: .18em;
  margin-top: 10px;
}
.lobby-sub {
  font-size: 11px;
  letter-spacing: .4em;
  color: var(--accent);
  margin: 10px 0 30px;
}
.lobby-form { display: flex; flex-direction: column; gap: 12px; }
.lobby-form input, .join-row input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fffdf8;
  font-size: 15px;
  font-family: inherit;
  text-align: center;
  outline: none;
  transition: border-color .2s;
}
.lobby-form input:focus, .join-row input:focus { border-color: var(--ink-2); }
.join-row { display: flex; gap: 10px; }
.join-row input { flex: 1; letter-spacing: .4em; text-transform: uppercase; }
.join-row .btn { flex-shrink: 0; }
.lobby-error { color: #a8473a; font-size: 13px; min-height: 18px; }

.room-code-label { font-size: 12px; letter-spacing: .2em; color: var(--ink-2); }
.room-code {
  font-family: var(--font-display);
  font-size: 44px;
  font-weight: 600;
  letter-spacing: .3em;
  text-indent: .3em;
  color: var(--accent);
  margin: 8px 0 18px;
  user-select: all;
}
.lobby-players {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}
.lobby-players li {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 14px;
  animation: rise .3s ease backwards;
}
.lobby-players .dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.lobby-players .host-tag {
  margin-left: auto;
  font-size: 11px;
  color: var(--gold);
  letter-spacing: .1em;
}
.lobby-wait { font-size: 13px; color: var(--ink-2); margin-top: 12px; }
.lobby-tip { font-size: 11px; letter-spacing: .15em; color: var(--ink-2); margin-top: 16px; opacity: .8; }
.lobby-foot {
  margin-top: 22px;
  font-size: 11px;
  letter-spacing: .3em;
  color: rgba(243, 234, 217, .5);
}
#btnStart { width: 100%; }

/* ============================================================
   对局布局
   ============================================================ */
.game {
  display: flex;
  gap: 14px;
  padding: 16px;
  max-width: 1380px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100svh;
  align-items: flex-start;
}
.board-wrap { flex: 1 1 72%; position: sticky; top: 14px; }
.panel {
  flex: 1 1 28%;
  max-width: 330px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: calc(100vh - 32px);
}

/* ---------------- 棋盘 ---------------- */
.board {
  position: relative;
  aspect-ratio: 1;
  width: 100%;
  max-width: min(94vmin, 880px);
  margin: 0 auto;
  background: var(--paper);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .4), inset 0 1px 0 rgba(255,255,255,.5);
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  grid-template-rows: repeat(11, 1fr);
  padding: 6px;
  gap: 2px;
}
.cell {
  position: relative;
  background: #fbf5e8;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 10px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: box-shadow .2s;
}
.cell:hover { box-shadow: 0 0 0 2px var(--gold); z-index: 3; }
.cell .bar { height: 5px; flex-shrink: 0; }
.cell .cicon {
  text-align: center;
  font-size: 13px;
  line-height: 1;
  padding-top: 4px;
  flex-shrink: 0;
}
.cell .cname {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 2px;
  line-height: 1.2;
  white-space: pre-line;
  font-weight: 500;
  color: var(--ink);
}
.cell .cprice { font-size: 8px; color: var(--ink-2); text-align: center; padding-bottom: 5px; }
.cell.corner { background: var(--paper-2); }
.cell.corner .cicon { font-size: 16px; padding-top: 6px; }
.cell.corner .cname { font-weight: 600; font-size: 10px; }
/* 建筑是格子的主视觉：升级后城市图标淡出、房子顶上 */
.cell .blds {
  position: absolute;
  top: 6px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 14px;
  line-height: 1;
  letter-spacing: -2px;
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .35));
  z-index: 2;
}
.cell.built .cicon { opacity: .22; }
.cell.grow { animation: cellGrow .5s ease; z-index: 3; }
@keyframes cellGrow { 50% { transform: scale(1.14); } }
/* 拥有者染色：底部色条 */
.cell .owner-strip {
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: 1px;
  height: 4px;
  border-radius: 2px;
}

/* 中心区 */
.board-center {
  grid-area: 2 / 2 / 11 / 11;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  position: relative;
  border-radius: 8px;
  background:
    radial-gradient(closest-side, rgba(192, 91, 77, .06), transparent 75%),
    repeating-linear-gradient(0deg, transparent 0 34px, rgba(56,49,38,.03) 34px 35px);
  padding: 10px;
}
.round-line { font-size: 12px; letter-spacing: .25em; color: var(--ink-2); }
.dice-area { display: flex; gap: 14px; }
.die.big {
  font-size: clamp(46px, 9vmin, 72px);
  line-height: 1;
  color: var(--ink);
  transition: transform .15s;
}
.die.big.rolling { animation: shake .55s ease; }
@keyframes shake {
  0%   { transform: rotate(0) scale(1); }
  25%  { transform: rotate(-18deg) scale(1.15); }
  50%  { transform: rotate(14deg) scale(1.08); }
  75%  { transform: rotate(-8deg) scale(1.12); }
  100% { transform: rotate(0) scale(1); }
}
.turn-line {
  font-size: clamp(13px, 2.4vmin, 16px);
  font-weight: 600;
  letter-spacing: .1em;
  min-height: 22px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.turn-line .dot { width: 12px; height: 12px; border-radius: 50%; }
.action-area {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  min-height: 46px;
  align-items: center;
}
.action-hint { font-size: 12px; color: var(--ink-2); letter-spacing: .1em; }
.count-ring { font-variant-numeric: tabular-nums; color: var(--accent); }

/* 中央水印 */
.center-mark {
  position: absolute;
  top: 11%;
  font-family: var(--font-display);
  font-size: clamp(26px, 6.5vmin, 54px);
  font-weight: 700;
  letter-spacing: .3em;
  text-indent: .3em;
  color: rgba(56, 49, 38, .07);
  pointer-events: none;
  user-select: none;
}

/* 中央公告 */
.announce {
  position: absolute;
  left: 5%;
  right: 5%;
  bottom: 9%;
  z-index: 6;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: #fffdf6;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 12px 16px;
  font-size: clamp(13px, 2.4vmin, 16px);
  font-weight: 600;
  letter-spacing: .04em;
  text-align: center;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .28);
  animation: popIn .3s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes popIn { from { opacity: 0; transform: translateY(14px) scale(.92); } }
.announce .a-emoji { font-size: 1.5em; line-height: 1; }
.announce .a-blds { font-size: 1.2em; }
b.down, .down { color: var(--accent); }
b.up, .up { color: #2f7d4f; }
.announce.a-pay { border-color: rgba(192, 91, 77, .55); }
.announce.a-gain { border-color: rgba(47, 125, 79, .5); }
.announce.a-card, .announce.a-deed { background: transparent; border: none; box-shadow: none; padding: 0; }

/* 抽到的卡 */
.draw-card {
  width: min(76%, 250px);
  background: linear-gradient(160deg, #fffdf6, #f4e9d3);
  border: 2px solid var(--gold);
  border-radius: 14px;
  padding: 15px 18px 12px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
  animation: flipIn .45s ease;
}
@keyframes flipIn { from { transform: perspective(600px) rotateY(85deg); opacity: 0; } }
.draw-kind { font-size: 13px; letter-spacing: .3em; text-indent: .3em; color: #a8861d; font-weight: 700; }
.draw-text { margin: 9px 0 8px; font-size: clamp(13px, 2.4vmin, 15px); font-weight: 500; line-height: 1.6; }
.draw-who { font-size: 11px; color: var(--ink-2); }

/* 地契卡（购地成交） */
.deed {
  position: relative;
  width: min(62%, 190px);
  background: #fffdf6;
  border: 2px solid var(--ink);
  border-radius: 10px;
  overflow: hidden;
  padding-bottom: 13px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
  animation: popIn .35s cubic-bezier(.2, 1.4, .4, 1);
}
.deed-bar { height: 14px; }
.deed-icon { font-size: 36px; line-height: 1; margin-top: 12px; }
.deed-name {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .2em;
  text-indent: .2em;
  margin-top: 6px;
}
.deed-price { font-size: 13px; color: var(--ink-2); margin-top: 3px; font-variant-numeric: tabular-nums; }
.deed-owner { font-size: 12px; margin-top: 6px; font-weight: 600; }
.deed-stamp {
  position: absolute;
  right: 7px;
  top: 32px;
  color: #c23a2b;
  border: 3px solid #c23a2b;
  border-radius: 8px;
  padding: 3px 7px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .2em;
  text-indent: .2em;
  transform: rotate(-18deg);
  opacity: .92;
  animation: stampIn .4s cubic-bezier(.2, 1.6, .4, 1) .3s backwards;
}
@keyframes stampIn { from { transform: rotate(-18deg) scale(2.6); opacity: 0; } }

/* 金额飘字 */
.float-amt {
  position: absolute;
  right: 12px;
  top: -6px;
  font-weight: 700;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  animation: floatUp 1.05s ease forwards;
  z-index: 5;
}
.float-amt.up { color: #2f9d5f; }
.float-amt.down { color: #e06a58; }
@keyframes floatUp {
  from { opacity: 0; transform: translateY(8px); }
  20%  { opacity: 1; }
  to   { opacity: 0; transform: translateY(-24px); }
}

/* 棋子落地弹跳 */
.token.bounce { animation: tokenBounce .45s cubic-bezier(.3, 1.6, .4, 1); }
@keyframes tokenBounce {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.5); }
  100% { transform: scale(1); }
}

/* 音效开关 */
.sound-btn {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 95;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(243, 234, 217, .35);
  background: rgba(0, 0, 0, .2);
  font-size: 16px;
  line-height: 1;
  transition: border-color .2s, transform .15s;
}
.sound-btn:hover { border-color: var(--paper); }
.sound-btn:active { transform: scale(.92); }

/* 棋子：白底彩圈 + 动物头像 */
.token {
  position: absolute;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2.5px solid var(--ink);
  background: #fffdf6;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .35);
  transition: left .18s ease, top .18s ease;
  z-index: 4;
  pointer-events: none;
}
.token > span { transform: translateY(.5px); }
.token.jail::after {
  content: "⛓️";
  position: absolute;
  right: -5px;
  bottom: -5px;
  font-size: .6em;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.4));
}
.token.dead { opacity: .25; filter: grayscale(1); }

/* 头像圆牌（面板 / 大厅 / 回合提示 / 结算通用） */
.pav {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: #fffdf6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  line-height: 1;
  flex-shrink: 0;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .15);
}
.pav.sm { width: 25px; height: 25px; font-size: 13px; }

/* ---------------- 右侧面板 ---------------- */
.panel-players {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pp {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--paper);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
  transition: outline .2s;
  outline: 2px solid transparent;
}
.pp.current { outline: 2px solid var(--gold); }
.pp.dead { opacity: .45; }
.pp .dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.pp .pp-name {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pp .pp-tag { font-size: 10px; color: var(--ink-2); }
.pp .pp-money {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 15px;
  transition: color .2s;
}
.pp .pp-money.flash-up { color: #2f7d4f; }
.pp .pp-money.flash-down { color: var(--accent); }

.panel-log {
  flex: 1;
  min-height: 120px;
  max-height: 300px;
  background: rgba(243, 234, 217, .92);
  border-radius: 12px;
  padding: 10px 12px;
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.8;
  color: var(--ink);
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, .08);
}
.panel-log .chat-line b { font-weight: 600; }
.panel-chat { display: flex; gap: 8px; }
.panel-chat input {
  flex: 1;
  padding: 9px 12px;
  border: none;
  border-radius: 10px;
  background: rgba(243, 234, 217, .92);
  font-size: 12.5px;
  font-family: inherit;
  outline: none;
}
.panel-chat .btn-line { border-color: rgba(243, 234, 217, .4); color: rgba(243, 234, 217, .85); }
.panel-chat .btn-line:hover { border-color: var(--paper); color: var(--paper); }

/* ---------------- 地块浮层 ---------------- */
.cell-pop {
  position: fixed;
  z-index: 80;
  width: 210px;
  background: #fffdf6;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 16px 44px rgba(0, 0, 0, .3);
  padding: 14px 16px;
  font-size: 13px;
  animation: rise .2s ease;
}
.cell-pop h4 { font-size: 15px; display: flex; align-items: center; gap: 8px; }
.cell-pop h4 .gdot { width: 10px; height: 10px; border-radius: 3px; }
.cell-pop .rows { margin-top: 8px; color: var(--ink-2); line-height: 1.9; }
.cell-pop .rows b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------------- 结算 ---------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(20, 28, 23, .8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.end-card {
  width: min(100%, 380px);
  background: var(--paper);
  border-radius: 18px;
  padding: 34px 30px 28px;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
  animation: rise .4s ease;
}
.end-card h2 {
  font-family: var(--font-display);
  font-size: 24px;
  letter-spacing: .12em;
}
.end-rank {
  list-style: none;
  margin: 22px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.end-rank li {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
}
.end-rank .medal { font-size: 16px; width: 24px; }
.end-rank .dot { width: 12px; height: 12px; border-radius: 50%; }
.end-rank .assets { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }
.end-rank li.out { opacity: .5; }
.end-actions { display: flex; gap: 10px; justify-content: center; }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 200;
  background: rgba(30, 26, 20, .92);
  color: #f3ead9;
  padding: 11px 24px;
  border-radius: 999px;
  font-size: 13px;
  letter-spacing: .08em;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  animation: rise .25s ease;
  max-width: calc(100vw - 40px);
  text-align: center;
}

/* ============================================================
   窄屏：棋盘在上、面板在下
   ============================================================ */
@media (max-width: 900px) {
  .game {
    flex-direction: column;
    padding: 10px 10px calc(16px + var(--safe-b));
    gap: 12px;
  }
  .board-wrap { position: static; width: 100%; flex: none; }
  .board { max-width: 100%; }
  .panel { max-width: none; width: 100%; max-height: none; }
  .panel-log { max-height: 150px; min-height: 100px; }
  .cell { font-size: 8px; border-radius: 3px; }
  .cell .cprice { display: none; }
  .cell .cicon { font-size: 10px; padding-top: 2px; }
  .cell.corner .cicon { font-size: 12px; padding-top: 4px; }
  .cell.corner .cname { font-size: 8px; }
  .cell .blds { font-size: 10px; top: 5px; letter-spacing: -1px; }
  .cell .bar { height: 4px; }
  .announce { left: 3%; right: 3%; bottom: 6%; padding: 9px 10px; gap: 6px; }
  .sound-btn { top: 10px; right: 10px; width: 34px; height: 34px; font-size: 14px; }
  .panel-players { flex-direction: row; flex-wrap: wrap; }
  .pp { flex: 1 1 46%; padding: 8px 10px; }
  .pp .pp-name { font-size: 12px; }
  .pp .pp-money { font-size: 13px; }
}
