:root {
  --bg: #0f1419; --panel: #1a2129; --border: #2b3644;
  --text: #e6edf3; --muted: #8b98a5; --accent: #3b82f6;
  --good: #22c55e; --bad: #ef4444; --gold: #f59e0b;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
  /* 禁双击放大：误触不再缩放页面（viewport 侧也锁了 user-scalable） */
  touch-action: manipulation;
}
.wrap { max-width: 860px; margin: 0 auto; padding: 12px 16px 40px; }
h1 { font-size: 21px; margin: 0 0 4px; }
.sub { color: var(--muted); font-size: 13px; margin: 0; }

.topbar {
  display: none;
}
.center-hint { display: none; }
.center-hint.show {
  display: block; text-align: center;
  font-size: 14px; color: #cfe8da; font-weight: 600;
  padding: 6px 12px; margin-bottom: 8px;
  text-shadow: 0 1px 4px rgba(0,0,0,.6);
}
.pill { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; font-size: 12px; color: var(--muted); white-space: nowrap; flex: 0 0 auto; }
.pill b { color: var(--text); }
/* 设置齿轮：浮在牌桌区右上角空地，不占行 */
.table-arena { position: relative; }
.table-arena .gear-fab {
  position: absolute; z-index: 6; top: 0; right: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(26, 33, 41, .85); border: 1px solid var(--border);
  color: var(--muted); border-radius: 50%; width: 40px; height: 40px;
  font-size: 18px; cursor: pointer; padding: 0; line-height: 1;
}
.gear-fab:hover { border-color: var(--accent); color: var(--text); }
/* 牌局管理行：重新发牌 25% + 撤销 25% + AI 建议 50%，小间隙分隔、各自独立圆角。
 * 比例用 calc 扣掉间隙后锁死（不按内容伸缩）。
 * 注意：容器是 #mini-row.buttons 里套的 div.mini-row，选择器必须写成后代形式；
 * .buttons.mini-row（双类同元素）匹配不到任何元素——之前两轮 CSS 没生效就是这个 bug。
 * 选择器也必须强于 .buttons 的 align-items:center，否则三颗按钮各按内容高度撑开。 */
#mini-row .mini-row { display: flex; gap: 8px; flex: 1 1 100%; align-items: stretch; }
.mini-row .btn.mini { flex: 0 0 calc(25% - 4px); }
.mini-row .btn.advice { flex: 0 0 calc(50% - 8px); }

