/* 桌球牌局发牌器 · 移动端样式 */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #0e1420;
  --panel: #182334;
  --card: #f5f2e8;
  --ink: #1c2733;
  --accent: #e8a13a;
  --accent-dark: #c9851f;
  --good: #3ecf8e;
  --muted: #8b9bb4;
  --line: #263650;
  --danger: #e06666;
}

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #1b2a45 0%, var(--bg) 60%);
  color: #e8edf5;
  min-height: 100dvh;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.85em; font-weight: normal; }

/* ---------- 视图切换（单页） ---------- */
.view { display: none; }
#view-lobby { align-items: center; justify-content: center; padding: 20px; min-height: 100dvh; }
#view-lobby.active { display: flex; }
#view-game.active { display: block; padding-bottom: 120px; }

/* ---------- 大厅页 ---------- */
.page-lobby { display: none; }

.panel {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 26px 22px;
  box-shadow: 0 18px 50px rgba(0,0,0,.45);
}

.logo { font-size: 34px; text-align: center; letter-spacing: 1px; }
.subtitle { text-align: center; color: var(--muted); font-size: 13px; margin: 6px 0 22px; }

.section { margin-top: 18px; }
.section h2 { font-size: 15px; margin-bottom: 10px; color: #cfe0f5; }

.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input,
.field select {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0f1826;
  color: #fff;
  outline: none;
}
.field select option { background: #0f1826; color: #fff; }
.field input:focus, .field select:focus { border-color: var(--accent); }

/* 创建房间：Joker 开关（勾选=54 张含大小王，默认 52 张） */
.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
}
.checkbox-field input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin: 0;
  padding: 0;
  border: none;
  accent-color: var(--accent);
}
.checkbox-field span {
  display: inline;
  margin: 0;
  font-size: 14px;
}

.btn {
  width: 100%;
  padding: 13px;
  font-size: 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #223049;
  color: #e8edf5;
  cursor: pointer;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-dark)); border: none; color: #201503; font-weight: 700; }
