* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: system-ui, sans-serif; background: #f5f0e6; min-height: 100vh; }
.screen { display: none; max-width: 720px; margin: 0 auto; padding: 16px; }
.screen.active { display: block; }
button { padding: 10px 20px; border: none; border-radius: 8px; background: #4a7c59; color: #fff; font-size: 16px; cursor: pointer; }
button:disabled { opacity: .5; }
input { padding: 10px; border: 1px solid #ccc; border-radius: 8px; font-size: 16px; }
.join-row { display: flex; gap: 8px; margin-top: 12px; }

/* ---- 棋盘（render.js）---- */
#board-wrap { max-width: 560px; margin: 0 auto; }
.board-svg { width: 100%; height: auto; display: block; }
.piece { transition: transform .4s ease; cursor: default; }
.piece.movable { cursor: pointer; }
.piece.movable circle { animation: pulse 1s infinite; }
@keyframes pulse { 50% { filter: brightness(1.3); } }

/* ---- 大厅 ---- */
#screen-lobby { max-width: 360px; margin-top: 10vh; }
#screen-lobby input { display: block; width: 100%; margin-bottom: 10px; }
#screen-lobby button { display: block; width: 100%; }
.join-row input { flex: 1 1 0; min-width: 0; width: auto; margin-bottom: 0; }
#screen-lobby .join-row button { flex: 0 0 auto; width: auto; white-space: nowrap; }
#lobby-msg { margin-top: 12px; color: #d9534f; font-size: 14px; min-height: 20px; }

/* ---- 等待页座位卡 ---- */
#screen-room { max-width: 420px; margin-top: 8vh; }
#screen-room button { display: block; width: 100%; margin-top: 10px; }
#seat-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 16px 0 4px; }
.seat-card {
  display: flex; align-items: center; gap: 8px;
  background: #fffdf7; border: 2px solid #c9bfa8; border-radius: 8px;
  padding: 10px 12px; font-size: 15px;
}
.seat-card.offline { opacity: .55; }
.seat-dot { width: 14px; height: 14px; border-radius: 50%; flex: none; border: 1px solid rgba(0,0,0,.12); }
.seat-red .seat-dot { background: #d9534f; }
.seat-yellow .seat-dot { background: #e8b339; }
.seat-blue .seat-dot { background: #4a7ebb; }
.seat-green .seat-dot { background: #4a9e5c; }
.seat-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-name.empty { color: #b3a98f; font-weight: 400; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 10px; flex: none; }
.tag-me { background: #4a7c59; color: #fff; }
.tag-off { background: #d8d2c2; color: #666; }

/* ---- 对局屏布局 ---- */
#screen-game.active { display: flex; gap: 16px; align-items: flex-start; }
#board-wrap { flex: 1; min-width: 0; }
#side-panel { width: 240px; flex: none; display: flex; flex-direction: column; gap: 10px; }

#players-status { display: flex; flex-direction: column; gap: 6px; }
.player-row {
  display: flex; align-items: center; gap: 8px; font-size: 14px;
  background: #fffdf7; border: 1px solid #e3dcc9; border-radius: 8px; padding: 5px 9px;
}
.player-row.offline { opacity: .55; }
.player-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.dot-red { background: #d9534f; }
.dot-yellow { background: #e8b339; }
.dot-blue { background: #4a7ebb; }
.dot-green { background: #4a9e5c; }
.btn-kick { padding: 2px 10px; font-size: 12px; background: #d9534f; }

#turn-indicator { font-size: 18px; font-weight: 700; color: #4a7c59; min-height: 24px; }
#turn-indicator.flash { animation: flash .3s 2; }
@keyframes flash { 50% { color: #d9534f; opacity: .35; } }

/* ---- 骰子 ---- */
#dice-area { display: flex; align-items: center; gap: 12px; }
#dice {
  width: 56px; height: 56px; flex: none;
  background: #fffdf7; border: 2px solid #c9bfa8; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700; color: #4a7c59;
}
#dice.pop { animation: dice-pop .4s ease; }
@keyframes dice-pop { 0% { transform: scale(.4); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }
#btn-roll { flex: 1; }

/* ---- 日志区 ---- */
#log-list {
  background: #fffdf7; border: 1px solid #c9bfa8; border-radius: 8px;
  padding: 8px 10px; max-height: 200px; overflow-y: auto; font-size: 13px; color: #555;
}
.log-item { padding: 3px 0; border-bottom: 1px dashed #eee; }
.log-item:last-child { border-bottom: none; }
.log-empty { color: #b3a98f; }

/* ---- 结算浮层 ---- */
#result-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, .45);
  display: none; align-items: center; justify-content: center;
}
#result-overlay.show { display: flex; }
.result-card {
  background: #fffdf7; border-radius: 12px; padding: 28px 32px;
  min-width: 260px; max-width: 90vw; text-align: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .25);
}
.result-title {
  font-size: 20px; font-weight: 700; margin-bottom: 18px; color: #3d3d3d;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.result-color { width: 16px; height: 16px; border-radius: 50%; display: inline-block; flex: none; }
.result-actions { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.btn-secondary { background: #8a9a8f; }
#btn-exit { display: block; width: 100%; margin-top: 10px; font-size: 14px; }
.result-wait { color: #888; font-size: 14px; padding: 6px 0; }

/* ---- 移动端 ---- */
@media (max-width: 520px) {
  .screen { padding: 10px; }
  #screen-game.active { flex-direction: column; }
  #side-panel { width: 100%; }
  #log-list { max-height: 120px; }
  #seat-list { grid-template-columns: 1fr; }
}
