:root {
  --bg: #0f172a;
  --panel: #14532d;
  --panel-2: #166534;
  --accent: #f59e0b;
  --text: #f8fafc;
  --muted: #94a3b8;
  --card-w: 34px;
  --card-h: 48px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(120% 100% at 50% 0%, #1e3a2f 0%, var(--bg) 70%);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  overscroll-behavior: none;
}

.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 16px;
}

.hidden { display: none !important; }

/* ---------- 加入屏 ---------- */
#join-screen { align-items: center; justify-content: center; gap: 12px; text-align: center; }
#join-screen h1 { margin: 0 0 4px; font-size: 30px; }
.subtitle { color: var(--muted); margin: 0 0 16px; }
input {
  width: 100%; max-width: 320px;
  padding: 12px 14px; border: 1px solid #334155; border-radius: 10px;
  background: #1e293b; color: var(--text); font-size: 16px; outline: none;
}
input:focus { border-color: var(--accent); }
.btn-row { display: flex; gap: 10px; margin-top: 4px; }
.btn {
  padding: 12px 18px; border: 1px solid #334155; border-radius: 10px;
  background: #1e293b; color: var(--text); font-size: 16px; cursor: pointer;
  user-select: none;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1f2937; font-weight: 600; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn:active { transform: scale(0.97); }
.hint { color: var(--muted); font-size: 13px; min-height: 18px; }

/* ---------- 游戏屏 ---------- */
#game-screen { min-height: 100vh; }

.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
#room-label { font-weight: 600; font-size: 15px; }

.others { display: flex; justify-content: space-between; gap: 10px; }
.player {
  flex: 1; background: rgba(30, 41, 59, 0.7); border-radius: 12px;
  padding: 10px; text-align: center; min-height: 70px; font-size: 13px; color: var(--muted);
}
.player .p-name { font-weight: 600; color: var(--text); font-size: 14px; }
.player.active { outline: 2px solid var(--accent); }
.player .tag { color: var(--accent); font-size: 12px; }

.table {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 10px; min-height: 180px;
}
.bottom-cards, .last-play { display: flex; gap: 6px; min-height: calc(var(--card-h) + 4px); }
.bottom-cards .lbl { align-self: center; color: var(--muted); font-size: 13px; margin-right: 4px; }
.status-line { color: var(--muted); font-size: 14px; min-height: 20px; }

/* ---------- 手牌 ---------- */
.me { padding-bottom: 8px; }
.my-info { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.my-info .tag { color: var(--accent); }
.hand { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; min-height: var(--card-h); }

.card {
  width: var(--card-w); height: var(--card-h); border-radius: 6px;
  background: #f8fafc; color: #0f172a; display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-weight: 700; font-size: 15px;
  position: relative; cursor: pointer; transition: transform 0.08s, box-shadow 0.08s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.4); user-select: none; line-height: 1;
}
.card .suit { font-size: 12px; }
.card.red { color: #dc2626; }
.card.selected { transform: translateY(-10px); box-shadow: 0 0 0 2px var(--accent); }
.card.face-down { background: #334155; color: transparent; }
.card.face-down .suit { color: transparent; }

.actions { display: flex; gap: 10px; justify-content: center; margin-top: 10px; min-height: 48px; }

/* ---------- 切换游戏链接 ---------- */
.switch-link {
  margin-top: 12px; color: var(--muted); font-size: 14px; text-decoration: none;
}
.switch-link:active { color: var(--accent); }

/* ---------- 够级六人桌 ---------- */
#table {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1.6fr 1fr;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "s2 s3 s4"
    "s1 center s5"
    "me  me    me";
  gap: 8px;
  min-height: 360px;
}
.seat {
  background: rgba(30, 41, 59, 0.7); border-radius: 10px;
  padding: 8px; text-align: center; font-size: 12px; color: var(--muted);
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 2px;
  min-height: 58px;
}
.seat .p-name { font-weight: 600; color: var(--text); font-size: 13px; }
.seat .p-sub { font-size: 12px; }
.seat.active { outline: 2px solid var(--accent); }
.seat.duitou { outline: 1px solid #f87171; }
.seat[data-rel="2"] { grid-area: s2; }
.seat[data-rel="3"] { grid-area: s3; }
.seat[data-rel="4"] { grid-area: s4; }
.seat[data-rel="1"] { grid-area: s1; }
.seat[data-rel="5"] { grid-area: s5; }
.seat[data-rel="0"] { grid-area: me; }

.tag { color: var(--accent); font-size: 11px; font-weight: 600; }
.tag.ally { color: #4ade80; }
.tag.foe { color: #f87171; }
.tag.turn { color: var(--accent); }
.tag.duitou-tag { color: #f87171; }
.tag.gouji-tag { color: #fbbf24; }

#center {
  grid-area: center; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
}
.last-play { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; justify-content: center; min-height: calc(var(--card-h) + 4px); }
.last-play .lbl { color: var(--muted); font-size: 12px; margin-right: 2px; }
.last-play .card { width: 26px; height: 38px; font-size: 12px; }
.last-play .card .suit { font-size: 10px; }
.status-line { color: var(--muted); font-size: 13px; min-height: 20px; text-align: center; }

/* 够级手牌更小更密 */
.gouji .hand { gap: 2px; }
.gouji #hand .card { width: 26px; height: 40px; font-size: 13px; }
.gouji #hand .card .suit { font-size: 10px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; top: 16%; transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.95); border: 1px solid #334155; color: var(--text);
  padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 10;
  max-width: 86vw; text-align: center;
}

/* ---------- 登录页 ---------- */
#login-screen { align-items: center; justify-content: center; gap: 12px; text-align: center; }
#login-screen h1 { margin: 0 0 4px; font-size: 30px; }
#login-btn { width: 100%; max-width: 320px; }

/* ---------- 大厅 / 选择玩法 ---------- */
.lobby { align-items: stretch; gap: 16px; }
.lobby-header { display: flex; justify-content: space-between; align-items: center; }
.greeting { color: var(--text); font-weight: 600; }
.lobby-title { margin: 8px 0 4px; font-size: 24px; }
.lobby-list { display: flex; flex-direction: column; gap: 12px; }
.game-card {
  display: flex; align-items: center; gap: 14px;
  padding: 16px; border-radius: 14px; text-decoration: none;
  background: #1e293b; border: 1px solid #334155; color: var(--text);
}
.game-card:active { transform: scale(0.98); border-color: var(--accent); }
.game-card.soon { opacity: 0.5; cursor: default; }
.game-card .text { display: flex; flex-direction: column; gap: 2px; }
.game-emoji { font-size: 28px; }
.game-name { font-size: 18px; font-weight: 600; }
.game-desc { font-size: 13px; color: var(--muted); }