.btn.danger { background: rgba(224,102,102,.15); border: 1px solid rgba(224,102,102,.55); color: #ffb3b3; }
.btn.small { width: auto; padding: 8px 14px; font-size: 14px; }
.btn:disabled { opacity: .45; }

.divider { text-align: center; color: var(--muted); margin: 20px 0 4px; font-size: 13px; }

.hint { font-size: 12px; color: var(--muted); margin-top: 8px; text-align: center; }
.hint-inline { display: block; font-style: normal; font-size: 11px; color: var(--muted); margin-top: 4px; }

.err {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 30;
  max-width: min(86vw, 420px);
  padding: 14px 18px;
  background: rgba(20,26,40,.96);
  border: 1px solid rgba(224,102,102,.6);
  color: #ffb3b3;
  border-radius: 12px;
  font-size: 14px;
  text-align: center;
  line-height: 1.5;
  box-shadow: 0 10px 34px rgba(0,0,0,.5);
  animation: err-pop .25s ease;
}
@keyframes err-pop {
  from { opacity: 0; transform: translate(-50%, -50%) scale(.92); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ---------- 游戏页 ---------- */
.page-game { display: none; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  background: rgba(14,20,32,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.room-badge { display: flex; align-items: baseline; gap: 8px; }
.room-label { font-size: 12px; color: var(--muted); }
.room-no { font-size: 22px; font-weight: 800; letter-spacing: 3px; color: var(--accent); }
.status { font-size: 12px; padding: 4px 10px; border-radius: 999px; }
.status.waiting { background: rgba(139,155,180,.15); color: var(--muted); }
.status.playing { background: rgba(62,207,142,.15); color: var(--good); }

.players-card, .hand-card {
  margin: 14px 14px 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}
.players-card h2, .hand-card h2 { font-size: 14px; margin-bottom: 10px; color: #cfe0f5; }

.player-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.player-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px;
  background: #0f1826;
  border-radius: 10px;
  font-size: 14px;
}
.player-item .me { color: var(--accent); }
.player-item .offline { color: var(--muted); text-decoration: line-through; }
.player-item .offline-badge { font-size: 11px; background: rgba(255,255,255,.08); color: var(--muted); padding: 2px 7px; border-radius: 999px; }
.player-item .owner-badge { font-size: 11px; background: rgba(232,161,58,.18); color: var(--accent); padding: 2px 7px; border-radius: 999px; }
.player-item .progress { color: var(--muted); font-size: 12px; }
.burst-badge {
  font-size: 11px;
  background: rgba(224,102,102,.2);
  color: #ff9b9b;
  border: 1px solid rgba(224,102,102,.6);
  padding: 2px 7px;
  border-radius: 999px;
  animation: pulse 1.2s infinite;
}
@keyframes pulse { 50% { opacity: .45; } }

.mode-switch { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.mode-switch input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.mode-switch select {
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0f1826;
  color: #fff;
  outline: none;
}
.mode-switch select option { background: #0f1826; }

.hand-head { display: flex; justify-content: space-between; align-items: baseline; }

.hand { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.empty-tip { grid-column: 1 / -1; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.8; padding: 20px 0; }

/* ---------- 底牌揭示 ---------- */
.reveal-card {
  margin: 14px 14px 0;
  background: var(--panel);
  border: 1px solid rgba(62,207,142,.35);
  border-radius: 14px;
  padding: 14px;
}
.reveal-player { margin-bottom: 14px; }
.reveal-player:last-child { margin-bottom: 0; }
.reveal-name { font-size: 13px; color: #cfe0f5; margin-bottom: 8px; font-weight: 600; }
.reveal-cards { grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 8px; }

.card.mini { aspect-ratio: 3/4; border-radius: 7px; cursor: default; }
.card.mini .card-rank {
  font-size: 14px;
  height: 16px;              /* 与普通卡同样式：统一高度 + 居中 */
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
.card.mini .card-rank.joker { font-size: 9px; letter-spacing: 0; }
.card.mini .card-suit {
  font-size: 11px;
  height: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.card.mini .card-ball { margin-top: 4px; width: 20px; height: 20px; font-size: 10px; }

.card {
  position: relative;
  aspect-ratio: 3/4.2;
  background: var(--card);
  color: var(--ink);
  border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 4px 10px rgba(0,0,0,.35);
  transition: transform .12s;
}
.card:active { transform: scale(.95); }
.card .card-rank {
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
  height: 28px;              /* 统一高度：普通牌与 Joker 一致 */
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;       /* Joker 不换行，防止撑高卡片 */
  max-width: 100%;
}
.card .card-rank.joker { font-size: 15px; letter-spacing: .5px; }
.card .card-suit {
  font-size: 16px;
  line-height: 1;
  height: 18px;              /* 统一高度：花色符号与 🃏 一致 */
  display: flex;
  align-items: center;
  justify-content: center;
}
.card .card-ball {
  margin-top: 8px;
  width: 30px; height: 30px; border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #fff8e8, #c9851f 55%, #8a5a12);
  color: #fff; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 -2px 3px rgba(0,0,0,.35), 0 2px 4px rgba(0,0,0,.3);
}
.card.red { color: #c22b2b; }
.card.played {
  background: #2a3548;
  color: var(--muted);
  cursor: default;
  box-shadow: none;
  opacity: .55;
}
.card.played .card-suit,
.card.played .card-rank { text-decoration: line-through; }
.card.played .card-ball { background: #3a4667; box-shadow: none; }

.actions {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; gap: 10px;
  padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
  background: rgba(14,20,32,.94);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}
.actions .btn { flex: 1; }

.room-toast {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%);
  background: #0f1826; border: 1px solid var(--accent);
  color: var(--accent);
  padding: 10px 18px; border-radius: 999px; font-size: 14px;
  z-index: 20;
  animation: pop .3s ease;
}
@keyframes pop { from { opacity: 0; transform: translateX(-50%) translateY(-8px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
