:root {
  --felt: #14532d;
  --felt-deep: #0b3b22;
  --ink: #14201a;
  --paper: #f6efe2;
  --gold: #e8c872;
  --gold-dim: #b0892e;
  --danger: #c23a4b;
  --ok: #1f8a4c;
  --line: rgba(255, 255, 255, 0.16);
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Source Han Sans SC", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--paper);
  background:
    radial-gradient(1200px 600px at 50% -10%, #1c7a46 0%, transparent 55%),
    linear-gradient(180deg, #0c291c, #07160f 70%);
}

button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.lobby {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.lobby-card {
  width: min(440px, 100%);
  background: rgba(10, 28, 20, 0.82);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px 24px 22px;
  box-shadow: var(--shadow);
}
.lobby-card h1 {
  margin: 0 0 6px;
  font-size: 28px;
  letter-spacing: 0.08em;
}
.lobby-card p { margin: 0 0 18px; color: #d7c8a4; line-height: 1.55; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 13px; color: #d7c8a4; }
.field input {
  border: 1px solid var(--line);
  background: #10261b;
  color: var(--paper);
  border-radius: 10px;
  padding: 10px 12px;
}
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--gold);
  color: #2a1c00;
  font-weight: 700;
}
.btn.ghost {
  background: transparent;
  color: var(--paper);
  border: 1px solid var(--line);
}
.btn.danger { background: var(--danger); color: white; }
.btn.ok { background: #2f9e62; color: white; }
.btn.small { padding: 7px 10px; font-size: 13px; }

.table-app {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}
.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.28);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; letter-spacing: 0.12em; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 13px; color: #e8d9b0; }
.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
  background: rgba(255,255,255,0.04);
}
.pill.hot { border-color: var(--gold-dim); color: var(--gold); }

.board {
  display: grid;
  grid-template-columns: 1fr minmax(200px, 260px);
  gap: 10px;
  padding: 10px;
  min-height: 0;
  overflow: hidden;
}
@media (max-width: 860px) {
  .board { grid-template-columns: 1fr; }
}

.felt {
  position: relative;
  min-height: 0;
  background:
    radial-gradient(circle at 50% 40%, #1b7a46, var(--felt-deep) 72%);
  border: 2px solid #c9a22755;
  border-radius: 22px;
  overflow: hidden;
}
.seat {
  position: absolute;
  min-width: 140px;
  text-align: center;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(0,0,0,0.28);
  border: 1px solid transparent;
}
.seat.turn { border-color: var(--gold); box-shadow: 0 0 0 2px #e8c87255; }
.seat.empty { opacity: 0.7; }
.seat .who { font-weight: 700; }
.seat .sub { font-size: 12px; color: #d7c8a4; }
.n { top: 10px; left: 50%; transform: translateX(-50%); }
.e { right: 10px; top: 50%; transform: translateY(-50%); }
.s { bottom: 10px; left: 50%; transform: translateX(-50%); }
.w { left: 10px; top: 50%; transform: translateY(-50%); }

.center {
  position: absolute;
  inset: 64px 72px 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  overflow: auto;
}
.center h2 { margin: 0; font-size: 20px; }
.center .hint { color: #e8d9b0; font-size: 14px; line-height: 1.5; max-width: 36ch; }
.trick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.pause {
  background: #7a1c1cdd;
  color: white;
  padding: 8px 12px;
  border-radius: 8px;
}

.side {
  background: rgba(0,0,0,0.28);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow: hidden;
}
.log {
  flex: 1;
  overflow: auto;
  font-size: 12px;
  line-height: 1.45;
  color: #e6d7b2;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.log div { border-bottom: 1px solid rgba(255,255,255,0.05); padding-bottom: 4px; }

.dock {
  padding: 8px 12px 12px;
  background: rgba(0,0,0,0.42);
  border-top: 1px solid var(--line);
  max-height: 36vh;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.hand {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 3px;
  overflow: auto;
  min-height: 0;
  max-height: 22vh;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 8px;
}
.status {
  text-align: center;
  font-size: 13px;
  color: #ead9ad;
  margin-bottom: 6px;
  min-height: 1.3em;
}
.err {
  text-align: center;
  color: #ffb4b8;
  min-height: 1.2em;
  font-size: 13px;
}

.card {
  width: 44px;
  height: 62px;
  border-radius: 8px;
  background: #fffdf6;
  color: #1b1b1b;
  border: 1px solid #c9b48a;
  box-shadow: 0 3px 0 #0002;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  user-select: none;
  position: relative;
  transition: transform .12s ease, box-shadow .12s ease;
}
.card .rk { font-weight: 800; font-size: 16px; line-height: 1; }
.card .st { font-size: 18px; }
.card.red { color: #c0162a; }
.card.joker { background: #22170d; color: var(--gold); border-color: #8a6a2a; }
.card.legal { box-shadow: 0 0 0 2px #49d27c, 0 3px 0 #0002; }
.card.sel {
  transform: translateY(-10px);
  box-shadow: 0 0 0 2px #e8c872, 0 8px 12px #0004;
}
.card.mini { width: 40px; height: 56px; }
.card.mini .rk { font-size: 13px; }
.card.mini .st { font-size: 14px; }
.card.back {
  background: repeating-linear-gradient(45deg, #6b1d27, #6b1d27 6px, #8a2431 6px, #8a2431 12px);
  color: transparent;
}

.spectate-note {
  text-align: center;
  color: #e8d9b0;
  padding: 16px;
}

.seats-pick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: #111c;
  border: 1px solid var(--line);
  padding: 8px 12px;
  border-radius: 8px;
}

@keyframes deal-in {
  from { transform: translateY(18px) scale(0.92); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.card.deal-in {
  animation: deal-in 0.28s ease-out;
}


/* —— 体验：牌桌常驻状态 —— */
.table-hud {
  position: absolute;
  top: 10px;
  left: 12px;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: min(420px, 55%);
  pointer-events: none;
}
.hud-item {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(232, 200, 114, 0.35);
  font-size: 12px;
  line-height: 1.3;
}
.hud-k { color: #cbb98a; }
.hud-v { color: #fff6d8; font-weight: 700; }
.hud-v.hot { color: var(--gold); }

/* 发牌进度：不挡操作（pointer-events:none） */
.deal-progress {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: min(280px, 46%);
  z-index: 2;
  pointer-events: none;
  text-align: center;
}
.deal-progress-track {
  height: 6px;
  border-radius: 99px;
  background: rgba(0,0,0,0.35);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.12);
}
.deal-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #c9a227, #e8c872);
  transition: width 0.08s linear;
}
.deal-progress-label {
  margin-top: 4px;
  font-size: 11px;
  color: #e8d9b0;
  text-shadow: 0 1px 2px #0008;
}

.your-turn-banner {
  background: linear-gradient(90deg, #b0892e, #e8c872, #b0892e);
  color: #2a1c00;
  font-weight: 800;
  padding: 6px 14px;
  border-radius: 999px;
  letter-spacing: 0.06em;
  animation: your-turn-pulse 1.2s ease-in-out infinite;
}
@keyframes your-turn-pulse {
  0%, 100% { box-shadow: 0 0 0 0 #e8c87266; }
  50% { box-shadow: 0 0 0 6px #e8c87222; }
}

.status.your-turn {
  color: #ffe08a;
  font-weight: 700;
  font-size: 14px;
}

.dock-soft {
  font-size: 12px;
  color: #cbb98a;
  align-self: center;
}

/* 合法 / 非法出牌 */
.card.illegal {
  opacity: 0.38;
  filter: grayscale(0.55);
  transform: none;
  box-shadow: none;
  cursor: not-allowed;
}
.card.legal {
  box-shadow: 0 0 0 2px #49d27c, 0 3px 0 #0002;
}
.card.declare-cand {
  box-shadow: 0 0 0 2px #e8c872, 0 3px 0 #0002;
}
.card.declare-focus {
  transform: translateY(-8px);
  box-shadow: 0 0 0 3px #ffd56a, 0 8px 14px #0005;
  z-index: 1;
}
.btn.declare {
  box-shadow: 0 0 0 1px #e8c87288;
}

/* 主牌高亮 */
.card.trump {
  background: linear-gradient(180deg, #fff8e8, #f3e0a8);
  border-color: #c9a227;
  box-shadow: 0 0 0 1px #c9a22766, 0 3px 0 #0002;
}
.card.trump.joker {
  background: #22170d;
  border-color: #e8c872;
}

/* 手牌图例 */
.card-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  justify-content: center;
  align-items: center;
  margin-bottom: 6px;
  font-size: 12px;
  color: #e8d9b0;
}
.card-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.card-legend .lg {
  display: inline-block;
  width: 14px;
  height: 18px;
  border-radius: 3px;
  border: 1px solid #c9b48a;
  background: #fffdf6;
  box-sizing: border-box;
}
.card-legend .lg.sel {
  transform: translateY(-2px);
  box-shadow: 0 0 0 2px #e8c872;
}
.card-legend .lg.legal {
  box-shadow: 0 0 0 2px #49d27c;
}
.card-legend .lg.trump {
  background: linear-gradient(180deg, #fff8e8, #f3e0a8);
  border-color: #c9a227;
}
.card-legend .lg.illegal {
  opacity: 0.38;
  filter: grayscale(0.55);
}
