/* 日本立直麻将样式（与斗地主/21点/UNO 同一套视觉语言：暗绿毛毡牌桌 + 金色点缀 + 白色卡片面板）
 *
 * 本文件由 uno-game/public/style.css 派生：
 *   - 上方「共享部分」逐字复用，改动需与另外三个游戏保持一致
 *   - 已剔除 UNO 专属区块（.ucard* / .color-* / .draw-pile / .pile-* / .uno-btn / .catch-btn）
 *   - 下方「麻将专属部分」为本游戏新增，命名统一带 mj- / mahjong 语义
 * 牌面类 .mj-tile 及其 34 种花色类在 tiles.css 中定义，本文件负责布局与交互。
 */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --felt: #1c6b46;
  --felt-dark: #145034;
  --panel: #ffffff;
  --panel-border: #d9e2dc;
  --ink: #1c2b24;
  --accent: #0f8a5f;
  --accent-dark: #0b6b49;
  --warn: #c0392b;
  --gold: #d4a017;
  --red: #d63031;
  --gray: #7a8a80;
  --uno-yellow: #fdcb35;
  --uno-green: #00b894;
  --uno-blue: #0984e3;
}

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: linear-gradient(160deg, #10281d 0%, #173a2a 55%, #10281d 100%);
  color: var(--ink);
  min-height: 100vh;
}

.app { max-width: 980px; margin: 0 auto; padding: 16px; }
.screen { display: none; }
.screen.active { display: block; }
.hidden { display: none !important; }

