/* 扑克赢率计算器 — 移动端样式 */
:root {
  --bg: #0b1310;
  --bg-soft: #101b16;
  --panel: #131f19;
  --panel-2: #17251e;
  --line: #26392f;
  --text: #e9f2ec;
  --dim: #85a394;
  --dim-2: #5f7d6d;
  --green: #29c46f;
  --green-dark: #128a49;
  --gold: #f2c14e;
  --red: #e5484d;
  --card: #f5f7f5;
  --card-ink: #17201c;
  /* 四色牌：深色底（阵列 / 图例 / 结果） */
  --su-c-dark: #46d18a;   /* ♣ 绿 */
  --su-d-dark: #5aa9ff;   /* ♦ 蓝 */
  --su-h-dark: #ff6068;   /* ♥ 红 */
  --su-s-dark: #eaf2ec;   /* ♠ 黑（深色底上用浅色） */
  /* 四色牌：白色牌面 */
  --su-c-card: #0d8a4d;
  --su-d-card: #1668e3;
  --su-h-card: #d3242f;
  --su-s-card: #171c19;
  --radius: 14px;
}

/* 花色颜色（默认深色底） */
.su-0 { color: var(--su-c-dark); }
.su-1 { color: var(--su-d-dark); }
.su-2 { color: var(--su-h-dark); }
.su-3 { color: var(--su-s-dark); }
/* 白色牌面上的花色（牌位 / 牌位条 / 预览） */
.slot .su-0, .pv-card .su-0, .chip-card .su-0 { color: var(--su-c-card); }
.slot .su-1, .pv-card .su-1, .chip-card .su-1 { color: var(--su-d-card); }
.slot .su-2, .pv-card .su-2, .chip-card .su-2 { color: var(--su-h-card); }
.slot .su-3, .pv-card .su-3, .chip-card .su-3 { color: var(--su-s-card); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(1200px 500px at 50% -200px, #123024 0%, rgba(11, 19, 16, 0) 70%),
    var(--bg);
  min-height: 100vh;
}

button { font-family: inherit; font-size: inherit; color: inherit; touch-action: manipulation; cursor: pointer; }

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 10px 12px 0;
}

