/* 雀局 · 网页麻将 */
:root {
  --bg: #f5f1e8;
  --panel: #ffffff;
  --ink: #2c2721;
  --ink-soft: #6b6257;
  --line: #e3dbc9;
  --brand: #1f7a5a;
  --brand-soft: #e6f3ed;
  --warn: #c0392b;
  --gold: #b8860b;
  --felt: #2f6b4f;
  --felt-dark: #245540;
  --tile-face: #fdfaf3;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.view { display: none; }
.view.active { display: block; }
.hidden { display: none !important; }

/* ---------------- 登录 ---------------- */
#view-auth {
  min-height: 100vh;
  display: none;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 30% 20%, #fbf7ee, #eae3d2);
}
#view-auth.active { display: flex; }
.auth-box {
  width: 380px;
  background: var(--panel);
  padding: 32px;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .12);
}
.brand { font-size: 40px; margin: 0; letter-spacing: 6px; color: var(--brand); }
.brand span { color: var(--gold); }
.brand-sub { color: var(--ink-soft); margin: 4px 0 20px; font-size: 13px; }
.tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.tab {
  flex: 1; padding: 8px; border: 1px solid var(--line); background: #fff;
  border-radius: 8px; cursor: pointer; color: var(--ink-soft);
}
.tab.active { background: var(--brand-soft); color: var(--brand); border-color: var(--brand); }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-soft); }
input, select {
  padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; color: var(--ink); background: #fff;
}
input:focus, select:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.msg { min-height: 20px; color: var(--warn); font-size: 13px; }

.btn {
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); cursor: pointer; font-size: 14px;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: #1a6749; color: #fff; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.host-btn { border-color: var(--brand); color: var(--brand); font-weight: 600; }
.host-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.host-banner {
  margin-bottom: 6px; padding: 6px 10px; border-radius: 8px;
  background: rgba(255, 179, 71, .16); border: 1px solid rgba(255, 126, 41, .5);
  color: #b85c12; font-size: 13px; font-weight: 600;
}

/* ---------------- 顶栏 ---------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.topbar.slim { padding: 8px 20px; }
.logo { font-size: 22px; letter-spacing: 4px; color: var(--brand); font-weight: 700; }
.logo.small { font-size: 18px; }
.user-box { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--ink-soft); }
.info-line { display: flex; gap: 18px; font-size: 13px; color: var(--ink-soft); align-items: center; }
#g-turn {
  background: #fff4d6; color: #8a6410; border: 1px solid var(--gold);
  border-radius: 20px; padding: 3px 12px; font-size: 12px; font-weight: 700;
}

/* ---------------- 大厅 ---------------- */
.lobby, .room {
  display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px;
  padding: 18px; max-width: 1180px; margin: 0 auto; align-items: start;
}
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 18px;
}
.panel h2 { font-size: 16px; margin: 0 0 12px; display: flex; align-items: center; gap: 10px; }
.panel h3 { font-size: 14px; margin: 16px 0 8px; }
.tag { font-size: 11px; color: var(--ink-soft); background: var(--brand-soft); padding: 2px 8px; border-radius: 10px; }

