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

@font-face {
  font-family: "FengKai MJ";
  src: url("fonts/fengkai-mj-subset.ttf?v=fkmj1") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --tw: clamp(30px, 5.4vw, 96px);       /* 手牌宽 */
  --th: calc(var(--tw) * 1.36);
  --dw: clamp(23px, 3.8vw, 58px);       /* 弃牌宽 */
  --dh: calc(var(--dw) * 1.36);
  --wp: clamp(7px, .55vw, 10px);        /* 牌墙小牌宽 */
  --gold: #d9b060;
  --ink: #0a2214;
}

html, body {
  margin: 0; padding: 0; height: 100%;
  background: #061a0e;
  color: #eef1ea;
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, sans-serif;
  overscroll-behavior: none;
  overflow: hidden;
}
#app { height: 100%; height: 100dvh; display: flex; flex-direction: column; }
button { font-family: inherit; cursor: pointer; border: none; }
button:disabled { cursor: default; }

/* 细圆滚动条，苹果风格 */
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.24) transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(255,255,255,.28), rgba(255,255,255,.16));
  border-radius: 999px;
  min-height: 36px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,214,130,.42); }
::-webkit-scrollbar-corner { background: transparent; }

/* ---------- 牌 ---------- */
.tile {
  position: relative;
  width: var(--dw); height: var(--dh);
  background: linear-gradient(180deg, #fffdf4 0%, #f7efd9 58%, #e9dcbd 100%);
  border-radius: 4px;
  box-shadow: 0 2px 0 #b9a880, 0 1px 3px rgba(0,0,0,.35);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  user-select: none; flex: 0 0 auto;
  font-weight: 700; line-height: 1;
  color: #333;
}
.tile .num { font-size: calc(var(--dh) * 0.42); }
.tile .suit { font-size: calc(var(--dh) * 0.29); opacity: .85; margin-top: 1px; }
.tile.s-w { color: #a3252b; }
.tile.s-t { color: #16558f; }
.tile.s-b { color: #1c6b3a; }
.tile .face { width: calc(100% - 7px); height: calc(100% - 7px); display: block; flex: 0 0 auto; overflow: hidden; }
.tile .wan-face {
  width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: "FengKai MJ", "KaiTi", "STKaiti", "SimSun", "Songti SC", serif;
}
.tile .wan-num { color: #1e1e1e; font-size: calc(var(--dh) * 0.47); line-height: .94; }
.tile .wan-suit { color: #b3263f; font-size: calc(var(--dh) * 0.33); line-height: 1; margin-top: 1px; letter-spacing: .02em; }
.tile.big .wan-num { font-size: calc(var(--th) * 0.45); }
.tile.big .wan-suit { font-size: calc(var(--th) * 0.32); }
/* 汉字使用内嵌矢量轮廓，尺寸按牌自身宽度缩放 */
.tile .mj-glyph { display: block; flex: 0 0 auto; pointer-events: none; }
/* 矢量字按牌自身宽度缩放，不能再用全局弃牌宽度 --dh：
   抓码小牌（26px）、副露小牌、桌面结算牌都比 --dw 小，否则字会撑出牌面。 */
.tile svg.wan-num { width: 68%; height: auto; aspect-ratio: 1; }
.tile svg.wan-suit { width: 49%; height: auto; aspect-ratio: 1; }
.tile.big svg.wan-num { width: 65%; height: auto; aspect-ratio: 1; }
.tile.big svg.wan-suit { width: 46%; height: auto; aspect-ratio: 1; }
.tile svg.joker, .tile svg.honor { width: 79%; height: auto; aspect-ratio: 1; }
.tile.big svg.joker, .tile.big svg.honor { width: 76%; height: auto; aspect-ratio: 1; }
.tile .joker { font-size: calc(var(--dh) * 0.58); color: #b3271f; font-weight: 900; letter-spacing: 0; line-height: 1; font-family: "FengKai MJ", "KaiTi", "STKaiti", "SimHei", "Microsoft YaHei", serif; }
.tile.big .joker { font-size: calc(var(--th) * 0.56); }
.tile .honor { font-size: calc(var(--dh) * 0.58); font-weight: 900; letter-spacing: 0; line-height: 1; font-family: "FengKai MJ", "KaiTi", "STKaiti", "SimHei", "Microsoft YaHei", serif; }
.tile.big .honor { font-size: calc(var(--th) * 0.56); }
.honor.h5 { color: #1c6b3a; }
.honor.h6 { color: #16558f; }
.tile.big { width: var(--tw); height: var(--th); border-radius: 5px; }
.tile.big .num { font-size: calc(var(--th) * 0.44); }
.tile.big .suit { font-size: calc(var(--th) * 0.29); }
.tile.back {
  background: linear-gradient(145deg, #2b7d55, #145236 60%, #0f4329 100%);
  border: 1px solid #0b3721;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.06), 0 1px 2px rgba(0,0,0,.35);
}
.tile.back::after { content: ""; position: absolute; inset: 3px; border-radius: 3px; border: 1px solid rgba(217,176,96,.30); }
.tile.back.deal-slot { visibility: hidden; }
.tile.back.deal-in { animation: dealBackIn .22s cubic-bezier(.2,.8,.3,1) both; }
/* 3D 起牌阶段：自己的牌背要和牌墙同一套绿色釉面、同一档圆角，
   不能再用 2D 那张深绿直角牌顶着。 */
body.mode-3d.in-game .hand-row .tile.big.back {
  border: 1px solid rgba(31,63,33,.72);
  border-radius: calc(var(--tw) * .13);
  background:
    linear-gradient(122deg, rgba(235,255,244,.10) 0%, rgba(255,255,255,0) 38%, rgba(0,0,0,.05) 100%),
    linear-gradient(145deg, #5d9b41 0%, #568f3c 28%, #4d8235 58%, #477930 82%, #426f2c 100%);
  box-shadow:
    inset 1px 0 0 rgba(230,255,230,.20),
    inset -1px 0 0 rgba(18,48,30,.18),
    inset 0 1px 0 rgba(245,255,240,.22),
    0 2px 0 #d8d0b8,
    0 3px 7px rgba(0,0,0,.30);
}
body.mode-3d.in-game .hand-row .tile.big.back::after {
  inset: 3px;
  border-radius: calc(var(--tw) * .10);
  border: 1px solid rgba(220,240,205,.18);
  box-shadow: inset 0 0 0 1px rgba(8,38,28,.16);
}
@keyframes dealBackIn {
  from { opacity: 0; transform: translateY(26px) scale(.9); }
  to { opacity: 1; transform: none; }
}
.tile.last {
  box-shadow: 0 2px 0 #b9a880, 0 1px 3px rgba(0,0,0,.35);
  filter: brightness(1.06);
}
.tile.latest { animation: dropIn .18s ease-out; }
@keyframes dropIn { from { transform: translateY(-10px) scale(.9); opacity: .4; } to { transform: none; opacity: 1; } }

/* 手牌额外状态 */
.tile.big { transition: transform .12s ease, box-shadow .12s ease; }
.tile.big.swiping { transition: none; z-index: 8; cursor: grabbing; }
.hand-row.hand-swipe-active { overflow-x: clip; overflow-y: visible; }
.tile.big.picked { transform: translateY(-10px); box-shadow: 0 2px 0 #b9a880, 0 6px 12px rgba(0,0,0,.45), 0 0 0 2px var(--gold); }
.tile.big.locked { filter: saturate(.55) brightness(.88); }
.tile.big.locked::after {
  content: ""; position: absolute; inset: 0; border-radius: 5px;
  background: repeating-linear-gradient(45deg, rgba(255,90,90,.10), rgba(255,90,90,.10) 4px, transparent 4px, transparent 8px);
}
.tile.big.drawn { box-shadow: 0 2px 0 #b9a880, 0 0 0 2px rgba(120,230,170,.9), 0 2px 6px rgba(0,0,0,.4); animation: drawIn .3s ease-out; }
.tile.big.drawn .newtag {
  position: absolute; top: -9px; left: 50%; transform: translateX(-50%);
  font-size: 9px; padding: 1px 5px; border-radius: 8px;
  background: #1f8b55; color: #eafff2; white-space: nowrap; font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,.4);
}
@keyframes drawIn { from { transform: translateY(22px); opacity: .3; } to { transform: none; opacity: 1; } }
.hand-gap { width: calc(var(--tw) * 0.5); flex: 0 0 auto; }
.hand-row {
  display: flex; align-items: flex-end; overflow-x: auto; overflow-y: hidden;
  padding: 12px 2px 2px;
  min-height: calc(var(--th) + 12px);
  scrollbar-width: none; -ms-overflow-style: none;
  touch-action: pan-x;
}
.hand-row::-webkit-scrollbar { display: none; width: 0; height: 0; }
.hand-inner { display: flex; align-items: flex-end; gap: clamp(1px, .35vw, 4px); margin: 0 auto; }
.hand-row .tile { cursor: pointer; }
.hand-row.hand-idle .tile { cursor: default; }
.hand-row .tile.big:hover { transform: translateY(-6px); }
.hand-row .tile.big.picked:hover { transform: translateY(-10px); }
.hand-row.hand-idle .tile.big:hover { transform: none; }
.hand-row .draw-slot {
  padding: 0; border: 1px solid rgba(255,255,255,.38);
  background: linear-gradient(180deg, #9be7b8, #2f9b63);
  color: #06260f; box-shadow: 0 3px 0 #14663c, 0 2px 8px rgba(0,0,0,.35);
  font-weight: 800; cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.hand-row .draw-slot span { display: block; font-size: calc(var(--th) * 0.27); line-height: 1.1; }
.hand-row .draw-slot:hover { transform: translateY(-6px); filter: brightness(1.06); box-shadow: 0 7px 14px rgba(0,0,0,.42), 0 0 0 2px rgba(125,235,170,.45); }
.hand-row.hand-idle .draw-slot { cursor: pointer; }
.hand-row.hand-idle .draw-slot:hover { transform: translateY(-6px); }
.hand-row .draw-slot:active { transform: translateY(1px); box-shadow: 0 1px 0 #14663c; }
.hand-row .draw-slot.waiting {
  cursor: default; pointer-events: none;
  background: linear-gradient(180deg, #82c99c, #256943);
  box-shadow: 0 3px 0 #114e2f, 0 2px 8px rgba(0,0,0,.35);
  animation: drawWait .55s ease-in-out infinite alternate;
}
.hand-row .draw-slot.waiting:hover { transform: none; filter: none; }
@keyframes drawWait {
  from { opacity: .72; transform: translateY(1px); }
  to { opacity: 1; transform: translateY(-2px); }
}
.backs.pulse { animation: backsPulse .6s ease; }
@keyframes backsPulse { 0%,100% { transform: none; } 40% { transform: translateY(-4px); } }

/* ---------- 结算摊牌：上/下横排，左/右横躺 90° 竖叠 ---------- */
.seat.over { opacity: 1; }
.final-hand {
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; max-width: 100%;
}
.final-hand.fh { flex-direction: row; flex-wrap: wrap; gap: 1px; }
.final-hand.fv { flex-direction: column; gap: 1px; }
.reveal-tile { border-radius: 3px; box-shadow: 0 1px 0 #b9a880, 0 1px 3px rgba(0,0,0,.3); }
.reveal-h {
  width: calc(var(--dw) * 0.82); height: calc(var(--dh) * 0.82);
}
.reveal-h .wan-num { font-size: calc(var(--dh) * 0.36); }
.reveal-h .wan-suit { font-size: calc(var(--dh) * 0.24); }
.reveal-h .honor, .reveal-h .joker { font-size: calc(var(--dh) * 0.44); }
.reveal-v {
  --rv-h: clamp(13px, 3vh, 36px);
  position: relative; overflow: hidden;
  width: calc(var(--rv-h) * 1.45); height: var(--rv-h);
}
.reveal-v .face,
.reveal-v .wan-face,
.reveal-v .honor,
.reveal-v .joker {
  position: absolute; top: 50%; left: 50%;
  width: var(--rv-h); height: calc(var(--rv-h) * 1.45);
  margin: 0;
  transform: translate(-50%, -50%) rotate(90deg);
}
.reveal-v .face { width: calc(var(--rv-h) * 0.92); height: calc(var(--rv-h) * 1.34); }
.reveal-v .wan-num { font-size: calc(var(--rv-h) * 0.55); }
.reveal-v .wan-suit { font-size: calc(var(--rv-h) * 0.34); }
.reveal-v .honor, .reveal-v .joker {
  display: flex; align-items: center; justify-content: center;
  font-size: calc(var(--rv-h) * 0.66);
}

/* ---------- 入口 / 大厅 ---------- */
.center-wrap {
  flex: 1; display: flex; align-items: center; justify-content: center; padding: 18px;
  background: radial-gradient(circle at 50% 28%, rgba(30,140,85,.35), transparent 62%),
              linear-gradient(160deg, #0b2a1a, #05170e);
  overflow-y: auto;
}
.card {
  width: min(430px, 100%);
  background: rgba(10, 33, 21, .94);
  border: 1px solid rgba(217,176,96,.32);
  border-radius: 16px;
  padding: 24px 20px;
  box-shadow: 0 18px 44px rgba(0,0,0,.55);
}
.brand { text-align: center; margin-bottom: 16px; }
.brand h1 { margin: 0; font-size: 26px; letter-spacing: 5px; color: var(--gold); }
.brand p { margin: 7px 0 0; font-size: 12px; color: #98b1a1; letter-spacing: 1px; line-height: 1.6; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: #98b1a1; margin-bottom: 6px; }
input[type=text], input[type=password] {
  width: 100%; padding: 11px 13px; border-radius: 9px;
  border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.06);
  color: #fff; font-size: 15px; outline: none; font-family: inherit;
}
input[type=text]:focus, input[type=password]:focus { border-color: var(--gold); }
input[type=text][readonly] { color: #c9b98d; background: rgba(255,255,255,.035); }
.btn {
  display: block; width: 100%; padding: 12px; border-radius: 10px; font-size: 15px; font-weight: 700;
  background: linear-gradient(180deg, #2e9d63, #1b7a47); color: #fff;
  box-shadow: 0 3px 0 #0f5230; transition: transform .1s;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #0f5230; }
.btn.ghostbtn { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.18); box-shadow: none; color: #dbe6de; }
.btn.gold { background: linear-gradient(180deg, #e5c274, #c2953c); color: #2a1d05; box-shadow: 0 3px 0 #8a6420; }
.btn.dangerbtn { background: linear-gradient(180deg, #c75b50, #8f2e29); color: #fff; box-shadow: 0 3px 0 #5b1a17; }
.btn:disabled { opacity: .5; }
.split { display: flex; align-items: center; gap: 10px; margin: 16px 0 10px; color: #7f978a; font-size: 12px; }
.split::before, .split::after { content: ""; flex: 1; height: 1px; background: rgba(255,255,255,.12); }
.code-row { display: flex; gap: 8px; }
.code-row input { letter-spacing: 3px; text-transform: uppercase; text-align: center; font-weight: 700; }
.code-row .btn { width: 105px; flex: 0 0 auto; }
.hint { font-size: 12px; color: #8aa294; line-height: 1.7; margin-top: 14px; }

.room-code { display: flex; align-items: baseline; justify-content: center; gap: 10px; margin-bottom: 14px; }
.room-code .num { font-size: 30px; font-weight: 800; letter-spacing: 6px; color: var(--gold); font-family: ui-monospace, Menlo, Consolas, monospace; }
.room-code .lbl { font-size: 12px; color: #8aa294; }
.seat-list { display: flex; flex-direction: column; gap: 8px; }
.seat-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; border-radius: 10px; font-size: 14px;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.07);
}
.seat-row.empty { color: #6d8378; font-style: italic; }
.seat-row .who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.seat-row .seatno { font-size: 11px; color: #7d968a; }
.seat-tail { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; }
.kickbtn {
  width: 24px; height: 22px; padding: 0; border-radius: 5px;
  border: 1px solid rgba(255,120,120,.28); background: rgba(255,90,90,.08);
  color: #ff9b9b; font-family: inherit; font-size: 11px; line-height: 1; cursor: pointer;
}
.kickbtn:hover { background: rgba(255,90,90,.18); color: #ffd0d0; }
.tag { font-size: 10px; padding: 1px 7px; border-radius: 20px; background: rgba(217,176,96,.18); color: var(--gold); white-space: nowrap; }
.tag.gray { background: rgba(255,255,255,.1); color: #b4c4ba; }
.tag.ready { background: rgba(76,190,120,.16); color: #9fe6b8; }
.tag.wait { background: rgba(255,190,120,.12); color: #ffc98a; }
.ready-hint {
  margin: -3px 0 0; text-align: center; color: #c9b98d;
  font-size: 11px; line-height: 1.5;
}
.section-label {
  margin: 18px 0 8px; font-size: 12px; color: #c9d8ce; letter-spacing: 1px;
  display: flex; align-items: baseline; gap: 8px;
}
.section-hint { font-size: 11px; color: #7f978a; letter-spacing: 0; }
.mode-select { display: flex; flex-direction: column; gap: 8px; }
.mode-card {
  position: relative; text-align: left; padding: 11px 13px; border-radius: 10px;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.1); color: #e6efe9;
}
.mode-card .mc-title { display: block; font-size: 14px; font-weight: 700; }
.mode-card .mc-desc { display: block; font-size: 11px; color: #93ab9d; margin-top: 3px; line-height: 1.5; }
.mode-card.on { border-color: rgba(217,176,96,.65); background: rgba(217,176,96,.12); }
.mode-card .mc-check { position: absolute; right: 12px; top: 11px; color: var(--gold); font-weight: 700; }
.mode-picker { position: relative; }
.mode-row { display: flex; flex-wrap: wrap; gap: 7px; }
.mode-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 8px 12px; border-radius: 9px;
  border: 1px solid rgba(255,255,255,.13); background: rgba(255,255,255,.05);
  color: #dce9e0; font-family: inherit; font-size: 13px; font-weight: 700;
}
.mode-pill.on {
  border-color: rgba(217,176,96,.7); background: rgba(217,176,96,.14); color: #ffe3ac;
}
.mode-pill[disabled] { opacity: .42; cursor: default; }
.mode-pill .soon {
  display: inline-block; padding: 1px 4px; border-radius: 4px;
  background: rgba(255,255,255,.1); color: #c8b07c;
  font-size: 9px; font-weight: 400; line-height: 1.4;
}
.mode-select {
  width: 100%; padding: 11px 38px 11px 13px; border-radius: 10px;
  background: rgba(255,255,255,.06); border: 1px solid rgba(217,176,96,.4);
  color: #f2e6c8; font-size: 15px; font-weight: 700; font-family: inherit;
  appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, #d9b060 50%), linear-gradient(135deg, #d9b060 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px, 6px 6px; background-repeat: no-repeat;
}
.mode-select:focus { outline: none; border-color: var(--gold); }
.mode-select:disabled { opacity: .85; cursor: default; }
.mode-select option { background: #0f2d1d; color: #f2e6c8; }
.mode-current {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-radius: 10px; font-size: 14px; font-weight: 800;
  background: rgba(217,176,96,.14); border: 1px solid rgba(217,176,96,.55); color: #f3e6c8;
}
.mode-current .mc-arrow { color: var(--gold); font-size: 13px; transition: transform .15s; }
.mode-current.open .mc-arrow { transform: rotate(180deg); }
.mode-current:disabled { opacity: .9; }
.mode-desc { margin: 6px 2px 0; font-size: 11px; color: #93ab9d; line-height: 1.6; }
.mode-menu { margin-top: 8px; display: flex; flex-direction: column; gap: 7px; }
.mode-menu.hidden { display: none; }
.setting-panel {
  border-radius: 10px; background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.09); padding: 4px 12px 8px;
}
.set-row { display: flex; align-items: center; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed rgba(255,255,255,.07); }
.set-row:last-of-type { border-bottom: 0; }
.set-name { font-size: 13px; color: #dfeae2; display: flex; flex-direction: column; gap: 2px; }
.set-hint { font-size: 10px; color: #7f978a; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button {
  width: 28px; height: 28px; border-radius: 7px; font-size: 15px; font-weight: 700; line-height: 1;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14); color: #e6efe9;
}
.stepper button:disabled { opacity: .3; }
.stepper button:active:not(:disabled) { background: rgba(217,176,96,.25); border-color: rgba(217,176,96,.5); }
.set-val { min-width: 30px; text-align: center; font-size: 15px; font-weight: 800; color: var(--gold); }
.ma-rule { margin: 7px 0 2px; font-size: 11px; color: #9bb3a4; line-height: 1.6; }
.seg-row { display: flex; gap: 6px; padding: 8px 0 6px; border-bottom: 1px dashed rgba(255,255,255,.07); }
.seg {
  flex: 1; padding: 7px 0; border-radius: 8px; font-size: 12px;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); color: #cfdcd3;
}
.seg.on { background: rgba(217,176,96,.18); border-color: rgba(217,176,96,.6); color: #f2dfb0; font-weight: 700; }
.seg:disabled { opacity: .75; }
.time-input {
  width: 118px; padding: 6px 8px; border-radius: 8px; font-size: 13px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.16);
  color: #eaf3ec; color-scheme: dark;
}
.lobby-actions { display: flex; flex-direction: column; gap: 9px; margin-top: 18px; }

.avatar {
  position: relative;
  width: 24px; height: 24px; border-radius: 50%; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: #08140d;
  background-color: #9fd2b2;
}
.avatar.has-photo {
  background-size: cover; background-position: center; background-repeat: no-repeat;
  color: transparent; text-shadow: none;
}
.avatar .seat-clock { z-index: 2; }
.seat-clock {
  display: none; position: absolute; right: -8px; bottom: -8px;
  width: 17px; height: 17px; border-radius: 50%;
  align-items: center; justify-content: center;
  background: #1b1206; color: #ffe6a8; font-size: 10px; font-style: normal; font-weight: 800;
  box-shadow: 0 0 0 1.5px rgba(255,222,150,.8);
}
.avatar.av0 { background-color: #ffd166; }
.avatar.av1 { background-color: #8fd0ff; }
.avatar.av2 { background-color: #ffb3a7; }
.avatar.av3 { background-color: #b7e4a2; }
.avatar.me { box-shadow: 0 0 0 2px rgba(255,255,255,.35); }
.seat-avatar-btn {
  appearance: none; padding: 2px; margin: -2px; border: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; min-height: 30px;
  background: transparent; color: inherit; font: inherit; cursor: pointer;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.seat-avatar-btn .avatar { transition: transform .15s ease, box-shadow .15s ease; }
.seat-avatar-btn:active .avatar { transform: scale(.92); }
.seat-avatar-btn:focus-visible { outline: 2px solid rgba(255,218,140,.85); outline-offset: 2px; }

/* ---------- 页面导航 ---------- */
.pagenav {
  flex: 0 0 auto; position: relative; display: flex; align-items: center; justify-content: center;
  gap: 6px; padding: 8px 10px 2px;
  background: transparent;
}
.pnav-main { display: flex; align-items: center; justify-content: center; gap: 6px; }
.pnav-tools { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); display: flex; align-items: center; gap: 5px; }
.pnav {
  padding: 5px 14px; border-radius: 999px; border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06); color: #b9ccbf; font-family: inherit;
  font-size: 12px; font-weight: 700; line-height: 1.2; cursor: pointer;
}
.pnav.on { color: #ffdf9e; border-color: rgba(255,214,130,.55); background: rgba(255,214,130,.14); }
.pnav:disabled { opacity: .34; cursor: default; }
.pnav.ptool { padding: 5px 10px; font-size: 11px; }
.pnav.ptool.on { color: #ffe6a8; border-color: rgba(255,214,130,.45); background: rgba(255,214,130,.13); }

/* ---------- 入口资料 ---------- */
.entry-profile { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 4px; }
.entry-card { padding: 22px 20px; }
.entry-card .brand { margin-bottom: 14px; }
.main-brand { margin: 2px 0 18px; }
.logo-stack {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
}
.logo-tiles {
  display: flex; align-items: center; justify-content: center;
  height: 58px; padding: 0 6px;
}
.logo-tile {
  position: relative; display: flex; align-items: center; justify-content: center;
  width: 40px; height: 52px; margin-left: -6px; border-radius: 6px;
  background: linear-gradient(155deg, #fffdf3 0%, #f8efd9 55%, #e3d4b8 100%);
  border: 1px solid rgba(217,176,96,.72);
  box-shadow: 0 4px 10px rgba(0,0,0,.45), 0 0 18px rgba(198,55,38,.18);
}
.logo-tile:first-child { margin-left: 0; }
.logo-tile:nth-child(1) { transform: rotate(-8deg) translateY(3px); }
.logo-tile:nth-child(2) { transform: rotate(-3deg); }
.logo-tile:nth-child(3) { transform: rotate(3deg); }
.logo-tile:nth-child(4) { transform: rotate(8deg) translateY(3px); }
.logo-tile span {
  position: relative; color: #c92f27; font-family: "KaiTi", "STKaiti", "SimSun", serif;
  font-size: 28px; font-weight: 900; line-height: 1; text-shadow: 0 1px 0 #fff;
}
.main-brand .game-logo {
  margin: 0; font-size: clamp(40px, 8.5vw, 52px); line-height: 1.12;
  font-family: "KaiTi", "STKaiti", "SimSun", serif;
  letter-spacing: 5px; color: transparent;
  background: linear-gradient(180deg, #fff9df 0%, #f7dda0 38%, #d6a24d 68%, #8f5a1f 100%);
  -webkit-background-clip: text; background-clip: text;
  filter: drop-shadow(0 2px 0 rgba(52,24,6,.85)) drop-shadow(0 0 16px rgba(222,166,70,.32));
}
.entry-avatar-btn {
  flex: 0 0 auto; width: 66px; height: 66px; padding: 0; border: 0; background: transparent;
  cursor: pointer; border-radius: 50%;
}
.avatar.entry-av {
  width: 66px; height: 66px; font-size: 26px;
  box-shadow: 0 0 0 2px rgba(255,214,130,.45), 0 6px 16px rgba(0,0,0,.35);
}
.entry-name { flex: 1; margin: 0; }
.entry-name-row { display: flex; align-items: stretch; gap: 6px; }
.entry-name-row input { flex: 1; min-width: 0; }
.mini-btn {
  flex: 0 0 auto; padding: 0 10px; border-radius: 8px; cursor: pointer;
  border: 1px solid rgba(255,214,130,.35); background: rgba(255,214,130,.09);
  color: #ffe0a2; font-family: inherit; font-size: 11px; line-height: 1.2;
}
.mini-btn:hover { background: rgba(255,214,130,.16); }
.entry-random { min-height: 34px; }
.entry-hint { margin: 2px 0 14px; color: #93aa9b; font-size: 11px; line-height: 1.55; }
.entry-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 13px; color: #8aa294; font-size: 11px; line-height: 1.5;
}
.entry-foot .music-link {
  flex: 0 0 auto; margin: 0; padding: 4px 9px; border-radius: 7px;
  border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.05);
  text-decoration: none;
}
.room-back { width: 100%; margin-bottom: 9px; }

/* ---------- 我的资料 ---------- */
.modal .card.profile-card {
  position: relative;
  width: min(480px, 100%); max-height: 90vh; overflow-y: auto;
}
.profile-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.profile-head h2 { margin: 0; font-size: 20px; color: #ffe0a2; }
.profile-head p { margin: 5px 0 0; font-size: 11px; color: #93aa9b; line-height: 1.5; }
.profile-layout { min-width: 0; }
.profile-main { min-width: 0; }
.profile-body { display: flex; gap: 18px; align-items: flex-start; }
.profile-avatar-btn {
  flex: 0 0 auto; width: 86px; padding: 0; border: 0; background: transparent;
  color: #9fb8a8; font-family: inherit; font-size: 11px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
}
.avatar.profile-av {
  width: 86px; height: 86px; font-size: 32px;
  box-shadow: 0 0 0 2px rgba(255,214,130,.4), 0 8px 20px rgba(0,0,0,.45);
}
.profile-fields { flex: 1; min-width: 0; }
.field .name-label { display: flex; align-items: center; gap: 8px; }
.field-hint { color: #8fa79a; font-size: 10px; font-weight: 400; letter-spacing: 0; }
.profile-pin-hint { margin: 8px 0 0; color: #8fa79a; font-size: 10px; line-height: 1.6; }
.preset-block { margin: 10px 0 0; }
.preset-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
.preset-av {
  aspect-ratio: 1; padding: 0; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; background-color: rgba(255,255,255,.08);
  background-position: center; background-size: cover;
}
.preset-av:hover { border-color: rgba(255,214,130,.55); }
.preset-av.on { border-color: #ffd27a; box-shadow: 0 0 0 2px rgba(255,211,122,.24); }
.avatar-picker {
  position: absolute; inset: 0; z-index: 20; display: flex;
  align-items: center; justify-content: center; padding: 12px;
  border-radius: inherit; background: rgba(5,18,11,.86);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.avatar-picker[hidden] { display: none; }
.avatar-picker-card {
  width: min(390px, 100%); max-height: calc(100% - 2px); overflow-y: auto;
  padding: 14px; border-radius: 13px;
  background: linear-gradient(180deg, #173325, #0e2118);
  border: 1px solid rgba(255,214,130,.3);
  box-shadow: 0 18px 44px rgba(0,0,0,.55);
}
.avatar-picker-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.avatar-picker-head h3 { margin: 0; color: #ffe0a2; font-size: 17px; }
.avatar-picker-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.avatar-picker-actions .btn { flex: 1; padding: 8px 10px; font-size: 12px; border-radius: 8px; }
.avatar-picker .preset-block { padding-top: 10px; border-top: 1px solid rgba(255,255,255,.09); }
.avatar-picker .preset-grid { gap: 7px; }
.avatar-picker-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 11px; padding-top: 9px; border-top: 1px solid rgba(255,255,255,.09);
}
.avatar-picker-foot span { color: #8fa79a; font-size: 10px; }
.profile-foot { display: flex; gap: 9px; margin-top: 14px; }
.profile-foot .btn { flex: 1; }
.profile-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px;
  margin-top: 13px;
}
.pstat {
  padding: 9px 3px 8px; border-radius: 9px; text-align: center;
  background: rgba(255,255,255,.045); border: 1px solid rgba(255,255,255,.09);
}
.pstat b { display: block; color: #ffe0a2; font-size: 19px; line-height: 1.15; }
.pstat b.pos { color: #9fe6b8; }
.pstat b.neg { color: #ff9b9b; }
.pstat span { display: block; margin-top: 4px; color: #8fa79a; font-size: 10px; }
.history-block {
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,.1);
}
.history-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.history-head h3 { margin: 0; color: #ffe0a2; font-size: 14px; }
.history-head span { color: #8fa79a; font-size: 10px; }
.history-empty {
  margin: 11px 0 2px; padding: 14px 10px; border-radius: 9px; text-align: center;
  color: #88a091; font-size: 11px; line-height: 1.6;
  background: rgba(255,255,255,.03); border: 1px dashed rgba(255,255,255,.1);
}
.history-list { max-height: 220px; margin-top: 5px; overflow-y: auto; }
.hrow {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,.07);
}
.hrow:last-child { border-bottom: 0; }
.hleft { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.hwhen { color: #dcefe1; font-size: 12px; }
.hmeta { color: #8fa79a; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hright { flex: 0 0 auto; text-align: right; }
.hscore { display: block; color: var(--gold); font-size: 18px; font-weight: 900; line-height: 1.2; }
.hscore.pos { color: #9fe6b8; }
.hscore.neg { color: #ff9b9b; }
.hhint { display: block; margin-top: 2px; color: #8fa79a; font-size: 10px; white-space: nowrap; }

/* ---------- 本局规则 ---------- */
.rules-card { width: min(470px, 100%); }
.rules-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.rules-head h2 { margin: 0; font-size: 20px; color: #ffe0a2; }
.rules-head p { margin: 5px 0 0; font-size: 11px; color: #93aa9b; }
.rule-list { border-top: 1px solid rgba(255,255,255,.08); }
.rule-item {
  display: flex; align-items: flex-start; gap: 12px; padding: 9px 0;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.rule-key { flex: 0 0 62px; color: var(--gold); font-size: 12px; font-weight: 700; }
.rule-val { flex: 1; color: #dbe6de; font-size: 12px; line-height: 1.65; }
.rules-note { margin: 11px 0 0; color: #93aa9b; font-size: 11px; line-height: 1.6; }
.rules-foot { margin-top: 13px; }

/* ---------- 顶栏 ---------- */
.game { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.topbar {
  position: relative; z-index: 6;
  display: flex; align-items: center; gap: 8px; padding: 5px 9px;
  background: transparent; font-size: 12px; color: #9db6a6; flex: 0 0 auto;
  overflow-x: auto; white-space: nowrap;
}
.topbar .room { color: var(--gold); font-weight: 700; letter-spacing: 2px; }
.topbar .modechip { font-size: 10px; padding: 1px 7px; border-radius: 10px; background: rgba(217,176,96,.16); color: var(--gold); }
.topbar .sessionchip { font-size: 10px; padding: 1px 7px; border-radius: 10px; background: rgba(255,255,255,.1); color: #cfdcd3; white-space: nowrap; }
.countdown-chip {
  font-size: 11px; padding: 2px 8px; border-radius: 10px; white-space: nowrap;
  color: #ffe6a8; border: 1px solid rgba(255,214,130,.45);
  background: rgba(255,214,130,.13);
  box-shadow: 0 0 10px rgba(255,200,100,.12);
}
.topbar .spacer { flex: 1; }
.minibtn { padding: 5px 9px; border-radius: 7px; font-size: 12px; background: rgba(255,255,255,.09); color: #d6e4da; border: 1px solid rgba(255,255,255,.1); }
.minibtn.chatbtn.on { color: #ffe6a8; border-color: rgba(255,214,130,.45); background: rgba(255,214,130,.13); }
.minibtn.bgmbtn.on { color: #ffe6a8; border-color: rgba(255,214,130,.45); background: rgba(255,214,130,.13); }
.music-link {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 10px; padding: 2px 0;
  background: transparent; border: 0; color: #8aa294; font-size: 11px; font-family: inherit;
  text-decoration: underline; text-underline-offset: 3px;
}
.music-link:hover { color: #ffe6a8; }
.chat-input {
  width: clamp(84px, 14vw, 140px); padding: 4px 8px; border-radius: 7px; font-size: 12px;
  border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.06);
  color: #eaf2ec; outline: none; font-family: inherit;
}
.chat-input:focus { border-color: var(--gold); }

/* ---------- 牌桌 ---------- */
.table {
  position: relative; flex: 1; min-height: 0; isolation: isolate;
  display: grid;
  grid-template-columns: minmax(52px, 10%) minmax(0, 1fr) minmax(52px, 10%);
  grid-template-rows: 146px minmax(0, 1fr);
  grid-template-areas: "tl top tr" "left center right";
  gap: 3px; padding: 4px 6px 0;
  background: radial-gradient(ellipse at 50% 45%, rgba(38,150,92,.5), rgba(6,34,19,.92) 72%),
              linear-gradient(180deg, #0d4a2a, #051e10);
}

.seat { display: flex; overflow: hidden; position: relative; z-index: 3; border-radius: 6px; }
.seat.top { grid-area: top; flex-direction: column; align-items: center; gap: 3px; }
.seat.left { grid-area: left; flex-direction: column; justify-content: center; align-items: flex-start; gap: 3px; }
.seat.right { grid-area: right; flex-direction: column; justify-content: center; align-items: flex-end; gap: 3px; }
/* 左右家的头像固定在竖向中线，手牌数量变化时不再上下跳。 */
.seat.left .seat-head, .seat.right .seat-head {
  position: absolute; z-index: 4; top: 50%; transform: translateY(-50%);
  max-width: 100%;
}
.seat.left .seat-head { left: 0; }
.seat.right .seat-head { right: 0; justify-content: flex-end; }
/* 宽屏左右两家的手牌背在靠外侧，头像/名字往内让出一列，避免头像压在手牌上。 */
@media (min-width: 761px) {
  .seat.left .seat-head {
    left: calc(var(--dw) * .8 + 8px);
    max-width: calc(100% - var(--dw) * .8 - 10px);
  }
  .seat.right .seat-head {
    right: calc(var(--dw) * .8 + 8px);
    max-width: calc(100% - var(--dw) * .8 - 10px);
  }
}
.seat.finished { opacity: .72; }
/* 02 紧凑胶囊：头像、名字、分数同排；名字限宽省略，分数紧跟名字。 */
.seat-head {
  display: inline-flex; align-items: center; flex-wrap: nowrap; gap: 6px;
  padding: 3px 14px 3px 4px; border-radius: 999px;
  background: linear-gradient(180deg, rgba(10, 42, 27, .94), rgba(4, 22, 14, .95));
  border: 1px solid rgba(235, 205, 145, .27);
  box-shadow: 0 5px 14px rgba(0, 0, 0, .34), inset 0 1px 0 rgba(255, 255, 255, .05);
  font-size: 14px; max-width: 100%; white-space: nowrap;
}
.seat .avatar { width: 32px; height: 32px; font-size: 16px; }
.seat-head .avatar, .mine-head .avatar { box-shadow: 0 0 0 2px rgba(255,255,255,.22); }
.seat.top .avatar { width: 32px; height: 32px; font-size: 16px; }
.pname {
  flex: 0 1 auto; min-width: 0; max-width: 5em;
  color: #fff4e2; font-size: 14px; font-weight: 700; line-height: 1.1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pscore {
  display: inline-flex; align-items: baseline; flex: 0 0 auto;
  color: var(--gold); font-weight: 800; font-size: 18px; line-height: 1;
  font-variant-numeric: tabular-nums; letter-spacing: .01em;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .45); white-space: nowrap;
}
.pscore .ps-base { display: inline-block; }
.pscore .ps-delta { display: inline-block; margin-left: 1px; font-size: .62em; line-height: 1; font-weight: 800; }
.pscore.minus .ps-delta { color: #ff9b9b; }
.pscore.negbase .ps-base { color: #ff9b9b; }
.windtag {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(217,176,96,.2); border: 1px solid rgba(217,176,96,.55);
  color: #ffe6a8; font-size: 12px; font-weight: 800; flex: 0 0 auto;
}
.pscore.neg { color: #ff9b9b; }
.seat-badges { display: flex; gap: 3px; flex-wrap: wrap; min-height: 0; }
.badge { font-size: 10px; padding: 1px 6px; border-radius: 10px; background: rgba(255,255,255,.12); color: #cfe0d6; white-space: nowrap; }
.badge.que { background: rgba(255,190,80,.2); color: #f5c671; }
.badge.off { background: rgba(255,255,255,.08); color: rgba(255,255,255,.62); border: 1px solid rgba(255,255,255,.14); }
.badge.hu { background: rgba(255,120,120,.22); color: #ffb3b3; }
.badge.turn { background: rgba(255,214,130,.28); color: #ffe6a8; animation: blink 1.2s infinite; }
.badge.turn-now { background: #e8bf6b; color: #241708; font-size: 11px; font-weight: 800; padding: 2px 7px; box-shadow: 0 1px 3px rgba(0,0,0,.35); }
.turn-glow {
  position: absolute; z-index: 2; pointer-events: none;
  border-radius: 50%;
  filter: blur(14px);
  mix-blend-mode: screen;
  animation: turnGlow 3.2s cubic-bezier(.45,0,.3,1) infinite;
  animation-delay: var(--glow-phase, 0s);
}
.turn-glow.tg-left {
  left: -4%; top: 6%; width: 42%; height: 88%;
  background: radial-gradient(ellipse 100% 55% at 0% 50%,
    rgba(255,244,184,.52) 0%, rgba(255,220,96,.32) 38%, rgba(255,184,28,.12) 66%, transparent 86%);
}
.turn-glow.tg-right {
  right: -4%; top: 6%; width: 42%; height: 88%;
  background: radial-gradient(ellipse 100% 55% at 100% 50%,
    rgba(255,244,184,.52) 0%, rgba(255,220,96,.32) 38%, rgba(255,184,28,.12) 66%, transparent 86%);
}
.turn-glow.tg-top {
  top: -3%; left: 12%; width: 76%; height: 42%;
  background: radial-gradient(ellipse 55% 100% at 50% 0%,
    rgba(255,244,184,.5) 0%, rgba(255,220,96,.3) 38%, rgba(255,184,28,.11) 66%, transparent 86%);
}
.turn-glow.tg-bottom {
  bottom: -3%; left: 12%; width: 76%; height: 42%;
  background: radial-gradient(ellipse 55% 100% at 50% 100%,
    rgba(255,244,184,.5) 0%, rgba(255,220,96,.3) 38%, rgba(255,184,28,.11) 66%, transparent 86%);
}
.turn-glow.source-glow {
  animation: sourceGlow 1.55s ease-out both;
}
@keyframes sourceGlow {
  0% { opacity: .9; transform: scale(.94); }
  18% { opacity: 1; transform: scale(1); }
  72% { opacity: .9; }
  100% { opacity: 0; transform: scale(1.02); }
}
/* 碰/杠金光只铺在桌面层：座位和牌都在它上面，光不会盖住牌面与文字 */
.table-action-glow {
  position: absolute; z-index: 1; pointer-events: none; border-radius: 50%;
  background: radial-gradient(ellipse 50% 50% at 50% 50%,
    rgba(255,240,198,.46) 0%, rgba(255,216,130,.25) 32%, rgba(255,186,70,.09) 58%, transparent 80%);
  filter: blur(10px);
  mix-blend-mode: screen;
  animation: tableBurst 1.45s ease-out both;
}
.table-action-glow.tag-top { left: 50%; top: 14%; width: 66%; height: 26%; }
.table-action-glow.tag-bottom { left: 50%; top: 84%; width: 56%; height: 26%; }
.table-action-glow.tag-left { left: 16%; top: 50%; width: 32%; height: 54%; }
.table-action-glow.tag-right { left: 84%; top: 50%; width: 32%; height: 54%; }
@keyframes tableBurst {
  0% { opacity: .9; transform: translate(-50%,-50%) scale(.6); }
  35% { opacity: .82; }
  100% { opacity: 0; transform: translate(-50%,-50%) scale(1.32); }
}
.seat.turnseat .pname { color: #ffe6b3; font-weight: 700; }
.mine-head.turnself .me-name { color: #ffe6b3; }
@keyframes turnGlow {
  0%, 100% { opacity: .82; }
  50% { opacity: 1; }
}
.seat.turnseat .pname { color: #ffe6b3; font-weight: 700; }
.mine-head.turnself .me-name { color: #ffe6b3; }
.turn-pointer {
  position: absolute; z-index: 12;
  display: inline-flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.turn-pointer .tp-num {
  width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 38% 30%, #fff5d2, #f0ca77 52%, #c08f37);
  color: #3a2504; font-size: 16px; font-weight: 800; line-height: 1; letter-spacing: 0;
  box-shadow: 0 0 0 2px rgba(255,244,214,.55), 0 3px 10px rgba(0,0,0,.45);
  animation: tmPulse 1.5s ease-in-out infinite;
}
.turn-pointer.tp-top { top: 150px; left: 50%; transform: translateX(-50%); }
.turn-pointer.tp-bottom { bottom: 3px; left: 50%; transform: translateX(-50%); }
.turn-pointer.tp-left { left: 13%; top: 50%; transform: translateY(-50%); }
.turn-pointer.tp-right { right: 13%; top: 50%; transform: translateY(-50%); }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .55; } }

.backs { display: flex; gap: 1px; }
.backs.h { flex-direction: row; }
.backs.v { flex-direction: column; gap: 0; }
.backs:empty, .final-hand:empty { display: none; }
.tile.strip-h { width: calc(var(--dw) * 0.25); height: calc(var(--dw) * 0.78); border-radius: 2px; }
.tile.strip-v { width: calc(var(--dw) * 0.80); height: calc(var(--dw) * 0.18); border-radius: 2px; }
.melds { display: flex; gap: 4px; flex-wrap: wrap; max-width: 100%; }
.meld { display: flex; gap: 1px; padding: 1px; border-radius: 3px; background: rgba(0,0,0,.2); }
.meld .tile { width: calc(var(--dw) * 0.78); height: calc(var(--dh) * 0.78); }
.meld .tile .wan-num { font-size: calc(var(--dh) * 0.36); }
.meld .tile .wan-suit { font-size: calc(var(--dh) * 0.25); }
.meld .tile .honor { font-size: calc(var(--dh) * 0.42); }
.meld .tile .joker { font-size: calc(var(--dh) * 0.42); }
.meld.gang { box-shadow: 0 0 0 1px rgba(217,176,96,.45); }

.center {
  grid-area: center; position: relative; z-index: 3;
  justify-self: center; align-self: stretch;
  width: min(100%, 1360px); min-width: 0; min-height: 0;
  display: grid; grid-template-columns: 1fr 1.35fr 1fr; grid-template-rows: 1fr 1.2fr 1fr;
}
.dz { display: flex; flex-wrap: wrap; gap: 1px; overflow: hidden; padding: 3px; align-content: flex-start; min-width: 0; }
.dz.top { grid-area: 1/2; justify-content: center; align-content: flex-end; }
.dz.right { grid-area: 2/3; justify-content: flex-end; }
.dz.bottom { grid-area: 3/2; justify-content: center; }
.dz.left { grid-area: 2/1; justify-content: flex-start; }
.wall-ring { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.wall-side { position: absolute; display: flex; gap: 3px; }
.wall-stack { display: flex; gap: 1px; }
.wall-side.ws-left .wall-stack, .wall-side.ws-right .wall-stack { flex-direction: column; }
.wall-side.ws-top { top: 2px; left: 12%; right: 12%; justify-content: center; }
.wall-side.ws-bottom { bottom: 2px; left: 12%; right: 12%; justify-content: center; }
.wall-side.ws-left { left: 2px; top: 12%; bottom: 12%; flex-direction: column; justify-content: center; }
.wall-side.ws-right { right: 2px; top: 12%; bottom: 12%; flex-direction: column; justify-content: center; }
.wall-pip {
  width: var(--wp); height: calc(var(--wp) * 1.4); flex: 0 0 auto; border-radius: 1px;
  background: linear-gradient(180deg, #f9f2df, #ded1b3);
  border: 1px solid rgba(120,102,68,.45);
  box-shadow: inset 0 -2px 0 rgba(160,140,100,.25);
}
.wall-side.ws-left .wall-pip, .wall-side.ws-right .wall-pip { width: calc(var(--wp) * 1.4); height: var(--wp); }
.wall-side.start {
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(255,214,130,.55), 0 0 14px rgba(255,200,100,.22);
  animation: wallStartPulse 1.5s ease-in-out infinite;
}
.wall-side.start .wall-pip { background: linear-gradient(180deg, #fff3c9, #e5c276); border-color: rgba(160,120,50,.6); }
@keyframes wallStartPulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(255,214,130,.4), 0 0 10px rgba(255,200,100,.15); }
  50% { box-shadow: 0 0 0 2px rgba(255,224,150,.8), 0 0 18px rgba(255,200,100,.35); }
}
.deal-banner {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%);
  z-index: 70; pointer-events: none; display: flex; align-items: center; gap: 10px;
  padding: 6px 16px; border-radius: 14px; max-width: min(560px, calc(100% - 20px));
  background: rgba(7,30,18,.92); border: 1px solid rgba(255,214,130,.35);
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.deal-banner .db-dice { display: flex; gap: 9px; flex: 0 0 auto; }
.deal-banner .db-die { display: flex; flex-direction: column; align-items: center; gap: 0; }
.deal-banner .db-die span { font-size: 9px; line-height: 1; color: #c8b98a; }
.deal-banner .db-die .die3d { transform: scale(.7); margin: -7px 0; }
.deal-banner .db-text {
  flex: 1; min-width: 0; font-size: 13px; color: #d9eadf;
  line-height: 1.4; text-align: left;
}
.deal-banner .db-line { display: block; }
.deal-banner .db-text b { color: #ffe6a8; font-size: 15px; }
.deal-banner .db-extra { margin-top: 2px; font-size: 11px; color: #93ab9d; }
.dz.top { padding-top: 14px; }
.dz.bottom { padding-bottom: 14px; }
.dz.left { padding-left: 14px; }
.dz.right { padding-right: 14px; }
.wallbox { grid-area: 2/2; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; z-index: 2; }
.center-stack {
  grid-area: 2/2; align-self: center; justify-self: center; z-index: 3;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  position: relative;
  pointer-events: none;
}
.center-stack .last-tip {
  position: absolute; top: calc(100% + 2px); left: 50%;
  transform: translateX(-50%); margin: 0;
}
.table-dice {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.center-stack .table-dice .dice-row { display: none; }
/* 摇完后的骰子固定在画面左上角，不再占桌心 */
.dice-hud {
  position: fixed;
  left: max(8px, env(safe-area-inset-left));
  top: calc(env(safe-area-inset-top) + 40px);
  z-index: 56;
  display: flex; align-items: center; gap: 6px;
  padding: 4px 6px;
  border: 1px solid rgba(217,176,96,.22);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(5,26,15,.62), rgba(2,14,8,.48));
  box-shadow: 0 6px 16px rgba(0,0,0,.24);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: none;
}
.dice-hud .dh-wind {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 6px;
  color: #ffe6a8; font-size: 15px; font-weight: 800; line-height: 1;
  background: rgba(255,214,130,.10);
  border: 1px solid rgba(255,214,130,.26);
  text-shadow: 0 1px 2px rgba(0,0,0,.5);
}
.dice-hud .die3d {
  transform: scale(.48);
  margin: -15px;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.42));
}
.dice-hud .dice-hud-row { display: flex; align-items: center; gap: 3px; }
.table-dice .dice-row { display: flex; align-items: center; justify-content: center; gap: 10px; }
.table-dice .die3d { transform: scale(.62); margin: -11px; filter: drop-shadow(0 3px 5px rgba(0,0,0,.45)); }
.dice-note {
  font-size: 11px; line-height: 1.35; color: #e8d8b0;
  background: rgba(0,0,0,.24); padding: 1px 8px; border-radius: 9px;
  white-space: nowrap; max-width: 14em; overflow: hidden; text-overflow: ellipsis;
}
.wall-num { font-size: 22px; font-weight: 800; color: #f0e4c2; text-shadow: 0 2px 6px rgba(0,0,0,.6); }
.wallstack { display: grid; grid-template-columns: repeat(6, auto); gap: 2px; margin-bottom: 4px; opacity: .95; }
.wall-tile { width: 13px; height: 18px; border-radius: 2px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.06), 0 1px 1px rgba(0,0,0,.3); }
.wall-tile::after { inset: 2px; border-radius: 1px; }
.wall-lbl { font-size: 10px; color: #a9c2b2; letter-spacing: 2px; }
.last-tip { margin-top: 6px; font-size: 11px; color: #f7dc9d; background: rgba(0,0,0,.28); padding: 2px 8px; border-radius: 10px; max-width: 12em; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat.left .meld .tile, .seat.right .meld .tile { width: calc(var(--dw) * 0.6); height: calc(var(--dh) * 0.6); }
.inner-ring { position: absolute; inset: 7%; border: 1px solid rgba(217,176,96,.16); border-radius: 10px; pointer-events: none; }

/* 轮次提示条 */
/* ---------- 轮次指示：出牌者前面的圆形读秒标记 ---------- */
.turnmark {
  position: absolute; z-index: 8;
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 38% 30%, #fff5d2, #f0ca77 52%, #c08f37);
  box-shadow: 0 0 0 2px rgba(255,244,214,.55), 0 3px 10px rgba(0,0,0,.45);
  color: #3a2504; font-weight: 800; font-size: 16px; letter-spacing: 0;
  pointer-events: none;
  animation: tmPulse 1.5s ease-in-out infinite;
}
@keyframes tmPulse {
  0%,100% { filter: brightness(1); }
  50% { filter: brightness(1.14); }
}
.turnmark .tm-arrow {
  position: absolute; width: 0; height: 0;
  border: 7px solid transparent;
}
.turnmark.tm-top { top: 146px; left: calc(50% - 18px); }
.turnmark.tm-top .tm-arrow { top: -13px; left: 50%; margin-left: -7px; border-bottom-color: #ecc36d; }
.turnmark.tm-bottom { bottom: 3px; left: calc(50% - 18px); }
.turnmark.tm-bottom .tm-arrow { bottom: -13px; left: 50%; margin-left: -7px; border-top-color: #ecc36d; }
.turnmark.tm-left { left: calc(10% - 42px); top: calc(50% - 18px); }
.turnmark.tm-left .tm-arrow { left: -13px; top: 50%; margin-top: -7px; border-right-color: #ecc36d; }
.turnmark.tm-right { right: calc(10% - 42px); top: calc(50% - 18px); }
.turnmark.tm-right .tm-arrow { right: -13px; top: 50%; margin-top: -7px; border-left-color: #ecc36d; }
.turnmark .tm-num { line-height: 1; }

/* ---------- 自己的区域 ---------- */
.mine {
  position: relative;
  flex: 0 0 auto; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(3,20,11,.6), rgba(3,16,9,.97));
  display: flex; flex-direction: column; gap: 5px;
  border-top: 1px solid rgba(217,176,96,.18);
  transition: box-shadow .2s, background .2s;
}
.mine.turnself::before {
  content: ''; position: absolute; inset: -20px 0 0; z-index: 0; pointer-events: none;
  background: radial-gradient(ellipse 60% 115% at 50% 100%,
    rgba(255,245,190,.52) 0%, rgba(255,221,100,.28) 40%, rgba(255,184,28,.10) 66%, transparent 86%);
  filter: blur(12px);
  mix-blend-mode: screen;
  animation: turnGlow 3.2s cubic-bezier(.45,0,.3,1) infinite;
  animation-delay: var(--glow-phase, 0s);
}
.mine.turnself > * { position: relative; z-index: 1; }
.mine-head {
  display: inline-flex; align-items: center; flex-wrap: nowrap; gap: 6px;
  padding: 3px 14px 3px 4px; border-radius: 999px;
  background: linear-gradient(180deg, rgba(10, 42, 27, .94), rgba(4, 22, 14, .95));
  border: 1px solid rgba(235, 205, 145, .27);
  box-shadow: 0 5px 14px rgba(0, 0, 0, .34), inset 0 1px 0 rgba(255, 255, 255, .05);
  font-size: 13px; color: #a9c2b2; max-width: 100%; white-space: nowrap;
  align-self: flex-start;
}
.mine-head .avatar { width: 32px; height: 32px; font-size: 16px; }
.mine-head .me-name { color: #fff4e2; font-weight: 700; font-size: 14px; line-height: 1.1; }
.mine-head .pscore { font-size: 18px; }
.mine-clock {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%; flex: 0 0 auto;
  background: radial-gradient(circle at 38% 30%, #fff5d2, #f0ca77 52%, #c08f37);
  color: #3a2504; font-size: 12px; font-weight: 800; line-height: 1;
  box-shadow: 0 0 0 1.5px rgba(255,244,214,.5), 0 2px 8px rgba(0,0,0,.4);
  animation: tmPulse 1.5s ease-in-out infinite;
}
.mine-clock:empty { display: none; }
.mine-head .mine-score { margin-left: auto; color: var(--gold); font-weight: 800; font-size: 20px; text-shadow: 0 1px 4px rgba(0,0,0,.45); }
.mine-head .mine-cum { margin-left: 6px; font-size: 12px; color: #9bb3a4; }
.meld-row { display: flex; gap: 5px; flex-wrap: wrap; }
.meld-row:empty { display: none; }
.actions { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; align-items: center; min-height: 78px; }
.tip { width: 100%; font-size: 12px; color: #9db6a6; text-align: center; margin: 0; line-height: 16px; min-height: 16px; }
.tip.on { color: #ffe1a8; font-weight: 600; }
.tip.react { color: #ffe6b3; font-size: 15px; font-weight: 800; letter-spacing: .02em; }
.react-hint {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; gap: 5px;
  min-width: 78px; height: 50px; padding: 0 8px; border-radius: 10px;
  background: linear-gradient(180deg, #f3d995, #d0a94f);
  border: 0;
  box-shadow: 0 3px 0 #977220;
  color: #33240a;
}
.react-hint .rh-from { font-size: 12px; line-height: 1; font-weight: 800; white-space: nowrap; }
.react-hint .react-tile {
  width: 28px; height: 38px; flex: 0 0 auto; border-radius: 3px;
  box-shadow: 0 2px 0 #a9926a, 0 2px 5px rgba(0,0,0,.32);
  animation: none;
}
@keyframes reactTile {
  0%,100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-2px) scale(1.05); }
}
.claim-arrows {
  position: absolute; inset: -9px; z-index: 4; pointer-events: none;
}
.claim-arrows .ca {
  position: absolute; font-style: normal; font-size: 10px; line-height: 1;
  color: #ffd66e; font-weight: 900;
  text-shadow: 0 0 6px rgba(255,201,96,.9), 0 1px 3px rgba(0,0,0,.85);
}
.claim-arrows .ca-top {
  top: -1px; left: 50%;
  animation: claimTop 1.15s ease-in-out infinite;
}
.claim-arrows .ca-right {
  right: -1px; top: 50%;
  animation: claimRight 1.15s ease-in-out .14s infinite;
}
.claim-arrows .ca-bottom {
  bottom: -1px; left: 50%;
  animation: claimBottom 1.15s ease-in-out .28s infinite;
}
.claim-arrows .ca-left {
  left: -1px; top: 50%;
  animation: claimLeft 1.15s ease-in-out .42s infinite;
}
.tile.claimable {
  z-index: 3;
}
.dz:has(.tile.claimable) { overflow: visible; z-index: 3; }
@keyframes claimTop {
  0%,100% { transform: translate(-50%,-3px); opacity: .45; }
  50% { transform: translate(-50%,3px); opacity: 1; }
}
@keyframes claimRight {
  0%,100% { transform: translate(3px,-50%); opacity: .45; }
  50% { transform: translate(-3px,-50%); opacity: 1; }
}
@keyframes claimBottom {
  0%,100% { transform: translate(-50%,3px); opacity: .45; }
  50% { transform: translate(-50%,-3px); opacity: 1; }
}
@keyframes claimLeft {
  0%,100% { transform: translate(-3px,-50%); opacity: .45; }
  50% { transform: translate(3px,-50%); opacity: 1; }
}
.act {
  height: 38px; min-width: 60px; padding: 0 14px; border-radius: 10px; font-size: 16px; font-weight: 800;
  background: linear-gradient(180deg, #f3d995, #d0a94f); color: #33240a;
  box-shadow: 0 3px 0 #977220; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1;
}
.act.react-act {
  height: 50px; min-width: 78px; padding: 0 20px;
  border-radius: 12px; font-size: 19px; letter-spacing: 1px;
}
.act.drawbtn { min-width: 132px; padding: 0 22px; font-size: 17px; letter-spacing: 2px; }
.act small { font-size: 9px; font-weight: 600; opacity: .8; margin-top: 1px; }
.act.dark { background: linear-gradient(180deg, #5b7064, #3d4f45); color: #e9f2ec; box-shadow: 0 3px 0 #26332c; }
.act.hu { background: linear-gradient(180deg, #ff9a84, #e0513c); color: #fff; box-shadow: 0 3px 0 #98281a; animation: huBeat 1s ease-in-out infinite; }
@keyframes huBeat { 0%,100% { filter: brightness(1); } 50% { filter: brightness(1.18); } }
.act.hu.zimo {
  position: relative; overflow: hidden;
  height: clamp(48px, 4.6vh, 56px); min-width: clamp(116px, 7.4vw, 142px);
  padding: 0 24px; border-radius: 13px; letter-spacing: 3px;
  font-size: clamp(19px, 1.25vw, 24px);
  color: #3b2200; border: 1px solid rgba(255,248,214,.95);
  background: linear-gradient(180deg, #fff4c4 0%, #ffd96f 42%, #edaa23 100%);
  text-shadow: 0 1px 0 rgba(255,255,255,.5);
  animation: zimoGlow 1.15s ease-in-out infinite;
}
.act.hu.zimo::after {
  content: ''; position: absolute; top: -25%; bottom: -25%; left: -45%; width: 28%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.72), transparent);
  transform: skewX(-18deg); animation: zimoShine 2.1s ease-in-out infinite;
  pointer-events: none;
}
@keyframes zimoGlow {
  0%, 100% {
    filter: brightness(1);
    box-shadow: 0 0 0 3px rgba(255,205,90,.2), 0 5px 0 #815208, 0 8px 22px rgba(0,0,0,.45), 0 0 16px rgba(255,190,60,.4);
  }
  50% {
    filter: brightness(1.1);
    box-shadow: 0 0 0 4px rgba(255,215,110,.35), 0 5px 0 #815208, 0 8px 24px rgba(0,0,0,.4), 0 0 34px rgba(255,190,60,.8);
  }
}
@keyframes zimoShine {
  0%, 20% { left: -45%; opacity: 0; }
  40% { opacity: .8; }
  65%, 100% { left: 125%; opacity: 0; }
}
.act.primary { background: linear-gradient(180deg, #8fe0ad, #35a06a); color: #06260f; box-shadow: 0 3px 0 #14663c; }
.act:active { transform: translateY(2px); box-shadow: none; }

/* ---------- 定缺弹窗 ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(3,12,7,.74); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 18px; z-index: 60;
}
.modal .card { width: min(390px, 100%); }
.modal .card.rebuild-card {
  width: min(400px, 100%);
  padding: 22px 20px 18px;
  text-align: left;
}
.rebuild-card h2 {
  margin: 0 0 10px;
  color: #ffe6a8;
  font-size: 19px;
  letter-spacing: 1px;
}
.rebuild-card p {
  margin: 0 0 9px;
  color: #cfdcd3;
  font-size: 13px;
  line-height: 1.7;
}
.rebuild-card p b { color: #ffe6a8; }
.rebuild-card .rebuild-warn { color: #f3bf94; font-size: 12px; }
.rebuild-actions {
  display: flex;
  gap: 9px;
  margin-top: 16px;
}
.rebuild-actions .btn {
  flex: 1;
  min-width: 0;
  width: auto;
}
.modal .card.pause-card {
  width: min(370px, 100%); padding: 26px 22px 22px; text-align: center;
}
.pause-badge {
  width: 46px; height: 46px; margin: 0 auto 10px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 23px; font-weight: 900; color: #3a2400; letter-spacing: -2px;
  background: linear-gradient(180deg, #fff1bd, #ffd264);
  border: 2px solid rgba(255,248,215,.85);
  box-shadow: 0 0 0 4px rgba(255,205,90,.16), 0 0 24px rgba(255,190,70,.45);
  animation: pausePulse 1.6s ease-in-out infinite;
}
@keyframes pausePulse {
  0%,100% { box-shadow: 0 0 0 4px rgba(255,205,90,.14), 0 0 18px rgba(255,190,70,.35); }
  50% { box-shadow: 0 0 0 7px rgba(255,205,90,.07), 0 0 30px rgba(255,190,70,.62); }
}
.pause-card h2 { margin: 4px 0 8px; font-size: 22px; color: #ffe6a8; letter-spacing: 1px; }
.pause-card p { margin: 0; font-size: 13px; line-height: 1.8; color: #adc4b6; }
.pause-actions { display: flex; justify-content: center; gap: 10px; margin-top: 18px; }
.pause-actions .btn { flex: 1; max-width: 140px; }
.pause-wait { display: flex; justify-content: center; gap: 5px; margin-top: 14px; }
.pause-wait i {
  width: 5px; height: 5px; border-radius: 50%; background: #ffd46c;
  animation: pauseDot 1.1s ease-in-out infinite;
}
.pause-wait i:nth-child(2) { animation-delay: .18s; }
.pause-wait i:nth-child(3) { animation-delay: .36s; }
@keyframes pauseDot { 0%,100% { opacity: .35; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }

/* ---------- 本局设置弹窗 ---------- */
.modal .card.settings-card {
  width: min(540px, 100%); max-height: 88vh; overflow-y: auto;
  padding: 0; text-align: left;
}
.settings-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 18px 20px 12px; background: rgba(10,33,21,.98);
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.settings-head h2 { margin: 0; font-size: 18px; letter-spacing: 1px; color: #f6e7c2; }
.settings-head p { margin: 5px 0 0; font-size: 11px; line-height: 1.5; color: #8fa79a; }

/* ---------- 背景音乐设置 ---------- */
.modal .card.bgm-card { width: min(620px, 100%); max-height: 88vh; overflow-y: auto; padding: 0; text-align: left; }
.set-select-wrap { position: relative; margin: 0 18px; }
.settings-actions { padding: 12px 18px 0; }
.settings-label {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  margin: 0 0 8px; color: #f3dfb2; font-size: 12px; font-weight: 800;
}
.settings-label span { color: #7f978a; font-size: 10px; font-weight: 400; }
.settings-action-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.settings-action {
  appearance: none; min-width: 0; min-height: 70px; padding: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border-radius: 10px; border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.045); color: #eaf4ec; font: inherit; cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .1s ease;
}
.settings-action:hover { border-color: rgba(217,176,96,.38); background: rgba(217,176,96,.08); }
.settings-action:active { transform: translateY(1px); }
.settings-action:disabled { opacity: .42; cursor: not-allowed; transform: none; }
.sa-ico {
  width: 28px; height: 28px; border-radius: 50%; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  color: #ffe6a8; font-size: 14px; font-weight: 800; line-height: 1;
  background: rgba(217,176,96,.13); border: 1px solid rgba(217,176,96,.28);
}
.sa-title { font-size: 12px; font-weight: 800; line-height: 1.2; white-space: nowrap; }
.settings-action.danger { border-color: rgba(255,120,120,.18); }
.settings-action.danger:hover { border-color: rgba(255,120,120,.46); background: rgba(255,100,100,.08); }
.settings-action.danger .sa-ico { color: #ffbcbc; background: rgba(255,110,110,.1); border-color: rgba(255,120,120,.3); }
.settings-action.danger .sa-title { color: #ffbcbc; }
.settings-divider { height: 1px; margin: 12px 18px 0; background: rgba(255,255,255,.07); }
.bgm-main { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 16px; padding: 0 18px; }
.bgm-main .set-caption { margin: 12px 0 7px; }
.bgm-main .set-select-wrap { margin: 0; }
.bgm-main .set-toggle { margin: 10px 0 0; }
.bgm-main .bgm-note { margin: 10px 0 0; }
.quality-actions { padding: 0 18px; }
.quality-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px;
}
.quality-chip {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  padding: 10px 12px; border-radius: 10px; cursor: pointer; text-align: left;
  border: 1px solid rgba(255,255,255,.09); background: rgba(255,255,255,.035);
  color: #cfdcd3; font-family: inherit;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.quality-chip:hover { border-color: rgba(255,214,130,.30); background: rgba(255,255,255,.07); }
.quality-chip.on {
  border-color: rgba(255,214,130,.55); color: #ffe6a8;
  background: linear-gradient(180deg, rgba(255,214,130,.16), rgba(255,214,130,.06));
  box-shadow: inset 0 0 0 1px rgba(255,214,130,.10), 0 4px 12px rgba(0,0,0,.18);
}
.quality-chip .q-name { font-size: 15px; font-weight: 800; line-height: 1.1; }
.quality-chip .q-desc { font-size: 10px; line-height: 1.4; color: #8fa79a; }
.quality-chip.on .q-desc { color: #d8c291; }
.quality-chip .q-rec {
  position: absolute; top: -7px; right: 8px; padding: 1px 6px; border-radius: 999px;
  background: #2f6b49; color: #eaffef; border: 1px solid rgba(140,225,173,.36);
  font-size: 9px; font-weight: 700; line-height: 1.4;
}
.set-select {
  width: 100%; height: 42px; padding: 0 36px 0 12px;
  border-radius: 10px; border: 1px solid rgba(230,193,112,.32);
  background: rgba(255,255,255,.055); color: #f7e7bf;
  font-family: inherit; font-size: 13px; font-weight: 700;
  appearance: none; -webkit-appearance: none; cursor: pointer;
}
.set-select:hover { background: rgba(255,255,255,.08); }
.set-select:focus { outline: none; border-color: rgba(230,193,112,.75); box-shadow: 0 0 0 2px rgba(230,193,112,.10); }
.set-select option { background: #0c2417; color: #e8f2eb; }
.set-select-wrap::after {
  content: '▾'; position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  color: #f2cf85; font-size: 12px; pointer-events: none;
}
.set-caption {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  margin: 15px 18px 7px; color: #f3dfb2; font-size: 13px; font-weight: 800;
}
.set-caption span { color: #7f978a; font-size: 10px; font-weight: 400; line-height: 1.4; }
.set-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 12px 18px 0; padding: 9px 12px; border-radius: 9px;
  border: 1px solid rgba(255,255,255,.09); background: rgba(255,255,255,.035);
  color: #cfdcd3; font-size: 12px;
}
.togglebtn {
  padding: 4px 12px; border-radius: 999px; border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.08); color: #b9ccbf; font-family: inherit; font-size: 11px; font-weight: 700;
}
.togglebtn.on { color: #ffe6a8; border-color: rgba(255,214,130,.45); background: rgba(255,214,130,.13); }
.bgm-note {
  margin: 10px 18px 0; color: #9db5a5; font-size: 11px; line-height: 1.6;
}
.bgm-note b { color: #f4d28b; }
.bgm-card > .btn { width: calc(100% - 36px); margin: 12px 18px 18px; }
.iconbtn {
  width: 28px; height: 28px; border-radius: 50%; flex: 0 0 auto;
  background: rgba(255,255,255,.08); color: #dbe8df; font-size: 14px; line-height: 1;
}
.iconbtn:hover { background: rgba(255,255,255,.15); }
.settings-body { padding: 0 20px 4px; }
.settings-foot { padding: 6px 20px 20px; }
.settings-foot .btn { width: 100%; }

/* ---------- 第一局抽位 / 摇骰 ---------- */
.modal .card.setup-card {
  width: min(680px, 100%); max-height: 92vh; overflow-y: auto;
  padding: 22px 22px 20px; text-align: center;
}
.setup-title { font-size: 26px; letter-spacing: 8px; color: #ffe6a8; font-weight: 800; }
.setup-tip { margin: 8px 0 16px; font-size: 12px; color: #9db6a6; line-height: 1.6; }
.setup-tiles { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.setup-tile {
  position: relative; width: 86px; height: 116px; border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: linear-gradient(160deg, #0e4a2c, #07301d);
  border: 1px solid rgba(255,255,255,.16);
  box-shadow: 0 4px 0 rgba(0,0,0,.35), inset 0 0 0 1px rgba(255,255,255,.06);
}
.setup-tile.back .setup-q { font-size: 40px; color: rgba(255,255,255,.25); font-weight: 800; }
.setup-tile.back.pickable { cursor: pointer; border-color: rgba(217,176,96,.7); }
.setup-tile.back.pickable:hover { transform: translateY(-5px); box-shadow: 0 10px 22px rgba(0,0,0,.45), 0 0 0 2px rgba(255,214,130,.5); }
.setup-tile.revealed { background: rgba(255,255,255,.07); border-color: rgba(217,176,96,.45); }
.setup-tile.flip-in { animation: setupFlip .4s ease both; }
.tile.setup-face { width: 56px; height: 76px; }
.tile.setup-face .honor { font-size: 42px; }
.setup-owner { font-size: 11px; color: #ffe1a8; max-width: 76px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes setupFlip {
  from { opacity: 0; transform: rotateY(80deg); }
  to { opacity: 1; transform: none; }
}
.setup-my { margin-top: 14px; font-size: 13px; color: #cfe0d6; }
.setup-my b { color: #ffe6a8; font-size: 18px; }
.setup-winds { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; font-size: 13px; color: #cfe0d6; }
.setup-winds span { padding: 3px 9px; border-radius: 8px; background: rgba(255,255,255,.06); }
.setup-winds span.east { background: rgba(217,176,96,.18); box-shadow: 0 0 0 1px rgba(217,176,96,.6); color: #ffe6a8; }
.setup-winds b { color: #fff; font-weight: 600; }
.setup-dice { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 16px; }
.setup-dice.idle { opacity: .55; }
.setup-dice.result { gap: 26px; }
.die-cell { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.die-role {
  font-size: 11px; line-height: 1; padding: 2px 8px; border-radius: 10px;
  letter-spacing: 1px; border: 1px solid rgba(255,255,255,.18); color: #dbe9df;
}
.die-role.big { color: #ffe3a5; border-color: rgba(255,214,130,.55); background: rgba(255,214,130,.12); }
.die-role.small { color: #b9e6cb; border-color: rgba(120,220,160,.4); background: rgba(120,220,160,.08); }
.dice-info {
  display: block; width: 100%; max-width: 420px;
  margin: 14px auto 0; text-align: left;
}
.dice-info-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 12px; margin-top: 7px; border-radius: 10px;
  background: rgba(255,255,255,.055); border: 1px solid rgba(255,215,130,.16);
  font-size: 14px; line-height: 1.35; color: #d6e6dc;
}
.dice-info-row .dic-k {
  flex: 0 0 auto; padding: 2px 8px; border-radius: 7px;
  font-size: 12px; font-weight: 700; letter-spacing: .5px;
  color: #ffe3a5; background: rgba(255,214,130,.12);
  border: 1px solid rgba(255,214,130,.42); white-space: nowrap;
}
.dice-info-row .dic-v { flex: 1; text-align: right; }
.dice-info-row .dic-v b { color: #ffe6a8; font-size: 15px; }
.dice-extra { margin: 12px 0 0; font-size: 13px; color: #9db6a6; text-align: center; }
.die3d {
  position: relative;
  width: 58px; height: 58px; perspective: 420px; flex: 0 0 auto;
}
.die-spinner {
  position: relative; z-index: 1; width: 100%; height: 100%;
  transform-style: preserve-3d;
}
.die-cube {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d;
}
.die-shadow {
  position: absolute; z-index: 0; left: 50%; bottom: -7px;
  width: 38px; height: 9px; border-radius: 50%;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at 50% 50%, rgba(0,0,0,.45), rgba(0,0,0,.16) 55%, transparent 76%);
  filter: blur(2px); opacity: .55; pointer-events: none;
}
.die-spinner.rolling { animation: diceTumble .8s cubic-bezier(.16,.78,.2,1) 1 both; will-change: transform; }
.setup-dice .die3d:nth-child(2) .die-spinner.rolling { animation-duration: .72s; animation-delay: .03s; }
.setup-dice.rolling .die-shadow { animation: diceShadow .8s cubic-bezier(.2,.75,.3,1) 1 both; }
.die-face {
  position: absolute; inset: 0; border-radius: 10px;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  padding: 9px; backface-visibility: hidden;
  background: linear-gradient(150deg, #fffdf4, #e5d6b8);
  box-shadow: inset 0 0 0 1px rgba(120,95,60,.28), inset 0 -7px 10px rgba(120,95,60,.2);
}
.die-face.front { transform: translateZ(29px); }
.die-face.back { transform: rotateY(180deg) translateZ(29px); }
.die-face.right { transform: rotateY(90deg) translateZ(29px); }
.die-face.left { transform: rotateY(-90deg) translateZ(29px); }
.die-face.top { transform: rotateX(90deg) translateZ(29px); }
.die-face.bottom { transform: rotateX(-90deg) translateZ(29px); }
.die-pip {
  width: 8px; height: 8px; border-radius: 50%; align-self: center; justify-self: center;
  background: #b3271f; box-shadow: inset 0 1px 1px rgba(0,0,0,.35); opacity: 0;
}
.die-pip.on { opacity: 1; }
@keyframes diceTumble {
  0% { transform: translate3d(0,0,0) rotateX(0deg) rotateY(0deg) rotateZ(0deg) scale3d(.96,.96,1); }
  6% { transform: translate3d(0,5px,0) rotateX(-216deg) rotateY(216deg) rotateZ(-5deg) scale3d(1.03,.9,1); }
  18% { transform: translate3d(0,-80px,0) rotateX(396deg) rotateY(389deg) rotateZ(-13deg) scale3d(1,1,1); }
  30% { transform: translate3d(0,-12.8px,0) rotateX(756deg) rotateY(778deg) rotateZ(11deg) scale3d(.82,.82,1); }
  38% { transform: translate3d(0,2px,0) rotateX(990deg) rotateY(1037deg) rotateZ(-6deg) scale3d(1.058,.9,1); }
  47% { transform: translate3d(0,-25px,0) rotateX(1224deg) rotateY(1296deg) rotateZ(7deg) scale3d(1.15,1.15,1); }
  56% { transform: translate3d(0,1px,0) rotateX(1440deg) rotateY(1555deg) rotateZ(-3deg) scale3d(.93,.86,1); }
  65% { transform: translate3d(0,-9.5px,0) rotateX(1620deg) rotateY(1836deg) rotateZ(2deg) scale3d(1.05,1.05,1); }
  76% { transform: translate3d(0,0,0) rotateX(1728deg) rotateY(2009deg) rotateZ(0deg) scale3d(.99,.99,1); }
  88% { transform: translate3d(0,-2px,0) rotateX(1782deg) rotateY(2117deg) rotateZ(0deg) scale3d(1.01,1.01,1); }
  100% { transform: translate3d(0,0,0) rotateX(1800deg) rotateY(2160deg) rotateZ(0deg) scale3d(1,1,1); }
}
@keyframes diceShadow {
  0% { transform: translateX(-50%) scale(.95); opacity: .48; }
  6% { transform: translateX(-50%) scale(1.02); opacity: .6; }
  18% { transform: translateX(-50%) scale(.62); opacity: .2; }
  30% { transform: translateX(-50%) scale(.9); opacity: .4; }
  38% { transform: translateX(-50%) scale(1.18); opacity: .72; }
  47% { transform: translateX(-50%) scale(.8); opacity: .32; }
  56% { transform: translateX(-50%) scale(1.12); opacity: .64; }
  65% { transform: translateX(-50%) scale(.88); opacity: .4; }
  76% { transform: translateX(-50%) scale(1.02); opacity: .55; }
  88% { transform: translateX(-50%) scale(.94); opacity: .48; }
  100% { transform: translateX(-50%) scale(.94); opacity: .5; }
}
.setup-roll { min-width: 200px; margin-top: 14px; padding: 12px 30px; font-size: 18px; letter-spacing: 3px; }
.setup-dice-tip { margin: 10px 0 0; font-size: 13px; color: #c8b98a; }
.setup-dice-tip b { color: #ffe6a8; }

/* 摇骰子：去掉遮罩和卡片背景，只留骰子 + 小按钮 */
.modal.dice-modal {
  background: transparent; backdrop-filter: none; pointer-events: none; padding: 0;
}
.dice-panel {
  position: relative; z-index: 8;
  pointer-events: auto; display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: min(320px, 86vw); padding: 0; text-align: center;
}
.dice-panel .setup-dice { margin-top: 0; }
/* 摇骰弹层里的骰子与桌面静止骰子同尺寸，避免摇完“变小” */
.dice-panel .setup-dice .die3d { transform: scale(.62); margin: -11px; }
.dice-panel .setup-roll {
  width: auto; min-width: 108px; margin-top: 2px; padding: 8px 18px;
  font-size: 15px; letter-spacing: 2px; border-radius: 10px;
}
.dice-now {
  margin: 0; font-size: 13px; line-height: 1.4; color: #d9eadf;
  text-shadow: 0 2px 8px rgba(0,0,0,.8);
}
.dice-now b { color: #ffe6a8; }

/* ---------- 自摸摸码 ---------- */
.modal.ma-modal {
  background:
    radial-gradient(circle at 50% 40%, rgba(255,201,96,.16), transparent 52%),
    rgba(2,10,6,.84);
}
.modal.reveal-table { background: rgba(3,12,7,.38); backdrop-filter: blur(0); }
.modal.ma-modal.reveal-table {
  background:
    radial-gradient(circle at 50% 40%, rgba(255,201,96,.12), transparent 52%),
    rgba(2,10,6,.42);
}
.modal .card.ma-card {
  position: relative; z-index: 2;
  width: min(880px, 94vw); max-height: 90vh; overflow-y: auto;
  padding: 30px 30px 26px; text-align: center;
  border: 1px solid rgba(255,215,135,.58);
  border-radius: 20px;
  background:
    radial-gradient(circle at 50% 0%, rgba(72,154,105,.42), transparent 48%),
    linear-gradient(160deg, #0e3422, #05170e 72%);
  box-shadow: 0 0 0 1px rgba(255,229,165,.1), 0 26px 80px rgba(0,0,0,.66),
              0 0 72px rgba(255,196,80,.16), inset 0 1px 0 rgba(255,255,255,.08);
}
/* 自摸大字改成一次性闪现，不再常驻抓码面板。 */
.modal.ma-modal .ma-stage { position: relative; display: flex; justify-content: center; max-width: 100%; }
/* 抓码面板右上角淡“胡”水印 */
.ma-card::before {
  content: "胡"; position: absolute; right: 26px; top: -22px;
  font-family: "KaiTi", "STKaiti", "SimSun", serif; font-size: 118px; line-height: 1;
  color: rgba(255,215,130,.10); pointer-events: none; z-index: 0;
}
/* 抓码结算面板整体上移，给底部自己的手牌留出更多空隙。 */
body.mode-3d.in-game .modal.ma-modal .ma-stage {
  transform: translateY(clamp(-24px, -2.4vh, -10px));
}
body.mode-3d.in-game .modal.ma-modal .card.ma-card { transform: none; }
.ma-head { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 7px; }
.ma-head h2 {
  margin: 2px 0 0; font-size: 36px; line-height: 1.2; letter-spacing: 2px; color: #ffe6a8;
  text-shadow: 0 2px 0 #6b4c14, 0 0 26px rgba(255,201,96,.42);
}
.ma-head p { margin: 0; font-size: 14px; color: #b8cec0; }
.ma-head h2 .ma-winner {
  font-size: inherit; color: #ffe6a8; letter-spacing: inherit; margin-right: 6px;
  text-shadow: inherit;
}
.ma-head p.ma-subline { color: #ffe1a1; font-size: 13px; letter-spacing: .5px; }
.ma-actions { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 20px; opacity: 0; animation: fadeUp .45s ease both; }
.ma-actions .btn { width: auto; min-width: 180px; }
.ma-btn {
  min-width: 240px !important; padding: 14px 44px !important; font-size: 22px !important;
  letter-spacing: 6px; animation: maBtnGlow 1.8s ease-in-out infinite;
}
.ma-tip { margin: 0; font-size: 13px; color: #9db6a6; }
.ma-wait { margin: 0; font-size: 15px; line-height: 1.9; color: #d6c28d; text-align: center; }
.ma-board {
  --ma-w: clamp(58px, 6.4vw, 92px);
  position: relative; z-index: 1;
  display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end;
  width: fit-content; max-width: 100%; margin: 20px auto 8px;
  padding: 18px 20px 20px; gap: 14px;
  border: 1px solid rgba(217,176,96,.38); border-radius: 16px;
  background:
    radial-gradient(ellipse at 50% 100%, rgba(64,142,96,.34), transparent 66%),
    linear-gradient(180deg, rgba(4,28,16,.94), rgba(2,16,9,.96));
  box-shadow: inset 0 2px 18px rgba(0,0,0,.55), inset 0 0 0 3px rgba(255,255,255,.025),
              0 8px 24px rgba(0,0,0,.3);
}
.tile.ma-big {
  width: var(--ma-w); height: calc(var(--ma-w) * 1.36); border-radius: 8px;
  transform-origin: 50% 100%; backface-visibility: hidden;
  box-shadow: 0 4px 0 #b9a880, 0 7px 14px rgba(0,0,0,.5);
  animation: maFlip .55s cubic-bezier(.2,1.35,.4,1) both;
}
.tile.ma-big .wan-num { font-size: min(calc(var(--th) * .45), calc(var(--ma-w) * .78)); }
.tile.ma-big .wan-suit { font-size: min(calc(var(--th) * .32), calc(var(--ma-w) * .57)); }
.tile.ma-big .honor { font-size: min(calc(var(--th) * .56), calc(var(--ma-w) * .94)); }
.tile.ma-big .joker { font-size: min(calc(var(--th) * .56), calc(var(--ma-w) * .94)); }
.tile.ma-big.on {
  box-shadow: 0 4px 0 #b9a880, 0 0 0 2px #ffd66e, 0 0 24px rgba(255,201,96,.82);
  z-index: 3;
}
.tile.ma-big.on::after {
  content: "中"; position: absolute; top: 2px; right: 2px;
  display: flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; padding: 0; border-radius: 50%;
  background: linear-gradient(180deg, #ffe7aa, #dcae4f); color: #2b1a05;
  font-size: 13px; font-weight: 900; line-height: 1;
  box-shadow: 0 2px 6px rgba(0,0,0,.45), 0 0 14px rgba(255,201,96,.5);
  z-index: 4;
}
.ma-count {
  position: relative; z-index: 1;
  margin-top: 18px; opacity: 0; animation: fadeUp .5s ease both;
  font-size: 18px; color: #dbe9df;
}
.ma-count b { font-size: 46px; line-height: 1; color: #ffe6a8; margin: 0 6px; text-shadow: 0 0 20px rgba(255,201,96,.45); }
.ma-count span { display: block; margin: 8px auto 0; font-size: 20px; font-weight: 700; color: #ffe0a0; }
.ma-count .ma-formula { font-size: 13px; font-weight: 600; color: #b9cfc0; letter-spacing: .02em; }
.ma-count .ma-total { margin-top: 4px; }
@keyframes maFlip {
  from { opacity: 0; transform: perspective(700px) rotateY(90deg) translateY(10px) scale(.86); }
  to { opacity: 1; transform: perspective(700px) rotateY(0) translateY(0) scale(1); }
}
@keyframes maBtnGlow {
  0%, 100% { filter: brightness(1); box-shadow: 0 4px 0 #8a6419, 0 0 14px rgba(255,201,96,.18); }
  50% { filter: brightness(1.08); box-shadow: 0 4px 0 #8a6419, 0 0 24px rgba(255,201,96,.5); }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.que-card .que-choices { display: flex; gap: 9px; margin-top: 6px; }
.qbtn {
  position: relative;
  flex: 1; padding: 12px 0 10px; border-radius: 12px; font-weight: 800;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.16); color: #fff;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.qbtn .rec {
  position: absolute; top: -8px; right: -5px; font-size: 9px; font-weight: 800;
  background: #d9b060; color: #2a1d05; padding: 1px 6px; border-radius: 8px;
}
.qbtn .qface { font-size: 24px; }
.qbtn .qsub { font-size: 10px; opacity: .7; font-weight: 600; }
.qbtn.s-w .qface { color: #ff9b9b; }
.qbtn.s-t .qface { color: #8cc6ff; }
.qbtn.s-b .qface { color: #8ee8ad; }
.qbtn:hover { border-color: var(--gold); }
.qbtn:active { transform: translateY(1px); }
.que-timer { margin-top: 12px; text-align: center; font-size: 12px; color: #f7dc9d; min-height: 16px; }

/* ---------- 结算 ---------- */
.modal .card.result { width: min(560px, 100%); max-height: 88vh; overflow-y: auto; }
.result .row { display: flex; justify-content: space-between; align-items: center; padding: 11px 8px; font-size: 16px; border-bottom: 1px dashed rgba(255,255,255,.1); }
.result .result-title { font-size: 22px; }
.result-actions { margin-top: 16px; }
.result .row .rn { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.result .row .pn { font-size: 18px; font-weight: 800; color: #f2f7f3; }
.result .rank {
  width: 21px; height: 21px; border-radius: 50%; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.1); color: #b9cabb; font-size: 11px; font-weight: 800;
}
.result .row-wrap.win .rank { background: var(--gold); color: #2b1a05; }
.result .me-tag {
  font-size: 10px; font-weight: 800; padding: 1px 6px; border-radius: 8px;
  background: var(--gold); color: #2b1a05;
}
.result .me-tag.win-tag {
  font-size: 11px; padding: 2px 9px; border-radius: 999px; letter-spacing: 1px;
  background: linear-gradient(180deg, #fff1bd, #ffd266);
  box-shadow: 0 0 0 1px rgba(255,244,210,.55), 0 0 12px rgba(255,196,70,.35);
}
.result .me-tag.win-tag.nojoker-win {
  font-size: 10px; padding: 2px 7px; letter-spacing: .5px;
}
.result .row .fan { color: #9bb3a4; font-size: 12px; }
.result .row .sc { font-weight: 800; font-size: 28px; line-height: 1; letter-spacing: .5px; }
.result .sc-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; max-width: 70%; }
.result .score-breakdown {
  font-size: 12px; line-height: 1.5; color: #a9c2b2;
  text-align: right; word-break: break-word;
}
.result .row-wrap.win {
  margin: 5px 0; padding: 2px 8px 6px; border: 1px solid rgba(255,214,130,.55); border-radius: 12px;
  background: rgba(255,201,96,.1); box-shadow: 0 0 16px rgba(255,201,96,.12);
}
.my-scoreline {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: 6px;
  margin: 8px 0 12px; padding: 8px 12px; border-radius: 12px;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.1);
  font-size: 13px; color: #cfe0d6;
}
.my-scoreline b { font-size: 32px; line-height: 1; }
.my-scoreline.pos b { color: #7ee0a2; }
.my-scoreline.neg b { color: #ff9b9b; }
.result .locknote { margin: 10px 0 0; font-size: 11px; color: #8fa89a; text-align: center; line-height: 1.6; }
.settle-vote {
  margin: 13px 0 2px; padding: 13px 14px; text-align: left;
  border: 1px solid rgba(255,201,96,.46); border-radius: 13px;
  background: linear-gradient(180deg, rgba(255,205,110,.12), rgba(255,205,110,.045));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 4px 16px rgba(0,0,0,.2);
}
.sv-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 14px; font-weight: 800; color: #ffe6a8; }
.sv-head b { font-size: 13px; color: #d6c28d; }
.sv-note { margin: 5px 0 9px; font-size: 11px; line-height: 1.65; color: #a9c2b2; }
.sv-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 9px; }
.sv-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 9px; font-size: 11px;
  background: rgba(255,255,255,.08); color: #d8e6dd;
}
.sv-pill b { font-size: 10px; font-weight: 800; opacity: .9; }
.sv-pill.ok { background: rgba(70,190,120,.18); color: #a9f0c4; }
.sv-pill.wait { background: rgba(255,201,96,.12); color: #e3cd93; }
.sv-pill.no { background: rgba(230,90,90,.18); color: #ffb3b3; }
.sv-actions { display: flex; gap: 8px; justify-content: center; }
.sv-actions .btn { margin: 0; }
.sv-wait { margin: 6px 0 0; text-align: center; font-size: 12px; color: #c8b98a; }
.sv-cancel { margin-top: 8px !important; padding: 8px !important; font-size: 13px !important; }
.settle-start { margin-top: 8px; }
.sc.pos { color: #7ee0a2; }
.sc.neg { color: #ff9b9b; }
.result .reason { font-size: 12px; color: #9bb3a4; margin: 4px 0 10px; }
.result .reason.sub { margin: -4px 0 10px; font-size: 11px; color: #c8b98a; }
.row-wrap { border-bottom: 1px dashed rgba(255,255,255,.1); padding-bottom: 6px; }
.row-wrap .row { border-bottom: 0; padding-bottom: 3px; }
.ma-line { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; padding: 2px 2px 4px; }
.tile.ma-tile {
  width: 26px; height: 34px; border-radius: 5px;
  animation: maIn .4s cubic-bezier(.2,1.5,.4,1) both;
}
.tile.ma-tile .wan-num { font-size: 15px; }
.tile.ma-tile .wan-suit { font-size: 10px; }
.tile.ma-tile .honor { font-size: 18px; }
.tile.ma-tile .joker { font-size: 18px; }
.tile.ma-tile.on {
  width: 32px; height: 42px; border-radius: 6px; z-index: 1;
  box-shadow: 0 0 0 2px var(--gold), 0 0 12px rgba(217,176,96,.65);
}
.tile.ma-tile.on .wan-num { font-size: 17px; }
.tile.ma-tile.on .wan-suit { font-size: 12px; }
.tile.ma-tile.on .honor { font-size: 21px; }
.tile.ma-tile.on .joker { font-size: 21px; }
.tile.ma-tile.on::after {
  content: '中'; position: absolute; top: -10px; right: -7px;
  background: var(--gold); color: #1c2a1f; font-size: 12px; font-weight: 900;
  border-radius: 4px; padding: 2px 6px; line-height: 1.15;
  box-shadow: 0 2px 6px rgba(0,0,0,.35);
}
@keyframes maIn {
  from { opacity: 0; transform: translateY(-10px) scale(.7) rotate(-6deg); }
  to { opacity: 1; transform: none; }
}

/* ---------- 日志 / 聊天 ---------- */
/* 聊天改为右上角半透明浮层：不挤压牌桌，可用顶栏按钮或面板右上角收起 */
.game.log-open { padding-right: 0; }

.logbox {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 44px);
  right: max(8px, env(safe-area-inset-right));
  bottom: auto; left: auto;
  width: min(320px, calc(100vw - 16px));
  max-height: min(56vh, calc(100dvh - 56px - env(safe-area-inset-bottom)));
  display: flex; flex-direction: column; gap: 7px;
  color: #c8d9cd;
  background:
    radial-gradient(120% 80% at 100% 0%, rgba(255,211,125,.10), transparent 56%),
    linear-gradient(180deg, rgba(8,31,19,.78), rgba(2,14,8,.66));
  border: 1px solid rgba(217,176,96,.30);
  border-radius: 14px;
  padding: 10px 12px;
  z-index: 55;
  box-shadow: 0 18px 48px rgba(0,0,0,.48), inset 0 1px 0 rgba(255,255,255,.06);
  backdrop-filter: blur(14px) saturate(1.12);
  -webkit-backdrop-filter: blur(14px) saturate(1.12);
  overflow: hidden;
  font-size: 11px;
}
.logbox .loghead {
  display: flex; align-items: center; justify-content: space-between;
  flex: 0 0 auto;
  font-size: 12px; color: #e8d6a5; letter-spacing: 1px;
  border-bottom: 1px solid rgba(255,255,255,.08); padding-bottom: 6px;
}
.logbox .loghead button { background: none; color: #9bb3a4; font-size: 16px; line-height: 1; padding: 2px 4px; }
.logbox .loghead button:hover { color: #f0e4c2; }
.logbox .log-body { overflow-y: auto; overscroll-behavior: contain; flex: 1 1 auto; min-height: 46px; line-height: 1.65; padding-right: 2px; }
.logbox .chat { color: #ffe6a8; }
.logbox .chat-quick {
  display: none; flex-wrap: wrap; gap: 5px;
  padding: 1px 0 2px; flex: 0 0 auto;
}
.logbox .chat-quick.open { display: flex; }
.logbox .quick-chip {
  flex: 0 0 auto; padding: 4px 9px; border-radius: 999px;
  background: rgba(255,255,255,.075); color: #d8e6dc;
  border: 1px solid rgba(217,176,96,.22);
  font-size: 11px; white-space: nowrap;
}
.logbox .quick-toggle {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; flex: 0 0 auto; padding: 4px 8px; border-radius: 7px;
  background: rgba(255,255,255,.055); color: #d8e6dc;
  border: 1px solid rgba(217,176,96,.18);
  font-size: 11px; font-family: inherit;
}
.logbox .quick-toggle .qt-state { color: #e8d6a5; font-size: 10px; letter-spacing: .5px; }
.logbox .quick-toggle[aria-expanded="true"] { color: #ffe6a8; border-color: rgba(255,214,130,.34); background: rgba(255,214,130,.08); }
.logbox .quick-chip:hover { color: #ffe3a9; border-color: rgba(217,176,96,.46); background: rgba(217,176,96,.12); }
.logbox .quick-chip:active { transform: translateY(1px); }
.logbox.hidden { display: none; }
.logbox .chatrow { display: flex; gap: 5px; }
.logbox .chatrow input {
  flex: 1; min-width: 0; padding: 5px 8px; border-radius: 6px; font-size: 12px;
  border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.06);
  color: #eaf2ec; outline: none; font-family: inherit;
}
.logbox .chatrow button { padding: 5px 10px; border-radius: 6px; background: rgba(255,255,255,.12); color: #e6efe9; font-size: 12px; }

/* ---------- 提示 / 动效 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 30%; transform: translateX(-50%) translateY(6px);
  background: rgba(0,0,0,.82); color: #ffe9bf; padding: 8px 16px; border-radius: 20px;
  font-size: 13px; z-index: 80; max-width: 82vw; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 开局分风 / 掷骰 ---------- */
.opening {
  position: fixed; top: 58px; left: 50%; transform: translateX(-50%);
  z-index: 30; pointer-events: none; width: min(560px, 92vw);
  animation: openingIn .35s ease both;
}
.opening-card {
  border-radius: 14px; padding: 14px 20px 12px;
  background: rgba(7,26,16,.92); border: 1px solid rgba(217,176,96,.55);
  box-shadow: 0 12px 36px rgba(0,0,0,.55), 0 0 28px rgba(217,176,96,.12);
  text-align: center; color: #f2e6c8;
}
.op-title { font-size: 12px; letter-spacing: 3px; color: #c8b98a; }
.op-winds { display: flex; justify-content: center; gap: 8px; margin: 9px 0 10px; flex-wrap: wrap; }
.op-wind {
  display: flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 8px;
  background: rgba(255,255,255,.07); font-size: 14px;
}
.op-wind span { color: var(--gold); font-weight: 800; }
.op-wind b { color: #fff; font-weight: 600; max-width: 6.5em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.op-dice-wrap { display: flex; align-items: center; justify-content: center; gap: 14px; }
.op-dice { display: flex; gap: 8px; }
.die {
  width: 40px; height: 40px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #fffdf2, #e3d5b6); color: #b3271f;
  font-size: 26px; font-weight: 900; box-shadow: 0 3px 0 #b9a880, 0 4px 12px rgba(0,0,0,.4);
  animation: dieRoll .55s cubic-bezier(.3,1.6,.5,1) both;
}
.die:nth-child(2) { animation-delay: .12s; }
.op-dice-tip { font-size: 12px; color: #9db6a6; }
.op-dice-tip b { color: #ffe6a8; font-size: 14px; }
.op-from { margin-top: 9px; font-size: 13px; color: #cfe0d6; }
.op-from b { color: #ffe6a8; font-size: 15px; }
@keyframes openingIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes dieRoll {
  from { opacity: 0; transform: rotate(-90deg) scale(.4); }
  to { opacity: 1; transform: none; }
}

.flash-layer { position: fixed; inset: 0; pointer-events: none; z-index: 75; display: flex; align-items: center; justify-content: center; }
.action-layer {
  position: fixed; inset: 0; pointer-events: none; z-index: 76;
  display: flex; align-items: center; justify-content: center;
  padding-bottom: 7vh;
}
.nojoker-layer {
  position: fixed; inset: 0; pointer-events: none; z-index: 59;
  display: flex; align-items: center; justify-content: center;
  padding-bottom: 4vh;
}
.nojoker-flash {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: 9px;
  animation: njWrap 2.05s ease-out both;
}
.nojoker-flash::before {
  content: ""; position: absolute; z-index: -1; left: 50%; top: 38%;
  width: min(520px, 82vw); height: min(170px, 27vw);
  transform: translate(-50%, -50%);
  background: repeating-conic-gradient(from -8deg at 50% 50%, rgba(237,178,69,.34) 0deg 4deg, transparent 4deg 12deg);
  -webkit-mask-image: radial-gradient(ellipse at center, #000 0 34%, transparent 73%);
  mask-image: radial-gradient(ellipse at center, #000 0 34%, transparent 73%);
  opacity: .72; pointer-events: none;
}
.nj-char {
  font-family: "FengKai MJ", "KaiTi", "STKaiti", "SimSun", "Songti SC", serif;
  font-size: clamp(92px, 14vw, 168px); font-weight: 700; line-height: .9; letter-spacing: 0;
  color: #fff6dd; -webkit-text-stroke: 2.5px #0d100e;
  paint-order: stroke fill;
  text-shadow: 6px 5px 0 #de392f, -3px -3px 0 #e8bc53, 0 13px 0 rgba(0,0,0,.25), 0 22px 30px rgba(0,0,0,.55);
  filter: drop-shadow(0 10px 16px rgba(0,0,0,.44));
  transform: rotate(-3deg);
  animation: njChar 1.55s cubic-bezier(.18,.9,.2,1) both;
}
.nj-sub {
  position: relative; z-index: 2;
  font-size: 13px; letter-spacing: 1px; color: #ffe9bd;
  text-shadow: 0 2px 6px rgba(0,0,0,.95), 0 0 3px rgba(0,0,0,.9);
  animation: njSub 1.9s ease both;
}
@keyframes njWrap { 0% { opacity: 0; } 9% { opacity: 1; } 74% { opacity: 1; } 100% { opacity: 0; } }
@keyframes njChar {
  0% { opacity: 0; transform: scale(.45) rotate(-7deg); filter: blur(5px); }
  22% { opacity: 1; transform: scale(1.08) rotate(-3deg); filter: blur(0); }
  36% { transform: scale(1) rotate(-3deg); }
  100% { opacity: 1; transform: scale(1.03) rotate(-2deg); }
}
@keyframes njSub {
  0%, 18% { opacity: 0; transform: translateY(8px); }
  34% { opacity: 1; transform: none; }
  86% { opacity: 1; }
  100% { opacity: .85; }
}
.action-layer.at-top {
  align-items: flex-start; justify-content: center;
  padding-top: 9vh; padding-bottom: 0;
}
.action-layer.at-right {
  align-items: center; justify-content: flex-end;
  padding-right: max(110px, 16vw); padding-bottom: 0;
}
.action-layer.at-bottom {
  align-items: flex-end; justify-content: center;
  padding-bottom: 21vh; padding-top: 0;
}
.action-layer.at-left {
  align-items: center; justify-content: flex-start;
  padding-left: max(110px, 16vw); padding-bottom: 0;
}
.action-flash {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  animation: afStamp 1.5s cubic-bezier(.18,.9,.2,1) both;
}
.af-stamp { position: relative; z-index: 2; }
/* 风楷爆字原版：金色放射线只做光，不垫实心底板 */
.af-stamp::before {
  content: ""; position: absolute; z-index: -1; left: 50%; top: 51%;
  width: min(500px, 76vw); height: min(164px, 25vw);
  transform: translate(-50%, -50%);
  background: repeating-conic-gradient(from -8deg at 50% 50%, rgba(237,178,69,.34) 0deg 4deg, transparent 4deg 12deg);
  -webkit-mask-image: radial-gradient(ellipse at center, #000 0 34%, transparent 73%);
  mask-image: radial-gradient(ellipse at center, #000 0 34%, transparent 73%);
  opacity: .72; pointer-events: none;
}
.af-char {
  display: block; font-family: "FengKai MJ", "KaiTi", "STKaiti", "SimSun", "Songti SC", serif;
  font-size: clamp(96px, 13vw, 178px); font-weight: 700; line-height: .9;
  letter-spacing: 0; color: #fff6dd;
  -webkit-text-stroke: 3px #0d100e;
  paint-order: stroke fill;
  text-shadow: 6px 5px 0 #de392f, -3px -3px 0 #e8bc53, 0 13px 0 rgba(0,0,0,.25), 0 22px 30px rgba(0,0,0,.55);
  filter: drop-shadow(0 10px 16px rgba(0,0,0,.44));
  transform: rotate(-4deg);
}
.af-two .af-char {
  font-size: clamp(66px, 8.6vw, 112px); letter-spacing: 2px;
  transform: rotate(-3deg);
}
.af-who {
  position: relative; z-index: 2; display: inline-flex; align-items: center; gap: 6px;
  margin-top: 10px; padding: 0;
  background: none;
  color: #f6dcab; font-size: 11px; font-weight: 500; letter-spacing: .1em;
  text-shadow: 0 2px 6px rgba(0,0,0,.95), 0 0 3px rgba(0,0,0,.9);
  animation: afTextIn .3s ease .18s both;
}
.af-who i { font-style: normal; color: #e2bd73; font-size: 12px; line-height: 1; }
.af-sub {
  position: relative; z-index: 2; max-width: 86vw; margin-top: 6px;
  color: rgba(255,246,226,.96); font-size: 12.5px; font-weight: 500; line-height: 1.4; text-align: center;
  text-shadow: 0 2px 7px rgba(0,0,0,.98), 0 0 3px rgba(0,0,0,.92);
  animation: afTextIn .3s ease .26s both;
}
@keyframes afStamp {
  0% { opacity: 0; transform: scale(.42) rotate(-12deg); }
  16% { opacity: 1; transform: scale(1.13) rotate(-2deg); }
  34% { transform: scale(1) rotate(0deg); }
  58% { opacity: 1; transform: scale(1.02) rotate(0deg); }
  82% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.1) rotate(1deg); }
}
@keyframes afTextIn {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: none; }
}
/* 自摸：只闪一次的大字氛围，不常驻抓码面板 */
.zimo-burst {
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; overflow: hidden;
}
.zimo-burst::before {
  content: ""; position: absolute; z-index: 0; width: min(88vw, 960px); aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,196,80,.18), rgba(255,173,44,.06) 44%, transparent 72%);
  animation: zimoBurstGlow 1.4s ease-out both;
}
.zimo-burst::after {
  content: ""; position: absolute; z-index: 0; left: 50%; top: 50%;
  width: min(620px, 90vw); height: min(200px, 29vw);
  transform: translate(-50%, -50%);
  background: repeating-conic-gradient(from -8deg at 50% 50%, rgba(237,178,69,.34) 0deg 4deg, transparent 4deg 12deg);
  -webkit-mask-image: radial-gradient(ellipse at center, #000 0 34%, transparent 73%);
  mask-image: radial-gradient(ellipse at center, #000 0 34%, transparent 73%);
  opacity: .72; pointer-events: none;
  animation: zimoBurstRays 1.4s ease-out both;
}
.zimo-burst span {
  position: relative; z-index: 2;
  font-family: "FengKai MJ", "KaiTi", "STKaiti", "SimSun", "Songti SC", serif;
  font-size: clamp(110px, 19vw, 250px); font-weight: 700; line-height: .9;
  letter-spacing: .04em; color: #fff6dd; white-space: nowrap;
  -webkit-text-stroke: 3px #0d100e;
  paint-order: stroke fill;
  text-shadow: 6px 5px 0 #de392f, -3px -3px 0 #e8bc53, 0 13px 0 rgba(0,0,0,.25), 0 22px 30px rgba(0,0,0,.55);
  filter: drop-shadow(0 10px 16px rgba(0,0,0,.44));
  transform: rotate(-3deg);
  animation: zimoBurst 1.4s cubic-bezier(.16,.9,.24,1) both;
}
@keyframes zimoBurst {
  0% { opacity: 0; transform: translateY(12px) scale(.55) rotate(-8deg); filter: blur(8px); }
  13% { opacity: 1; transform: translateY(0) scale(1.08) rotate(-3deg); filter: blur(0); }
  26% { transform: scale(1) rotate(-3deg); }
  66% { opacity: 1; transform: scale(1.03) rotate(-2deg); }
  100% { opacity: 0; transform: scale(1.12) rotate(0deg); filter: blur(3px); }
}
@keyframes zimoBurstGlow {
  0% { opacity: 0; transform: scale(.6); }
  20% { opacity: 1; transform: scale(1); }
  70% { opacity: .55; transform: scale(1.08); }
  100% { opacity: 0; transform: scale(1.2); }
}
@keyframes zimoBurstRays {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.88); }
  20% { opacity: .72; transform: translate(-50%, -50%) scale(1); }
  70% { opacity: .5; transform: translate(-50%, -50%) scale(1.04); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.12); }
}
.flash {
  font-size: clamp(30px, 7vw, 56px); font-weight: 900; letter-spacing: 4px;
  color: #ffd76e; -webkit-text-stroke: 1.5px rgba(74,44,5,.55);
  text-shadow: 0 2px 0 #9b6b17, 0 4px 0 #503207, 0 4px 18px rgba(0,0,0,.8), 0 0 30px rgba(255,193,70,.5);
  animation: flashIn .55s ease-out forwards;
}
.flash small {
  display: block; font-size: 15px; letter-spacing: 2px; margin-top: 8px;
  color: #ffe9b0; font-weight: 600; text-shadow: 0 2px 8px rgba(0,0,0,.8);
}
@keyframes flashIn {
  0% { transform: scale(.5) rotate(-6deg); opacity: 0; }
  25% { transform: scale(1.15) rotate(0); opacity: 1; }
  70% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.06); opacity: 0; }
}

/* 点击牌桌头像：玩家资料小卡 */
.player-sheet {
  position: fixed; inset: 0; z-index: 58; display: flex;
  align-items: center; justify-content: center; padding: 14px;
}
/* 摇骰弹层在 body 层，3D 的 #app 又被限制在 z-index:1，
   资料卡在 #app 里再提高层级也压不过它；所以打开资料卡时直接把骰子层收起，
   关闭资料卡后再恢复，避免“摇骰子”按钮穿透到资料卡中间。 */
body.player-sheet-open .modal.dice-modal { display: none !important; }
.player-sheet-mask {
  position: absolute; inset: 0;
  background: rgba(2, 9, 5, .58);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.player-sheet.sheet-opening .player-sheet-mask {
  animation: sheetFade .18s ease both;
}
.player-sheet-card {
  position: relative; z-index: 1;
  width: min(350px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px); overflow-y: auto;
  padding: 24px 20px 16px; text-align: center; color: #eaf3ec;
  border: 1px solid rgba(226,190,105,.42); border-radius: 18px;
  background:
    radial-gradient(circle at 50% 0%, rgba(72,154,105,.32), transparent 52%),
    linear-gradient(165deg, #103a25, #06190f 76%);
  box-shadow: 0 24px 70px rgba(0,0,0,.58), inset 0 1px 0 rgba(255,255,255,.08);
}
.player-sheet.sheet-opening .player-sheet-card {
  animation: fadeUp .2s ease both;
}
.player-sheet-close {
  position: absolute; top: 8px; right: 9px;
  width: 28px; height: 28px; padding: 0; border: 1px solid rgba(255,255,255,.12);
  border-radius: 50%; background: rgba(255,255,255,.06); color: #c8d8cc;
  font: inherit; font-size: 15px; line-height: 1; cursor: pointer;
}
.player-sheet-close:active { background: rgba(255,255,255,.12); }
.pdetail-top { display: flex; align-items: center; gap: 14px; text-align: left; }
.pdetail-avatar { flex: 0 0 auto; display: inline-flex; }
.avatar.pdetail-av {
  width: 68px; height: 68px; font-size: 28px;
  box-shadow: 0 0 0 2px rgba(255,222,150,.34), 0 7px 18px rgba(0,0,0,.38);
}
.pdetail-id { min-width: 0; flex: 1; }
.pdetail-id h2 {
  margin: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: #fff4d6; font-size: 23px; line-height: 1.25; letter-spacing: .02em;
}
.pdetail-tags { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.pdetail-tag {
  display: inline-flex; align-items: center; height: 20px; padding: 0 8px;
  border-radius: 999px; background: rgba(255,255,255,.09);
  color: #bed1c3; font-size: 11px; font-weight: 700; white-space: nowrap;
}
.pdetail-tag.wind { background: rgba(255,214,130,.17); color: #ffe0a2; }
.pdetail-tag.you { background: rgba(255,214,130,.3); color: #2b1a05; }
.pdetail-tag.host { background: rgba(255,196,96,.2); color: #ffd98f; }
.pdetail-tag.bot { background: rgba(150,190,255,.16); color: #bdd6ff; }
.pdetail-tag.offline { background: rgba(255,255,255,.08); color: #aabbc0; }
.pdetail-tag.que { background: rgba(255,196,96,.17); color: #f5c671; }
.pdetail-tag.hu { background: rgba(255,120,120,.2); color: #ffb3b3; }
.pdetail-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 16px; }
.pdetail-stat {
  padding: 10px 10px 9px; border: 1px solid rgba(255,255,255,.09);
  border-radius: 11px; background: rgba(3,17,10,.42);
}
.pdetail-stat b {
  display: block; color: #e7f0e9; font-size: 28px; line-height: 1.05;
  font-variant-numeric: tabular-nums; text-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.pdetail-stat b.pos { color: #8fe3ab; }
.pdetail-stat b.neg { color: #ffa2a2; }
.pdetail-stat span { display: block; margin-top: 4px; color: #9db5a6; font-size: 11px; letter-spacing: .06em; }
.pdetail-closebtn {
  width: 100%; margin-top: 14px; padding: 8px 12px;
  border-radius: 9px; font-size: 13px;
}
@keyframes sheetFade { from { opacity: 0; } to { opacity: 1; } }

.conn-overlay {
  position: fixed; inset: 0; z-index: 2147483000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0; padding: 28px; text-align: center; color: #fff;
  background:
    radial-gradient(circle at 50% 42%, rgba(90, 24, 24, .38), transparent 46%),
    rgba(7, 11, 9, .88);
  -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px);
  animation: connFadeIn .22s ease-out both;
}
.conn-overlay.out { opacity: 0; transition: opacity .24s ease; }
.conn-overlay.is-reconnected {
  background:
    radial-gradient(circle at 50% 42%, rgba(18, 90, 56, .34), transparent 46%),
    rgba(7, 11, 9, .84);
}
.conn-mark {
  width: 54px; height: 54px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid rgba(255, 211, 120, .78);
  color: #ffd77a; font-size: 28px; font-weight: 800; line-height: 1;
  box-shadow: 0 0 34px rgba(255, 190, 90, .14);
}
.conn-title {
  margin: 18px 0 0; font-size: clamp(36px, 7vw, 62px); font-weight: 800;
  letter-spacing: .1em; line-height: 1.08; color: #ffe6a8;
  text-shadow: 0 10px 34px rgba(0, 0, 0, .46);
}
.conn-overlay.is-reconnected .conn-mark { border-color: rgba(126, 232, 164, .9); color: #9ff5bf; }
.conn-overlay.is-reconnected .conn-title { color: #b9f7cf; }
.conn-desc {
  margin: 14px 0 0; max-width: 30em; font-size: 16px; line-height: 1.7;
  color: rgba(255, 255, 255, .84);
}
.conn-progress {
  margin-top: 20px; min-height: 20px; display: flex; align-items: center; gap: 9px;
  font-size: 12px; color: rgba(255, 255, 255, .56);
}
.conn-spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .22); border-top-color: #ffd77a;
  animation: connSpin 1s linear infinite;
}
.conn-overlay.is-reconnected .conn-spinner { display: none; }
.conn-overlay.is-reconnected .conn-progress { color: rgba(185, 247, 207, .7); }
.conn-overlay.is-reconnected .conn-mark { animation: connPop .35s ease-out both; }

@keyframes connFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes connSpin {
  to { transform: rotate(360deg); }
}
@keyframes connPop {
  0% { transform: scale(.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@media (max-width: 760px) {
  .conn-overlay { padding: 24px 18px calc(24px + env(safe-area-inset-bottom)); }
  .conn-mark { width: 46px; height: 46px; font-size: 24px; }
  .conn-title { margin-top: 14px; letter-spacing: .08em; }
  .conn-desc { font-size: 14px; }
}

@media (max-width: 900px) {
  .game.log-open { padding-right: 0; }
  .logbox {
    left: auto; right: max(8px, env(safe-area-inset-right));
    top: calc(env(safe-area-inset-top) + 42px);
    bottom: auto;
    width: min(300px, calc(100vw - 16px));
    max-height: min(52vh, calc(100dvh - 54px - env(safe-area-inset-bottom)));
    border-radius: 12px;
  }
}

@media (max-width: 760px) {
  .table { grid-template-columns: clamp(54px, 13vw, 64px) minmax(0,1fr) clamp(54px, 13vw, 64px); grid-template-rows: 88px minmax(0,1fr); }
  .wall-num { font-size: 17px; }
  .pname { max-width: 5.5em; font-size: 12px; }
  .avatar { width: 20px; height: 20px; font-size: 11px; }
  .seat .avatar { width: 28px; height: 28px; font-size: 14px; }
  /* 手机侧边座位留出外侧手牌列，头像和名字缩成窄列往内放 */
  .seat.left .seat-head, .seat.right .seat-head { gap: 3px; max-width: calc(100% - 22px); }
  .seat.left .seat-head { left: 20px; }
  .seat.right .seat-head { right: 20px; }
  .seat.left .avatar, .seat.right .avatar { width: 24px; height: 24px; font-size: 12px; }
  .seat.left .pname, .seat.right .pname { font-size: 11px; max-width: 100%; }
  .seat.left .windtag, .seat.right .windtag { width: 18px; height: 18px; font-size: 10px; }
  .seat.left .pscore, .seat.right .pscore { font-size: 14px; }
  .seat.top .avatar { width: 30px; height: 30px; font-size: 15px; }
  .pscore { font-size: 16px; }
  .seat-head { padding: 2px 9px 2px 3px; }
  .mine-head { gap: 3px; padding: 1px 9px 1px 2px; }
  .mine-head .avatar { width: 22px; height: 22px; font-size: 11px; }
  .mine-head .me-name { font-size: 11px; }
  .mine-head .pscore { font-size: 14px; }
  .mine-clock { width: 20px; height: 20px; font-size: 9px; }
  .mine-head .mine-score { font-size: 18px; }
  .turnmark { width: 30px; height: 30px; font-size: 14px; }
  .turnmark.tm-top { top: 88px; left: calc(50% - 15px); }
  .turn-pointer.tp-top { top: 92px; }
  .turn-pointer .tp-num { width: 30px; height: 30px; font-size: 14px; }
  .actions { min-height: 68px; }
  .react-hint { gap: 4px; padding: 0 7px; min-width: 68px; height: 46px; }
  .react-hint .rh-from { font-size: 11px; }
  .react-hint .react-tile { width: 24px; height: 32px; }
  .act.react-act { height: 46px; min-width: 68px; padding: 0 15px; font-size: 17px; }
  .turnmark.tm-bottom { bottom: 2px; left: calc(50% - 15px); }
  .turnmark.tm-left { left: 50px; top: calc(50% - 15px); }
  .turnmark.tm-right { right: 50px; top: calc(50% - 15px); }
  .turn-pointer.tp-bottom { bottom: 2px; }
  .turn-pointer.tp-left { left: 50px; }
  .turn-pointer.tp-right { right: 50px; }
  .seat.turnseat { border-radius: 8px; }
  .act { font-size: 13px; padding: 6px 9px; min-width: 46px; }
  .topbar { flex-wrap: wrap; white-space: normal; row-gap: 4px; overflow: visible; }
  .topbar .spacer { display: none; }
}

/* 手机手牌分两行，保证最右边的「摸牌」不用横向拖动也能看到 */
@media (max-width: 560px) {
  :root { --tw: clamp(34px, 10.5vw, 44px); }
  .hand-row { overflow-x: hidden; overflow-y: visible; padding-top: 10px; }
  .hand-inner {
    width: 100%; max-width: calc(var(--tw) * 7 + 12px);
    margin-left: auto; margin-right: auto;
    display: grid;
    grid-template-columns: repeat(7, var(--tw));
    grid-auto-rows: var(--th);
    justify-content: center; align-content: end; align-items: end;
    column-gap: 2px; row-gap: 4px;
    min-height: calc(var(--th) * 2 + 4px);
  }
  .hand-gap { display: none; }
  .hand-inner .draw-slot,
  .hand-inner .tile.drawn { grid-row: 2; grid-column: 7; }
  .hand-row .tile.big.picked { transform: translateY(-4px); }
  .hand-row .draw-slot:hover { transform: none; }
  .actions { min-height: 56px; }
  .profile-stats { grid-template-columns: repeat(2, 1fr); }
  .history-list { max-height: 180px; }
  .modal .card.setup-card { padding: 18px 14px 16px; }
  .setup-title { font-size: 22px; letter-spacing: 5px; }
  .setup-tip { margin: 6px 0 10px; }
  .setup-tiles {
    display: grid; grid-template-columns: repeat(2, clamp(100px, 28vw, 118px));
    justify-content: center; gap: 12px 14px;
  }
  .setup-tile { width: 100%; height: clamp(136px, 38vw, 160px); }
  .setup-tile.back .setup-q { font-size: clamp(42px, 13vw, 54px); }
  .tile.setup-face { width: 66%; height: auto; aspect-ratio: 56 / 76; }
  .tile.setup-face .honor { font-size: clamp(42px, 12.5vw, 58px); }
  .setup-owner { max-width: 100%; }
  .dice-info { max-width: 100%; margin-top: 10px; }
  .dice-info-row { padding: 7px 10px; gap: 8px; font-size: 13px; }
  .dice-info-row .dic-k { font-size: 11px; padding: 2px 6px; }
  .dice-info-row .dic-v b { font-size: 14px; }
  .deal-banner {
    top: 58px; left: 8px; right: 8px; transform: none;
    max-width: none; padding: 5px 9px; gap: 8px;
  }
  .deal-banner .db-text { font-size: 12px; line-height: 1.35; }
  .deal-banner .db-text b { font-size: 13px; }
  .deal-banner .db-extra { font-size: 10px; }
  .dice-panel { width: min(300px, 88vw); gap: 6px; }
  .action-layer { padding-bottom: 10vh; }
  .pagenav { flex-wrap: wrap; row-gap: 4px; padding: 6px 8px 3px; gap: 4px; }
  .pnav-main { width: 100%; gap: 4px; }
  .pnav { padding: 5px 11px; font-size: 11px; }
  .pnav.ptool { padding: 5px 10px; font-size: 10px; }
  .pnav-tools { position: static; transform: none; width: 100%; justify-content: center; gap: 5px; }
  .profile-body { flex-direction: column; align-items: center; }
  .profile-fields { width: 100%; }
  .entry-foot { flex-wrap: wrap; }
  .entry-foot .music-link { margin-left: auto; }
  .action-layer.at-top { padding-top: 12vh; padding-bottom: 0; }
  .action-layer.at-bottom { padding-bottom: 25vh; padding-top: 0; }
  .action-layer.at-left { padding-left: max(104px, 16vw); padding-bottom: 0; }
  .action-layer.at-right { padding-right: max(104px, 16vw); padding-bottom: 0; }
  .af-char { font-size: clamp(88px, 24vw, 124px); }
  .af-two .af-char { font-size: clamp(58px, 16vw, 88px); }
  .af-who { margin-top: 7px; font-size: 12px; padding: 3px 10px; }
  .af-sub { font-size: 13px; max-width: 92vw; }
  .dice-panel .setup-roll { width: auto; min-width: 96px; padding: 7px 14px; font-size: 14px; }
}

/* ---------- 牌桌聊天大字：谁说就出现在谁那边 ---------- */
.chat-callout-layer {
  position: fixed; inset: 0; z-index: 56;
  pointer-events: none;
}
.chat-callout {
  --tx: 0; --ty: 0;
  position: absolute; max-width: min(420px, 38vw);
  text-align: center; white-space: pre-wrap; word-break: break-word;
  opacity: 0; visibility: hidden;
  transform: translate(var(--tx), var(--ty)) scale(.72);
  transform-origin: 50% 50%;
  transition: opacity .18s ease, transform .2s cubic-bezier(.2,.9,.25,1.2), visibility .18s ease;
}
.chat-callout.show { opacity: 1; visibility: visible; transform: translate(var(--tx), var(--ty)) scale(1); }
.cc-text {
  display: inline-block;
  font-family: "KaiTi", "STKaiti", "SimSun", "Songti SC", serif;
  font-size: clamp(40px, 4.3vw, 66px); font-weight: 900; line-height: 1.12;
  letter-spacing: 1px; color: #ffd76e;
  -webkit-text-stroke: 1.5px rgba(74,44,5,.6);
  text-shadow: 0 2px 0 #9b6b17, 0 5px 0 #503207,
    0 12px 26px rgba(0,0,0,.68), 0 0 30px rgba(255,193,70,.52);
}
.chat-callout.cc-long { max-width: min(470px, 46vw); }
.chat-callout.cc-long .cc-text {
  font-size: clamp(22px, 2.6vw, 38px); line-height: 1.32;
  letter-spacing: 0; -webkit-text-stroke-width: 1px;
}
.chat-callout.cc-top { top: 16%; left: 50%; --tx: -50%; }
.chat-callout.cc-bottom { bottom: 26%; left: 50%; --tx: -50%; }
.chat-callout.cc-left { left: 7vw; top: 41%; --ty: -50%; }
.chat-callout.cc-right { right: 7vw; top: 41%; --ty: -50%; }
@media (max-width: 760px) {
  .chat-callout { max-width: 62vw; }
  .chat-callout.cc-top { top: 15%; }
  .chat-callout.cc-bottom { bottom: 27%; }
  .chat-callout.cc-left { left: 3vw; top: 37%; }
  .chat-callout.cc-right { right: 3vw; top: 37%; }
  .cc-text { font-size: clamp(34px, 8.5vw, 48px); }
  .chat-callout.cc-long .cc-text { font-size: clamp(20px, 5vw, 28px); }
}

@media (max-width: 420px) {
  .reveal-h { width: calc(var(--dw) * 0.66); height: calc(var(--dh) * 0.66); }
}

/* ---------- 页面切换与加载 ---------- */
.page-in { animation: pageIn .16s ease-out both; }
@keyframes pageIn { from { opacity: .42; } to { opacity: 1; } }

.load-layer {
  position: fixed; inset: 0; z-index: 70;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4, 16, 9, .42);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  opacity: 0; visibility: hidden;
  transition: opacity .16s ease, visibility .16s ease;
}
.load-layer.show { opacity: 1; visibility: visible; }
.load-box {
  min-width: 150px; padding: 16px 22px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(21, 58, 38, .96), rgba(10, 34, 21, .96));
  border: 1px solid rgba(217, 176, 96, .24);
  box-shadow: 0 18px 46px rgba(0, 0, 0, .42);
  color: #efe6d2; font-size: 13px; letter-spacing: .04em;
}
.load-ring {
  width: 17px; height: 17px; flex: 0 0 auto;
  border: 2px solid rgba(217, 176, 96, .18);
  border-top-color: #e8c67f;
  border-radius: 50%;
  animation: loadSpin .78s linear infinite;
}
@keyframes loadSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .page-in { animation: none; }
  .load-ring { animation-duration: 1.6s; }
}

/* ---------- 手机横屏引导 ---------- */
#orient-gate {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background:
    radial-gradient(ellipse at 50% 38%, rgba(27, 104, 62, .38), rgba(2, 12, 7, .96) 68%),
    #03120a;
  text-align: center;
  touch-action: none;
  -webkit-user-select: none; user-select: none;
}
@media (orientation: portrait) and (pointer: coarse) {
  #orient-gate { display: flex; }
}
html.mobile-device.portrait-orientation #orient-gate { display: flex; }
html.mobile-device:not(.portrait-orientation) #orient-gate { display: none; }
.orient-card {
  width: min(310px, 82vw);
  padding: 26px 22px 22px;
  border-radius: 20px;
  border: 1px solid rgba(217, 176, 96, .34);
  background: linear-gradient(180deg, rgba(22, 66, 43, .96), rgba(6, 26, 16, .98));
  box-shadow: 0 22px 60px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .06);
}
.orient-phone {
  position: relative;
  width: 48px;
  height: 76px;
  margin: 0 auto 17px;
  border: 2px solid rgba(232, 198, 127, .9);
  border-radius: 11px;
  box-shadow: 0 0 0 1px rgba(217, 176, 96, .18), 0 6px 22px rgba(0, 0, 0, .35);
  animation: orientPhone 2.8s ease-in-out infinite;
}
.orient-phone::before {
  content: "";
  position: absolute;
  inset: 6px 4px 12px;
  border-radius: 6px;
  border: 1px solid rgba(255, 235, 190, .18);
  background: linear-gradient(160deg, rgba(55, 130, 84, .45), rgba(7, 31, 18, .6));
}
.orient-phone span {
  position: absolute;
  left: 50%;
  bottom: 5px;
  width: 13px;
  height: 2px;
  margin-left: -6.5px;
  border-radius: 2px;
  background: rgba(232, 198, 127, .65);
}
@keyframes orientPhone {
  0%, 18% { transform: rotate(0deg); }
  36%, 78% { transform: rotate(-90deg); }
  94%, 100% { transform: rotate(0deg); }
}
.orient-card h2 {
  margin: 0;
  font-size: 21px;
  letter-spacing: 2px;
  color: #ffe3a4;
  font-family: "KaiTi", "STKaiti", "SimSun", serif;
}
.orient-card p {
  margin: 9px 0 0;
  font-size: 13px;
  line-height: 1.7;
  color: #cfe0d6;
}
.orient-card small {
  display: block;
  margin-top: 7px;
  font-size: 11px;
  line-height: 1.6;
  color: #88a393;
}

/* ---------- 微信内 / iPhone 全屏引导 ---------- */
.minibtn.screenbtn,
.pnav.screenbtn {
  color: #ffe6a8;
  border-color: rgba(255,214,130,.42);
  background: rgba(255,214,130,.10);
}
.screen-guide {
  position: fixed; inset: 0; z-index: 140;
  display: none; align-items: center; justify-content: center;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}
.screen-guide.show { display: flex; }
.sg-mask {
  position: absolute; inset: 0;
  background: rgba(2, 10, 6, .62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.sg-card {
  position: relative; z-index: 1;
  width: min(520px, 92vw); max-height: 86vh; overflow-y: auto;
  padding: 24px 24px 18px;
  border: 1px solid rgba(255,215,135,.55);
  border-radius: 18px;
  background:
    radial-gradient(circle at 30% 0%, rgba(72,154,105,.36), transparent 50%),
    linear-gradient(160deg, #0e3422, #05170e 75%);
  box-shadow: 0 24px 70px rgba(0,0,0,.62), 0 0 60px rgba(255,196,80,.14), inset 0 1px 0 rgba(255,255,255,.08);
  text-align: left;
  -webkit-overflow-scrolling: touch;
}
.sg-x {
  position: absolute; top: 7px; right: 9px;
  width: 30px; height: 30px; padding: 0;
  border: 0; border-radius: 8px;
  background: transparent; color: #9bb3a4; font-size: 18px; line-height: 1;
}
.sg-badge {
  width: 40px; height: 40px; margin-bottom: 12px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; border: 1px solid rgba(255,215,135,.36);
  background: rgba(255,214,130,.09); color: #ffd76e;
  font-size: 22px; font-weight: 800; line-height: 1;
}
.sg-card h2 {
  margin: 0; color: #ffe3a4; font-family: "KaiTi", "STKaiti", "SimSun", serif;
  font-size: 23px; letter-spacing: 1px; line-height: 1.3;
}
.sg-body { margin-top: 10px; color: #d6e6dc; font-size: 14px; line-height: 1.7; }
.sg-body p { margin: 0 0 10px; }
.sg-steps { display: flex; flex-direction: column; gap: 7px; margin: 13px 0; }
.sg-steps span { display: flex; align-items: center; gap: 9px; line-height: 1.5; }
.sg-steps b {
  flex: 0 0 auto; width: 20px; height: 20px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: #e8c67f; color: #1b2418; font-size: 12px; font-weight: 900;
}
.sg-steps em { font-style: normal; color: #ffe6a8; font-weight: 800; }
.sg-hint {
  margin: 10px 0 0; padding-top: 10px;
  border-top: 1px solid rgba(255,215,135,.16);
  color: #9db6a6; font-size: 12px; line-height: 1.7;
}
.sg-link {
  display: block; width: 100%; margin-top: 10px; padding: 8px 9px;
  border: 1px solid rgba(255,215,135,.35); border-radius: 8px;
  background: rgba(0,0,0,.25); color: #ffe6a8; font-size: 11px; font-family: inherit;
}
.sg-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 16px; }
.sg-btn {
  padding: 9px 15px; border-radius: 10px; border: 1px solid rgba(255,215,135,.22);
  background: rgba(255,255,255,.08); color: #f2e5c6;
  font-family: inherit; font-size: 13px; font-weight: 800; line-height: 1;
}
.sg-btn.gold {
  border-color: rgba(255,224,160,.72);
  background: linear-gradient(180deg, #f3cf7e, #c18a35);
  color: #20150a;
  box-shadow: 0 3px 12px rgba(0,0,0,.35);
}
.sg-btn.ghost { color: #ffe6a8; background: rgba(255,214,130,.08); }
.sg-foot { margin: 12px 0 0; color: #7f978a; font-size: 11px; line-height: 1.5; }
@media (orientation: landscape) and (max-height: 560px) {
  .sg-card { width: min(600px, 88vw); max-height: 90vh; padding: 16px 18px 13px; }
  .sg-badge { width: 32px; height: 32px; margin-bottom: 7px; font-size: 18px; }
  .sg-card h2 { font-size: 19px; }
  .sg-body { margin-top: 7px; font-size: 12.5px; line-height: 1.55; }
  .sg-steps { gap: 4px; margin: 8px 0; }
  .sg-hint { margin-top: 7px; padding-top: 7px; font-size: 11px; }
  .sg-actions { margin-top: 10px; }
  .sg-btn { padding: 8px 13px; font-size: 12px; }
  .sg-foot { margin-top: 8px; font-size: 10px; }
}

/* ---------- 手机横屏短屏：牌桌尽量铺满，手牌压到底部 ---------- */
@media (orientation: landscape) and (max-width: 1100px) and (max-height: 620px) {
  :root {
    --tw: clamp(28px, 5.4vw, 52px);
    --dw: clamp(22px, 3.4vw, 36px);
  }
  .topbar {
    padding: 3px max(7px, env(safe-area-inset-right)) 3px max(7px, env(safe-area-inset-left));
    gap: 5px;
    font-size: 11px;
    flex-wrap: nowrap;
    white-space: nowrap;
    overflow-x: auto;
  }
  .topbar .spacer { display: block; flex: 1; }
  .topbar .minibtn { padding: 3px 7px; font-size: 11px; }
  .game.log-open { padding-right: 0; }
  .logbox {
    left: auto; right: max(8px, env(safe-area-inset-right));
    top: calc(env(safe-area-inset-top) + 42px);
    bottom: auto;
    width: min(300px, calc(100vw - 16px));
    max-height: min(52vh, calc(100dvh - 54px - env(safe-area-inset-bottom)));
    border-radius: 12px;
  }
  .table {
    grid-template-columns: clamp(46px, 8vw, 58px) minmax(0, 1fr) clamp(46px, 8vw, 58px);
    grid-template-rows: 76px minmax(0, 1fr);
    gap: 2px;
    padding: 2px 4px 0;
  }
  .seat .avatar { width: 26px; height: 26px; font-size: 13px; }
  .seat.top { overflow: visible; }
  .seat.top .avatar { width: 30px; height: 30px; font-size: 15px; }
  .pname { font-size: 12px; max-width: 6em; }
  .pscore { font-size: 15px; }
  .windtag { width: 18px; height: 18px; font-size: 10px; }
  .seat.left .avatar, .seat.right .avatar { width: 22px; height: 22px; font-size: 11px; }
  .seat.left .pname, .seat.right .pname { font-size: 11px; }
  .seat.left .windtag, .seat.right .windtag { width: 17px; height: 17px; font-size: 9px; }
  .seat.left .pscore, .seat.right .pscore { font-size: 13px; }
  .mine {
    padding: 3px max(6px, env(safe-area-inset-right)) calc(3px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
    gap: 2px;
  }
  .mine-head { gap: 3px; padding: 1px 9px 1px 2px; }
  .mine-head .avatar { width: 22px; height: 22px; font-size: 11px; }
  .mine-head .me-name { font-size: 11px; }
  .mine-head .pscore { font-size: 14px; }
  .mine-clock { width: 20px; height: 20px; font-size: 9px; }
  .mine-head .mine-score { font-size: 17px; }
  .actions { min-height: 44px; gap: 6px; }
  .actions:empty { display: none; }
  .tip { font-size: 11px; line-height: 14px; min-height: 14px; }
  .hand-row { padding: 12px 2px 0; min-height: calc(var(--th) + 4px); }
  .hand-inner {
    display: flex;
    width: auto;
    max-width: 100%;
    min-height: 0;
    margin: 0 auto;
    align-items: flex-end;
    gap: clamp(1px, .3vw, 3px);
  }
  .hand-gap { display: block; width: 8px; }
  .turnmark.tm-top { top: 76px; }
  .turn-pointer.tp-top { top: 76px; }
  .turnmark.tm-left, .turnmark.tm-right { top: 50%; }
  .turn-pointer.tp-left, .turn-pointer.tp-right { top: 50%; }

  /* 3D：牌桌铺满整个对局区，自己的手牌浮在底部，牌桌不再被挤成一条 */
  body.mode-3d.in-game .table {
    grid-template-rows: 58px minmax(0, 1fr);
    padding-bottom: 0;
  }
  body.mode-3d.in-game .seat.top { overflow: visible; }
  body.mode-3d.in-game .seat.left .seat-head,
  body.mode-3d.in-game .seat.right .seat-head { top: 33%; }
  body.mode-3d.in-game .turnmark.tm-top { top: 58px; }
  body.mode-3d.in-game .turn-pointer.tp-top { top: 58px; }
  body.mode-3d.in-game .mine {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 7;
    padding-top: 0;
    border-top: 0;
    background: linear-gradient(to top,
      rgba(3, 16, 9, .98) 0,
      rgba(3, 16, 9, .90) calc(var(--th) * .42),
      rgba(3, 16, 9, .56) calc(var(--th) * .78),
      rgba(3, 16, 9, .16) calc(var(--th) + 2px),
      rgba(3, 16, 9, 0) calc(var(--th) + 22px));
    pointer-events: none;
  }
  body.mode-3d.in-game .mine > * { pointer-events: auto; }
  body.mode-3d.in-game .mine-head { text-shadow: 0 1px 4px rgba(0, 0, 0, .7); }
  body.mode-3d.in-game .mine-head .mine-cum { color: #bdd0c3; }

  /* 2D / HTML 弹层：手机横屏短屏下收紧，不要一张结果卡铺满整屏 */
  .modal { padding: 8px; }
  .modal .card {
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    overflow-y: auto;
  }
  .modal .card.ma-card {
    width: min(480px, calc(100vw - 24px));
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    padding: 16px 20px 14px;
    border-radius: 14px;
  }
  .ma-card::before { right: 14px; top: -10px; font-size: 78px; }
  .ma-head { gap: 3px; }
  .ma-head h2 { font-size: 25px; line-height: 1.15; letter-spacing: 1px; }
  .ma-head h2 .ma-winner { font-size: inherit; letter-spacing: inherit; margin-right: 4px; }
  .ma-head p { font-size: 12px; }
  .ma-head p.ma-subline { font-size: 11px; letter-spacing: 0; }
  .ma-board {
    --ma-w: clamp(46px, 6.4vw, 64px);
    margin: 10px auto 4px;
    padding: 9px 12px 11px;
    gap: 8px;
    border-radius: 12px;
  }
  .tile.ma-big.on::after {
    width: 18px; height: 18px; font-size: 11px; top: 2px; right: 2px;
  }
  .ma-count { margin-top: 9px; font-size: 13px; }
  .ma-count b { margin: 0 4px; font-size: 30px; }
  .ma-count span { margin-top: 3px; font-size: 13px; }
  .ma-count .ma-formula { font-size: 11px; }
  .ma-count .ma-total { margin-top: 2px; font-size: 12px; }
  .ma-actions { margin-top: 9px; gap: 6px; }
  .ma-actions .btn { min-width: 140px; padding: 8px 18px; font-size: 14px; }
  .ma-btn { min-width: 180px !important; padding: 9px 26px !important; font-size: 17px !important; letter-spacing: 3px; }
  .ma-tip { font-size: 11px; }
  .ma-wait { font-size: 13px; line-height: 1.6; }

  .modal .card.result {
    width: min(540px, calc(100vw - 24px));
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    padding: 12px 16px;
  }
  .result .row { padding: 7px 4px; font-size: 13px; }
  .result .row .pn { font-size: 15px; }
  .result .row .sc { font-size: 22px; }
  .result .score-breakdown { font-size: 10px; line-height: 1.35; }
  .result .row-wrap.win { margin: 4px 0; padding: 1px 6px 4px; }
  .my-scoreline { margin: 5px 0 8px; padding: 5px 8px; font-size: 11px; }
  .my-scoreline b { font-size: 24px; }
  .result .reason { margin: 2px 0 6px; font-size: 11px; }
  .result .locknote { margin-top: 6px; font-size: 10px; }
  .settle-vote { margin: 8px 0 2px; padding: 9px 10px; }
  .sv-head { font-size: 12px; }
  .sv-note { margin: 4px 0 6px; font-size: 10px; line-height: 1.5; }
  .sv-actions .btn { padding: 8px; font-size: 13px; }

  .modal .card.setup-card {
    width: min(540px, calc(100vw - 24px));
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    padding: 14px 16px 12px;
  }
  .setup-title { font-size: 20px; letter-spacing: 4px; }
  .setup-tip { margin: 4px 0 8px; font-size: 11px; }
  .setup-tiles { gap: 7px; }
  .setup-tile { width: 62px; height: 84px; border-radius: 6px; }
  .setup-tile.back .setup-q { font-size: 30px; }
  .tile.setup-face { width: 42px; height: 57px; }
  .tile.setup-face .honor { font-size: 32px; }
  .setup-owner { max-width: 60px; font-size: 9px; }
  .setup-my { margin-top: 7px; font-size: 11px; }
  .setup-my b { font-size: 15px; }
  .setup-winds { margin-top: 6px; gap: 6px; font-size: 11px; }
  .setup-dice { margin-top: 6px; gap: 8px; }

  .modal .card.settings-card {
    width: min(540px, calc(100vw - 24px));
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    padding: 0;
  }
  .modal .card.bgm-card,
  .modal .card.profile-card,
  .modal .card.rules-card {
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
  }
  .settings-head { padding: 11px 14px 8px; }
  .settings-head h2 { font-size: 16px; }
  .settings-body { padding: 0 14px 2px; }
  .settings-foot { padding: 4px 14px 10px; }
  .modal .card.profile-card,
  .modal .card.rules-card { padding: 14px 16px; }

  /* 横屏宽而矮：所有弹层统一居中，横向展开，纵向不够时在卡片内部滚动 */
  .modal { align-items: center; justify-content: center; }
  .modal .card.settings-card,
  .modal .card.setup-card { width: min(640px, calc(100vw - 24px)); }
  .modal .card.result { width: min(620px, calc(100vw - 24px)); }
  .modal .card.ma-card { width: min(420px, calc(100vw - 24px)); }
  .modal .card.profile-card,
  .modal .card.rules-card { width: min(560px, calc(100vw - 24px)); }
  .modal .card.bgm-card { width: min(520px, calc(100vw - 24px)); }
  .modal .card.que-card { width: min(520px, calc(100vw - 24px)); }
  .modal .card.pause-card { width: min(440px, calc(100vw - 24px)); }

  /* 入口/大厅也按横屏宽高收口，卡片不超出上下边界 */
  .center-wrap { padding: 10px; }
  .center-wrap .card {
    width: min(480px, calc(100vw - 20px));
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
    overflow-y: auto;
    padding: 16px 18px;
  }
}

/* 横屏矮窗口的入口页：整体收紧，首页一屏能看完 */
@media (orientation: landscape) and (max-height: 760px) {
  .entry-card {
    width: min(430px, calc(100vw - 16px));
    padding: 10px 16px;
  }
  .entry-card .main-brand {
    margin: 0 0 6px;
  }
  .entry-card .brand {
    margin-bottom: 6px;
  }
  .entry-card .logo-stack {
    gap: 2px;
  }
  .entry-card .logo-tiles {
    height: 42px;
    padding: 0 4px;
  }
  .entry-card .logo-tile {
    width: 30px;
    height: 38px;
    margin-left: -4px;
    border-radius: 5px;
  }
  .entry-card .logo-tile span {
    font-size: 21px;
  }
  .entry-card .main-brand .game-logo {
    font-size: clamp(30px, 4.6vh, 38px);
    line-height: 1;
    letter-spacing: 3px;
  }
  .entry-card .entry-profile {
    gap: 10px;
    margin-bottom: 2px;
    align-items: center;
  }
  .entry-card .entry-avatar-btn {
    width: 48px;
    height: 48px;
  }
  .entry-card .avatar.entry-av {
    width: 48px;
    height: 48px;
    font-size: 20px;
  }
  .entry-card .entry-name label {
    margin-bottom: 3px;
  }
  .entry-card .entry-name-row input {
    padding: 8px 10px;
    font-size: 13px;
  }
  .entry-card .mini-btn.entry-random {
    min-height: 30px;
    padding: 0 8px;
    font-size: 10px;
  }
  .entry-card .entry-hint {
    margin: 0 0 6px;
    font-size: 10px;
    line-height: 1.35;
  }
  .entry-card .btn {
    padding: 8px;
    font-size: 14px;
  }
  .entry-card .split {
    margin: 8px 0 6px;
    font-size: 11px;
  }
  .entry-card .code-row input {
    padding: 8px 10px;
    font-size: 13px;
  }
  .entry-card .code-row .btn {
    width: 92px;
  }
  .entry-card .entry-foot {
    margin-top: 6px;
    font-size: 10px;
    line-height: 1.35;
  }
}

/* 横屏矮窗口的结算页：收紧四行成绩和按钮，避免上下滚动 */
@media (orientation: landscape) and (max-height: 760px) {
  .modal.result-modal .card.result {
    padding: 8px 12px;
  }
  .result .brand {
    margin-bottom: 4px;
  }
  .result .result-title {
    font-size: 18px;
  }
  .result .my-scoreline {
    margin: 3px 0 5px;
    padding: 3px 8px;
    gap: 4px;
    font-size: 10px;
    border-radius: 8px;
  }
  .result .my-scoreline b {
    font-size: 20px;
  }
  .result .row-wrap {
    padding-bottom: 3px;
  }
  .result .row {
    padding: 4px 4px;
    font-size: 12px;
    gap: 6px;
  }
  .result .row .rn {
    gap: 5px;
  }
  .result .row .pn {
    font-size: 13px;
  }
  .result .rank {
    width: 17px;
    height: 17px;
    font-size: 9px;
  }
  .result .row .sc {
    font-size: 18px;
  }
  .result .sc-wrap {
    gap: 1px;
  }
  .result .score-breakdown {
    font-size: 9px;
    line-height: 1.2;
  }
  .result .row-wrap.win {
    margin: 2px 0;
    padding: 1px 5px 3px;
    border-radius: 9px;
  }
  .result .me-tag.win-tag {
    font-size: 9px;
    padding: 1px 6px;
    letter-spacing: 0;
  }
  .result .ma-line {
    gap: 3px;
    padding: 0 0 2px;
  }
  .result .tile.ma-tile {
    width: 22px;
    height: 29px;
  }
  .result .tile.ma-tile .wan-num {
    font-size: 11px;
  }
  .result .tile.ma-tile .wan-suit {
    font-size: 8px;
  }
  .result .tile.ma-tile .honor,
  .result .tile.ma-tile .joker {
    font-size: 14px;
  }
  .result .tile.ma-tile.on {
    width: 26px;
    height: 33px;
  }
  .result .tile.ma-tile.on .wan-num {
    font-size: 13px;
  }
  .result .tile.ma-tile.on .wan-suit {
    font-size: 9px;
  }
  .result .tile.ma-tile.on .honor,
  .result .tile.ma-tile.on .joker {
    font-size: 16px;
  }
  .result .tile.ma-tile.on::after {
    top: -8px;
    right: -5px;
    font-size: 9px;
    padding: 1px 4px;
  }
  .result .locknote {
    margin: 4px 0 0;
    font-size: 9px;
    line-height: 1.3;
  }
  .result .settle-vote {
    margin: 5px 0 0;
    padding: 7px 9px;
  }
  .result .sv-head {
    font-size: 12px;
  }
  .result .sv-note {
    margin: 3px 0 5px;
    font-size: 9px;
    line-height: 1.35;
  }
  .result-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
  }
  .result-actions [data-act="settlesession"] {
    order: 1;
    margin-top: 0;
  }
  .result-actions [data-act="restart"] {
    order: 2;
  }
  .result-actions .btn {
    flex: 1;
    min-width: 0;
    padding: 7px 8px;
    font-size: 13px;
  }
}

@media (orientation: landscape) and (max-height: 560px) {
  /* 房间页横屏两栏排布，第一屏看完座位、规则和按钮 */
  .center-wrap .card.lobby-card {
    width: min(660px, calc(100vw - 20px));
    max-height: calc(100dvh - 20px);
    padding: 12px 16px;
    display: grid;
    grid-template-columns: minmax(0, 1.04fr) minmax(0, 1fr);
    align-items: start;
    column-gap: 18px;
  }
  .lobby-card .room-code {
    margin: 0 0 6px;
    gap: 8px;
  }
  .lobby-card .room-code .num {
    font-size: 24px;
    letter-spacing: 4px;
  }
  .lobby-card .room-code .lbl {
    font-size: 10px;
  }
  .lobby-card .seat-list {
    gap: 5px;
  }
  .lobby-card .seat-row {
    padding: 5px 8px;
    border-radius: 8px;
    font-size: 12px;
  }
  .lobby-card .seat-row .who {
    gap: 6px;
  }
  .lobby-card .seat-row .avatar {
    width: 22px;
    height: 22px;
    font-size: 11px;
  }
  .lobby-card .seat-row .seatno {
    font-size: 9px;
  }
  .lobby-card .seat-tail {
    gap: 5px;
  }
  .lobby-card .seat-row .tag {
    font-size: 9px;
    padding: 1px 5px;
  }
  .lobby-card .kickbtn {
    width: 20px;
    height: 18px;
    font-size: 10px;
  }
  .lobby-card .section-label {
    margin: 0 0 4px;
    font-size: 11px;
  }
  .lobby-card .section-hint {
    font-size: 9px;
  }
  .lobby-card .mode-row {
    gap: 5px;
  }
  .lobby-card .mode-pill {
    padding: 5px 9px;
    font-size: 11px;
    border-radius: 7px;
  }
  .lobby-card .mode-pill .soon {
    font-size: 8px;
  }
  .lobby-card .mode-desc {
    margin: 4px 0 0;
    font-size: 10px;
    line-height: 1.45;
  }
  .lobby-card .lobby-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    margin-top: 8px;
  }
  .lobby-card .lobby-actions .btn {
    min-width: 0;
    padding: 7px 4px;
    font-size: 12px;
    border-radius: 8px;
  }
  .lobby-card .ready-hint {
    grid-column: 1 / -1;
    margin: 0;
    font-size: 9px;
    line-height: 1.3;
  }
  .lobby-card .hint {
    margin-top: 6px;
    font-size: 9px;
    line-height: 1.35;
  }
  .modal .card.settings-card {
    width: min(640px, calc(100vw - 20px));
    max-height: calc(100dvh - 12px);
  }
  .settings-head {
    padding: 8px 12px 6px;
  }
  .settings-head h2 {
    font-size: 15px;
  }
  .settings-head p {
    margin-top: 2px;
    font-size: 9px;
    line-height: 1.3;
  }
  .settings-body {
    padding: 0 12px;
  }
  .set-row {
    padding: 4px 0;
  }
  .set-name {
    gap: 0;
    font-size: 12px;
  }
  .set-hint {
    font-size: 9px;
  }
  .stepper {
    gap: 5px;
  }
  .stepper button {
    width: 24px;
    height: 24px;
    font-size: 13px;
  }
  .set-val {
    min-width: 26px;
    font-size: 13px;
  }
  .ma-rule {
    margin: 5px 0 0;
    font-size: 9px;
    line-height: 1.4;
  }
  .settings-foot {
    padding: 5px 12px 8px;
  }
  .settings-foot .btn {
    padding: 9px;
    font-size: 14px;
    border-radius: 9px;
  }
  .modal.bgm-modal .card.bgm-card {
    width: min(600px, calc(100vw - 20px));
    max-height: calc(100dvh - 12px);
  }
  .bgm-card .bgm-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
    column-gap: 16px;
    padding: 8px 12px 0;
  }
  .bgm-card .set-caption {
    margin: 4px 0;
    font-size: 11px;
  }
  .bgm-card .set-caption span {
    font-size: 9px;
  }
  .bgm-card .set-select-wrap {
    margin: 0;
  }
  .bgm-card .set-select {
    height: 32px;
    padding: 0 30px 0 10px;
    font-size: 12px;
    border-radius: 8px;
  }
  .bgm-card .set-toggle {
    margin: 6px 0 0;
    padding: 5px 8px;
    border-radius: 7px;
    font-size: 11px;
  }
  .bgm-card .togglebtn {
    padding: 3px 10px;
    font-size: 10px;
  }
  .bgm-card .bgm-note {
    margin: 6px 0 0;
    font-size: 9px;
    line-height: 1.4;
  }
  .bgm-card > .btn {
    width: calc(100% - 24px);
    margin: 8px 12px 10px;
    padding: 9px;
    font-size: 13px;
    border-radius: 9px;
  }
  .bgm-card .settings-actions {
    padding: 6px 12px 0;
  }
  .bgm-card .settings-label {
    margin-bottom: 5px;
    font-size: 10px;
  }
  .bgm-card .settings-label span {
    font-size: 8px;
  }
  .bgm-card .quality-actions {
    padding: 0 12px;
  }
  .bgm-card .quality-grid {
    gap: 5px;
  }
  .bgm-card .quality-chip {
    padding: 6px 8px;
    border-radius: 7px;
  }
  .bgm-card .quality-chip .q-name {
    font-size: 12px;
  }
  .bgm-card .quality-chip .q-desc {
    font-size: 9px;
  }
  .bgm-card .quality-chip .q-rec {
    top: -6px;
    right: 5px;
    font-size: 8px;
  }
  .bgm-card .settings-action-grid {
    gap: 5px;
  }
  .bgm-card .settings-action {
    min-height: 46px;
    padding: 3px;
    gap: 2px;
    border-radius: 7px;
  }
  .bgm-card .sa-ico {
    width: 20px;
    height: 20px;
    font-size: 11px;
  }
  .bgm-card .sa-title {
    font-size: 10px;
  }
  .bgm-card .settings-divider {
    margin: 6px 12px 0;
  }
  .modal.profile-modal .card.profile-card {
    width: min(680px, calc(100vw - 20px));
    height: calc(100dvh - 20px);
    max-height: calc(100dvh - 20px);
    padding: 10px 12px;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    align-items: stretch;
  }
  .profile-card .profile-head {
    grid-row: 1;
    margin-bottom: 6px;
  }
  .profile-card .profile-head h2 {
    font-size: 16px;
  }
  .profile-card .iconbtn {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }
  .profile-card .profile-layout {
    grid-row: 2;
    display: grid;
    grid-template-columns: minmax(0, 1.28fr) minmax(0, .82fr);
    gap: 10px;
    align-items: stretch;
    min-height: 0;
    overflow: hidden;
  }
  .profile-card .profile-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
  }
  .profile-card .profile-body {
    flex-direction: row;
    align-items: flex-start;
    gap: 9px;
  }
  .profile-card .profile-avatar-btn {
    width: 52px;
    gap: 4px;
    font-size: 9px;
  }
  .profile-card .avatar.profile-av {
    width: 52px;
    height: 52px;
    font-size: 20px;
    box-shadow: 0 0 0 1px rgba(255,214,130,.4), 0 5px 14px rgba(0,0,0,.4);
  }
  .profile-card .profile-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }
  .profile-card .profile-fields .field:first-child {
    grid-column: 1 / -1;
  }
  .profile-card .field {
    margin-bottom: 0;
  }
  .profile-card .field label {
    margin-bottom: 3px;
    font-size: 9px;
  }
  .profile-card .name-label {
    gap: 4px;
  }
  .profile-card .mini-btn {
    padding: 2px 6px;
    font-size: 9px;
    border-radius: 5px;
  }
  .profile-card input[type=text],
  .profile-card input[type=password] {
    padding: 6px 8px;
    border-radius: 7px;
    font-size: 12px;
  }
  .profile-card .profile-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
    margin-top: 7px;
  }
  .profile-card .pstat {
    padding: 4px 2px;
    border-radius: 7px;
  }
  .profile-card .pstat b {
    font-size: 15px;
  }
  .profile-card .pstat span {
    margin-top: 1px;
    font-size: 8px;
  }
  .profile-card .history-block {
    display: flex;
    flex-direction: column;
    min-height: 0;
    margin-top: 0;
    padding: 0 0 0 10px;
    border-top: 0;
    border-left: 1px solid rgba(255,255,255,.1);
  }
  .profile-card .history-head h3 {
    font-size: 11px;
  }
  .profile-card .history-head span {
    font-size: 8px;
  }
  .profile-card .history-list {
    flex: 1;
    min-height: 0;
    max-height: none;
  }
  .profile-card .history-empty {
    margin: 4px 0 0;
    padding: 8px 6px;
    font-size: 9px;
    line-height: 1.4;
  }
  .profile-card .hrow {
    padding: 4px 0;
    gap: 6px;
  }
  .profile-card .hwhen {
    font-size: 9px;
  }
  .profile-card .hmeta,
  .profile-card .hhint {
    font-size: 8px;
  }
  .profile-card .hscore {
    font-size: 14px;
  }
  .profile-card .profile-foot {
    grid-row: 3;
    gap: 6px;
    margin-top: 8px;
  }
  .profile-card .profile-foot .btn {
    padding: 8px;
    font-size: 12px;
    border-radius: 8px;
  }
  .avatar-picker-card {
    width: min(370px, 100%);
    max-height: calc(100% - 4px);
    padding: 11px 12px;
  }
  .avatar-picker-head h3 {
    font-size: 15px;
  }
  .avatar-picker .preset-grid {
    grid-template-columns: repeat(9, minmax(0, 1fr));
    gap: 5px;
  }
  .avatar-picker .preset-av {
    border-width: 1px;
  }
  .avatar-picker-actions .btn {
    padding: 7px 8px;
    font-size: 11px;
  }
  .avatar-picker-foot {
    margin-top: 8px;
    padding-top: 7px;
  }
  .modal.ma-modal .card.ma-card {
    width: min(400px, calc(100vw - 20px));
    min-height: min(180px, calc(100dvh - 20px));
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
    padding: 12px 14px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .ma-card::before {
    right: 10px;
    top: -8px;
    font-size: 58px;
  }
  .ma-head {
    gap: 1px;
  }
  .ma-head h2 {
    font-size: 21px;
    line-height: 1.15;
    letter-spacing: .5px;
  }
  .ma-head h2 .ma-winner { font-size: inherit; letter-spacing: inherit; margin-right: 3px; }
  .ma-head p {
    font-size: 10px;
  }
  .ma-head p.ma-subline {
    font-size: 9px;
    letter-spacing: 0;
  }
  .ma-board {
    --ma-w: clamp(44px, 5.4vw, 52px);
    margin: 7px auto 3px;
    padding: 6px 8px 7px;
    gap: 5px;
    border-radius: 9px;
  }
  .tile.ma-big.on::after {
    width: 16px; height: 16px; font-size: 10px; top: 2px; right: 2px;
  }
  .ma-count {
    margin-top: 6px;
    font-size: 11px;
  }
  .ma-count b {
    margin: 0 3px;
    font-size: 25px;
  }
  .ma-count span {
    margin-top: 2px;
    font-size: 10px;
  }
  .ma-count .ma-formula {
    font-size: 9px;
  }
  .ma-count .ma-total {
    margin-top: 1px;
    font-size: 9px;
  }
  .ma-actions {
    margin-top: 7px;
    gap: 4px;
  }
  .ma-actions .btn {
    min-width: 120px;
    padding: 6px 16px;
    font-size: 12px;
  }
  .ma-btn {
    min-width: 150px !important;
    padding: 7px 20px !important;
    font-size: 15px !important;
    letter-spacing: 2px;
  }
  .ma-tip {
    font-size: 10px;
  }
  .ma-wait {
    font-size: 12px;
    line-height: 1.5;
  }
}

/* 手机横屏：玩家资料卡压成小面板，不顶出上下边界 */
@media (orientation: landscape) and (max-height: 560px) {
  .player-sheet-card {
    width: min(320px, calc(100vw - 20px));
    padding: 16px 16px 12px;
    border-radius: 14px;
  }
  .player-sheet-close {
    top: 6px;
    right: 7px;
    width: 25px;
    height: 25px;
    font-size: 13px;
  }
  .pdetail-top {
    gap: 11px;
    padding-right: 16px;
  }
  .avatar.pdetail-av {
    width: 56px;
    height: 56px;
    font-size: 23px;
    box-shadow: 0 0 0 1.5px rgba(255,222,150,.32), 0 5px 14px rgba(0,0,0,.36);
  }
  .pdetail-id h2 {
    font-size: 20px;
  }
  .pdetail-tags {
    gap: 4px;
    margin-top: 5px;
  }
  .pdetail-tag {
    height: 18px;
    padding: 0 7px;
    font-size: 10px;
  }
  .pdetail-stats {
    gap: 7px;
    margin-top: 10px;
  }
  .pdetail-stat {
    padding: 7px 8px 6px;
    border-radius: 9px;
  }
  .pdetail-stat b {
    font-size: 23px;
  }
  .pdetail-stat span {
    margin-top: 2px;
    font-size: 10px;
  }
  .pdetail-closebtn {
    margin-top: 9px;
    padding: 6px 10px;
    font-size: 12px;
  }
}

/* ---------- 手机横屏 3D：自己的信息卡回到手牌上方，并与三家统一尺寸 ---------- */
@media (orientation: landscape) and (min-width: 900px) and (max-height: 620px) {
  body.mode-3d.in-game .mine-head {
    gap: 5px;
    padding: 2px 10px 2px 3px;
  }
  body.mode-3d.in-game .mine-head .avatar,
  body.mode-3d.in-game .seat .avatar {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }
  body.mode-3d.in-game .seat-head { gap: 5px; padding: 2px 10px 2px 3px; }
  body.mode-3d.in-game .mine-head .me-name,
  body.mode-3d.in-game .seat .pname { font-size: 12px; }
  body.mode-3d.in-game .mine-head .pscore,
  body.mode-3d.in-game .seat .pscore { font-size: 16px; }
  body.mode-3d.in-game .mine-head .mine-clock {
    width: 18px;
    height: 18px;
    font-size: 8px;
  }
}