/* ---------------- 顶部 ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 2px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo {
  width: 38px; height: 38px;
  flex: 0 0 38px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: linear-gradient(160deg, #1f3d2e, #12241b);
  border: 1px solid var(--line);
  font-size: 20px;
  color: var(--green);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}
.brand-text h1 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tagline { margin: 1px 0 0; font-size: 11.5px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text { min-width: 0; }
.topbar-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.mini-btn {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line);
  color: var(--dim);
  border-radius: 9px;
  padding: 6px 10px;
  font-size: 12.5px;
}
.mini-btn:active { background: rgba(255,255,255,.1); }

/* ---------------- 游戏切换 ---------------- */
.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 12px;
}
.tab {
  border: 0;
  background: transparent;
  color: var(--dim);
  padding: 9px 4px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 550;
  transition: background .15s, color .15s;
}
.tab.active {
  background: linear-gradient(180deg, #22633f, #1a4d31);
  color: #eafff3;
  box-shadow: 0 1px 0 rgba(255,255,255,.08) inset, 0 4px 14px rgba(21,120,69,.28);
}

/* ---------------- 面板 ---------------- */
.panel {
  background: linear-gradient(180deg, rgba(255,255,255,.018), rgba(255,255,255,0)) , var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.panel-head h2 { margin: 0; font-size: 14px; font-weight: 600; color: #d8ebdf; letter-spacing: .3px; }
.hint { font-size: 11.5px; color: var(--dim-2); }
.tip { margin: 10px 0 0; font-size: 11.5px; color: var(--dim-2); line-height: 1.5; }
.tip b { color: var(--dim); font-weight: 600; }
.dim { color: var(--dim-2); }

.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button {
  width: 30px; height: 30px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  color: var(--text);
  font-size: 17px;
  line-height: 1;
  display: grid; place-items: center;
}
.stepper button:disabled { opacity: .35; }
.stepper span { min-width: 26px; text-align: center; font-variant-numeric: tabular-nums; font-size: 14px; }

/* ---------------- 牌位 ---------------- */
.board-row { display: flex; align-items: flex-start; gap: 6px; }
.slot-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.slot-label { font-size: 10px; color: var(--dim-2); letter-spacing: .5px; }
.board-divider { width: 1px; align-self: stretch; background: var(--line); margin: 2px 3px 16px; }

.slot {
  position: relative;
  width: 46px; height: 62px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.14);
  background: var(--card);
  color: var(--card-ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 4px 0;
  box-shadow: 0 1px 2px rgba(0,0,0,.35);
  transition: transform .12s ease, box-shadow .12s ease;
  overflow: hidden;
}
.slot:active { transform: scale(.95); }
.slot .r { font-size: 19px; font-weight: 700; line-height: 1.05; letter-spacing: -.5px; }
.slot .s { font-size: 17px; line-height: 1.05; }
.slot .dimmed { opacity: .28; }
.slot.empty {
  background: rgba(255,255,255,.03);
  border: 1px dashed #34513f;
  color: var(--dim-2);
  box-shadow: none;
}
.slot.partial { border-color: rgba(41,196,111,.5); }
.slot.sm { width: 40px; height: 55px; }
.slot.sm .r { font-size: 16.5px; }
.slot.sm .s { font-size: 15px; }
.slot.flash { animation: flash .5s ease; }
.slot.cursor { border-color: rgba(41,196,111,.95); box-shadow: 0 0 0 2px rgba(41,196,111,.55), 0 0 14px rgba(41,196,111,.35); }
@keyframes flash {
  0% { box-shadow: 0 0 0 0 rgba(41,196,111,.75); }
  100% { box-shadow: 0 0 0 12px rgba(41,196,111,0); }
}

/* ---------------- 玩家 ---------------- */
.player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 8px 10px;
  border-radius: 11px;
  background: var(--panel-2);
  border: 1px solid rgba(255,255,255,.045);
  margin-bottom: 7px;
}
.player:last-child { margin-bottom: 0; }
.player-name {
  font-size: 12.5px;
  color: var(--dim);
  writing-mode: horizontal-tb;
  flex: 0 0 42px;
  font-variant-numeric: tabular-nums;
}
.player .hand { display: flex; gap: 5px; flex-wrap: wrap; }
.player.stacked { display: block; }
.player.stacked .hand { margin-top: 8px; }
.player-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.player .tools { display: flex; align-items: center; gap: 6px; margin-left: auto; flex: 0 0 auto; }
.head-right { display: flex; align-items: center; gap: 8px; }
.player .rm {
  margin-left: 0;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--dim-2);
  border-radius: 8px;
  font-size: 12px;
  padding: 6px 8px;
}

/* ---------------- 模拟次数 ---------------- */
.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.chip {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.03);
  color: var(--dim);
  border-radius: 10px;
  padding: 9px 4px;
  text-align: center;
  font-size: 13px;
  line-height: 1.25;
}
.chip small { display: block; font-size: 10.5px; color: var(--dim-2); }
.chip.active {
  border-color: rgba(41,196,111,.55);
  background: rgba(41,196,111,.12);
  color: #d9f7e6;
}
.chip.active small { color: #7fd3a4; }

/* ---------------- 校验提示 ---------------- */
.alert {
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12.5px;
  margin-bottom: 12px;
  background: rgba(229,72,77,.12);
  border: 1px solid rgba(229,72,77,.4);
  color: #ffc9cb;
}
.alert.warn { background: rgba(242,193,78,.1); border-color: rgba(242,193,78,.35); color: #ffe6ab; }
.hidden { display: none !important; }

/* ---------------- 结果 ---------------- */
.results-list { display: flex; flex-direction: column; gap: 9px; }
.empty-note { margin: 2px 0; font-size: 12.5px; color: var(--dim-2); }
.res {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  padding: 9px 10px;
  border-radius: 11px;
  background: var(--panel-2);
  border: 1px solid rgba(255,255,255,.05);
}
.res.best { border-color: rgba(242,193,78,.45); background: linear-gradient(180deg, rgba(242,193,78,.09), rgba(255,255,255,.01)); }
.res-name { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.res-name .crown { font-size: 12px; }
.res-hand { font-size: 11.5px; color: var(--dim-2); letter-spacing: .4px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.res-hand .dim { color: var(--dim-2); }
.res-eq { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--green); text-align: right; }
.res.best .res-eq { color: var(--gold); }
.bar {
  grid-column: 1 / -1;
  height: 7px;
  border-radius: 4px;
  background: rgba(255,255,255,.07);
  overflow: hidden;
  margin-top: 4px;
}
.bar > i {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #1e9c58, #35d07c);
  transition: width .35s ease;
}
.res.best .bar > i { background: linear-gradient(90deg, #b98a1e, #f2c14e); }
.res-detail { grid-column: 1 / -1; font-size: 11px; color: var(--dim-2); font-variant-numeric: tabular-nums; margin-top: 2px; }

/* ---------------- 底部操作栏 ---------------- */
.bottom-space { height: 96px; }
.actionbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(11,19,16,.55), rgba(11,19,16,.96) 55%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255,255,255,.05);
  z-index: 20;
}
.actionbar-row {
  max-width: 536px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.action-info { font-size: 11.5px; color: var(--dim-2); flex: 1; min-width: 0; }
.cta {
  flex: 0 0 auto;
  min-width: 148px;
  border: 0;
  border-radius: 12px;
  padding: 13px 20px;
  font-size: 15px;
  font-weight: 650;
  color: #04180e;
  background: linear-gradient(180deg, #3ddc85, #1eb463);
  box-shadow: 0 6px 18px rgba(30,180,99,.3);
}
.cta:active { transform: translateY(1px); }
.cta.cancel { background: linear-gradient(180deg, #f2686c, #d33b40); color: #2a0405; box-shadow: none; }
.cta:disabled { opacity: .5; box-shadow: none; }
.progress {
  max-width: 536px;
  margin: 0 auto 8px;
  height: 3px;
  border-radius: 2px;
  background: rgba(255,255,255,.1);
  overflow: hidden;
}
.progress-inner { height: 100%; width: 0%; background: linear-gradient(90deg, #29c46f, #7ee7ab); transition: width .12s linear; }

/* ---------------- 选牌弹层 ---------------- */
.modal { position: fixed; inset: 0; z-index: 50; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-width: 560px;
  margin: 0 auto;
  background: #14211b;
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  border-top: 1px solid rgba(255,255,255,.08);
  padding: 8px 14px calc(14px + env(safe-area-inset-bottom));
  animation: slideUp .22s cubic-bezier(.2,.9,.3,1);
  max-height: 94vh;
  display: flex;
  flex-direction: column;
}
@keyframes slideUp { from { transform: translateY(24px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }
.sheet-grip { width: 36px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.16); margin: 2px auto 10px; }
.sheet-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.nav-arrow {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  color: var(--dim);
  font-size: 19px;
  line-height: 1;
  display: grid; place-items: center;
}
.nav-arrow:active { background: rgba(255,255,255,.12); }
.sh-mid { flex: 1 1 auto; min-width: 0; }
.sh-mid h3 { margin: 0; font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-toast { font-size: 11.5px; color: var(--dim-2); min-height: 17px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-toast.ok { color: #7fe0a6; }
.pv-toast.warn { color: #ffb4b6; }

/* ---------------- 卡牌阵列（13×4 + 无花色列 + 无点数行） ---------------- */
.card-grid {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 3px;
  padding: 2px 0 4px;
}
.gc {
  position: relative;
  height: 30px;
  /* 让 14 行 + 顶部牌位条能在一屏内完整显示（短屏自动变小） */
  height: clamp(22px, calc((94vh - 330px) / 14), 36px);
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.035);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  font-size: 13px;
  font-size: clamp(11.5px, 1.7vh, 13.5px);
  font-weight: 650;
  letter-spacing: -.2px;
  transition: transform .1s ease, background .12s ease;
}
.gc .gcr { color: var(--text); }
.gc .gcs { font-weight: 600; }
.gc .gcs.dim, .gc .gcr.dim { color: var(--dim-2); font-weight: 500; }
.gc:active { transform: scale(.93); }
/* 本手牌已选中的牌：点亮（可再点一下取消） */
.gc.selected { background: rgba(41,196,111,.16); border-color: rgba(41,196,111,.75); }
.gc.selected .gcr { color: #dcfbe9; }
/* 被公共牌 / 别家手牌占用的牌：变灰且不可点 */
.gc.taken { background: #1b2a23; border-color: #2a4034; }
.gc.taken .gcr { color: #86a596; }
.gc.taken .gcs { filter: saturate(.4) brightness(.8); }
.gc.taken .badge { background: #7d8f85; color: #101713; }
/* 只给点数 / 只给花色 且已被别处使用：仍可点（只是提醒） */
.gc.shared { border-color: rgba(255,255,255,.22); border-style: dashed; }
.gc.shared .badge { background: #8b9a92; color: #121815; }
.gc.off { opacity: .26; }
.gc.cursor { border-color: rgba(41,196,111,.95); box-shadow: 0 0 0 1px rgba(41,196,111,.6) inset, 0 0 10px rgba(41,196,111,.25); }
.gc .badge {
  position: absolute; top: 1px; right: 2px;
  font-size: 8px; font-weight: 700; font-style: normal;
  line-height: 1.35;
  padding: 0 2px;
  border-radius: 3px;
  color: #0b1310;
  background: #7fd3a4;
  min-width: 8px;
  text-align: center;
}
.gc .badge:empty { display: none; }

/* 本手牌已选中的牌（弹层顶部一排） */
.hand-row { display: flex; gap: 6px; margin-bottom: 8px; }
.chip-card {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  max-width: 66px;
  height: 54px;
  border-radius: 9px;
  border: 1px solid rgba(255,255,255,.14);
  background: var(--card);
  color: var(--card-ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0;
  gap: 0;
  box-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.chip-card .r { font-size: 17px; font-weight: 700; line-height: 1.05; }
.chip-card .s { font-size: 15px; line-height: 1.05; }
.chip-card .dimmed { opacity: .28; }
.chip-card.empty { background: rgba(255,255,255,.04); border: 1px dashed #34513f; color: var(--dim-2); box-shadow: none; }
.chip-card.active { border-color: #29c46f; box-shadow: 0 0 0 2px rgba(41,196,111,.55); }
.chip-card .idx { position: absolute; top: 1px; left: 4px; font-size: 9px; color: #93a89d; }
.chip-card.empty .idx { color: var(--dim-2); }
.chip-card .x {
  position: absolute; top: 1px; right: 2px;
  font-size: 10px; font-style: normal;
  color: #8aa79a;
  padding: 0 2px;
  line-height: 1.3;
}
.gc-any { color: var(--dim); font-weight: 600; font-size: 12px; border-style: dashed; }
.sheet-actions.two { grid-template-columns: 1fr 1.5fr; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 8px; }
.sheet-tip b { font-style: normal; }

/* 超短屏幕（如 320×568）挤一挤，保证 14 行全部可见 */
@media (max-height: 640px) {
  .card-grid { gap: 2px; }
  .gc { height: clamp(19px, calc((94vh - 250px) / 14), 30px); font-size: 11.5px; }
  .sheet-tip { display: none; }
  .sheet { padding-top: 4px; }
  .sheet-grip { margin-bottom: 6px; }
  .sheet-head { margin-bottom: 6px; }
  .chip-card { height: 44px; }
  .chip-card .r { font-size: 15px; }
  .hand-row { margin-bottom: 6px; }
}
.sheet-tip { margin: 8px 0 0; font-size: 11px; color: var(--dim-2); line-height: 1.4; }
.pv { display: flex; align-items: center; gap: 9px; }
.pv-card {
  width: 46px; height: 62px;
  border-radius: 8px;
  background: var(--card);
  color: var(--card-ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 700;
}
.pv-card .r { font-size: 19px; line-height: 1.05; }
.pv-card .s { font-size: 17px; line-height: 1.05; }
.pv-card .dimmed { opacity: .28; }
.pv-desc { font-size: 12px; color: var(--dim); max-width: 150px; }

.btn {
  border-radius: 12px;
  padding: 13px 10px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  font-size: 14.5px;
  font-weight: 600;
}
.btn.primary { border: 0; color: #04180e; background: linear-gradient(180deg, #3ddc85, #1eb463); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .38; }
