* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --green: #1b5e43;
  --green-dark: #124232;
  --felt: #1e6b4e;
  --gold: #e8b84b;
  --bg: #0f1a16;
  --card-bg: #fdfcf8;
  --text: #e8f0ec;
  --muted: #8ba99b;
  --red: #d94a3d;
  --danger: #e05a4f;
}
html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Noto Sans CJK SC", sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
#app { height: 100%; position: relative; }
.view { display: none; height: 100%; flex-direction: column; }
.view.active { display: flex; }

/* 登录 */
#view-login { align-items: center; justify-content: center; padding: 24px; }
.login-box { width: 100%; max-width: 340px; }
.login-box h1 { font-size: 28px; letter-spacing: 1px; text-align: center; color: var(--gold); }
.login-box .sub { text-align: center; color: var(--muted); font-size: 13px; margin: 6px 0 22px; }
.login-box input {
  width: 100%; padding: 13px 14px; margin-bottom: 11px;
  background: #18261f; border: 1px solid #2a4034; border-radius: 10px;
  color: var(--text); font-size: 15px; outline: none;
}
.login-box input:focus { border-color: var(--green); }
button { cursor: pointer; font-family: inherit; border: none; border-radius: 10px; font-size: 15px; }
button.primary { background: var(--green); color: #fff; padding: 13px; width: 100%; font-weight: 600; }
button.primary:active { background: var(--green-dark); }
button.ghost { background: transparent; border: 1px solid #2f4a3c; color: var(--text); padding: 9px 14px; }
button.small { font-size: 13px; padding: 6px 11px; }
button.big { padding: 15px; font-size: 16px; }
.error { color: var(--danger); font-size: 13px; margin-top: 9px; text-align: center; min-height: 18px; }

.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tabs .tab {
  flex: 1; padding: 9px; background: #18261f; color: var(--muted);
  border-radius: 8px; font-size: 14px;
}
.tabs .tab.active { background: var(--green); color: #fff; }

/* 大厅 */
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  background: #13201a; border-bottom: 1px solid #1f2f27; flex-shrink: 0;
}
.brand { font-weight: 700; color: var(--gold); font-size: 15px; }
.user { margin-left: auto; color: var(--muted); font-size: 13px; }
.status { margin-left: auto; color: var(--muted); font-size: 12px; }
.lobby-body { flex: 1; overflow-y: auto; padding: 14px 16px 30px; }
.lobby-actions { display: flex; gap: 9px; margin-bottom: 14px; }
.lobby-actions .primary { flex: 2; }
.lobby-actions .ghost { flex: 1; }
.panel { display: none; }
.panel.active { display: block; }

.room-list { display: flex; flex-direction: column; gap: 9px; }
.room-item {
  background: #17251f; border: 1px solid #24382d; border-radius: 11px;
  padding: 13px 15px; display: flex; align-items: center; gap: 10px;
}
.room-item .info { flex: 1; }
.room-item .title { font-size: 15px; font-weight: 600; }
.room-item .meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.room-item button { background: var(--green); color: #fff; padding: 8px 15px; font-size: 13px; border-radius: 8px; }
.empty { color: var(--muted); font-size: 14px; text-align: center; padding: 40px 20px; }

.rank-list .rank-item, .match-item {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  background: #17251f; border-radius: 10px; margin-bottom: 8px; font-size: 14px;
}
.rank-item .idx { width: 26px; color: var(--muted); font-weight: 700; }
.rank-item .idx.top1 { color: var(--gold); }
.rank-item .nm { flex: 1; }
.rank-item .sc { color: var(--gold); font-weight: 600; }
.match-item { cursor: pointer; }
.match-item .grow { flex: 1; }
.match-item .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* 牌桌 */
#view-table { background: radial-gradient(circle at 50% 40%, #22654a, #0e1f18 75%); }
.table-wrap { flex: 1; position: relative; min-height: 0; }
.seats { position: absolute; inset: 0; }
.seat { position: absolute; text-align: center; width: 88px; }
.seat .avatar {
  width: 44px; height: 44px; border-radius: 50%; background: #2a4034;
  margin: 0 auto 5px; display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--gold); border: 2px solid transparent;
}
.seat.active .avatar { border-color: var(--gold); box-shadow: 0 0 12px rgba(232,184,75,.6); }
.seat .pname { font-size: 12px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat .pcount { font-size: 11px; color: var(--muted); margin-top: 2px; }
.seat-north { top: 12px; left: 50%; transform: translateX(-50%); }
.seat-south { bottom: 8px; left: 50%; transform: translateX(-50%); }
.seat-west { left: 12px; top: 50%; transform: translateY(-50%); }
.seat-east { right: 12px; top: 50%; transform: translateY(-50%); }

.center { position: absolute; inset: 90px 100px; display: flex; align-items: center; justify-content: center; }
.last-play { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; max-width: 100%; }
.last-play .label { width: 100%; text-align: center; font-size: 12px; color: var(--gold); margin-bottom: 6px; }

/* 牌 */
.card {
  width: 38px; height: 54px; background: var(--card-bg); border-radius: 5px;
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #1a1a1a; position: relative;
  box-shadow: 0 1px 3px rgba(0,0,0,.35); user-select: none; flex-shrink: 0;
}
.card.red { color: #c0392b; }
.card.joker { font-size: 10px; }
.card .suit { font-size: 15px; line-height: 1; }
.card.selected { transform: translateY(-12px); box-shadow: 0 0 0 2px var(--gold); }

.myhand {
  display: flex; flex-wrap: wrap; gap: 3px; padding: 10px 12px 6px;
  justify-content: center; flex-shrink: 0; max-height: 30vh; overflow-y: auto;
  background: rgba(0,0,0,.18);
}
.actions-row { display: flex; gap: 9px; padding: 8px 14px 16px; flex-shrink: 0; }
.actions-row button { flex: 1; padding: 12px; }
.actions-row .primary { flex: 2; }
.actions-row button:disabled { opacity: .4; }

/* 分析面板 */
.analysis {
  background: rgba(0,0,0,.3); border-top: 1px solid #1f2f27; flex-shrink: 0;
  padding: 9px 14px; max-height: 20vh; overflow-y: auto;
}
.analysis-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.analysis-head span { font-size: 13px; color: var(--gold); font-weight: 600; }
.analysis-body { font-size: 12.5px; color: #b9cec4; line-height: 1.6; }
.analysis-body .tag { color: var(--gold); font-weight: 600; }

/* 复盘 */
.replay-body { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.replay-controls {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  border-bottom: 1px solid #1f2f27; flex-shrink: 0;
}
.replay-controls button { flex: 1; }
#replay-progress { font-size: 13px; color: var(--muted); min-width: 70px; text-align: center; }
.replay-feed { flex: 1; overflow-y: auto; padding: 12px 16px 30px; font-size: 13.5px; }
.replay-line { padding: 7px 0; border-bottom: 1px solid #1a2a22; color: #b9cec4; }
.replay-line .seatname { color: var(--gold); font-weight: 600; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px);
  background: rgba(20,32,26,.97); border: 1px solid #33513f; color: var(--text);
  padding: 11px 20px; border-radius: 22px; font-size: 13.5px; opacity: 0;
  transition: all .22s; pointer-events: none; z-index: 99; max-width: 84vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
