/* styles.css —— 跑胡子测试版样式（移动端优先） */
:root {
  --bg: #0f1420;
  --panel: #1a2233;
  --panel2: #232e45;
  --line: #33415f;
  --txt: #e8edf6;
  --muted: #93a0bd;
  --accent: #ffb347;
  --accent2: #4fd1c5;
  --red: #ff5a5a;
  --green: #38d39f;
  --danger: #ff6b6b;
  --tile-bg: #f5efe0;
  --tile-txt: #1c2433;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg); color: var(--txt);
  overflow-x: hidden;
}
#app { max-width: 560px; margin: 0 auto; min-height: 100vh; position: relative; }
.screen { min-height: 100vh; display: flex; flex-direction: column; }

/* 首页 */
.home-card {
  margin: auto; padding: 28px 22px; width: 100%; max-width: 420px; text-align: center;
}
.home-card h1 { font-size: 46px; margin: 10px 0 4px; letter-spacing: 6px; color: var(--accent); }
.sub { color: var(--txt); margin: 0 0 2px; font-size: 16px; }
.sub2 { color: var(--muted); margin: 0 0 22px; font-size: 13px; }
.btn {
  display: block; width: 100%; margin: 10px 0; padding: 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--panel2); color: var(--txt);
  font-size: 16px; cursor: pointer; transition: .15s;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: linear-gradient(135deg, #ffb347, #ff8a3d); color: #1c1206; border: none; font-weight: 700; }
.btn.tiny { width: auto; display: inline-block; padding: 6px 12px; font-size: 13px; margin: 0; }
.btn:disabled { opacity: .4; cursor: default; }
.invite { margin-top: 22px; text-align: left; background: var(--panel); border: 1px dashed var(--line); border-radius: 12px; padding: 12px; }
.invite-row { font-size: 13px; color: var(--muted); }
.invite code { color: var(--accent2); word-break: break-all; }
.hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; line-height: 1.5; }

/* 顶栏 */
#topbar {
  display: flex; justify-content: space-between; align-items: center; padding: 10px 14px;
  background: var(--panel); border-bottom: 1px solid var(--line); font-size: 13px; gap: 8px;
}
.tb-left span, .tb-right span { margin-right: 10px; color: var(--muted); }
#dealerInfo { color: var(--accent); }