.room-list { display: flex; flex-direction: column; gap: 10px; }
.room-item {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.room-item .rmain { flex: 1; }
.room-item .rname { font-weight: 600; }
.room-item .rmeta { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: #eee; margin-left: 6px; }
.badge.public { background: var(--brand-soft); color: var(--brand); }
.badge.private { background: #fdecec; color: var(--warn); }
.badge.playing { background: #fff4d6; color: var(--gold); }
.empty { color: var(--ink-soft); font-size: 13px; padding: 12px 0; }

.rule-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }
.rule-item {
  display: flex; gap: 8px; align-items: flex-start; font-size: 13px;
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fffdf8;
}
.rule-item input { margin-top: 2px; }
.rule-item .rlabel { font-weight: 600; }
.rule-item .rdesc { color: var(--ink-soft); font-size: 11px; }
.inline { display: flex; gap: 12px; }
.inline label { flex: 1; }
form .btn { margin-top: 12px; width: 100%; }

/* ---------------- 房间座位 ---------------- */
.seat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seat-card {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  background: #fffdf8;
}
.seat-card.mine { border-color: var(--brand); background: var(--brand-soft); }
.seat-card .sname { font-weight: 600; margin-bottom: 8px; }
.seat-card .s-score { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.seat-card .s-score b { color: var(--brand); font-size: 13px; }
.seat-card .sctl { display: flex; gap: 6px; margin-top: 8px; }
.seat-card select { padding: 4px 6px; font-size: 12px; }
.hint { font-size: 12px; color: var(--ink-soft); margin-top: 10px; }
.actions { display: flex; gap: 10px; margin-top: 14px; }

/* ---------------- 牌桌 ---------------- */
/* 牌桌视图：顶栏固定 + 牌桌区可滚动 + 手牌区钉在底部。
   这样牌河/对手背面牌高度变化只会让牌桌区内部滚动，绝不会顶动手牌区（杜绝上下抖动）。 */
#view-game { display: none; }
#view-game.active {
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;     /* dvh 适配移动端浏览器地址栏伸缩 */
  overflow: hidden;
}
#view-game .topbar { flex: 0 0 auto; }

.table-wrap {
  display: grid; grid-template-columns: 1fr 260px; gap: 14px;
  padding: 14px 18px; max-width: 1280px; margin: 0 auto;
  flex: 1 1 auto; min-height: 0; overflow-y: auto; align-content: start;
}
.table {
  background: radial-gradient(circle at 50% 40%, var(--felt), var(--felt-dark));
  border-radius: 18px; padding: 12px; display: flex; flex-direction: column; gap: 8px;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, .35);
  min-height: 520px;
}
.table-mid { display: grid; grid-template-columns: 150px 1fr 150px; gap: 8px; }
.center-area {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
}
.discard-area {
  display: flex; flex-wrap: wrap; gap: 4px; width: 100%; min-height: 150px;
  align-content: flex-start; justify-content: center;
}
.wall-count { color: #d8f0e2; font-size: 12px; }

/* 百搭牌常驻展示 */
.wild-box { display: flex; justify-content: center; margin-bottom: 2px; }
.wild-card {
  display: flex; align-items: center; gap: 10px;
  background: rgba(0, 0, 0, .32); border: 1px dashed var(--gold); border-radius: 12px;
  padding: 6px 14px;
}
.wild-item { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.wild-cap { color: #ffe9a8; font-size: 11px; letter-spacing: 1px; }
.wild-arrow { color: var(--gold); font-size: 18px; }
.wild-tip { color: #cfead9; font-size: 11px; line-height: 1.4; margin-left: 6px; }
.wild-box.off .wild-tip { color: #9dbfae; }

/* 百搭牌面：金色描边 + 角标 */
.tile.wild-tile {
  outline: 2px solid var(--gold); background: linear-gradient(170deg, #fffdf3, #ffefc9);
  box-shadow: 0 0 10px rgba(184, 134, 11, .55);
}
.tile.wild-tile::after {
  content: "百"; position: absolute; top: -7px; right: -7px;
  font-size: 9px; font-weight: 700; color: #8a6410;
  background: #ffd978; border-radius: 4px; padding: 0 3px; line-height: 13px;
}
.tile.wild-ind { opacity: .85; }

/* 中央「最新打出的牌」 */
.last-discard {
  min-height: 88px; display: flex; align-items: center; justify-content: center;
}
.ld-card {
  display: flex; align-items: center; gap: 12px;
  background: rgba(0, 0, 0, .3); border: 1px solid var(--gold); border-radius: 12px;
  padding: 8px 16px; box-shadow: 0 0 0 3px rgba(184, 134, 11, .22), 0 6px 18px rgba(0, 0, 0, .35);
  animation: ldPop .32s ease-out;   /* 每次有人出牌都会重建，动画自然重播 */
}
@keyframes ldPop {
  from { transform: scale(.72); opacity: .3; }
  to   { transform: scale(1); opacity: 1; }
}
.ld-card .ld-tile { transform: scale(1.15); }
.ld-info { line-height: 1.35; }
.ld-who { color: #ffe9a8; font-size: 14px; font-weight: 700; }
.ld-what { color: #d8f0e2; font-size: 12px; }
.ld-empty { color: #b9d8c7; font-size: 12px; }

.seat-slot {
  background: rgba(255, 255, 255, .08); border-radius: 12px; padding: 8px;
  color: #eaf6ef; font-size: 12px; transition: box-shadow .2s, background .2s;
}
.seat-slot.active {
  background: rgba(255, 214, 120, .16);
  animation: seatPulse 1.6s ease-in-out infinite;
}
@keyframes seatPulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--gold), inset 0 0 12px rgba(255, 214, 120, .14); }
  50%      { box-shadow: 0 0 0 3px #ffd978, inset 0 0 26px rgba(255, 214, 120, .32); }
}
.player-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.player-head .pname { font-weight: 700; font-size: 13px; }
.player-head .wind {
  background: var(--gold); color: #fff; border-radius: 4px; padding: 1px 6px; font-size: 11px;
}
.player-head.active .pname { color: #ffe9a8; }
.player-head .pscore { margin-left: auto; font-size: 12px; }
.turn-badge {
  background: #ffd978; color: #4a3605; font-size: 10px; font-weight: 700;
  padding: 1px 7px; border-radius: 9px; animation: badgeBlink 1.1s ease-in-out infinite;
}
.turn-badge.youjin {
  background: linear-gradient(135deg, #ffb347, #ff7e29); color: #fff;
  box-shadow: 0 0 10px rgba(255, 126, 41, .7);
}
@keyframes badgeBlink { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
.tile-row { display: flex; flex-wrap: wrap; gap: 3px; }
.melds { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.meld-group { display: flex; gap: 2px; padding: 2px; background: rgba(0, 0, 0, .2); border-radius: 6px; }

/* ---------------- 牌 ---------------- */
.tile {
  background: var(--tile-face); border: 1px solid #d9d2c2; border-radius: 5px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25); user-select: none; line-height: 1;
  position: relative;
}
.tile .num { font-weight: 800; letter-spacing: -.5px; }
.tile .suit { font-size: .58em; margin-top: 2px; font-weight: 700; }
.tile.size-md { width: 42px; height: 58px; font-size: 21px; }
.tile.size-sm { width: 32px; height: 44px; font-size: 16px; }
.tile.size-xs { width: 24px; height: 34px; font-size: 12px; border-radius: 4px; }
/* 花色区分：数字牌用「顶部粗色条 + 淡底色 + 同色字」，字牌用灰底 + 专属色 */
.tile.m { border-top: 5px solid #d22f1e; background: #fff4f2; }
.tile.s { border-top: 5px solid #1f9d55; background: #eefaf2; }
.tile.p { border-top: 5px solid #2f6fd0; background: #eef4ff; }
.tile.z { border-top: 5px solid #555; background: #f7f3ec; }
.tile.m .num, .tile.m .suit { color: #c0271a; }
.tile.s .num, .tile.s .suit { color: #11823f; }
.tile.p .num, .tile.p .suit { color: #1b5cbe; }
.tile.z .num { color: #2c2721; }
.tile.z .suit { color: #6b6257; }
.tile.z5 .num { color: #c0271a; }   /* 中 */
.tile.z6 .num { color: #11823f; }   /* 發 */
.tile.z7 .num { color: #1f8fb8; }   /* 白（青色，与字牌灰底区分） */
.tile.back {
  background: linear-gradient(160deg, #3f8f6c, #2c6a4f); border-color: #1f5039;
}
.tile.discard-new {
  outline: 2px solid var(--gold); transform: scale(1.2);
  box-shadow: 0 0 10px rgba(255, 214, 120, .95); z-index: 2;
}
.tile.selectable { cursor: pointer; }
.tile.selectable:hover { transform: translateY(-4px); }
.tile.selected { outline: 3px solid var(--brand); transform: translateY(-8px); }
.tile.youjin-cand { outline: 3px solid #ff7e29; transform: translateY(-8px);
  box-shadow: 0 0 12px rgba(255, 126, 41, .65); animation: badgeBlink 1s ease-in-out infinite; }

/* 摸进的那张：单独隔离 + 金框上浮 */
.draw-split {
  display: flex; align-items: center; justify-content: center;
  align-self: stretch; margin: 0 10px;
}
.draw-split span {
  writing-mode: vertical-rl; font-size: 10px; font-weight: 700; color: #8a6410;
  border: 1px dashed var(--gold); border-radius: 6px; padding: 5px 2px;
  background: #fff6e0;
}
.tile.drawn {
  outline: 2px solid var(--gold); background: #fffdf3;
  transform: translateY(-8px);
  box-shadow: 0 6px 14px rgba(184, 134, 11, .45);
}
.tile.drawn.selectable:hover { transform: translateY(-12px); }
.tile.drawn.selected { transform: translateY(-14px); }

/* 轮次提示：悬浮在牌桌/手牌区上方，完全脱离文档流，避免提示出现/消失时挤动手牌 */
.turn-tip {
  position: absolute; top: 2px; left: 0; right: 0; text-align: center;
  font-size: 13px; font-weight: 700; min-height: 24px; white-space: nowrap;
  pointer-events: none; z-index: 5;
}
.turn-tip.me {
  display: inline-block; color: #fff; background: var(--warn);
  padding: 5px 16px; border-radius: 22px; font-size: 15px;
  box-shadow: 0 4px 14px rgba(192, 57, 43, .35);
  animation: tipPulse 1.3s ease-in-out infinite;
}
@keyframes tipPulse {
  0%, 100% { box-shadow: 0 4px 14px rgba(192, 57, 43, .35); transform: scale(1); }
  50%      { box-shadow: 0 4px 22px rgba(192, 57, 43, .6); transform: scale(1.03); }
}
.turn-tip.me .dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  background: #fff; margin-right: 7px; animation: badgeBlink 1s ease-in-out infinite;
}
.turn-tip.other { color: var(--ink-soft); display: inline-block; }

/* 需要我操作：手牌区整块发光，牌桌描金边（只切底色/光晕，不改布局，杜绝抖动） */
.my-hand.need-action {
  background: #fff7e3;
  border-color: var(--gold);
  animation: handGlow 1.4s ease-in-out infinite;
}
@keyframes handGlow {
  0%, 100% { box-shadow: 0 0 0 3px var(--gold), 0 0 12px rgba(184, 134, 11, .22); }
  50%      { box-shadow: 0 0 0 4px #ffd978, 0 0 30px rgba(184, 134, 11, .5); }
}
.table.my-turn { box-shadow: inset 0 0 60px rgba(0, 0, 0, .35), 0 0 0 3px var(--gold); }

/* ---------------- 手牌区 ---------------- */
.hand-bar {
  flex: 0 0 auto;                      /* 在 #view-game 的 flex 列里钉在底部，高度固定不随牌桌变化 */
  max-width: 1280px; margin: 0 auto; width: 100%;
  padding: 10px 18px 16px;
  display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap;
  background: var(--bg);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 18px rgba(0, 0, 0, .08);
}
.hand-main { flex: 1; min-width: 320px; position: relative; padding-top: 32px; }
.my-hand {
  display: flex; gap: 4px; flex-wrap: wrap; min-height: 74px; align-items: flex-end;
  padding: 0 10px 6px 10px; border-radius: 14px; border: 1px solid transparent;
  background: #fffdf8;
}
.action-bar { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.prompt-box { display: flex; gap: 8px; flex-wrap: wrap; }
.act-btn {
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--brand);
  background: #fff; color: var(--brand); cursor: pointer; font-size: 14px; font-weight: 600;
}
.act-btn.hu { background: var(--warn); color: #fff; border-color: var(--warn); }
.act-btn.youjin { background: linear-gradient(135deg, #ffb347, #ff7e29); color: #fff; border-color: #ff7e29; font-weight: 700; }
.act-btn.pass { border-color: var(--ink-soft); color: var(--ink-soft); }
.countdown {
  font-size: 13px; color: var(--warn); font-weight: 700;
  border: 1px solid var(--warn); border-radius: 20px; padding: 4px 12px;
}

/* ---------------- 侧栏 ---------------- */
.side-panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
}
.side-panel h3 { font-size: 13px; margin: 0 0 8px; }
.log-box {
  height: 260px; overflow-y: auto; font-size: 12px; color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: #fffdf8;
}
.log-box div { padding: 2px 0; border-bottom: 1px dashed #f0e9db; }
.rule-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 11px; padding: 3px 8px; border-radius: 10px; background: #f1ece0; color: var(--ink-soft); }
.chip.on { background: var(--brand-soft); color: var(--brand); }
.chip.off { background: #f5e6e4; color: #a55; text-decoration: line-through; }

/* ---------------- 结算 & toast ---------------- */
.modal {
  position: fixed; inset: 0; background: rgba(20, 16, 10, .55);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal-box {
  background: var(--panel); border-radius: 16px; padding: 24px; width: 560px;
  max-height: 84vh; overflow-y: auto;
}
.modal-box h2 { margin: 0 0 14px; }
.result-foot {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line);
}
.result-foot .chip { background: var(--brand-soft); color: var(--brand); font-weight: 700; }

/* 结算：跟随牌桌方向旋转；横屏（宽 > 高）时左右两列展示 */
#modal-result[data-rotation="clockwise"] { transform: rotate(90deg) translateY(-100%); transform-origin: top left; }
#modal-result[data-rotation="counterclockwise"] { transform: rotate(-90deg) translateX(-100%); transform-origin: top left; }
.result-cols { display: grid; grid-template-columns: 1fr; gap: 0 24px; }
.result-col h3 { margin: 0 0 4px; font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.result-block { margin-bottom: 12px; }
#modal-result.landscape .modal-box { width: min(96%, 900px); max-height: 92%; padding: 16px 22px; }
#modal-result.landscape .modal-box h2 { margin: 0 0 10px; font-size: 19px; }
#modal-result.landscape .result-cols { grid-template-columns: 1fr 1fr; }
#modal-result.landscape .result-col h3 { margin-top: 0; }
#modal-result.landscape .result-col + .result-col { border-left: 1px dashed var(--line); padding-left: 20px; }
#modal-result.landscape .result-foot { margin-top: 10px; padding-top: 10px; }

/* ---------------- 座位选择 ---------------- */
.seat-picker { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.seat-option {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  display: flex; flex-direction: column; gap: 7px; background: var(--bg, #fff);
}
.seat-option.free { border-color: var(--brand); background: var(--brand-soft); }
.seat-option.mine { box-shadow: 0 0 0 2px var(--brand); }
.seat-option.bot, .seat-option.human { opacity: .82; }
.so-head { display: flex; align-items: center; gap: 8px; }
.so-wind {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: var(--brand); color: #fff; font-size: 17px; font-weight: 700;
}
.so-idx { font-size: 13px; font-weight: 700; }
.so-who { font-size: 13px; color: var(--ink-soft); min-height: 18px; }
@media (max-width: 520px) {
  .seat-picker { grid-template-columns: 1fr; }
}
.result-row {
  display: flex; justify-content: space-between; padding: 8px 0;
  border-bottom: 1px dashed var(--line); font-size: 14px;
}
.result-row .delta.plus { color: var(--warn); font-weight: 700; }
.result-row .delta.minus { color: #1b7a3d; font-weight: 700; }
.result-fans { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.result-hand { display: flex; gap: 3px; flex-wrap: wrap; margin-top: 6px; }
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: rgba(40, 32, 22, .92); color: #fff; padding: 10px 18px;
  border-radius: 8px; font-size: 13px; z-index: 60;
}

/* ============================ 移动端适配 ============================ */
/* 平板及以下：两栏布局改为单栏 */
@media (max-width: 1000px) {
  .lobby, .room { grid-template-columns: 1fr; }
  .table-wrap { grid-template-columns: 1fr; }
}

/* 手机：整体缩放 + 触摸优化 */
@media (max-width: 768px) {
  /* 顶栏：允许换行，信息行独占一行，避免溢出 */
  .topbar { padding: 8px 12px; flex-wrap: wrap; gap: 6px; }
  .topbar.slim { padding: 6px 12px; }
  .logo { font-size: 18px; letter-spacing: 2px; }
  .logo.small { font-size: 16px; }
  .user-box { gap: 8px; font-size: 12px; margin-left: auto; }
  .info-line { order: 3; width: 100%; gap: 10px; font-size: 11px; justify-content: flex-start; }
  #g-wall { display: none; }                 /* 手机上隐藏牌墙数，腾出空间 */

  /* 登录：卡片收窄 */
  .auth-box { width: 92%; max-width: 360px; padding: 22px; }
  .brand { font-size: 34px; letter-spacing: 4px; }

  /* 大厅 / 房间 */
  .lobby, .room { padding: 12px; gap: 12px; }
  .panel { padding: 14px; }
  .panel h2 { font-size: 15px; }
  .inline { flex-direction: column; gap: 8px; }

  /* 牌桌：压缩四向座位与内边距 */
  .table-wrap { padding: 8px; gap: 8px; }
  .table { padding: 8px; gap: 6px; min-height: 340px; border-radius: 14px; }
  .table-mid { grid-template-columns: 74px 1fr 74px; gap: 6px; }
  .seat-slot { padding: 6px; font-size: 11px; }
  .player-head { gap: 5px; margin-bottom: 4px; flex-wrap: wrap; }
  .player-head .pname { font-size: 11px; }
  .player-head .pscore { font-size: 11px; }
  .player-head .wind { padding: 1px 4px; font-size: 10px; }
  .tile-row { gap: 2px; }
  .melds { gap: 4px; margin-top: 3px; }
  .meld-group { padding: 1px; gap: 1px; }
  .discard-area { min-height: 92px; gap: 3px; }

  /* 牌面统一缩小（保持万/条/筒/字配色不变），手牌、对手、牌河、百搭同步生效 */
  .tile.size-md { width: 34px; height: 47px; font-size: 17px; }
  .tile.size-sm { width: 26px; height: 36px; font-size: 13px; }
  .tile.size-xs { width: 19px; height: 27px; font-size: 10px; border-radius: 3px; }
  .tile .suit { font-size: .56em; }
  .tile .num { letter-spacing: -.3px; }
  .last-discard { min-height: 66px; }
  .ld-card { gap: 8px; padding: 6px 12px; }
  .ld-card .ld-tile { transform: scale(1.1); }

  /* 手牌区占满整行，动作按钮换行到下方（适合拇指操作）；底部钉死由 flex 列保证，无需 sticky */
  .hand-bar {
    padding: 8px 8px 12px; gap: 8px;
    position: static;
    background: var(--bg);
    border-top: 1px solid var(--line);
    box-shadow: 0 -4px 14px rgba(0, 0, 0, .06);
  }
  .hand-main { flex: 1 1 100%; min-width: 0; }
  .my-hand { min-height: 56px; gap: 3px; }
  .action-bar { margin-left: 0; width: 100%; }
  .prompt-box { width: 100%; gap: 6px; }

  /* 触摸目标：按钮加高，字号略增 */
  .btn { padding: 11px 16px; font-size: 15px; min-height: 42px; }
  .btn.small { min-height: 36px; padding: 7px 12px; }
  .act-btn { padding: 11px 16px; font-size: 15px; min-height: 42px; }
  .tab { min-height: 42px; }
  .actions { flex-wrap: wrap; }
  .actions .btn { flex: 1 1 auto; }

  /* 侧栏：日志变矮，避免把手牌挤太远 */
  .side-panel { padding: 10px 12px; }
  .side-panel h3 { font-size: 13px; }
  .log-box { height: 150px; }

  /* 结算弹窗：全宽 */
  .modal-box { width: 94%; max-width: 440px; padding: 18px; }
  .result-foot { gap: 8px; }
  .result-foot .btn { flex: 1 1 auto; }
  .result-row { font-size: 13px; }

  .seat-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
}

/* 小屏手机（iPhone SE 等）：进一步收紧 */
@media (max-width: 420px) {
  .table-mid { grid-template-columns: 60px 1fr 60px; }
  .seat-slot { padding: 4px; }
  .tile.size-md { width: 30px; height: 42px; font-size: 15px; }
  .tile.size-sm { width: 23px; height: 32px; font-size: 12px; }
  .tile.size-xs { width: 17px; height: 24px; font-size: 9px; }
  .my-hand { gap: 2px; }
  .turn-tip.me { font-size: 13px; padding: 4px 12px; }
  .info-line { font-size: 10px; gap: 8px; }
  #g-room { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