/* ---------- 通用 ---------- */
.btn {
  background: var(--accent); color: #fff; border: none;
  padding: 10px 22px; border-radius: 10px; font-size: 15px;
  cursor: pointer; transition: .15s; font-weight: 600;
}
.btn:hover { background: var(--accent-dark); transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.big { font-size: 19px; padding: 16px 34px; }
.btn.alt { background: #2563a8; }
.btn.alt:hover { background: #1d4f85; }
.btn.warn { background: var(--gold); color: #3a2c00; }
.btn.warn:hover { background: #b58910; }
.btn.ghost { background: transparent; color: #cfe3d7; border: 1px solid #3d5c4c; }
.btn.ghost:hover { background: rgba(255,255,255,.08); }
.btn.small { padding: 6px 12px; font-size: 13px; }

input {
  padding: 10px 12px; border: 1px solid #b9ccc1; border-radius: 8px;
  font-size: 15px; outline: none; background: #fbfdfc; color: var(--ink);
}
input:focus { border-color: var(--accent); }

.card-panel {
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 14px; padding: 18px; box-shadow: 0 4px 14px rgba(0,0,0,.25);
}

.tag {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  background: #e4efe9; color: var(--accent-dark); font-size: 13px; font-weight: 600;
}
.tag.gold { background: #fdf3d5; color: #8a6400; }

/* ---------- 首页 ---------- */
.home-wrap { text-align: center; padding: 48px 12px; color: #eaf5ee; }
.logo { font-size: 56px; letter-spacing: 4px; color: #fff; text-shadow: 0 3px 12px rgba(0,0,0,.5); }
.logo span { color: var(--gold); }
.slogan { margin: 12px 0 34px; color: #a9c9b6; letter-spacing: 2px; }
.home-btns { display: flex; gap: 18px; justify-content: center; margin-bottom: 40px; flex-wrap: wrap; }

.rules { max-width: 620px; margin: 0 auto; text-align: left; }
.rules h3 { margin-bottom: 10px; color: var(--accent-dark); }
.rules li { margin: 6px 0 6px 20px; color: #33463c; font-size: 14px; line-height: 1.6; }

/* ---------- 大厅 ---------- */
.lobby-wrap { max-width: 560px; margin: 30px auto; }
.lobby-wrap h2 { color: #fff; margin-bottom: 16px; text-align: center; }
.form-panel label { display: block; font-size: 13px; color: var(--gray); margin: 14px 0 6px; }
.form-panel input { width: 100%; }
.form-panel .btn { width: 100%; margin-top: 18px; }
.divider { text-align: center; color: #a7b8ae; font-size: 13px; margin: 20px 0 6px; }
.join-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.join-row .code-input { width: 110px; text-transform: uppercase; letter-spacing: 4px; text-align: center; font-weight: 700; }
.rejoin-tip { margin-top: 12px; font-size: 12px; color: var(--gray); line-height: 1.6; }
.rejoin-tip b { color: var(--accent-dark); }

/* ---------- 房间 ---------- */
.room-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 14px; color: #eaf5ee;
}
.room-code { font-size: 15px; }
.room-code b { font-size: 22px; letter-spacing: 5px; color: var(--gold); margin: 0 4px; }
#btn-copy { background: none; border: none; color: #a9c9b6; cursor: pointer; font-size: 15px; }

#need-more {
  background: #fff3cd; color: #7a5b00; text-align: center; font-weight: 700;
  padding: 10px; border-radius: 10px; margin-bottom: 14px; border: 1px solid #f1dc9b;
}

.table {
  background:
    radial-gradient(ellipse at center, var(--felt) 0%, var(--felt-dark) 100%);
  border-radius: 20px; padding: 22px 18px;
  border: 6px solid #6b4a1f; box-shadow: inset 0 0 60px rgba(0,0,0,.45), 0 8px 24px rgba(0,0,0,.4);
  margin-bottom: 14px;
  display: flex; flex-direction: column; gap: 10px;
}

/* ---------- 对手席位 ---------- */
.opp-row { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.opp-seat {
  background: rgba(0,0,0,.28); border-radius: 14px; padding: 10px 8px;
  min-width: 140px; flex: 0 1 30%; text-align: center;
  border: 2px solid transparent; transition: .2s;
}
.opp-seat.is-turn { border-color: var(--gold); box-shadow: 0 0 14px rgba(212,160,23,.55); }
.pname { color: #fff; font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.score-line { color: #ffd97a; font-size: 12px; font-weight: 700; margin-top: 5px; }
.count-line { color: #b7d6c4; font-size: 12px; margin-top: 3px; }

.card-backs { display: flex; justify-content: center; gap: 2px; min-height: 26px; margin-top: 6px; flex-wrap: wrap; max-width: 100%; }
.card-back {
  width: 16px; height: 24px; border-radius: 3px;
  background: repeating-linear-gradient(45deg, #264d8f 0 4px, #1d3d73 4px 8px);
  border: 1px solid #16305c; box-shadow: 0 1px 3px rgba(0,0,0,.4);
}

/* ---------- 中央区 ---------- */
.center-area {
  min-height: 150px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
}
.center-row { display: flex; align-items: center; justify-content: center; gap: 30px; flex-wrap: wrap; }



/* ---------- 我的座位 ---------- */
.my-seat {
  background: rgba(0,0,0,.28); border-radius: 14px; padding: 12px 14px;
  border: 2px solid transparent; transition: .2s;
}
.my-seat.is-turn { border-color: var(--gold); box-shadow: 0 0 14px rgba(212,160,23,.55); }
.my-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.my-head .pname { font-size: 15px; }
.my-head .score-line { margin-top: 0; }
.my-tip { color: #ffe9b0; font-size: 14px; font-weight: 600; min-height: 20px; margin: 8px 0 6px; }
/* M-B3：听牌提示行内的补充元素 */
.my-tip .wait-left { color: #9fd6b4; font-size: 11px; font-weight: 600; margin-left: 2px; }
.my-tip .wait-left.is-dead { color: #ff8484; }
.my-tip .tip-estimate { color: #ffd76a; font-size: 12px; font-weight: 600; }
.my-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.act-group { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- 手牌 ---------- */
.my-hand {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end;
  min-height: 96px; max-width: 100%;
  margin: 10px 0 4px; row-gap: 12px; padding: 14px 8px 12px;
}

/* ---------- 日志 ---------- */
.log-panel h4 { color: var(--accent-dark); margin-bottom: 8px; }
#log-list {
  max-height: 170px; overflow-y: auto; font-size: 13px; line-height: 1.8; color: #41564a;
}
#log-list div { border-bottom: 1px dashed #e4ece7; padding: 2px 0; }

/* ---------- 结算横幅 ---------- */
#round-banner {
  background: linear-gradient(90deg, #d4a017, #f0c94a);
  color: #3a2c00; text-align: center; font-size: 18px; font-weight: 800;
  padding: 12px; border-radius: 12px; margin-bottom: 14px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%) translateY(20px);
  background: #23342b; color: #fff; padding: 10px 22px; border-radius: 10px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 99;
  box-shadow: 0 6px 18px rgba(0,0,0,.4); max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 门户链接 ---------- */
.portal-link { margin: -22px 0 30px; }
.portal-link a { color: #a9c9b6; font-size: 14px; text-decoration: none; border-bottom: 1px dashed #3d5c4c; padding-bottom: 2px; }
.portal-link a:hover { color: #fff; }
.room-hall-link { color: #a9c9b6; font-size: 13px; text-decoration: none; border: 1px solid #3d5c4c; border-radius: 20px; padding: 4px 12px; transition: .15s; }
.room-hall-link:hover { color: #fff; background: rgba(255,255,255,.08); }

/* ---------- 弹窗 ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal-card { background: #fff; border-radius: 14px; padding: 18px; max-width: 360px; width: 100%; }
.modal-card h3 { margin-bottom: 10px; color: var(--accent-dark); }
.modal-card p { font-size: 14px; line-height: 1.6; color: #33463c; }
.modal-btns { display: flex; gap: 10px; justify-content: flex-end; margin-top: 10px; }


/* ---------- 账号系统 ---------- */
.acct-box { border: 1px dashed #b9ccc1; border-radius: 10px; padding: 12px; margin-bottom: 16px; background: #f6faf7; }
.acct-row { display: flex; gap: 8px; }
.acct-row input { flex: 1; min-width: 0; }
.acct-btns { display: flex; gap: 8px; margin-top: 10px; }
.acct-btns .btn { flex: 1; }
.acct-hint { margin-top: 8px; font-size: 12px; color: var(--gray); }
#acct-profile { display: flex; align-items: center; gap: 12px; }
.acct-avatar { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; background: #dfe9e2; cursor: pointer; border: 2px solid var(--accent); }
.acct-info { flex: 1; display: flex; flex-direction: column; gap: 2px; font-size: 14px; min-width: 0; }
.acct-records, .acct-bank { color: var(--gray); font-size: 12px; }
.acct-box .btn { width: auto; margin-top: 0; }
.acct-box .btn.ghost { color: var(--gray); border-color: #b9ccc1; }
.acct-box .btn.ghost:hover { background: #eef4ef; color: var(--ink); }
.acct-actions { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.acct-actions .acct-link { text-decoration: none; text-align: center; }
.seat-avatar { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; vertical-align: -6px; margin-right: 5px; border: 1px solid rgba(255,255,255,.4); }
.rec-line { color: #9db8a8; font-size: 11px; min-height: 14px; margin-top: 2px; }

/* ---------- 移动端 ---------- */
@media (max-width: 620px) {
  .logo { font-size: 40px; }
  .home-btns { flex-direction: column; align-items: center; }
  .app { padding: 10px; }
  .table { padding: 14px 10px; }
  .center-row { gap: 16px; }
  .opp-seat { min-width: 140px; min-width: 128px; flex: 0 1 46%; }
}

/* ---------- 房规面板 / UNO 按钮 / 惩罚叠加 ---------- */
.bottom-row { display: flex; gap: 12px; align-items: stretch; }
.bottom-row .log-panel { flex: 1; }
.rules-panel { flex: 0 0 300px; }
.rules-panel h4, .log-panel h4 { color: var(--accent-dark); margin-bottom: 8px; }
.rule-row { display: flex; align-items: flex-start; gap: 8px; padding: 5px 0; font-size: 12px; line-height: 1.5; }
.rule-flag { flex: 0 0 42px; font-weight: 800; text-align: center; border-radius: 10px; padding: 1px 0; font-size: 11px; }
.rule-flag.on { background: #dff0e5; color: var(--accent-dark); }
.rule-flag.off { background: #f0f0f0; color: #999; }
.rule-text { color: #33463c; }
.rules-panel.editable .rule-text { color: #1c2b24; }

/* 拨动开关 */
.rule-switch { position: relative; display: inline-block; width: 38px; height: 20px; flex: 0 0 38px; }
.rule-switch input { opacity: 0; width: 0; height: 0; }
.rule-slider { position: absolute; cursor: pointer; inset: 0; background: #ccc; border-radius: 20px; transition: .2s; }
.rule-slider::before { content: ""; position: absolute; height: 14px; width: 14px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.rule-switch input:checked + .rule-slider { background: var(--accent); }
.rule-switch input:checked + .rule-slider::before { transform: translateX(18px); }


@media (max-width: 720px) {
  .bottom-row { flex-direction: column; }
  .rules-panel { flex: none; }
}


/* 名次徽标 */
.rank-badge { background: var(--gold); color: #3a2c00; border-radius: 10px; padding: 1px 7px; font-size: 11px; font-weight: 800; vertical-align: 1px; }

/* ================================================================== *
 *                        麻将专属部分
 * ================================================================== */

/* ---------- 牌桌：四麻 / 三麻 两套布局 ---------- */
.table { position: relative; }
.table.mode-yonma .table-grid,
.table.mode-sanma .table-grid {
  display: grid; gap: 10px;
  grid-template-columns: minmax(132px, 1fr) minmax(200px, 1.7fr) minmax(132px, 1fr);
  grid-template-areas:
    ".    top    ."
    "left center right";
}
#seat-top { grid-area: top; }
#seat-left { grid-area: left; }
#seat-right { grid-area: right; }
.table-grid .center-area { grid-area: center; }

/* 宝牌指示牌区（需求 7）：牌桌上边缘居中，5 个槽位 */
.dora-row { display: flex; justify-content: center; align-items: flex-end; gap: 6px; margin-bottom: 10px; min-height: 48px; }
.dora-row .dora-label { color: #ffe9b0; font-size: 12px; font-weight: 700; margin-right: 4px; align-self: center; }
.dora-slot {
  width: 34px; height: 48px; border-radius: 5px;
  border: 1px dashed rgba(255,255,255,.35); background: rgba(0,0,0,.18);
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.dora-slot.is-empty { opacity: .45; }
.dora-slot.is-flipped { animation: mj-flip-in .45s ease-out; }
@keyframes mj-flip-in { from { transform: rotateY(90deg); opacity: 0; } to { transform: rotateY(0); opacity: 1; } }
.dora-row.is-ura { display: none; margin-top: 4px; }
.dora-row.is-ura.show { display: flex; }
.dora-row.is-ura .dora-slot { border-style: solid; border-color: var(--gold); box-shadow: 0 0 10px rgba(212,160,23,.45); }

/* ---------- 座位内的手牌背面堆 / 副露 / 最近打出（需求 4） ---------- */
.opp-seat .card-backs { max-width: 100%; }
.opp-melds { display: flex; justify-content: center; gap: 5px; flex-wrap: wrap; margin-top: 6px; max-width: 100%; }
.meld-group { display: flex; gap: 1px; padding: 1px; border-radius: 3px; background: rgba(255,255,255,.07); }
.meld-group.is-open { border: 1px solid rgba(255,255,255,.25); }
.meld-group.is-concealed { border: 1px solid var(--gold); }
.opp-played { margin-top: 6px; font-size: 12px; color: #ffe9b0; min-height: 16px; font-weight: 700; }
.seat-badges { display: flex; justify-content: center; gap: 4px; flex-wrap: wrap; margin: 3px 0 2px; }
.dealer-badge, .riichi-badge, .furiten-badge, .spec-badge, .bot-badge {
  border-radius: 10px; padding: 0 6px; font-size: 10px; font-weight: 800; line-height: 16px;
}
.bot-badge { background: #2b5f8a; color: #eaf5ee; }   /* AI 玩家：青灰底，区别于金/红徽标 */
.dealer-badge { background: var(--gold); color: #3a2c00; }
.riichi-badge { background: var(--red); color: #fff; }
/* M-B5：抜北展示行 —— 占满整行，把北牌逼到副露的下一行 */
.kita-row { display: flex; justify-content: center; gap: 2px; width: 100%; margin-top: 2px; }
.furiten-badge { background: #6b4a1f; color: #ffe9b0; }
.spec-badge { background: rgba(255,255,255,.2); color: #eaf5ee; }
.opp-seat.spectating, .opp-seat.abandoned { opacity: .55; }
.opp-seat.abandoned { border-style: dashed; }

/* ---------- 中央区：四方牌河 ---------- */
.center-area { position: relative; }
.river-zone {
  display: grid; gap: 6px; width: 100%;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-areas:
    ".   rtop  ."
    "rleft info rright"
    ".   rme   .";
  align-items: center; justify-items: center;
}
.river-top { grid-area: rtop; }
.river-left { grid-area: rleft; }
.river-right { grid-area: rright; }
.river-me { grid-area: rme; }
.river { display: flex; flex-wrap: wrap; gap: 2px; justify-content: center; max-width: 100%; cursor: pointer; }
.river.is-collapsed .river-tile:nth-child(-n+6) { display: none; }
.river-tile.is-called { opacity: .35; filter: grayscale(.6); }
/* 立直宣言牌横摆在牌河（M-B2）：rotate 后视觉宽 = 牌高，左右各补 3px margin 防重叠 */
.river-tile.is-riichi { transform: rotate(90deg); margin: 0 3px; }
/* 最后一张打出的牌：蓝色描边 + 微光（M-B2，不分真人/AI） */
.river-tile.is-last { outline: 2px solid #5db3ff; outline-offset: 1px; border-radius: 4px; box-shadow: 0 0 8px rgba(93,179,255,.75); }
.center-info { grid-area: info; text-align: center; color: #ffe9b0; font-size: 12px; line-height: 1.7; }
.center-info .wall-count { font-size: 14px; font-weight: 800; }
.center-info .round-name { color: #fff; font-weight: 800; font-size: 14px; }

/* ---------- 供托（立直棒 / 本场棒） ---------- */
.sticks-area { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 6px; min-height: 12px; }
.riichi-stick, .honba-stick {
  width: 26px; height: 7px; border-radius: 2px; background: #f4f1e8;
  box-shadow: inset 0 0 0 1px #c9c2ae; display: inline-block;
}
.honba-stick { width: 20px; background: #fdf3d5; box-shadow: inset 0 0 0 1px var(--gold); }
.sticks-area .stick-count { color: #ffe9b0; font-size: 12px; font-weight: 700; }

/* ---------- 骰子开桌（需求 6，纯 CSS 动画） ---------- */
.dice-overlay {
  position: absolute; inset: 0; z-index: 20;
  background: radial-gradient(ellipse at center, rgba(0,0,0,.45), rgba(0,0,0,.72));
  border-radius: 20px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  animation: mj-fade-in .2s ease-out;
}
.dice-overlay.leaving { animation: mj-fade-out .35s ease-in forwards; }
@keyframes mj-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes mj-fade-out { to { opacity: 0; } }
.dice-pair { display: flex; gap: 22px; }
.die {
  width: 62px; height: 62px; border-radius: 12px; background: #fff;
  box-shadow: 0 6px 16px rgba(0,0,0,.5), inset 0 -3px 0 rgba(0,0,0,.08);
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  padding: 8px;
}
.die.rolling { animation: mj-dice-roll .55s cubic-bezier(.3,.7,.4,1.1) infinite; }
@keyframes mj-dice-roll {
  0%   { transform: rotate(0deg) translateY(0) scale(1); }
  35%  { transform: rotate(140deg) translateY(-14px) scale(1.08); }
  70%  { transform: rotate(280deg) translateY(4px) scale(.96); }
  100% { transform: rotate(360deg) translateY(0) scale(1); }
}
.die .pip { width: 10px; height: 10px; border-radius: 50%; background: #1c2b24; align-self: center; justify-self: center; }
.dice-caption { color: #ffe9b0; font-size: 15px; font-weight: 700; letter-spacing: 1px; }
.dice-caption b { color: var(--gold); font-size: 20px; }

/* ---------- 我的手牌 ---------- */
.tile-slot { display: inline-flex; align-items: flex-end; }
/* M-B4：SVG 牌面容器（tile-face.js 生成的 <svg> 铺满牌壳，仅留 1px 给边框） */
.mj-tile .mj-svg { position: absolute; inset: 1px; }
.mj-tile .mj-svg svg { width: 100%; height: 100%; display: block; }
/* 相邻牌的重叠量由 fitHand() 动态写入 --hand-overlap（保证手机端每张牌都能看清）；第一张牌不位移 */
.my-hand .tile-slot + .tile-slot { margin-left: var(--hand-overlap, -14px); }
/* 刚摸到的牌与手牌之间留出空隙，一眼能分辨 */
.my-hand .tile-slot.is-drawn { margin-left: 10px !important; }
/* M-B2：立直宣言牌不再横放于手牌（横摆在牌河，见 .river-tile.is-riichi） */
.my-hand .mj-tile { cursor: pointer; }
.my-hand .mj-tile:hover { transform: translateY(-6px); z-index: 2; }
.my-hand .mj-tile.selected { transform: translateY(-14px); border-color: var(--gold); box-shadow: 0 6px 14px rgba(212,160,23,.5); }
.my-hand .mj-tile.disabled { opacity: .35; filter: grayscale(.7); cursor: default; }
.hand-empty { color: #a9c9b6; font-size: 13px; padding: 14px 0; }

/* ---------- 座位框内的小元素补充（需求 4） ---------- */
.empty-seat { color: #9db8a8; font-size: 12px; font-weight: 600; }
.back-count { color: #cfe6d8; font-size: 12px; font-weight: 700; padding: 5px 0; letter-spacing: 1px; }
.played-label { color: #b9d3c5; font-size: 11px; margin-right: 3px; }
.rule-lock { color: var(--gray); font-size: 11px; font-weight: 400; margin-left: 4px; }
.opp-seat .pname .nm { vertical-align: 2px; }

/* ---------- 操作按钮（需求 3） ---------- */
.btn.riichi { background: var(--red); color: #fff; }
.btn.riichi:hover { background: #b51f20; }
.btn.win { background: var(--gold); color: #3a2c00; font-weight: 900; animation: win-pulse 1s infinite; }
.btn.win:hover { background: #b58910; }
@keyframes win-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.btn.call { background: #2563a8; color: #fff; }
.btn.call:hover { background: #1d4f85; }

/* ---------- 规则面板的非布尔控件（需求 2） ---------- */
.rule-seg { display: inline-flex; border: 1px solid #b9ccc1; border-radius: 8px; overflow: hidden; flex: 0 0 auto; }
.rule-seg .seg-item {
  border: none; background: #fff; color: var(--ink); font-size: 11px; font-weight: 700;
  padding: 2px 7px; cursor: pointer; transition: .15s; border-left: 1px solid #e2ebe6;
}
.rule-seg .seg-item:first-child { border-left: none; }
.rule-seg .seg-item.active { background: var(--accent); color: #fff; }
.rule-seg .seg-item:not(.active):hover { background: #eef4ef; }
.rule-seg[disabled] .seg-item { cursor: default; }
select.rule-select {
  border: 1px solid #b9ccc1; border-radius: 8px; padding: 2px 6px; font-size: 12px;
  background: #fbfdfc; color: var(--ink); flex: 0 0 auto; outline: none;
}
select.rule-select:focus { border-color: var(--accent); }
.rule-row.is-danger .rule-text { color: #a5321f; }

/* ---------- 番符弹窗（需求 8） ---------- */
.agari-modal .modal-card { max-width: 440px; max-height: 88vh; overflow-y: auto; }
.agari-winner { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.agari-winner .win-name { font-size: 17px; font-weight: 800; color: var(--accent-dark); }
.agari-winner .win-kind { border-radius: 10px; padding: 1px 8px; font-size: 11px; font-weight: 800; background: #fdf3d5; color: #8a6400; }
.agari-winner .win-kind.ron { background: #fdecea; color: #b51f20; }
.agari-hand { display: flex; flex-wrap: wrap; gap: 2px; justify-content: center; padding: 8px 0; border-top: 1px dashed var(--panel-border); border-bottom: 1px dashed var(--panel-border); }
.agari-hand .mj-tile.is-win { outline: 2px solid var(--red); outline-offset: 1px; }
.agari-section { margin-top: 10px; }
.agari-section h4 { font-size: 13px; color: var(--accent-dark); margin-bottom: 4px; }
.agari-yaku-row, .agari-fu-row, .agari-delta-row { display: flex; justify-content: space-between; font-size: 13px; line-height: 1.7; color: #33463c; }
.agari-fu-row, .agari-delta-row { font-size: 12px; color: #5b6f63; }
.agari-yaku-row.is-dora { color: #8a6400; }
.agari-yaku-row.is-uradora { color: #b51f20; font-weight: 700; }
.agari-total {
  margin-top: 12px; padding: 10px; border-radius: 10px; text-align: center;
  background: linear-gradient(90deg, #d4a017, #f0c94a); color: #3a2c00; font-weight: 800; font-size: 17px;
}
.agari-total .limit-badge { display: block; font-size: 12px; letter-spacing: 2px; margin-bottom: 2px; }
.agari-deltas { margin-top: 8px; }
.agari-delta-row .delta-pos { color: #b51f20; font-weight: 700; }
.agari-delta-row .delta-neg { color: #0b6b49; font-weight: 700; }
.agari-tabs { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.agari-tab { border: 1px solid var(--panel-border); background: #fff; border-radius: 10px; font-size: 12px; padding: 3px 9px; cursor: pointer; }
.agari-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.agari-sub { font-size: 12px; color: var(--gray); margin-top: 6px; text-align: center; }

/* ---------- 结算横幅 / 顺位表 ---------- */
#round-banner.win { background: linear-gradient(90deg, #0f8a5f, #16b37c); color: #fff; }
#round-banner.draw { background: linear-gradient(90deg, #7a8a80, #9fb0a6); color: #fff; }
.rank-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 13px; }
.rank-table th, .rank-table td { padding: 5px 6px; border-bottom: 1px dashed #e4ece7; text-align: left; color: #33463c; }
.rank-table th { color: var(--gray); font-weight: 700; font-size: 12px; }
.rank-table .score-pos { color: #b51f20; font-weight: 700; }
.rank-table .score-neg { color: #0b6b49; font-weight: 700; }

/* ---------- 首页 / 大厅补充 ---------- */
.mode-picker { display: flex; gap: 12px; justify-content: center; margin: 6px 0 12px; flex-wrap: wrap; }
.mode-card {
  flex: 1; max-width: 210px; border: 2px solid #d9e2dc; border-radius: 12px; padding: 12px;
  cursor: pointer; background: #fbfdfc; text-align: center; transition: .15s;
}
.mode-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.mode-card.active { border-color: var(--accent); background: #eef7f2; box-shadow: 0 0 0 3px rgba(15,138,95,.12); }
.mode-card .mc-title { font-size: 16px; font-weight: 800; color: var(--accent-dark); }
.mode-card .mc-desc { font-size: 12px; color: var(--gray); margin-top: 4px; line-height: 1.5; }
.disclaimer { max-width: 640px; margin: 14px auto 0; font-size: 12px; color: #a9c9b6; text-align: center; line-height: 1.6; }

/* ---------- 麻将移动端降级（需求 5） ---------- */
@media (max-width: 620px) {
  .mj-tile { --tw: 26px; --th: 36px; }
  .mj-tile.mini { --tw: 15px; --th: 21px; }
  .mj-tile.micro { --tw: 12px; --th: 17px; }
  .table.mode-yonma .table-grid,
  .table.mode-sanma .table-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "top    top"
      "left   right"
      "center center";
  }
  .opp-seat { flex: 0 1 46%; min-width: 118px; }
  .opp-seat .card-backs { max-height: 34px; overflow: hidden; }
  .opp-melds { gap: 3px; }
  .dora-row { min-height: 36px; gap: 4px; }
  .dora-slot { width: 26px; height: 36px; }
  .my-hand { min-height: 72px; padding: 10px 4px 8px; row-gap: 9px; }
  .my-actions { gap: 8px; }
  .my-actions .btn { padding: 9px 14px; font-size: 14px; }
  .river.is-collapsed { max-height: 40px; overflow: hidden; }
  .agari-modal .modal-card { max-width: 100%; }
}