/* 牌桌 */
#gameRoot { flex: 1; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.seat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.seat.human { border-color: var(--accent); }
.seat-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; margin-bottom: 4px; }
.seat-name { font-weight: 600; }
.seat-name .you { color: var(--accent); font-size: 11px; margin-left: 4px; }
.dealer-badge { background: var(--accent); color: #1c1206; border-radius: 6px; padding: 1px 6px; font-size: 11px; font-weight: 700; }
.seat-score { color: var(--accent2); font-weight: 700; }
.melds { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; min-height: 4px; }
.meld { display: flex; gap: 1px; padding: 2px; background: rgba(0,0,0,.2); border-radius: 6px; border: 1px solid var(--line); }
.backrow { display: flex; gap: 2px; flex-wrap: wrap; }
/* 张数角标：手牌 + 门子 的实有张数 / 应有张数 */
.count-badge { font-size: 11px; line-height: 15px; color: #6f7ea3; text-align: center; letter-spacing: .3px; }
.count-badge.bad { color: #ff9b8a; font-weight: 700; }
/* 刚从底牌补进手的那张牌：虚线框，一眼看出「什么时候进的手」 */
.tile.from-wall { outline: 2px dashed #f0c56a; outline-offset: 2px; }
.turn-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--line); margin-left: 6px; }
.turn-dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }

.table-mid { display: flex; gap: 8px; }
.table-mid .seat { flex: 1; }
.center { flex: 1.4; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px; min-height: 90px; }
.center .turn-name { color: var(--green); font-size: 14px; margin-bottom: 6px; }
.discard-pile { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; max-width: 100%; }

/* 牌（长条形：竖长窄） */
.tile {
  width: 27px; height: 46px; border-radius: 6px; background: var(--tile-bg); color: var(--tile-txt);
  display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700;
  border: 1px solid #c9bfa6; user-select: none; flex: 0 0 auto; position: relative;
}
.tile.sm { width: 24px; height: 40px; font-size: 17px; }
.tile.mini { width: 19px; height: 31px; font-size: 13px; border-radius: 4px; }
.tile.red { color: #c0241c; }
.tile.back { background: #2b3650; color: transparent; border-color: #1c2433; }
.tile.back::after { content: "胡"; color: #51618a; font-size: 12px; }
.tile.sel { outline: 3px solid var(--accent); transform: translateY(-6px); }
.tile.clickable { cursor: pointer; }
/* 坎：三张相同，不能拆散打出 */
.tile.locked { outline: 2px solid var(--accent2); outline-offset: -2px; cursor: not-allowed; }
.tile.locked::after { content: '坎'; position: absolute; top: -1px; right: 1px; font-size: 9px; color: #fff; background: var(--accent2); border-radius: 0 6px 0 6px; padding: 0 3px; line-height: 13px; }
/* 手牌分列：一摞一摞，可拖动换列 */
.hand-cols { display: flex; align-items: flex-end; gap: 7px; padding: 6px 2px 2px; overflow-x: auto; }
.hand-col { position: relative; display: flex; align-items: flex-end; padding-bottom: 15px; min-width: 27px; }
.hand-col .tile + .tile { margin-left: -13px; }
/* 手机上按住拖动要先禁掉滚动/缩放，否则手指一动就滚页面 */
.hand-col .tile { box-shadow: 2px 0 3px rgba(0, 0, 0, .4); touch-action: none; }
.hand-col.col-kan .tile { box-shadow: 2px 0 0 var(--accent2), 2px 0 3px rgba(0, 0, 0, .4); }
.col-tag { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); font-size: 10px; font-style: normal; color: var(--accent2); }
.hand-col.add-zone {
  width: 27px; min-height: 46px; border: 1px dashed var(--line); border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted);
}
.add-plus { font-size: 17px; color: var(--accent); line-height: 1; }
.add-txt { font-size: 9px; margin-top: 2px; }
.hand-col.drop-on { outline: 2px dashed var(--accent2); background: rgba(79, 209, 197, .08); border-radius: 10px; }
.drag-ghost { position: fixed; z-index: 99; pointer-events: none; opacity: .9; transform: rotate(-5deg); box-shadow: 0 8px 16px rgba(0, 0, 0, .55); }
.tile.dragging { opacity: .28; }

/* 动作区 */
#actions { padding: 10px 14px calc(14px + env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line); min-height: 60px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
#actions .btn { width: auto; flex: 1; margin: 0; min-width: 80px; }
.act-hint { color: var(--muted); font-size: 13px; width: 100%; }

/* 弹窗 */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 18px; }
.modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px; width: 100%; max-width: 440px; max-height: 86vh; overflow-y: auto; }
.modal-box h2 { margin: 0 0 12px; color: var(--accent); }
.modal-box h3 { color: var(--accent2); margin: 16px 0 6px; font-size: 15px; }
.modal-box p, .modal-box li { line-height: 1.6; font-size: 14px; color: var(--txt); }
.modal-box .row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.modal-box .row .v { font-weight: 700; }
.win-list { font-size: 14px; line-height: 1.7; }
.rules-text { font-size: 13px; color: var(--muted); line-height: 1.6; }
/* 本把复盘：一条一条的动作流水 */
.replay { margin: 10px 0 4px; padding-left: 0; list-style: none; max-height: 46vh; overflow: auto; }
.replay li { position: relative; padding: 7px 8px 7px 34px; font-size: 13px; line-height: 1.5; color: var(--text);
             border-bottom: 1px dashed rgba(140,160,200,.22); }
.replay li:last-child { border-bottom: 0; }
.replay li .no { position: absolute; left: 0; top: 7px; width: 24px; text-align: center; font-size: 11px;
                 color: var(--muted); font-variant-numeric: tabular-nums; }
.replay li.empty { color: var(--muted); }
.tag { display: inline-block; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; font-size: 12px; color: var(--accent2); margin: 2px 3px 2px 0; }
.center-link { text-align: center; color: var(--muted); font-size: 13px; margin-top: 10px; }

/* 首页配置 */
.config { text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 0 0 6px; }
.config label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.config input { width: 100%; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--txt); font-size: 15px; }

/* 休息座位 */
.seat.resting { opacity: .45; }
.rest-badge { background: var(--line); color: var(--txt); border-radius: 6px; padding: 1px 6px; font-size: 11px; margin-left: 6px; }

