/* ============================================================
   打两圈 —— 横屏牌桌
   牌面是内联的素材图（src/ui/tileArt.js），牌墙和牌背用 CSS 叠出来。
   ============================================================ */

:root {
  --felt: #1b5c49;
  --felt-deep: #0e3b30;
  --felt-darkest: #082820;
  --felt-line: rgba(255, 255, 255, .06);
  --ivory: #fbf7ea;
  --ivory-edge: #ded5bd;
  --ink: #2a2a26;
  --muted: #8fb2a5;
  --gold: #e3bb63;

  /* 自己手牌的尺寸，横屏高度自适应 */
  --th: clamp(36px, 13vh, 56px);
  --tw: calc(var(--th) * .73);
  /* 三家的牌背 */
  --bh: calc(var(--th) * .58);
  --bw: calc(var(--bh) * .72);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--felt-darkest);
  color: var(--ivory);
  user-select: none;
}

#app { height: 100%; }
.view { height: 100%; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* ================= 选玩法 ================= */

#menu {
  background: radial-gradient(circle at 50% 30%, #247056 0%, var(--felt) 40%, var(--felt-darkest) 100%);
  padding: 24px;
  align-items: center;
  justify-content: center;
}

.menu-head { text-align: center; margin-bottom: 20px; }
.menu-head h1 {
  font-size: 30px; font-weight: 400; letter-spacing: 8px;
  margin: 0 0 10px; text-indent: 8px;
}
.menu-head .sub { margin: 0; color: var(--muted); font-size: 13px; letter-spacing: 2px; }

/* 每人开局带多少点 */
.stake {
  width: 100%; max-width: 420px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 13px;
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(251, 247, 234, .05);
  border: 1px solid rgba(251, 247, 234, .1);
}
.stake-label { font-size: 12px; color: var(--muted); letter-spacing: 1px; }
.stake-opts { display: flex; gap: 6px; }
.stake-btn {
  min-width: 44px; padding: 5px 2px;
  border-radius: 8px;
  border: 1px solid rgba(251, 247, 234, .16);
  background: rgba(251, 247, 234, .06);
  color: rgba(251, 247, 234, .8);
  font: inherit; font-size: 13px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: background .14s ease, color .14s ease;
}
.stake-btn.on {
  background: linear-gradient(180deg, #f0c674, var(--gold));
  color: #3a2a06; font-weight: 600; border-color: transparent;
}

.rule-cards { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 13px; }

/* 单机 / 和朋友打 + 名字 */
.mode-row {
  width: 100%; max-width: 420px;
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 13px;
}
.mode-opts {
  display: flex; gap: 3px;
  padding: 3px;
  border-radius: 10px;
  background: rgba(251, 247, 234, .06);
  border: 1px solid rgba(251, 247, 234, .1);
}
.mode-btn {
  border: 0; border-radius: 8px;
  padding: 6px 12px;
  background: transparent;
  color: rgba(251, 247, 234, .6);
  font: inherit; font-size: 12.5px; letter-spacing: 1px;
  cursor: pointer;
  transition: background .14s ease, color .14s ease;
}
.mode-btn.on {
  background: linear-gradient(180deg, #f0c674, var(--gold));
  color: #3a2a06; font-weight: 600;
}
.name-input {
  flex: 1 1 auto; min-width: 0;
  padding: 7px 10px;
  border-radius: 9px;
  border: 1px solid rgba(251, 247, 234, .14);
  background: rgba(0, 0, 0, .18);
  color: var(--ivory);
  font: inherit; font-size: 13px;
  text-align: center;
  letter-spacing: 1px;
}
.name-input::placeholder { color: rgba(251, 247, 234, .28); }
.name-input:focus { outline: none; border-color: rgba(227, 187, 99, .55); }

/* ================= 等待好友 ================= */

#lobby {
  background: radial-gradient(circle at 50% 30%, #247056 0%, var(--felt) 40%, var(--felt-darkest) 100%);
  /* 顶栏要通栏，内容自己居中 */
  align-items: stretch;
  padding: 0 0 18px;
}

.lobby-body {
  flex: 1 1 auto;
  width: 100%; max-width: 460px;
  margin: 0 auto;
  display: flex; flex-direction: column; align-items: center;
  gap: 12px;
  padding: 8px 16px 0;
  min-height: 0;
}

.lobby-head {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(251, 247, 234, .06);
  border: 1px solid rgba(251, 247, 234, .12);
}
.lobby-codes { flex: 1 1 auto; display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; min-width: 0; }
.lobby-code, .lobby-key { display: flex; align-items: baseline; gap: 8px; }
.lobby-code span, .lobby-key span { font-size: 11.5px; color: var(--muted); letter-spacing: 2px; }
.lobby-code b {
  font-size: 26px; font-weight: 500; letter-spacing: 7px;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
/* 口令：几位数字，房主可以口头念给朋友 */
.lobby-key b {
  font-size: 18px; font-weight: 500; letter-spacing: 3px;
  color: rgba(251, 247, 234, .8);
  font-variant-numeric: tabular-nums;
}

.lobby-seats {
  width: 100%;
  display: grid; grid-template-columns: 1fr 1fr; gap: 9px;
}
.seat-card {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 12px;
  border-radius: 12px;
  background: rgba(251, 247, 234, .07);
  border: 1px solid rgba(251, 247, 234, .12);
  min-width: 0;
}
.seat-card.is-ai { background: rgba(251, 247, 234, .03); border-style: dashed; }
.seat-card.is-me { border-color: rgba(227, 187, 99, .65); }
.sc-wind {
  flex: 0 0 auto;
  width: 22px; height: 22px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: #2a1a06;
  background: rgba(227, 187, 99, .8);
}
.seat-card.is-ai .sc-wind { background: rgba(251, 247, 234, .16); color: rgba(251, 247, 234, .5); }
.sc-name {
  flex: 1 1 auto; min-width: 0;
  font-size: 13.5px; color: var(--ivory);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.seat-card.is-ai .sc-name { color: rgba(251, 247, 234, .45); }
.sc-state { flex: 0 0 auto; font-size: 10.5px; color: rgba(251, 247, 234, .38); }

.lobby-ready {
  font-size: 12.5px; letter-spacing: 1px;
  color: rgba(251, 247, 234, .5);
  padding: 11px 18px;
  border-radius: 11px;
  border: 1px dashed rgba(251, 247, 234, .22);
}
.lobby-ready::before { content: '✓ '; color: #9fe0b5; }

.lobby-join { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.lobby-input {
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid rgba(251, 247, 234, .16);
  background: rgba(0, 0, 0, .2);
  color: var(--ivory);
  font: inherit; font-size: 13px;
  text-align: center;
  letter-spacing: 1px;
  min-width: 0;
}
.lobby-input::placeholder { color: rgba(251, 247, 234, .28); }
.lobby-input:focus { outline: none; border-color: rgba(227, 187, 99, .55); }
#joinName { flex: 1 1 120px; max-width: 180px; }
.lobby-input.key { flex: 0 0 84px; letter-spacing: 4px; font-variant-numeric: tabular-nums; }

.lobby-tip { margin: 2px 0 0; font-size: 12px; color: rgba(251, 247, 234, .4); letter-spacing: 1px; text-align: center; }

.btn.big { width: 100%; max-width: 320px; padding: 12px; font-size: 15px; }

@media (max-height: 430px) {
  .lobby-code b { font-size: 20px; }
  .seat-card { padding: 8px 10px; }
  .lobby-body { gap: 8px; }
}

.rule-card {
  display: flex; align-items: center; gap: 14px;
  width: 100%; text-align: left; font: inherit; color: inherit;
  padding: 16px 18px;
  border-radius: 14px;
  background: rgba(251, 247, 234, .06);
  border: 1px solid rgba(251, 247, 234, .12);
  cursor: pointer;
  transition: transform .14s ease, background .14s ease, border-color .14s ease;
  text-align: left; width: 100%; color: inherit; font: inherit;
}
.rule-card:active { transform: scale(.98); background: rgba(251, 247, 234, .12); border-color: rgba(227, 187, 99, .4); }

.rule-badge {
  width: 44px; height: 44px; flex: 0 0 44px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  background: rgba(251, 247, 234, .1);
  border: 1px solid rgba(251, 247, 234, .16);
}
.rule-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.rule-name { font-size: 16px; display: block; }
.rule-desc {
  font-size: 12px; color: var(--muted); line-height: 1.5;
  display: block; white-space: normal; word-break: break-word;
}
.rule-go { color: var(--muted); font-size: 18px; flex: 0 0 auto; }
/* 圈数选择（倒子可选四圈 / 八圈），点它只换圈数、不进入对局 */
.rule-circles { display: flex; gap: 6px; margin-top: 6px; }
.rule-circles .rc {
  font-size: 10.5px; font-weight: 400; line-height: 1;
  padding: 4px 9px; border-radius: 20px;
  border: 1px solid rgba(251, 247, 234, .18);
  color: rgba(251, 247, 234, .55);
  cursor: pointer;
  transition: background .14s ease, color .14s ease, border-color .14s ease;
}
.rule-circles .rc.on {
  background: linear-gradient(180deg, #f0c674, var(--gold));
  border-color: transparent; color: #3a2a06; font-weight: 600;
}

/* 这一桌怎么算完（南京才有「两家进院子收场」），挂在玩法自己身上 */
.rule-note {
  display: block;
  margin-top: 3px;
  font-size: 10.5px;
  letter-spacing: .3px;
  color: rgba(227, 187, 99, .62);
}

.menu-foot { margin-top: 26px; font-size: 11.5px; color: rgba(251, 247, 234, .3); letter-spacing: 1px; }

/* ================= 牌桌骨架 ================= */

#table {
  position: relative;
  background:
    radial-gradient(ellipse at 50% 45%, #27795f 0%, var(--felt) 45%, var(--felt-deep) 100%);
}

.bar {
  display: flex; align-items: center; gap: 8px;
  padding: max(6px, env(safe-area-inset-top)) 12px 6px;
  font-size: 12.5px;
  background: rgba(8, 40, 32, .72);
  backdrop-filter: blur(8px);
  flex: 0 0 auto;
  z-index: 5;
}
.icon-btn {
  background: none; border: 0; color: rgba(251, 247, 234, .8);
  font-size: 20px; line-height: 1; padding: 2px 7px; cursor: pointer;
}
.icon-btn.right { margin-left: auto; font-size: 16px; }
/* 语音开关：开着是喇叭，关掉划一道斜杠并变灰 */
.icon-btn#btnVoice { font-size: 15px; opacity: .9; }
.icon-btn#btnVoice.muted { opacity: .38; }
.bar-title { letter-spacing: 1.5px; color: rgba(251, 247, 234, .92); }
.bar-sep { width: 1px; height: 12px; background: rgba(251, 247, 234, .18); }
.bar-status { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1 1 auto; }
.bar-status .ok { color: #9fe0b5; }
.bar-status .warn { color: #ffb9a6; }
.bar-status .lack { color: #f0c674; }
.bar-status .dot { opacity: .35; margin: 0 5px; }

/* 比下胡：庄家连庄后整局翻倍，顶栏挂个金牌 */
.bar-bifu {
  flex: 0 0 auto;
  font-size: 10.5px; letter-spacing: .5px;
  color: #ffe6a2;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(227, 187, 99, .16);
  border: 1px solid rgba(227, 187, 99, .45);
  box-shadow: 0 0 9px rgba(227, 187, 99, .28);
}
.bar-bifu b { font-weight: 700; }

.bar-pts {
  flex: 0 0 auto;
  font-size: 11px; color: rgba(251, 247, 234, .55);
  font-variant-numeric: tabular-nums;
}
.bar-pts b { color: #ffe6a2; font-weight: 600; font-size: 12.5px; }
.bar-pts .yard { color: #ffb9a6; font-size: 11.5px; }
/* 不计院子的玩法（倒子）点数会是负的，给它一个提示色 */
.bar-pts b.neg { color: #ffb9a6; }

.board {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 4px 8px 0;
  gap: 2px;
}

.board-mid {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: stretch;
  gap: 4px;
}

/* ================= 四家座位 ================= */

.seat { display: flex; position: relative; }

.seat-top {
  flex-direction: row; align-items: center; justify-content: center;
  gap: 7px;
  padding-top: 2px;
}
/* 自己：花牌＋副露占一行，手牌单独一行 */
.seat-bottom {
  flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 2px 8px;
  padding-top: 1px;
}
.seat-left, .seat-right {
  flex: 0 0 auto;
  flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  width: 58px;
}
/* 左右两家：花牌一列、手牌一列，并排放 */
.seat-body { display: flex; align-items: center; justify-content: center; gap: 3px; min-height: 0; flex: 0 0 auto; }

.seat-tag {
  display: flex; flex-direction: column; align-items: center; gap: 0; flex: 0 0 auto;
  font-size: 9.5px;
  color: rgba(251, 247, 234, .55);
  letter-spacing: .3px;
  line-height: 1.35;
  text-align: center;
}
.seat-top .seat-tag { flex-direction: row; align-items: center; gap: 5px; }
.tag-name { white-space: nowrap; }
.tag-dealer {
  font-style: normal; font-size: 8px; line-height: 1.35;
  color: #3a2a06; background: var(--gold);
  border-radius: 2.5px; padding: 0 2px;
  margin-right: 2px;
  display: inline-block; vertical-align: 1px;
}
.tag-pts { font-size: 9px; color: rgba(227, 187, 99, .78); font-variant-numeric: tabular-nums; }
.tag-pts.yard { color: #ffb9a6; }
.tag-pts.neg { color: #ffb9a6; }
/* 喂牌数：已经喂到 2 嘴，再来一嘴就要包牌了 */
.tag-feed {
  font-size: 8.5px; line-height: 1.4;
  padding: 0 4px; border-radius: 4px;
  color: #ffd9a0;
  background: rgba(200, 120, 40, .32);
  box-shadow: inset 0 0 0 1px rgba(255, 190, 110, .45);
}
.tag-meld { font-size: 8.5px; color: rgba(251, 247, 234, .32); }

/* 定缺：每家定的哪一门都挂在名牌上，缺万红、缺条绿、缺筒蓝。
   这门还没打完时描一圈虚线，打干净了才变成实心 —— 一眼看出谁还欠着 */
.tag-lack {
  font-size: 8.5px; line-height: 1.4;
  padding: 0 3px; border-radius: 3px;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.tag-lack.s0 { color: #ff9a8a; background: rgba(190, 64, 48, .18); }
.tag-lack.s1 { color: #8fd98a; background: rgba(48, 130, 60, .18); }
.tag-lack.s2 { color: #8fc4f0; background: rgba(40, 96, 150, .2); }
.tag-lack.left { border-style: dashed; opacity: .95; }
/* 包牌：这个人的碰杠被同一家喂满三嘴，成牌得那一家掏三家钱 */
.tag-pack {
  font-size: 8.5px; font-weight: 700; color: #2a1a06;
  background: linear-gradient(180deg, #f3c76a, #d8a03c);
  border-radius: 3px; padding: 0 3px; line-height: 1.4;
}

/* 牌背排列 */
.seat-hand { display: flex; gap: 1.5px; }
.h-row { flex-direction: row; justify-content: center; }
.v-col { flex-direction: column; justify-content: center; }

.back {
  background: linear-gradient(168deg, #8fd066 0%, #5da646 48%, #42892f 100%);
  border-radius: 2.5px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .45),
    inset 0 -1px 0 rgba(0, 0, 0, .22),
    0 1px 2px rgba(0, 0, 0, .32);
  flex: 0 0 auto;
}
.h-row .back { width: calc(var(--bw) * .78); height: var(--bh); }
.v-col .back { width: var(--bh); height: calc(var(--bw) * .68); }

/* ================= 中央：牌墙 + 轮盘 + 牌池 ================= */

.center {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
}

/* --- 牌墙：正方形围成一圈，每墩上下两张摞着，叠出「墙」的层次 --- */

.wall {
  position: absolute;
  left: 50%; top: 50%;
  /* 边长由 JS 按可用空间算好写进 --wall-side：正方形，不随屏幕拉成扁框 */
  width: var(--wall-side, 300px);
  height: var(--wall-side, 300px);
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 2;
  transition: width .35s ease, height .35s ease;
}

/* 左右两条铺满整条边，上下两条再缩进一个墙厚 —— 四角正好拼成直角 */
.wside { position: absolute; display: flex; gap: 2px; }
.wside.l, .wside.r { top: 0; bottom: 0; width: var(--thick, 26px); flex-direction: column; }
.wside.l { left: 0; }
.wside.r { right: 0; }
.wside.t, .wside.b {
  left: var(--thick, 26px); right: var(--thick, 26px);
  height: var(--thick, 26px);
  flex-direction: row;
}
.wside.t { top: 0; }
.wside.b { bottom: 0; }

/* 一墩牌：外面一排是上面那张，里面一排是下面那张 */
.seg { position: relative; flex: 1 1 0; min-width: 0; min-height: 0; }
.wside.t .seg, .wside.b .seg { height: 100%; }
.wside.l .seg, .wside.r .seg { width: 100%; }

.lay {
  position: absolute;
  border-radius: 2.5px;
  transition: opacity .22s ease, transform .26s ease;
}

/* 下面那张：贴着圆心一侧，摸走上面那张后才露出来 */
.wside.t .lay.low { left: 1px; right: 1px; bottom: 0; height: 46%; }
.wside.b .lay.low { left: 1px; right: 1px; top: 0; height: 46%; }
.wside.l .lay.low { top: 1px; bottom: 1px; right: 0; width: 46%; }
.wside.r .lay.low { top: 1px; bottom: 1px; left: 0; width: 46%; }

/* 上面那张：压在靠外一侧，比下面那张亮一层 */
.wside.t .lay.up { left: 0; right: 0; top: 0; height: 52%; }
.wside.b .lay.up { left: 0; right: 0; bottom: 0; height: 52%; }
.wside.l .lay.up { top: 0; bottom: 0; left: 0; width: 52%; }
.wside.r .lay.up { top: 0; bottom: 0; right: 0; width: 52%; }

.lay.up {
  background: linear-gradient(180deg, #a8e682 0%, #7cc45c 42%, #4c9a37 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .55),
    inset 0 0 0 1px rgba(0, 0, 0, .16);
}
.lay.low {
  background: linear-gradient(180deg, #6cae52 0%, #4e9139 48%, #336c24 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .26),
    inset 0 0 0 1px rgba(0, 0, 0, .2);
}
.wside.l .lay.up, .wside.r .lay.up {
  background: linear-gradient(90deg, #a8e682 0%, #7cc45c 42%, #4c9a37 100%);
}
.wside.r .lay.up { background: linear-gradient(270deg, #a8e682 0%, #7cc45c 42%, #4c9a37 100%); }
.wside.l .lay.low { background: linear-gradient(90deg, #6cae52 0%, #4e9139 48%, #336c24 100%); }
.wside.r .lay.low { background: linear-gradient(270deg, #6cae52 0%, #4e9139 48%, #336c24 100%); }

/* 上面那张朝圆心压一道影：那道影就是两层的分界，也是「厚度」的来源。
   用 drop-shadow 而不是 box-shadow，形状能贴着圆角走，更像真投影。 */
.wside.t .lay.up { filter: drop-shadow(0 3px 2px rgba(0, 0, 0, .55)); }
.wside.b .lay.up { filter: drop-shadow(0 -3px 2px rgba(0, 0, 0, .55)); }
.wside.l .lay.up { filter: drop-shadow(3px 0 2px rgba(0, 0, 0, .55)); }
.wside.r .lay.up { filter: drop-shadow(-3px 0 2px rgba(0, 0, 0, .55)); }

/* 只剩下面那张：牌面露出来（亮一档），那段墙矮下去一截 —— 一眼看出这墩摸过一张 */
.seg.s-half .lay.low {
  filter: brightness(1.12) saturate(1.02);
  box-shadow:
    inset 0 2px 3px rgba(0, 0, 0, .38),
    inset 0 0 0 1px rgba(0, 0, 0, .18);
}

/* 摸走的牌淡出、缩一下，像被拿走 */
.seg.s-half .lay.up, .seg.s-gone .lay.up { opacity: 0; transform: scale(.88); }
.seg.s-gone .lay.low { opacity: 0; transform: scale(.88); }

/* 墙的两个断口：绿线＝正常摸牌口，金线＝补花／杠补的墙尾。
   横墙断口画竖线、竖墙断口画横线，看起来就是墙被切开的截面。 */
/* 断口截面：横墙上画一道竖线，竖墙上画一道横线，长度就是墙的厚度 */
.wmark {
  position: absolute;
  border-radius: 2px;
  transform: translate(-50%, -50%);
  transition: opacity .25s ease;
  width: calc(var(--thick, 40px) * .8); height: 3px;
}
.wmark.h { width: 3px; height: calc(var(--thick, 40px) * .8); }
.wmark.draw {
  background: #86f09a;
  box-shadow: 0 0 5px rgba(134, 240, 154, .95), 0 0 10px rgba(134, 240, 154, .55);
}
.wmark.bonus {
  background: #ffd97a;
  box-shadow: 0 0 6px rgba(255, 217, 122, 1), 0 0 12px rgba(255, 217, 122, .6);
  animation: wmarkPulse 1.8s ease-in-out infinite;
}
@keyframes wmarkPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.5); }
}
/* 补牌那一下，金口炸开一圈 */
.wmark.hit { animation: wmarkHit .55s ease-out; }
@keyframes wmarkHit {
  0% { box-shadow: 0 0 0 0 rgba(255, 217, 122, .95), 0 0 14px rgba(255, 217, 122, 1); }
  100% { box-shadow: 0 0 0 14px rgba(255, 217, 122, 0), 0 0 14px rgba(255, 217, 122, 0); }
}

/* --- 摸牌飞行：牌从墙的断口飞到手上 --- */
.fly-layer {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 60;
}
.fly-tile {
  position: absolute;
  width: 22px; height: 30px;
  margin: -15px 0 0 -11px;
  border-radius: 3px;
  background-size: cover; background-position: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .45);
  transition: transform .34s cubic-bezier(.26, .7, .32, 1), opacity .34s ease-out;
  will-change: transform, opacity;
}
.fly-tile.flower { box-shadow: 0 0 0 1.5px var(--gold), 0 4px 12px rgba(0, 0, 0, .5); }

/* --- 中央轮盘：圈数 / 圈风 / 剩余张数 / 当前出牌人 --- */

.dial {
  position: absolute;
  left: 50%; top: 50%;
  /* 直径跟着牌墙一起缩，小屏上别把方框撑爆 */
  width: var(--dial, 84px); height: var(--dial, 84px);
  margin: calc(var(--dial, 84px) / -2) 0 0 calc(var(--dial, 84px) / -2);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 32%, #26354b 0%, #141d2b 55%, #080d15 100%);
  box-shadow:
    0 0 0 1.5px rgba(227, 187, 99, .42),
    0 4px 16px rgba(0, 0, 0, .5),
    inset 0 2px 6px rgba(255, 255, 255, .07);
  z-index: 3;
  display: flex; align-items: center; justify-content: center;
}

/* 剩余进度：外圈一道弧，摸得越少弧越短 */
.dial-arc {
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  background: conic-gradient(
    from -90deg,
    rgba(150, 220, 160, .85) var(--p, 100%),
    rgba(255, 255, 255, .07) 0
  );
  -webkit-mask: radial-gradient(circle,
    transparent 0 calc(var(--dial, 84px) / 2 - 5px),
    #000 calc(var(--dial, 84px) / 2 - 5px) calc(var(--dial, 84px) / 2 - 1.5px));
  mask: radial-gradient(circle,
    transparent 0 calc(var(--dial, 84px) / 2 - 5px),
    #000 calc(var(--dial, 84px) / 2 - 5px) calc(var(--dial, 84px) / 2 - 1.5px));
  transition: background .3s ease;
}

.dial-face {
  position: absolute; inset: 0;
  border-radius: 50%;
}

/* 四家的风位：画在盘面上，谁的风谁就亮 */
.dial-w {
  position: absolute;
  font-size: 9px; line-height: 1;
  color: rgba(251, 247, 234, .34);
  font-family: "Songti SC", "STSong", serif;
  transition: color .2s ease, text-shadow .2s ease;
}
.w-n { top: 9px; left: 50%; transform: translateX(-50%); }
.w-s { bottom: 9px; left: 50%; transform: translateX(-50%); }
.w-w { left: 9px; top: 50%; transform: translateY(-50%); }
.w-e { right: 9px; top: 50%; transform: translateY(-50%); }
.dial-w.active {
  color: #ffe6a2;
  font-size: 11px;
  font-weight: 600;
  text-shadow: 0 0 9px rgba(255, 205, 110, .95), 0 0 3px rgba(255, 220, 150, .9);
}

.dial-core {
  position: absolute;
  left: 50%; top: 50%;
  width: 63%; height: 63%;
  margin: -31.5% 0 0 -31.5%;
  border-radius: 50%;
  border: 1px solid rgba(227, 187, 99, .22);
  background: radial-gradient(circle at 50% 28%, rgba(70, 104, 138, .34), rgba(5, 10, 18, .82));
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  line-height: 1;
}

.dial-round {
  font-size: 9px;
  color: rgba(227, 187, 99, .82);
  letter-spacing: .5px;
}
.dial-wind {
  font-size: 23px;
  color: #f7e9c2;
  font-family: "Songti SC", "STSong", serif;
  margin: 2px 0 3px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .6);
}
.dial-left {
  font-size: 9px;
  color: rgba(251, 247, 234, .45);
  font-variant-numeric: tabular-nums;
}
.dial-left b { color: rgba(251, 247, 234, .9); font-weight: 500; font-size: 11px; }

/* 指针：指向正在出牌的那一家 */
.dial-needle {
  position: absolute;
  left: 50%; top: -7px;
  width: 0; height: 0;
  margin-left: -4.5px;
  border-left: 4.5px solid transparent;
  border-right: 4.5px solid transparent;
  border-bottom: 6.5px solid #f0cd7d;
  transform-origin: 50% calc(var(--dial, 84px) / 2 + 7px);
  transition: transform .28s cubic-bezier(.4, 1.4, .6, 1);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .6));
}

/* --- 牌池：紧贴牌墙外侧，四家各占一条，朝外一张张码 --- */

.pools { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.pool { position: absolute; display: flex; }

.pool.t {
  top: 1%; left: 8%; right: 8%;
  height: calc((100% - var(--wall-side, 300px)) / 2 - 7px);
  justify-content: center; align-items: flex-end;
  flex-wrap: wrap-reverse;
  align-content: flex-end;
}
.pool.b {
  bottom: 1%; left: 8%; right: 8%;
  height: calc((100% - var(--wall-side, 300px)) / 2 - 7px);
  justify-content: center; align-items: flex-start;
  flex-wrap: wrap;
  align-content: flex-start;
}
/* 左右两条紧贴方形牌墙外侧，多出来的牌朝屏幕边缘续列 */
.pool.l {
  right: calc(50% + var(--wall-side, 300px) / 2 + 8px);
  top: 4%; bottom: 4%; width: 16%;
  flex-flow: column wrap;
  justify-content: center; align-content: flex-end;
}
.pool.r {
  left: calc(50% + var(--wall-side, 300px) / 2 + 8px);
  top: 4%; bottom: 4%; width: 16%;
  flex-flow: column wrap;
  justify-content: center; align-content: flex-start;
}

.pool .tile {
  width: 16px; height: 22px;
  border-radius: 2.5px;
  cursor: default;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .32);
}

/* 上一张打出的牌：金边 + 微光，一眼能找到 */
.pool .tile.last {
  box-shadow:
    0 0 0 1.5px var(--gold),
    0 0 7px rgba(227, 187, 99, .75),
    0 1px 2px rgba(0, 0, 0, .35);
  transform: translateY(-1px);
}
.pool .tile.last::after {
  content: '';
  position: absolute;
  left: 50%; bottom: -3px;
  width: 3px; height: 3px;
  margin-left: -1.5px;
  border-radius: 50%;
  background: var(--gold);
}

/* ================= 自己的手牌 ================= */

.seat-bottom {
  flex: 0 0 auto;
  padding-bottom: 4px;
}

.seat-bottom .seat-hand { flex: 0 0 100%; }
.seat-hand.h-row .tile {
  width: var(--tw);
  height: var(--th);
}

/* 手牌多了自动缩，14 张不会顶出屏幕 */
#myHand { max-width: 100%; }

/* 牌：牌面是素材图（data URI 内联），牌身的厚度和投影由 CSS 补 */
.tile {
  position: relative;
  border-radius: 3px;
  background-color: #fbf7ea;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
  box-shadow:
    0 2px 0 #6d9a5b,
    0 3px 5px rgba(0, 0, 0, .3);
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
  cursor: pointer;
  transition: transform .1s ease, box-shadow .1s ease;
  overflow: hidden;
}

/* 小牌：边线收细，否则 15px 的牌会被框吃掉 */
.tile.mini {
  box-shadow:
    0 1px 0 #6d9a5b,
    0 1px 2px rgba(0, 0, 0, .28);
}

.tile.just-drawn { transform: translateY(-4px); box-shadow: 0 2px 0 var(--ivory-edge), 0 5px 9px rgba(0, 0, 0, .4); }

/* 点中还没打出去的那张：抬起来 + 描一圈金边，手机上「碰一下就出牌」太容易误触。
   再点一下才真的打，点别的牌就换选中 */
.tile.picked {
  transform: translateY(-11px) scale(1.04);
  box-shadow:
    0 0 0 2px var(--gold),
    0 7px 12px rgba(0, 0, 0, .45);
  z-index: 3;
}
/* 已经发出去了、等服务端回话：先淡掉，别让人以为点空了 */
.tile.sending {
  opacity: .35;
  transform: translateY(-14px) scale(.96);
  transition: transform .12s ease, opacity .12s ease;
}
.tile.dim { opacity: .45; pointer-events: none; }

/* 定缺的牌：盖一层灰膜（牌面还看得见），底边挂一个「缺」小条。
   这几张是必须先打掉的，所以盖了灰反而最好点，不能再压暗 */
#myHand .tile.lack { box-shadow: 0 2px 0 #6d9a5b, 0 3px 5px rgba(0, 0, 0, .3); }
#myHand .tile.lack::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(58, 64, 62, .52);
  box-shadow: inset 0 0 0 1px rgba(232, 201, 106, .6);
  pointer-events: none;
}
#myHand .tile.lack::before {
  content: '缺';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 10px; line-height: 10px;
  text-align: center;
  font-size: 8px;
  letter-spacing: 1px;
  color: #f7f4ea;
  background: rgba(34, 40, 38, .86);
  pointer-events: none;
  z-index: 2;
}

/* 缺门还没打完时，别的牌先锁着：手点上去没反应，但看得清是什么牌 */
.tile.frozen { opacity: .5; cursor: default; }

#myHand .tile:active { transform: translateY(-7px); }

/* 副露 */
.seat-melds { display: flex; gap: 7px; flex-wrap: wrap; justify-content: center; min-height: 0; }
.meld-group { display: flex; gap: 1px; }
.meld-group .tile { width: calc(var(--tw) * .62); height: calc(var(--th) * .62); border-radius: 2.5px; }

/* 左右两家的花牌：一列竖着摆在手牌外侧 */
.seat-bonus.v {
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 1px;
}
.seat-bonus.v .tile { width: 14px; height: 19px; }
.seat-top .seat-bonus .tile { width: 16px; height: 22px; }

/* 亮出的花牌：牌面同样用素材图，别在这写 background 简写，会把 background-size 打回 auto */
.seat-bonus { display: flex; gap: 2px; flex-wrap: wrap; justify-content: center; min-height: 0; max-width: 100%; }
.seat-bonus .tile {
  width: 17px; height: 22px; border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .38);
  cursor: default;
}
.seat-bonus:empty { display: none; }

.seat-bottom .seat-bonus .tile { width: 24px; height: 31px; }
.seat-bottom .seat-bonus { gap: 3px; }

/* 花牌是亮在桌上不计入手牌的东西，给它一个小标记，免得看着像又一行打出去的牌 */
.seat-top .seat-bonus::before,
.seat-bottom .seat-bonus::before {
  content: '花';
  align-self: center;
  margin-right: 2px;
  font-size: 10px;
  color: rgba(251, 247, 234, .4);
}

/* ================= 操作按钮 ================= */

.actions {
  flex: 0 0 auto;
  display: flex; gap: 8px; justify-content: center; align-items: center;
  padding: 5px 12px calc(7px + env(safe-area-inset-bottom));
  background: rgba(8, 40, 32, .68);
  backdrop-filter: blur(8px);
  min-height: 44px;
}

/* 听牌条：手牌和按钮之间，一行说清「听什么、各多少点」 */
.listen-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 9px;
  padding: 3px 14px 1px;
  font-size: 11.5px;
  line-height: 15px;
  color: rgba(251, 247, 234, .82);
  overflow: hidden;
  white-space: nowrap;
}
.listen-bar.hidden { display: none; }

.ls-title {
  flex: 0 0 auto;
  font-size: 10px;
  letter-spacing: 2px;
  color: #0f3a2e;
  background: #e8c96a;
  border-radius: 3px;
  padding: 1px 5px;
}

/* 报过地听：牌子换成描边款，一眼看出「已经锁牌了」 */
.ls-title.on {
  background: transparent;
  color: #e8c96a;
  box-shadow: inset 0 0 0 1px rgba(232, 201, 106, .6);
}

.ls-item {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
}
.ls-item b { font-weight: 500; color: #fbf7ea; }
.ls-item span { font-size: 10.5px; color: #e8c96a; }

/* 手牌上「打了就听」的角标 */
#myHand .tile.ting::after {
  content: '听';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 11px;
  line-height: 11px;
  text-align: center;
  font-size: 8px;
  letter-spacing: 1px;
  color: #2c2109;
  background: linear-gradient(180deg, rgba(232, 201, 106, .92), rgba(209, 172, 66, .96));
}

.btn {
  border: 0; border-radius: 9px;
  padding: 8px 20px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  letter-spacing: 2px;
  transition: transform .1s ease, filter .1s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .28);
}
.btn:active { transform: scale(.96); filter: brightness(.94); }
.btn.primary { background: linear-gradient(180deg, #f0c674, var(--gold)); color: #3a2a06; }
.btn.ghost { background: rgba(251, 247, 234, .12); color: var(--ivory); border: 1px solid rgba(251, 247, 234, .18); }
.btn.hu { background: linear-gradient(180deg, #e05a4f, #c73a30); color: #fff; }
.btn.kong { background: linear-gradient(180deg, #4a92d6, #3a7ab8); color: #fff; }
.btn.pass { background: rgba(251, 247, 234, .09); color: rgba(251, 247, 234, .72); }

.act-hint { font-size: 11.5px; color: rgba(251, 247, 234, .3); letter-spacing: 2px; }

/* ================= 提示条 ================= */

.toast {
  position: fixed;
  left: 50%; top: 10px;
  z-index: 70;
  transform: translate(-50%, -4px) scale(.94);
  background: rgba(6, 28, 22, .94);
  border: 1px solid rgba(251, 247, 234, .14);
  color: var(--ivory);
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 12.5px;
  letter-spacing: 1px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  white-space: nowrap;
  z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }

/* ================= 结算 ================= */

/* 流局不该显示成赢牌的红字 */
.result-card.draw .result-score { color: #6b6a63; }

.overlay {
  position: absolute; inset: 0;
  background: rgba(4, 18, 14, .8);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 30;
}

.result-card {
  width: 100%; max-width: 340px;
  max-height: 100%;
  /* 竖向 flex：明细自己滚，两个按钮永远钉在卡片底部 */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--ivory);
  color: var(--ink);
  border-radius: 16px;
  padding: 22px 20px 18px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .5);
}
.result-card h2 { margin: 0 0 12px; font-size: 18px; font-weight: 500; letter-spacing: 2px; flex: 0 0 auto; }
.result-mine { flex: 0 0 auto; }

.result-score {
  font-size: 36px; font-weight: 500; line-height: 1;
  font-variant-numeric: tabular-nums;
  margin-bottom: 5px;
  color: #a32d2d;
  flex: 0 0 auto;
}
/* 整场结算输钱时别用赢牌的红 */
.result-score.lose { color: #4b7a5e; }
/* 一炮多响时几个点数并排，用斜杠隔开 */
.result-score i {
  font-style: normal;
  font-size: .58em;
  opacity: .45;
  margin: 0 3px 0 1px;
}
.result-score .unit { font-size: 14px; font-weight: 400; opacity: .5; margin-left: 3px; }

.result-mine {
  font-size: 13px; letter-spacing: 1px;
  margin: 3px 0 14px; min-height: 18px;
}
.result-mine .win { color: #b3352b; font-weight: 500; }
.result-mine .lose { color: #4b7a5e; font-weight: 500; }

/* 胡的什么牌：先摆牌，再列牌型点数。
   一炮多响就一段一段摞，最多三段，多了自己在卡片里滚 */
.result-hand {
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0 0 12px;
}
.rh-item {
  background: #f2eee2;
  border: 1px solid #e4dece;
  border-radius: 9px;
  padding: 6px 7px 7px;
  margin-bottom: 6px;
  text-align: left;
}
.rh-item:last-child { margin-bottom: 0; }
.rh-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  font-size: 11px; color: #6a6a64;
  margin-bottom: 5px;
  letter-spacing: .3px;
}
.rh-head b { font-weight: 600; color: #a34a2a; }
.rh-win-tile { color: #8a7a56; white-space: nowrap; }

/* 牌：一副摆一行，副露和手牌之间留一道缝，胡的那张单独挪到最右 */
.rh-hand {
  display: flex; flex-wrap: wrap; align-items: flex-end;
  justify-content: center;
  gap: 2px 2px;
}
.rh-meld { display: inline-flex; gap: 1px; margin-right: 3px; flex: 0 0 auto; }
.rh-meld:last-of-type { margin-right: 0; }
/* 副露和手牌之间立一道细线，一眼分得出哪几张是明着的 */
.rh-gap {
  display: inline-block;
  width: 1px;
  align-self: stretch;
  margin: 1px 5px;
  background: #d9d2be;
  flex: 0 0 auto;
}

.rh-tile {
  display: inline-block;
  flex: 0 0 auto; /* 不够宽就换行，别把牌挤瘪 */
  width: 16px; height: 22px;
  border-radius: 2px;
  background-color: #fbf7ea;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
  box-shadow: 0 1px 0 #cfc9b8, 0 1px 2px rgba(0, 0, 0, .22);
}
/* 胡的那张：金框 + 抬起来一点，一眼看出是哪张进来的 */
.rh-tile.win {
  box-shadow:
    0 0 0 1.5px #c8912f,
    0 3px 6px rgba(180, 126, 30, .45);
  transform: translateY(-2px);
}

.rh-bonus {
  display: flex; align-items: center; justify-content: center;
  gap: 2px; margin-top: 5px;
}
.rh-bonus .rh-tile { opacity: .78; width: 14px; height: 19px; }
.rh-tag {
  font-size: 9px; color: #9a927e;
  margin-right: 2px;
}

.result-detail {
  font-size: 12px; color: #6a6a64; line-height: 1.7;
  margin-bottom: 14px;
  /* 明细自己在卡片里滚，别把按钮顶出去 */
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
/* 明细装不下才淡出最后一点，提示还能往下滚（JS 打标记） */
.result-detail.scrollable {
  -webkit-mask-image: linear-gradient(180deg, #000 calc(100% - 16px), transparent);
  mask-image: linear-gradient(180deg, #000 calc(100% - 16px), transparent);
  padding-right: 2px;
}

.result-detail .row { display: flex; justify-content: space-between; gap: 12px; }
/* 左边是标签（「牌型」「三张在手」这种），别让它被挤成竖排 */
.result-detail .row span:first-child { flex: 0 0 auto; white-space: nowrap; }
.result-detail .row span:last-child { font-variant-numeric: tabular-nums; text-align: right; word-break: break-word; }
.result-detail .sep { height: 1px; background: #e6e2d8; margin: 7px 0; }

.result-btns { display: flex; gap: 9px; flex: 0 0 auto; }
.result-btns .btn { flex: 1; padding: 9px 12px; }
.result-btns .ghost { background: #eeebe2; color: #55554f; box-shadow: none; }
.result-btns .primary { background: #12463a; color: var(--ivory); }

/* ================= 竖屏提示 ================= */

.rotate-tip {
  position: fixed; inset: 0;
  background: var(--felt-darkest);
  display: none;
  flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; z-index: 60;
}
.rotate-tip .rot-icon {
  font-size: 36px; color: rgba(251, 247, 234, .5);
  animation: rot 2.4s ease-in-out infinite;
}
@keyframes rot {
  0%, 40% { transform: rotate(0); }
  60%, 100% { transform: rotate(-90deg); }
}
.rotate-tip p { margin: 0; font-size: 14px; color: rgba(251, 247, 234, .6); letter-spacing: 3px; }

/* 竖屏不再拦人了：
   手机（尤其微信内置浏览器）很多时候转不了屏，那就把牌桌按竖屏重排一遍。
   手牌宽度按屏幕宽算，牌墙放到中间那块最大的正方形，左右两家收窄一点让位。 */
@media (orientation: portrait) {
  .rotate-tip { display: none !important; }

  :root {
    /* 14 张手牌刚好铺满一行 */
    --tw: calc((100vw - 26px) / 14);
    --th: calc(var(--tw) / .73);
  }

  #table { padding-bottom: env(safe-area-inset-bottom); }
  .board { padding: 2px 6px 0; gap: 3px; }
  .bar { font-size: 11.5px; padding-left: 8px; padding-right: 8px; gap: 6px; }

  /* 左右两家让点位置给牌墙 */
  .seat-left, .seat-right { width: 46px; }
  .seat-body { gap: 2px; }

  .seat-bottom { gap: 1px 6px; padding-bottom: 2px; }
  .seat-bottom .seat-bonus .tile { width: 20px; height: 26px; }

  /* 牌池：竖屏时上下两块又高又空，牌要贴着牌墙摆，别飘到半空 */
  .pool .tile { width: 13px; height: 18px; }
  .pool.t { left: 2%; right: 2%; flex-wrap: wrap; align-content: flex-end; }
  .pool.b { left: 2%; right: 2%; flex-wrap: wrap; align-content: flex-start; }
  .pool.l, .pool.r { width: 11%; top: 2%; bottom: 2%; }

  /* 提示条放屏下方：竖屏顶上坐着一家，压上去会挡牌 */
  .toast { top: auto; bottom: 120px; transform: translate(-50%, 4px) scale(.94); }
  .toast.show { transform: translate(-50%, 0) scale(1); }

  .actions { min-height: 46px; padding: 4px 8px max(6px, env(safe-area-inset-bottom)); gap: 6px; }
  .btn { padding: 8px 14px; font-size: 13.5px; letter-spacing: 1px; }

  /* 听牌条在竖屏会占掉一整行，压扁一点 */
  .listen-bar { font-size: 11px; padding: 4px 8px; gap: 8px; }

  /* 结算卡片撑满宽度，别在窄屏里缩成一条 */
  .result-card { max-width: 100%; width: 100%; }
  .overlay { padding: 12px; }

  /* 等待区 */
  .lobby-seats { grid-template-columns: 1fr; }
  .lobby-head { flex-wrap: wrap; gap: 8px; }
  .lobby-code b { font-size: 24px; }
  #joinName { flex: 1 1 100%; max-width: none; }
  .lobby-input.key { flex: 1 1 84px; }
  .lobby-join .btn { flex: 1 1 100%; }
}

/* ================= 桌面端 ================= */

@media (min-width: 720px) and (min-height: 420px) {
  body { display: flex; align-items: center; justify-content: center; background: #04140f; }
  #app {
    position: relative;
    width: min(96vw, 1040px);
    height: min(94vh, 600px);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 26px 70px rgba(0, 0, 0, .6), 0 0 0 1px rgba(255, 255, 255, .05);
    /* 桌面窗口通常够宽，不让竖屏提示挡路 */
  }
  #app .rotate-tip { position: absolute; display: none !important; }
  :root { --th: clamp(34px, 8.6vh, 52px); }
}

/* 很矮的横屏手机，把牌再压小一点 */
@media (max-height: 400px) {
  :root { --th: clamp(30px, 11vh, 44px); }
  .bar { padding-top: 3px; padding-bottom: 3px; }
  .actions { min-height: 38px; padding-top: 3px; padding-bottom: 4px; }
  .btn { padding: 6px 16px; font-size: 13px; }
}

/* ================= 矮屏结算：把间距压紧，保证按钮不被挤出卡片 ================= */

@media (max-height: 520px) {
  .overlay { padding: 12px; }
  .result-card {
    max-width: 330px;
    padding: 15px 18px 13px;
    border-radius: 14px;
  }
  .result-card h2 { font-size: 16px; margin-bottom: 8px; letter-spacing: 1.5px; }
  .result-score { font-size: 30px; margin-bottom: 3px; }
  .result-score .unit { font-size: 12px; }
  .result-mine { font-size: 12px; margin: 1px 0 9px; min-height: 15px; }
  .result-detail { font-size: 11.5px; line-height: 1.42; margin-bottom: 10px; }
  .result-detail .sep { margin: 5px 0; }
  .result-btns .btn { padding: 7px 10px; font-size: 13px; letter-spacing: 1px; }
}