.table-arena {
  display: flex; justify-content: center;
  margin-top: 20px; margin-bottom: 20px;
}
.table-ellipse {
  position: relative; width: 640px; height: 420px;
  background: radial-gradient(ellipse at 50% 40%, #1c4430, #12301f 70%, #0b2416);
  border: 6px solid #2a4a3a; border-radius: 50%;
  box-shadow: inset 0 0 60px rgba(0,0,0,.45), 0 6px 24px rgba(0,0,0,.4);
}
.table-center {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  text-align: center; width: 80%;
}
.street-label { font-size: 13px; letter-spacing: .18em; color: #cfe8da; font-weight: 700; margin-bottom: 10px; }
.board-row { display: flex; gap: 8px; justify-content: center; margin-bottom: 12px; min-height: 57px; }
.card-slot {
  width: 40px; height: 57px; border-radius: 6px;
  border: 1.5px dashed rgba(255,255,255,.25);
  background: rgba(0,0,0,.18); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: rgba(255,255,255,.45);
  transition: border-color .15s;
}
.card-slot:hover { border-color: var(--accent); }
.card-slot.ready {
  border-color: var(--accent);
  background: rgba(45, 160, 120, .32);
  box-shadow: 0 0 0 1px rgba(45,160,120,.35), 0 0 14px rgba(45,160,120,.25);
  font-size: 16px; font-weight: 700; color: #fff;
}
.card-slot.locked { cursor: not-allowed; border-color: rgba(255,255,255,.12); background: rgba(255,255,255,.04); }
.card-slot.locked:hover { border-color: rgba(255,255,255,.12); box-shadow: none; }
.lock-ico {
  position: relative; width: 20px; height: 21px;
}
.lock-ico::before {
  content: ""; position: absolute; left: 50%; transform: translateX(-50%);
  top: 0; width: 10px; height: 9px;
  border: 2px solid #9aa4b0; border-bottom: 0; border-radius: 6px 6px 0 0;
}
.lock-ico::after {
  content: ""; position: absolute; left: 50%; transform: translateX(-50%);
  bottom: 0; width: 18px; height: 12px;
  background: #9aa4b0; border-radius: 4px;
}
.pot-label { font-size: 14px; color: #d9ecdf; font-weight: 600; }

.seats { position: absolute; inset: 0; pointer-events: none; }
.seat {
  position: absolute; transform: translate(-50%, -50%);
  background: var(--panel); border: 2px solid var(--border); border-radius: 8px;
  padding: 4px 6px; min-width: 84px; text-align: center; cursor: default;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  transition: border-color .15s, box-shadow .15s;
  user-select: none;
  pointer-events: auto;
}
.seat.me { border-color: var(--border); box-shadow: none; }
.seat.actor { border-color: var(--good); box-shadow: 0 0 12px rgba(34,197,94,.5); }
.seat.folded { opacity: .4; }
.seat.folded .seat-name { text-decoration: line-through; }
.seat .seat-name { font-size: 13px; font-weight: 700; }
.seat .seat-stack { font-size: 12px; color: #93c5fd; cursor: pointer; }
.seat .seat-stack:hover { text-decoration: underline; }
.seat .seat-stack.allin { color: #f87171; font-weight: 700; }
.seat .seat-stack input { width: 64px; font-size: 12px; text-align: right;
  background: #0f172a; color: #e2e8f0; border: 1px solid var(--good); border-radius: 4px; }
.seat .seat-chip {
  position: absolute; z-index: 3; display: flex; align-items: center; gap: 4px;
  background: rgba(0,0,0,.55); border: 1px solid var(--border); border-radius: 9px;
  padding: 1px 6px; font-size: 11px; font-weight: 700; color: #fde68a;
  white-space: nowrap; pointer-events: none;
}
.seat .seat-chip .chip-ico {
  width: 13px; height: 13px; border-radius: 50%; flex: 0 0 auto;
  background: #f59e0b; border: 2px solid #fcd34d;
  box-shadow: inset 0 0 0 1px #b45309;
}
.seat .seat-top {
  display: flex; align-items: center; justify-content: center; gap: 2px;
  min-height: 46px; min-width: 68px;
}
.seat .avatar-btn {
  border: 0; cursor: pointer; padding: 4px 14px; border-radius: 6px;
  background: linear-gradient(135deg, #3b82f6, #2563eb); color: #fff;
  font-size: 13px; font-weight: 700;
}
.seat .avatar-btn:hover { background: linear-gradient(135deg, #2563eb, #1d4ed8); }
.seat .card-back {
  width: 32px; height: 42px; border-radius: 6px;
  background: repeating-linear-gradient(45deg, #16314f, #16314f 5px, #122840 5px, #122840 10px);
  border: 1px solid #3b82f6; box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.seat .dealer-mark {
  position: absolute; top: -9px; left: -9px;
  background: #fff; color: #111; border-radius: 50%; width: 14px; height: 14px;
  font-size: 8px; font-weight: 800; display: flex; align-items: center; justify-content: center;
  z-index: 5;
}

.card {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  width: 40px; height: 57px; border-radius: 6px;
  background: #fdfdfd; color: #1a1a1a; border: 1px solid #ddd;
  font-size: 22px; font-weight: 700; line-height: 1; box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.card.red { color: #d33; }
.card .suit { font-size: 27px; line-height: 1; }
.card.small { width: 32px; height: 44px; font-size: 18px; }
.card.small .suit { font-size: 21px; }

.btn {
  background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  padding: 9px 18px; font-size: 14px; cursor: pointer; font-weight: 600;
}
.btn:hover { background: #2563eb; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.btn.ghost:hover { border-color: var(--accent); color: var(--text); background: transparent; }
.lookup-row { display: flex; gap: 8px; margin: 12px 0; }
.lookup-row input {
  flex: 1; background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 12px; font-size: 13px; font-family: monospace;
}
.lookup-row input:focus { outline: none; border-color: var(--accent); }
#lookup-result { display: none; }
#lookup-result.show { display: block; }
#lookup-result .decision-line { font-size: 16px; font-weight: 700; margin: 6px 0; }
#lookup-result .reason { white-space: pre-wrap; }

.action-panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; margin-bottom: 10px;
}
.turn-info { font-size: 14px; margin-bottom: 10px; color: var(--text); }
.turn-info b { color: var(--gold); }
.turn-info.empty { display: none; }
.buttons { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.pot-row { display: flex; gap: 6px; flex-basis: 100%; }
.pot-btn {
  background: var(--bg); color: var(--muted); border: 1px solid var(--border);
  border-radius: 6px; padding: 3px 9px; font-size: 11px; cursor: pointer; font-family: inherit;
}
.pot-btn:hover { border-color: var(--accent); color: var(--text); }
.pot-btn.allin { border-color: var(--bad); color: #f87171; }
.pot-btn.allin:hover { background: var(--bad); color: #fff; border-color: var(--bad); }
.pot-btn:disabled, .raise-size input:disabled { opacity: .35; cursor: not-allowed; }
.buttons .btn { font-size: 14px; padding: 10px 22px; }
.btn.fold { background: var(--bad); }
.btn.call { background: var(--good); }
.btn.raise { background: var(--accent); }
.btn.advice { background: var(--gold); color: #111; }
.btn.advice:hover { background: #fbbf24; }
.raise-size { display: inline-flex; align-items: center; gap: 8px; }
/* 下注输入框住在快捷行 All in 后面：占满行剩宽度 */
.pot-row .raise-size { flex: 1 1 70px; min-width: 70px; }
.pot-row .raise-size input { flex: 1; min-width: 0; }
.raise-size input {
  width: 110px; background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 8px 10px; font-size: 14px;
}

.advice-summary { margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px dashed var(--border); display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; }
.advice-summary.hidden { display: none; }
/* 操作建议单行：动作 + 尺寸 + 小置信度 + 最右详细按钮 */
.advice-summary .as-action { font-size: 22px; font-weight: 800; line-height: 1; white-space: nowrap; }
.advice-summary .as-action.fold { color: var(--bad); }
.advice-summary .as-action.check, .advice-summary .as-action.call { color: var(--good); }
.advice-summary .as-action.bet, .advice-summary .as-action.raise { color: var(--accent); }
.advice-summary .as-sizing { font-size: 15px; font-weight: 600; color: var(--text); white-space: nowrap; }
.advice-summary .as-conf { display: inline-flex; align-items: center; gap: 6px; }
.advice-summary .as-conf-label { font-size: 11px; color: var(--muted); white-space: nowrap; }
.advice-summary .as-conf-bar { width: 90px; height: 7px; border-radius: 4px; background: var(--bg); border: 1px solid var(--border); overflow: hidden; }
.advice-summary .as-conf-bar i { display: block; height: 100%; background: linear-gradient(90deg, #fbbf24, var(--gold)); }
.advice-summary .as-conf-num { font-size: 14px; font-weight: 700; color: var(--gold); white-space: nowrap; }
#mini-row { margin-bottom: 10px; }
.advice-summary .as-loading { font-size: 13px; color: var(--muted); }
.advice-summary .as-detail {
  margin-left: auto; background: transparent; border: 1px solid var(--border);
  color: var(--muted); border-radius: 6px; padding: 4px 12px; font-size: 12px;
  cursor: pointer; font-family: inherit;
}
.advice-summary .as-detail:hover { border-color: var(--accent); color: var(--text); }

#advice, #skills { display: none; }
#advice.show, #skills.show { display: block; }
.advice, .skills { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; }
.advice h3, .skills h3 { font-size: 12px; color: var(--muted); margin: 0 0 10px; letter-spacing: .05em; font-weight: 600; }
.advice-tag { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.advice-tag code { flex: 1; font-size: 11px; color: #93c5fd; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; white-space: pre-wrap; word-break: break-all; }
.copy-advice { flex-shrink: 0; font-size: 12px; }
.advice .decision { margin-bottom: 10px; }
.advice .action { font-size: 20px; font-weight: 700; color: var(--good); }
.advice .sizing { font-size: 16px; color: var(--text); margin-left: 8px; }
.advice .conf { font-size: 13px; color: var(--muted); margin-top: 2px; }
.advice .reason { margin-top: 8px; font-size: 13px; color: var(--muted); white-space: pre-wrap; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; }
.skill { border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 6px; padding: 9px 12px; margin-bottom: 8px; background: var(--bg); }
.skill .head { font-size: 13px; font-weight: 600; }
.skill .meta { font-size: 11px; color: var(--muted); margin: 2px 0 5px; }
.skill .rec { font-size: 13px; color: #93c5fd; }
.skill .why { font-size: 12px; color: var(--muted); margin-top: 4px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal.hidden { display: none; }
.modal-box {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; max-width: 640px; width: 92%; max-height: 88vh; overflow: auto;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; font-weight: 700; font-size: 15px; }
.modal-close { cursor: pointer; font-size: 24px; color: var(--muted); line-height: 1; padding: 0 4px; }
.modal-close:hover { color: var(--text); }
.settings-box { width: 340px; display: flex; flex-direction: column; gap: 14px; }
.settings-box .btn { align-self: stretch; padding: 10px; }
.settings-field { display: flex; flex-direction: column; gap: 6px; }
.settings-field label { font-size: 13px; color: var(--muted); }
.pool-picker { display: flex; flex-direction: column; gap: 4px; }
.pool-picker label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text); cursor: pointer; }
.settings-field select,
.settings-field input {
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 8px 10px; font-size: 14px; font-family: inherit;
}
.picker-grid { display: grid; grid-template-columns: repeat(13, 1fr); gap: 6px; }
.picker-grid .card { cursor: pointer; }
.picker-grid .card.picked { outline: 3px solid var(--accent); }
.picker-grid .card.used { opacity: .35; cursor: not-allowed; }

.flash {
  position: fixed; top: 16px; right: 16px; background: var(--panel);
  border: 1px solid var(--border); color: var(--text); padding: 10px 16px;
  border-radius: 8px; font-size: 13px; box-shadow: 0 4px 20px rgba(0,0,0,.4); z-index: 60;
  max-width: 320px;
}
.flash.hidden { display: none; }

.loading { opacity: .6; cursor: wait !important; }

@media (max-width: 720px) {
  /* ── iPhone 竖屏：底部固定操作栏（拇指区）+ 零布局跳动 ──
   * 参考 GGPoker 手游 / iOS 底部 Tab 栏：
   * 1. .action-panel position:fixed → 它内部任何变化（按钮增减、建议出现、
   *    加载态）都不再推动页面内容，内容区只管滚动。
   * 2. 内容区 padding-bottom 按操作栏最大高度预留 → 栏再长也盖不住正文。
   * 3. 栏内各槽位固定高度：turn-info 单行省略、建议区隐形占位、按钮区
   *    最小高度 → 栏自身高度也基本恒定，视觉不跳。
   * 桌面端（DOM 顺序 header/pills/牌桌/决策区）完全不受影响。 */
  body { overflow-x: clip; }
  .wrap {
    max-width: 100%; overflow-x: clip;
    padding: 8px 10px calc(290px + env(safe-area-inset-bottom));
  }

  /* 齿轮浮在牌桌右上角（牌桌边距空地），手机上稍小一点 */
  .table-arena .gear-fab { width: 36px; height: 36px; font-size: 16px; }
  /* MP 座位离右上角齿轮太近会被视觉压住，左移让位（只改手机，桌面不动） */
  #seat-mp { transform: translate(calc(-50% - 16px), -50%); }

  /* 状态 pills 更小，横滑查看（常驻，不跳动） */
  .topbar { gap: 6px; padding: 6px 8px; margin-bottom: 8px; }
  .pill { font-size: 11px; padding: 3px 8px; }

  /* 底部固定操作栏：毛玻璃 + 圆角顶边 + 刘海垫底 */
  .action-panel {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    margin: 0; border-radius: 16px 16px 0 0;
    border: 1px solid var(--border); border-bottom: 0;
    background: rgba(26, 33, 41, .96);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    box-shadow: 0 -6px 24px rgba(0, 0, 0, .45);
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  }
  /* 状态行：永远单行，空时也占位 */
  .turn-info {
    font-size: 13px; margin-bottom: 6px; min-height: 22px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .turn-info.empty { display: block; }
  /* 建议槽：单行（动作+尺寸+小置信度+最右详细）；没出建议时隐形占位 */
  .advice-summary {
    margin-bottom: 0; padding-bottom: 8px; gap: 8px;
    min-height: 48px; border-bottom: 0; flex-wrap: nowrap;
  }
  .advice-summary.hidden { display: flex; visibility: hidden; }
  .advice-summary .as-action { font-size: 20px; }
  .advice-summary .as-sizing { font-size: 14px; }
  .advice-summary .as-conf-label { display: none; }
  .advice-summary .as-conf-bar { flex: 0 0 auto; width: 56px; }
  .advice-summary .as-conf-num { font-size: 13px; }
  .advice-summary .as-detail { min-height: 36px; font-size: 12px; padding: 4px 8px; }
  /* 中央提示（未开局）：牌桌正中 */
  .center-hint.show { font-size: 13px; }
  /* 管理行下方间距 */
  #mini-row { margin-bottom: 8px; min-height: 52px; }
  /* 按钮区：最小高度占位；快捷行单行横滑；主操作单行；AI 建议独占一行 */
  .buttons { gap: 8px; min-height: 52px; }
  .pot-row {
    flex-basis: 100%; flex-wrap: nowrap; overflow-x: auto;
    -webkit-overflow-scrolling: touch; padding-bottom: 2px;
  }
  .pot-row .pot-btn { flex: 0 0 auto; min-height: 38px; }
  .buttons .btn {
    flex: 1 1 0; min-height: 52px; white-space: nowrap;
    font-size: 15px; padding: 12px 8px;
  }
  .pot-row .raise-size { flex: 1 1 0; min-width: 0; }
  .pot-row .raise-size input { width: 100%; min-height: 44px; font-size: 16px; }
  /* 牌局管理行三颗按钮与主操作按钮等高（52px），比例锁 25/25/50 不断行 */
  .mini-row { gap: 8px; flex-wrap: nowrap; }
  /* 高度锁死 52px + 文本 flex 居中：不依赖字体度量，三颗必然等高 */
  #mini-row .mini-row > .btn {
    height: 52px; min-height: 52px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
  }
  .mini-row .btn.mini { font-size: 13px; min-height: 52px; padding: 12px 4px; white-space: nowrap; }
  .mini-row .btn.advice { font-size: 14px; min-height: 52px; padding: 12px 4px; white-space: nowrap; }

  /* 牌桌：94vw 等比缩小；8 人桌座位框上下各探出约 20px，
   * arena 上下留 44px 边距，保证不叠到 pills 和找理由行 */
  .table-arena { margin: 44px 0; }
  .table-ellipse {
    width: min(340px, 94vw); height: 300px;
    border-width: 4px;
  }
  .street-label { font-size: 11px; margin-bottom: 6px; }
  .board-row { gap: 5px; margin-bottom: 8px; min-height: 42px; }
  .card-slot { width: 30px; height: 42px; font-size: 11px; }
  .card-slot.ready { font-size: 14px; }
  .pot-label { font-size: 12px; }
  /* 座位压扁：选择按钮/牌背/字号全缩小，单框约 68px 高，相邻座位不再互叠 */
  .seat { min-width: 60px; padding: 2px 3px; border-radius: 7px; }
  .seat .seat-name { font-size: 11px; line-height: 1.3; }
  .seat .seat-stack { font-size: 11px; min-height: 32px; line-height: 1.3; }
  .seat .seat-stack input { width: 52px; }
  .seat .seat-top { min-height: 28px; min-width: 50px; }
  .seat .avatar-btn { padding: 4px 10px; font-size: 11px; min-height: 36px; }
  .seat .card-back { width: 22px; height: 30px; }
  .seat .seat-chip { font-size: 10px; padding: 0 5px; }
  .seat .dealer-mark { width: 13px; height: 13px; font-size: 8px; }
  .card { width: 30px; height: 42px; font-size: 16px; }
  .card .suit { font-size: 19px; }
  .card.small { width: 26px; height: 36px; font-size: 14px; }
  .card.small .suit { font-size: 16px; }

  /* 详情区字号与边距 */
  .advice, .skills { padding: 12px; margin-bottom: 10px; }
  .advice .action { font-size: 18px; }
  .advice .reason { font-size: 13px; }
  .skill .rec { font-size: 13px; }
  .lookup-row { margin: 8px 0; }
  .lookup-row input { font-size: 13px; min-height: 44px; }
  .lookup-row .btn { min-height: 44px; }

  /* 弹窗占满手机屏 */
  .modal-box { width: 94%; max-height: 92dvh; padding: 14px; }
  .modal-close { font-size: 30px; padding: 4px 10px; }
  /* 选牌器：13 列 mini 卡（约 22px/张，可点） */
  .picker-grid { gap: 3px; }
  .picker-grid .card {
    width: auto; height: 36px; font-size: 13px; border-radius: 4px;
  }
  .picker-grid .card .suit { font-size: 14px; }
  .settings-box { width: 94%; }
  .settings-field select, .settings-field input { min-height: 44px; font-size: 16px; }
  .flash { left: 10px; right: 10px; max-width: none; }
}

@media (max-width: 360px) {
  /* 小屏 iPhone（SE/mini）：牌桌再小一档（底部栏按钮保持单行，不全宽堆叠） */
  .table-ellipse { width: min(310px, 94vw); height: 280px; }
  .seat { min-width: 56px; }
  .buttons .btn { font-size: 14px; padding: 12px 4px; }
}