/* 亮出的门子：提=三暗叠一明、偎=两暗叠一明，打横放在下牌区 */
.play-area { background: rgba(0, 0, 0, .16); border: 1px solid var(--line); border-radius: 10px; padding: 4px; }
.meld { display: flex; align-items: flex-end; padding: 3px 5px; background: rgba(0, 0, 0, .28); border-radius: 8px; border: 1px solid var(--line); margin-right: 6px; }
.meld .tile + .tile { margin-left: -1px; }
.meld .stack { margin-left: -11px; box-shadow: 2px 0 3px rgba(0, 0, 0, .45); }
.meld .stack:first-child { margin-left: 0; }
.meld .stack-top { margin-left: -9px; z-index: 3; box-shadow: 2px 0 0 var(--accent); }
.meld-tag { font-style: normal; font-size: 10px; color: var(--accent); margin: 0 4px 0 5px; align-self: center; }
.meld-hu { font-style: normal; font-size: 10px; color: var(--muted); align-self: center; }
/* 虚拟牌桌：每家出/翻的牌依次排在自己旁边 */
.table-zone { display: flex; align-items: center; min-height: 28px; margin: 4px 0; padding: 2px 4px; background: rgba(0, 0, 0, .18); border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; }
.table-zone.mine { border-color: var(--accent); background: rgba(255, 179, 71, .07); }
.zone-row { display: flex; gap: 2px; align-items: center; flex-wrap: wrap; }
.zone-empty { font-size: 11px; color: var(--muted); }
/* 被碰/跑/吃的牌 → 暗色 */
.tile.gone { background: #39415a; color: #7d89a6; border-color: #2a3145; }
.tile.gone .gone-tag { position: absolute; bottom: -1px; right: -1px; background: #232a3c; color: #8e9ab5; font-style: normal; font-size: 8px; border-radius: 5px 0 0 0; padding: 0 3px; }
/* 当前有动作的一方 */
.seat.acting { border-color: var(--green); }

/* 亮出的门子按类型着色 */
.meld-kan  { border-color: #6b7fa8; }              /* 坎（暗） */
.meld-wei  { border-color: #8d7bd8; }              /* 偎（两暗一明） */
.meld-peng { border-color: var(--accent2); }        /* 碰（三明） */
.meld-ti   { border-color: var(--accent); background: rgba(255,179,71,.14); }  /* 提（三暗一明） */
.meld-pao  { border-color: var(--red); background: rgba(255,90,90,.14); }      /* 跑（四明） */
.meld-shun { border-color: var(--green); }          /* 顺子/吃 */
.meld-tong { border-color: #79a0e0; }               /* 同数/绞 */

/* 中央牌 */
.center .pile { display: flex; gap: 4px; }
.center .pile .tile { width: 34px; height: 48px; font-size: 20px; }
.center .notice { margin-top: 8px; color: var(--accent2); font-size: 13px; text-align: center; max-width: 260px; line-height: 1.5; }
/* 本把休息（对家坐庄）：只留一句话 */
.seat.resting { opacity: .75; }
.rest-hint { color: #5f6d90; font-size: 12px; text-align: center; padding: 10px 4px; }
/* 剩余底牌张数：挂在中间那摞牌正下方 */
.center .wall-count { margin-top: 5px; font-size: 12px; color: #8fa0c6; letter-spacing: .5px; }
.center .wall-count:empty { display: none; }
/* 本局座位表：每局开局随机换一次方位，写在这儿一眼能看出换没换 */
.center .seat-line { margin-top: 6px; font-size: 12px; color: #7f8da6; letter-spacing: .5px; }
/* 吃的多组法选择按钮 */
.btn.chi-opt { font-size: 14px; padding: 10px 8px; border-color: var(--accent2); color: var(--accent2); }
#actions .btn.chi-opt { flex: 1 1 100%; width: 100%; }

/* 每把流水表 */
.flow-wrap { overflow-x: auto; margin: 10px 0; }
table.flow { border-collapse: collapse; width: 100%; font-size: 13px; }
table.flow th, table.flow td { border: 1px solid var(--line); padding: 5px 6px; text-align: center; white-space: nowrap; }
table.flow th { background: var(--panel2); color: var(--muted); font-weight: 600; }
table.flow td.note { text-align: left; color: var(--muted); font-size: 12px; }
table.flow td.hu { cursor: pointer; color: var(--accent); font-weight: 700; }
table.flow td.hu:hover { background: rgba(255, 179, 71, .18); }
/* 胡数栏：自摸 +N 偏绿、放炮 -N 偏红，一眼看出这把谁收谁付 */
table.flow td.hu.zimo { color: #7ee0a8; }
table.flow td.hu.jiepao { color: #ff9b8a; }
.flow-note { margin-top: 6px; font-size: 13px; color: var(--muted); min-height: 20px; }
.flow-note.show { color: var(--txt); }
table.flow tr.fin td { color: var(--accent); font-weight: 700; background: rgba(255,179,71,.08); }
table.flow tr.settle td { color: var(--accent2); font-weight: 700; background: rgba(79,209,197,.08); }
