:root {
  --bg: #101019;
  --panel: #1c1c2a;
  --panel-2: #26263a;
  --line: #33334a;
  --text: #e9e9f2;
  --muted: #9292ad;
  --gold: #f2c14e;
  --green: #47c97e;
  --red: #e2607b;
  --blue: #5aa9e6;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 50% -10%, #23233a 0%, var(--bg) 60%);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

.hidden { display: none !important; }
.screen { min-height: 100vh; }

/* ---------------- 大厅 ---------------- */
#lobby { display: flex; align-items: center; justify-content: center; padding: 24px; }

.lobby-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px 26px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
}

.lobby-card h1 {
  margin: 0 0 6px;
  font-size: 26px;
  text-align: center;
  background: linear-gradient(90deg, var(--gold), #fff3c9, var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle { margin: 0 0 22px; text-align: center; color: var(--muted); font-size: 13px; }

.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

input {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 15px;
  outline: none;
}
input:focus { border-color: var(--gold); }

.btn {
  padding: 11px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  transition: .15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--gold); transform: translateY(-1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn.primary { background: linear-gradient(135deg, var(--gold), #d99e21); color: #241c00; border: none; font-weight: 700; }
.btn.wide { width: 100%; }
.btn.danger { background: #3a1f2a; border-color: var(--red); color: #ffd7e0; }

.divider { display: flex; align-items: center; gap: 10px; margin: 16px 0; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.join-row { display: flex; gap: 8px; }
.join-row input { flex: 1; text-transform: uppercase; letter-spacing: 3px; text-align: center; font-weight: 700; }

.msg { min-height: 20px; margin: 14px 0 0; font-size: 13px; color: var(--red); text-align: center; }

.rules { margin-top: 18px; font-size: 13px; color: var(--muted); }
.rules summary { cursor: pointer; color: var(--blue); }
.rules ul { margin: 10px 0 0; padding-left: 18px; line-height: 1.9; }
.rules b { color: var(--text); }

/* ---------------- 顶栏 ---------------- */
.topbar { display: flex; gap: 10px; justify-content: center; padding: 14px; flex-wrap: wrap; }
.pill {
  padding: 7px 14px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line);
  font-size: 13px; color: var(--muted);
}
.pill b { color: var(--gold); font-size: 14px; letter-spacing: 1px; }

/* ---------------- 棋盘 ---------------- */
.board {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
  padding: 0 14px 18px;
  max-width: 900px;
  margin: 0 auto;
  min-height: calc(100vh - 70px);
}

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.panel.me { background: linear-gradient(180deg, #1f2438, var(--panel)); }
.panel.opponent { background: linear-gradient(180deg, #2a1f28, var(--panel)); }

.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.pname { font-weight: 700; }
.badge { padding: 3px 10px; border-radius: 999px; font-size: 12px; background: var(--panel-2); border: 1px solid var(--line); }
.badge.emperor { color: #241c00; background: var(--gold); border-color: var(--gold); font-weight: 700; }
.badge.beggar { color: #1a0f2a; background: var(--blue); border-color: var(--blue); font-weight: 700; }
.chips { margin-left: auto; color: var(--green); font-weight: 700; }

/* ---------------- 手牌 ---------------- */
.hand { display: flex; gap: 8px; flex-wrap: wrap; min-height: 74px; align-items: center; }

.card {
  width: 62px; height: 88px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; user-select: none;
  border: 2px solid rgba(255, 255, 255, .12);
  box-shadow: 0 6px 16px rgba(0, 0, 0, .35);
  transition: .15s;
}
.card.emperor { background: linear-gradient(160deg, #f6d574, #c9962a); color: #2b1f00; }
.card.commoner { background: linear-gradient(160deg, #4a4f68, #33374a); color: #e6e9f5; }
.card.beggar { background: linear-gradient(160deg, #6d4bb5, #452e80); color: #f0e9ff; }

.card.clickable { cursor: pointer; }
.card.clickable:hover { transform: translateY(-8px); border-color: var(--gold); }
.card.selected { transform: translateY(-12px); border-color: var(--green); }
.card.disabled { opacity: .45; cursor: not-allowed; }

.back-hand .card { background: repeating-linear-gradient(45deg, #2c2c44, #2c2c44 6px, #34345a 6px, #34345a 12px); border-color: var(--line); color: transparent; }

.played { display: flex; gap: 8px; min-height: 10px; margin-top: 8px; align-items: center; color: var(--muted); font-size: 12px; }

/* ---------------- 中间区 ---------------- */
.center { display: flex; flex-direction: column; gap: 10px; }
.stake { text-align: center; font-size: 14px; color: var(--muted); padding: 10px; border-radius: 10px; background: var(--panel-2); }
.stake b { color: var(--gold); }

.duels { display: flex; flex-direction: column; gap: 6px; max-height: 130px; overflow-y: auto; }
.duel-row { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 7px 10px; background: var(--panel-2); border-radius: 8px; }
.duel-row .mini { padding: 2px 8px; border-radius: 6px; font-size: 12px; }
.mini.emperor { background: var(--gold); color: #2b1f00; }
.mini.commoner { background: #4a4f68; color: #e6e9f5; }
.mini.beggar { background: #6d4bb5; color: #f0e9ff; }
.duel-row .res { margin-left: auto; font-weight: 700; }
.res.win-e { color: var(--gold); }
.res.win-b { color: var(--blue); }
.res.tie { color: var(--muted); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; align-items: center; }
.actions input { width: 100px; text-align: center; }
.actions .hint { color: var(--muted); font-size: 13px; }

.log { max-height: 120px; overflow-y: auto; font-size: 12.5px; color: var(--muted); line-height: 1.8; border-top: 1px dashed var(--line); padding-top: 8px; }

/* ---------------- 提示 ---------------- */
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  padding: 11px 20px; border-radius: 10px;
  background: #3a1f2a; border: 1px solid var(--red); color: #ffd7e0;
  font-size: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}

