:root {
  --felt: #14532d;
  --felt-2: #0f3d22;
  --ink: #e8f5ec;
  --dim: #93b8a3;
  --gold: #f5c451;
  --danger: #ff6b6b;
  --line: rgba(255, 255, 255, 0.14);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font: 15px/1.5 "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 50% 35%, var(--felt) 0%, var(--felt-2) 70%, #08240f 100%);
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
}
.brand { font-size: 18px; font-weight: 700; letter-spacing: 1px; }
.brand .sub { font-size: 12px; font-weight: 400; color: var(--dim); margin-left: 6px; }
.right { display: flex; align-items: center; gap: 10px; }
.fp { font-family: ui-monospace, Consolas, monospace; font-size: 11px; color: var(--dim); }
.conn { font-size: 12px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); }
.conn.on { color: #9ae6b4; }
.conn.off { color: var(--danger); }

.scoreboard {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  max-width: 1080px;
  margin: 10px auto 0;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
  font-size: 13px;
}
.scoreboard .sb-main b { color: var(--gold); font-size: 15px; }
.scoreboard .sb-rounds { color: var(--dim); font-size: 12px; }
.scoreboard .sb-win { color: #9ae6b4; }

/* ★ 2026-10-09：420 太窄——加了【开新桌】之后"房间号 + 三个按钮"挤不下，会被迫换到第三行。
   加宽到 520 ⇒ 恢复两行（昵称/房间号一行，开新桌/入座/旁观一行），房间列表也跟着宽松些。 */
.lobby { max-width: 520px; margin: 48px auto; padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: rgba(0, 0, 0, 0.22); }
.lobby h2 { margin: 0 0 6px; font-size: 17px; }
.hint { color: var(--dim); font-size: 13px; margin: 0 0 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rooms { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
.rooms-head { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--dim); margin-bottom: 6px; }
button.mini { padding: 3px 9px; font-size: 12px; border-radius: 7px; }
.roomlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 180px; overflow-y: auto; }
.roomlist li { display: flex; align-items: center; gap: 10px; font-size: 13px; padding: 5px 8px; border-radius: 7px; background: rgba(255, 255, 255, 0.05); }
.roomlist li.empty { color: var(--dim); justify-content: center; background: none; }
.roomlist .rcode { font-family: ui-monospace, Consolas, monospace; font-weight: 700; color: var(--gold); }
.roomlist .rmeta { color: var(--dim); font-size: 12px; }
label { font-size: 13px; color: var(--dim); }
input {
  flex: 1 1 140px;
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  color: var(--ink);
  font-size: 15px;
}
button {
  padding: 8px 14px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
}
button:hover:not(:disabled) { background: rgba(255, 255, 255, 0.16); }
button:disabled { opacity: 0.35; cursor: not-allowed; }
button.primary { background: var(--gold); color: #2a1c00; border-color: transparent; font-weight: 700; }
button.primary:hover:not(:disabled) { background: #ffd873; }

.table {
  display: grid;
  grid-template-areas:
    "lu top ru"
    "ld center rd"
    "me me me";
  grid-template-columns: minmax(120px, 1fr) minmax(220px, 1.4fr) minmax(120px, 1fr);
  gap: 10px;
  max-width: 1080px;
  margin: 12px auto;
  padding: 0 12px 20px;
}
#slot-lu { grid-area: lu; }
#slot-top { grid-area: top; }
#slot-ru { grid-area: ru; }
#slot-ld { grid-area: ld; }
#slot-rd { grid-area: rd; }
.center { grid-area: center; }
.me { grid-area: me; }

.seat {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.22);
  min-height: 76px;
}
.seat.turn { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(245, 196, 81, 0.28); }
.seat.off { opacity: 0.5; }
.seat .name { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.seat .tag { font-size: 11px; padding: 1px 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.12); color: var(--dim); font-weight: 400; }
.seat .meta { font-size: 12px; color: var(--dim); margin-top: 4px; }
.seat .rankname { color: var(--gold); font-size: 12px; }

.center { border: 1px dashed var(--line); border-radius: 12px; padding: 12px; text-align: center; min-height: 120px; }
.turnline { font-size: 14px; margin-bottom: 8px; }
.turnline b { color: var(--gold); }
.lastplay { font-size: 15px; min-height: 24px; }
.lastplay .lbl { color: var(--dim); font-size: 12px; }
.tricklist { margin-top: 8px; font-size: 12px; color: var(--dim); display: flex; flex-direction: column; gap: 2px; }
.tribute { margin-top: 10px; font-size: 12px; color: var(--gold); border-top: 1px dashed var(--line); padding-top: 8px; }
.matchresult { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; font-size: 12px; color: var(--dim); }
.matchresult .mr-title { font-size: 14px; color: var(--gold); margin-bottom: 4px; }
.matchresult .mr-line { margin-top: 2px; }
.badge { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 999px; background: rgba(245, 196, 81, 0.18); color: var(--gold); margin-left: 6px; }
.badge.bomb { background: rgba(255, 107, 107, 0.22); color: #ff9b9b; }
.badge.hong { background: rgba(139, 122, 255, 0.24); color: #c3b8ff; }
.badge.burn { background: rgba(255, 152, 0, 0.22); color: #ffc46b; }

.meinfo { font-size: 13px; color: var(--dim); margin: 10px 0 6px; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.bombs { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; }
.bombs:empty { display: none; }
.bombrow {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px dashed #b7791f;
  border-radius: 9px;
  background: rgba(183, 121, 31, 0.12);
  width: fit-content;
}
.bomblabel { font-size: 12px; color: var(--gold); white-space: nowrap; }
.seat .put { font-size: 11px; color: var(--muted); margin-top: 2px; }
.seat .put b { color: var(--gold); }
.seat .put.pass { color: var(--muted); }
.seat .put.none { color: var(--muted); opacity: 0.6; }

/* ── 传统牌面 + 同点数重叠（老姚 2026-10-25）────────────────────────── */
/* 手牌：同点数一组，组内每张往左压一半；不同点数之间额外空一点 */
.hand .card { margin-left: -23px; }
.hand .card.grp-start { margin-left: 12px; }
.hand .card:first-child { margin-left: 0; }
.hand .card:hover { z-index: 5; }
.hand .card.sel { z-index: 6; }

/* 出过的牌：各自面前一小堆（只画点数+花色） */
.putcards { display: flex; margin-top: 3px; }
.minicard {
  position: relative;
  width: 26px;
  height: 36px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #fbfbf7;
  color: #111;
  font-weight: 700;
  flex: none;
  margin-left: -11px;
}
.minicard:first-child { margin-left: 0; }
.minicard .r { position: absolute; top: 1px; left: 2px; font-size: 11px; line-height: 1; }
.minicard .s { position: absolute; top: 12px; left: 2px; font-size: 10px; line-height: 1; }
.minicard.red { color: #c02626; }
.minicard.joker .r { font-size: 9px; }
.tricklist .tl-play { color: var(--text); }
.tricklist .tl-pass { color: var(--muted); }
.hand { display: flex; flex-wrap: wrap; gap: 4px; min-height: 74px; align-items: flex-end; }
.card {
  position: relative;
  width: 46px;
  height: 66px;
  padding: 0;
  border-radius: 7px;
  border: 1px solid #cbd5e1;
  background: #fbfbf7;
  color: #111;
  font-weight: 700;
  transition: transform 0.08s ease;
}
/* 传统牌面：点数在上、花色在下，整体贴在**左上角** */
.card .corner {
  position: absolute;
  top: 3px;
  left: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.05;
}
.card .r { font-size: 15px; line-height: 1.05; }
.card .s { font-size: 13px; line-height: 1; }
.card.red { color: #c02626; }
.card.joker .r { font-size: 12px; }
.card.sel { transform: translateY(-10px); border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
.card:hover { transform: translateY(-6px); }
.card.sel:hover { transform: translateY(-12px); }

.actions { margin-top: 12px; display: flex; gap: 10px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  max-width: 90vw;
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(180, 30, 30, 0.94);
  color: #fff;
  font-size: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

/* ── 待决策（要不要革命 / 叫上班 / 同邦贡）────────────────────────── */
.decide {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--gold);
  border-radius: 10px;
  background: rgba(255, 216, 115, 0.12);
  text-align: center;
}
.decide.wait { border-color: var(--line); background: rgba(255, 255, 255, 0.05); color: var(--muted); }
.decide-q { font-weight: 700; margin-bottom: 6px; }
.decide-btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.decide-btn { min-width: 96px; }
.decide-btn.is-default { border-color: var(--gold); }
.decide-hint { margin-top: 6px; font-size: 12px; color: var(--muted); }

/* ── 旁观 / 让位（老姚 2026-10-25）────────────────────────────────── */
.roomlist li { cursor: pointer; }
.roomlist li:hover { background: rgba(255, 255, 255, 0.08); }
/* ★ 2026-10-09：进不去的桌（已开局 / 人满）**不能**画成可点——老姚就是点了这种"6/6 已开局"，
   被拒之后观感等于"不能建房间"。置灰 + 禁点，鼠标也不给"能点"的暗示。 */
.roomlist li.dead { cursor: not-allowed; opacity: 0.42; }
.roomlist li.dead:hover { background: none; }
.roomlist li.dead .rmeta:last-child { color: #e79d84; }
.watchbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }
.watchbar .wb-label { font-size: 12px; color: var(--muted); }
.watchbar .mini.on { border-color: var(--gold); color: var(--gold); }
.watchbar .mini.take { border-color: #7dd3fc; color: #7dd3fc; }
.seat .tag.yield { border-color: #7dd3fc; color: #7dd3fc; }
.seat .tag.burn { border-color: #fb923c; color: #fb923c; }
.seat .tag.burnfail { border-color: #f87171; color: #f87171; }

/* ── 出炸 / 出轰的震动 + 烟火（老姚 2026-10-25）──────────────────────── */
@keyframes gk-shake {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  10% { transform: translate(-6px, 2px) rotate(-0.5deg); }
  25% { transform: translate(5px, -3px) rotate(0.6deg); }
  40% { transform: translate(-4px, 3px) rotate(-0.4deg); }
  55% { transform: translate(4px, -2px) rotate(0.4deg); }
  70% { transform: translate(-3px, 1px) rotate(-0.2deg); }
  85% { transform: translate(2px, -1px) rotate(0.2deg); }
}
.table.shake { animation: gk-shake 520ms ease-in-out; }
.table.shake-hard { animation: gk-shake 760ms ease-in-out; }

.fx {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none; /* 别挡住点牌 */
  z-index: 50;
}
.fxlabel {
  position: fixed;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  font-size: 64px;
  font-weight: 900;
  letter-spacing: 4px;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(0, 0, 0, 0.65), 0 2px 6px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  z-index: 51;
}

/* H5 自适应（老姚 2026-10-25：要做成上云的 H5 自适应页面）────────────────
   手机上竖屏也要能打：桌子三列压窄、牌变小、按钮变大好点。
   桌面（≥641px）不受影响。 */
@media (max-width: 640px) {
  body { font-size: 14px; }
  .table {
    grid-template-columns: minmax(70px, 1fr) minmax(112px, 1.25fr) minmax(70px, 1fr);
    gap: 5px;
    padding: 0 6px 14px;
    margin: 6px auto;
  }
  .seat { padding: 5px 6px; border-radius: 9px; }
  .seat .name { font-size: 12px; }
  .seat .meta, .seat .put, .seat .rankname { font-size: 10px; }
  .card { width: 30px; height: 44px; padding: 0; border-radius: 5px; }
  .card .corner { top: 2px; left: 3px; }
  .card .r { font-size: 12px; }
  .card .s { font-size: 10px; }
  .card.joker .r { font-size: 9px; }
  .card.sel { transform: translateY(-6px); }
  .hand { gap: 0; min-height: 50px; }
  .hand .card { margin-left: -15px; }
  .hand .card.grp-start { margin-left: 7px; }
  .minicard { width: 20px; height: 28px; margin-left: -9px; }
  .minicard .r { font-size: 9px; }
  .minicard .s { font-size: 8px; top: 10px; }
  .bombs { gap: 3px; }
  #bombs .bombrow { padding: 3px 5px; gap: 3px; }
  .bomblabel { font-size: 10px; }
  .tricklist { font-size: 11px; }
  .center { padding: 6px; }
  .actions { gap: 6px; }
  .actions button { padding: 9px 12px; font-size: 14px; }
  #scoreboard, .roombar { font-size: 11px; }
  .toast { bottom: 12px; font-size: 13px; }
  /* 手机上牌多时**横向滚动**（老姚 2026-10-25），不要挤成好几行 */
  .hand {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    padding-top: 12px; /* 给"选中的牌往上抬"留空间 */
    -webkit-overflow-scrolling: touch;
  }
  .tricklist { max-height: 88px; overflow-y: auto; }
}

/* 横屏手机（矮）⇒ 再压一压，别让手牌把桌面挤没 */
@media (max-height: 520px) and (orientation: landscape) {
  .table { gap: 4px; margin: 4px auto; }
  .seat { padding: 4px 6px; }
  .seat .meta, .seat .put, .seat .rankname { font-size: 10px; }
  .card { width: 26px; height: 38px; }
  .card .r { font-size: 11px; }
  .card .s { font-size: 9px; }
  .hand { min-height: 40px; padding-top: 10px; }
  .hand .card { margin-left: -13px; }
  .tricklist { max-height: 56px; overflow-y: auto; }
  .center { font-size: 12px; }
}
