/* style.css — 杭州麻将牌桌 */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --tile-w: 46px; --tile-h: 64px;
  --tile-s: 27px; --tile-s-h: 38px;
}
body {
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  background: radial-gradient(ellipse at 50% 40%, #1d6b4a 0%, #0f3d2a 60%, #082b1d 100%);
  color: #eee; min-height: 100vh; user-select: none;
}
#app { max-width: 1100px; margin: 0 auto; padding: 8px; }

#topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 14px; background: rgba(0,0,0,.35);
  border-radius: 10px; margin-bottom: 10px; flex-wrap: wrap;
}
#topbar .brand { font-size: 20px; font-weight: 700; letter-spacing: 6px; color: #ffd76a; }
#roomInfo b { color: #ffd76a; letter-spacing: 2px; }
#metaInfo { color: #cfe; font-size: 13px; }
#connInfo { margin-left: auto; font-size: 12px; color: #9c9; }

.view.hidden, .modal.hidden { display: none; }
.hidden { display: none !important; }
.spectator-badge {
  background: #3a3f4a; color: #ffd76a; border: 1px solid #ffd76a;
  padding: 2px 10px; border-radius: 12px; font-size: 12px;
}
.hand-empty { color: #7a7f8a; font-size: 13px; padding: 18px 0; text-align: center; }

/* ---------- 大厅 ---------- */
#lobby h2 { margin: 14px 0; }
.seat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.seat-card {
  background: rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.15);
  border-radius: 10px; padding: 12px; min-height: 110px; text-align: center;
}
.seat-card .name { font-size: 16px; font-weight: 600; }
.seat-card .tag { font-size: 11px; color: #ffd76a; }
.seat-card .tag.dealer { color: #ff8; }
.seat-card.empty { border-style: dashed; }
.seat-card .join-row { margin-top: 8px; display: flex; gap: 6px; justify-content: center; }
.seat-card input {
  background: #fff; color: #333; border: none; border-radius: 6px;
  padding: 6px 8px; width: 110px; font-size: 13px; outline: none;
}
.seat-card .bot-badge { color: #7cf; font-size: 12px; margin-top: 6px; }
.seat-card.host { border-color: #ffd76a; }
.controls { margin-top: 16px; display: flex; gap: 10px; flex-wrap: wrap; }
.hint { margin-top: 14px; font-size: 12px; color: #bcd; line-height: 1.7; }
code { background: rgba(255,255,255,.15); padding: 1px 6px; border-radius: 4px; }

/* ---------- 牌桌 ---------- */
#table { position: relative; height: 92vh; min-height: 640px; }
.seat-area { position: absolute; }
.area-top    { top: 4px;    left: 50%; transform: translateX(-50%); width: 96%; text-align: center; }
.area-left   { left: 4px;  top: 50%; transform: translateY(-50%); }
.area-right  { right: 4px; top: 50%; transform: translateY(-50%); width: 170px; }
.area-bottom { bottom: 4px; left: 50%; transform: translateX(-50%); width: 98%; }
.area-center {
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 340px; text-align: center; pointer-events: none;
}
#centerInfo { font-size: 13px; color: #ffe9b0; margin-bottom: 8px; line-height: 1.7; }

/* 玩家卡片（桌面内） */
.player-card {
  background: rgba(0,0,0,.4); border-radius: 10px; padding: 8px 10px;
  border: 1px solid rgba(255,255,255,.12); font-size: 13px;
}
.player-card.active { border-color: #ffd76a; box-shadow: 0 0 12px rgba(255,215,106,.5); }
.player-card .pname { font-weight: 600; display: flex; gap: 8px; align-items: center; }
.player-card .dealer-mark { color: #ffd76a; }
.player-card .score { color: #9fe8b0; }
.player-card .turn-indicator { color: #ffd76a; }

.other-hand { display: flex; gap: 2px; margin-top: 6px; flex-wrap: wrap; }
.melds-row, .discards-row { display: flex; gap: 3px; margin-top: 6px; flex-wrap: wrap; }
.melds-row { justify-content: flex-end; }
.area-top .melds-row, .area-top .discards-row { justify-content: center; }
.area-left .melds-row, .area-right .melds-row { flex-direction: column; }
.area-left .discards-row { flex-direction: column; }
.area-right .discards-row { flex-direction: column; }

/* ---------- 牌张 ---------- */
.tile {
  width: var(--tile-w); height: var(--tile-h); background: linear-gradient(#fff, #e8e4d8);
  border-radius: 6px; border: 1px solid #999; box-shadow: 0 2px 4px rgba(0,0,0,.4);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 700; cursor: default; line-height: 1.1;
}
.tile.small { width: var(--tile-s); height: var(--tile-s-h); border-radius: 4px; font-size: 12px; }
.tile .num { font-size: 20px; }
.tile.small .num { font-size: 13px; }
.tile .suit { font-size: 13px; }
.tile.small .suit { font-size: 9px; }
.tile.m .num, .tile.z5 .num { color: #d33; }
.tile.s .num, .tile.z6 .num { color: #2a2; }
.tile.p .num { color: #25c; }
.tile.z1 .num, .tile.z2 .num, .tile.z3 .num, .tile.z4 .num { color: #444; }
.tile.z7 .num { color: #999; }
.tile.honor { font-size: 17px; }
.tile.honor.small { font-size: 12px; }
.tile.back {
  background: repeating-linear-gradient(45deg, #37a06b, #37a06b 4px, #2d8759 4px, #2d8759 8px);
  border-color: #1d5c3d; color: transparent;
}
.tile.back .num, .tile.back .suit { visibility: hidden; }
#myHand .tile {
  cursor: pointer; transition: transform .12s;
  border: 2px solid transparent;
}
#myHand .tile:hover { transform: translateY(-8px); border-color: #ffd76a; }
#myHand .tile.just-drawn { border-color: #7cf; }
#myHand .tile.win-tile { border-color: #f66; background: #fff3f0; }
#lastDiscard { min-height: 50px; display: flex; gap: 4px; justify-content: center; align-items: center; }
#lastDiscard:empty { display: none; }

/* ---------- 操作栏 ---------- */
.action-bar {
  margin-top: 10px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
  min-height: 44px;
}
button {
  background: linear-gradient(#ffd76a, #e8b83a); border: none; border-radius: 8px;
  padding: 10px 22px; font-size: 15px; font-weight: 700; color: #4a3200;
  cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.4);
}
button:hover { filter: brightness(1.08); }
button.ghost { background: rgba(255,255,255,.12); color: #eee; }
button.danger { background: linear-gradient(#f88, #d33); color: #fff; }
button:disabled { opacity: .4; cursor: not-allowed; }
.claim-group { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal-box {
  background: #f5f0e0; color: #333; border-radius: 12px; padding: 24px 30px;
  min-width: 320px; max-width: 460px; box-shadow: 0 10px 40px rgba(0,0,0,.6);
}
.modal-box h3 { margin-bottom: 12px; color: #8b2c1e; }
#modalBody { font-size: 14px; line-height: 1.9; }
#modalBody table { width: 100%; border-collapse: collapse; }
#modalBody td, #modalBody th { padding: 4px 8px; border-bottom: 1px solid #ddd; text-align: center; }
.modal-actions { margin-top: 16px; text-align: center; }

@media (max-width: 760px) {
  :root { --tile-w: 34px; --tile-h: 48px; --tile-s: 20px; --tile-s-h: 28px; }
  #table { height: auto; min-height: 0; display: block; }
  .area-top { position: static; transform: none; padding: 6px; }
  .area-left, .area-right { position: static; transform: none; width: 50%; display: inline-block; vertical-align: top; padding: 4px; }
  .area-left { left: auto; } .area-right { right: auto; }
  .area-center { position: static; transform: none; margin: 8px auto; }
  .area-bottom { position: static; transform: none; width: 100%; padding-bottom: 20px; }
  .seat-grid { grid-template-columns: repeat(2, 1fr); }
}
