/* 卡五星训练 —— 大牌面、大按钮、高对比，手机横竖屏都能用 */

:root {
  --felt: #14432f;
  --felt-2: #1b5a3f;
  --panel: rgba(0, 0, 0, 0.22);
  --panel-line: rgba(255, 255, 255, 0.14);
  --ink: #f4f1e8;
  --muted: #b9cbbf;
  --gold: #ffd54a;
  --ivory: #fffaf0;
  --paper-ink: #24302a;
  --red: #d64541;
  --green: #2e9d5b;
  --blue: #2f6fc2;
  --orange: #e08a1e;
  --purple: #8e5bd8;

  /* 页面可用宽高：orient.js 按实际窗口设置（牌桌转 90 度时是转完之后的宽高） */
  --app-w: 100vw;
  --app-h: 100dvh;
  --hand-w: clamp(21px, calc((var(--app-w) - 52px) / 14.6), 64px);
  --small-w: clamp(20px, calc(var(--hand-w) * 0.62), 38px);
  --mini-w: clamp(17px, calc(var(--app-w) * 0.025), 30px);
  --xs-w: clamp(9px, calc(var(--app-w) * 0.013), 14px);
  --gap: 8px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(ellipse at 50% 30%, var(--felt-2), var(--felt) 70%);
  background-color: var(--felt);
  color: var(--ink);
  font: 18px/1.5 -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; }
h1, h2 { margin: 0; }

/* ---------- 按钮 ---------- */
.btn {
  white-space: nowrap;
  min-height: 44px;
  padding: 6px 16px;
  border: 0;
  border-radius: 10px;
  background: #e9e4d6;
  color: #1d2a23;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-primary { background: var(--gold); color: #2b2100; }
.btn-big { min-height: 60px; font-size: 22px; width: 100%; }
.btn-small { min-height: 38px; padding: 4px 12px; font-size: 16px; }
.btn-link { background: none; box-shadow: none; color: var(--muted); text-decoration: underline; }
.btn-hint { background: #7fd3a2; }
.btn-rec[aria-pressed="true"] { background: #7fd3a2; }
.btn-act .btn-prob { margin-left: 6px; font-size: 0.72em; font-weight: 800; opacity: 0.92; }
.btn-act.rec-best { box-shadow: 0 0 0 3px #7cfc9a, 0 2px 0 rgba(0, 0, 0, 0.35); }
.btn-act { min-height: 56px; min-width: 84px; font-size: 22px; }
.btn-hu { background: var(--red); color: #fff; }
.btn-gang { background: var(--orange); color: #fff; }
.btn-peng { background: var(--blue); color: #fff; }
.btn-liang { background: var(--purple); color: #fff; }
.chip {
  border: 1px solid var(--panel-line);
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
  border-radius: 999px;
  padding: 2px 10px;
  margin: 2px 4px;
  font-size: 15px;
  cursor: pointer;
}

/* ---------- 登录 ---------- */
.login-page { display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(420px, 100%);
  background: var(--ivory);
  color: var(--paper-ink);
  border-radius: 18px;
  padding: 28px 22px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  text-align: center;
}
.brand { font-size: 46px; font-weight: 800; letter-spacing: 6px; color: #b3261e; }
.brand-sub { margin: 0 0 18px; color: #6b7a70; }
.login-card form { display: grid; gap: 12px; text-align: left; }
.login-card input {
  min-height: 56px;
  font-size: 22px;
  padding: 8px 12px;
  border: 2px solid #c9bfa5;
  border-radius: 10px;
  width: 100%;
}
.msg { min-height: 1.5em; color: #b3261e; margin: 0; text-align: center; }

/* ---------- 通用卡片 ---------- */
.screen { max-width: 1200px; margin: 0 auto; padding: 8px max(10px, env(safe-area-inset-right)) 16px max(10px, env(safe-area-inset-left)); }
.card {
  background: var(--ivory);
  color: var(--paper-ink);
  border-radius: 14px;
  padding: 14px 16px;
  margin: 12px 0;
}
.card h2 { font-size: 20px; margin-bottom: 8px; }
.muted { color: var(--muted); }
.card .muted { color: #6b7a70; }
.small { font-size: 14px; }
.big { font-size: 20px; font-weight: 700; }
.pos { color: #3fbf6f; }
.neg { color: #ff7a6e; }
.card .pos { color: #1c8a47; }
.card .neg { color: #c0392b; }
.good { color: #1c8a47; font-weight: 700; }
.warn { color: #b3261e; font-weight: 700; }

/* ---------- 大厅 ---------- */
.lobby { max-width: 560px; }
.lobby-head { text-align: center; padding: 18px 0 6px; }
.lobby-head h1 { font-size: 52px; letter-spacing: 8px; color: var(--gold); text-shadow: 0 3px 0 rgba(0, 0, 0, 0.35); }
.lobby-head p { margin: 4px 0 0; color: var(--muted); }
.lobby-actions { display: grid; gap: 12px; margin: 16px 0; }
.level-card { margin-top: 16px; }
.level-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; margin-bottom: 10px; }
.level-picker { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.btn.lv { min-height: 56px; padding: 4px 6px; font-size: 20px; line-height: 1.2; }
.btn.lv small { display: block; font-size: 12px; font-weight: 500; }
.btn.lv[aria-checked="true"] { background: var(--gold); color: #2b2100; box-shadow: 0 0 0 3px rgba(255, 213, 74, 0.35), 0 2px 0 rgba(0, 0, 0, 0.35); }
.level-desc { margin: 10px 0 0; color: #55645b; font-size: 16px; }
.pill-level:empty { display: none; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid #e6dfcc; }
.setting:first-of-type { border-top: 0; }
.setting input[type="checkbox"] { width: 28px; height: 28px; flex: none; }
.setting select { min-height: 42px; border-radius: 8px; padding: 4px 8px; }
.rules summary { font-weight: 700; cursor: pointer; font-size: 20px; }
.rules li { margin: 6px 0; }
.lobby-foot { text-align: center; }

/* ---------- 双人局 ---------- */
.duo-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px; margin-bottom: 10px; }
.duo-name { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-weight: 700; }
.duo-name input { flex: 1; min-width: 0; min-height: 48px; font-size: 20px; padding: 6px 12px; border: 2px solid #c9bfa5; border-radius: 10px; }
.duo-list { list-style: none; padding: 0; margin: 0 0 10px; display: grid; gap: 8px; }
.duo-list:empty { display: none; }
.duo-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: #f1ebdb; }
.duo-main { flex: 1; min-width: 0; }
.duo-text { font-weight: 800; font-size: 19px; }
.duo-item .btn { min-width: 96px; }
.duo-tip { margin: 10px 0 0; }
.room { max-width: 560px; }
.room-card { text-align: center; }
.room-big { font-size: 26px; font-weight: 800; margin: 8px 0; }
.room-info { color: #6b7a70; margin: 0 0 10px; font-size: 16px; }
.room-steps { text-align: left; margin: 0 auto 6px; padding-left: 1.4em; max-width: 26em; }
.room-steps li { margin: 6px 0; }

/* ---------- 顶栏 ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 0 6px; }
.topinfo { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; }
.pill { background: rgba(0, 0, 0, 0.3); border-radius: 999px; padding: 2px 12px; font-weight: 700; }
.game-id { font-size: 13px; color: var(--muted); font-family: ui-monospace, Menlo, Consolas, monospace; }

/* ---------- 牌 ---------- */
.tile {
  --w: var(--mini-w);
  position: relative;
  display: inline-block;
  flex: none;
  width: var(--w);
  aspect-ratio: 3 / 4;
  border-radius: calc(var(--w) * 0.13);
  background: var(--ivory);
  box-shadow: 0 calc(var(--w) * 0.06) 0 #2f7d55, 0 calc(var(--w) * 0.09) calc(var(--w) * 0.1) rgba(0, 0, 0, 0.35);
  transition: transform 0.12s ease;
}
.tile svg { display: block; width: 100%; height: 100%; }
.tile-hand { --w: var(--hand-w); cursor: pointer; }
.tile-small { --w: var(--small-w); }
.tile-mini { --w: var(--mini-w); }
.tile-xs { --w: var(--xs-w); box-shadow: none; }
.tile-back { background: #2f7d55; box-shadow: 0 calc(var(--w) * 0.06) 0 #e9e2cc, 0 1px 2px rgba(0, 0, 0, 0.3); }
.tile-index {
  position: absolute;
  top: 1px;
  left: 1px;
  font-size: calc(var(--w) * 0.22);
  font-weight: 800;
  line-height: 1;
  color: #333;
  background: rgba(255, 250, 240, 0.9);
  border-radius: 3px;
  padding: 0 1px;
  pointer-events: none;
}
.tile-mini .tile-index { font-size: calc(var(--w) * 0.3); }
.tile.selected { transform: translateY(calc(var(--w) * -0.3)); outline: 3px solid var(--gold); outline-offset: 1px; }
.tile.forbidden { filter: grayscale(0.85) brightness(0.65); }
.tile.forbidden::after {
  content: "✕";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: calc(var(--w) * 0.7);
  color: var(--red);
  font-weight: 900;
}
.tile.ting-ok::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(var(--w) * -0.3);
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #7cfc9a;
  transform: translateX(-50%);
}
.tile.liang-ok { outline: 4px solid #c39bff; outline-offset: 1px; }
.tile.dim { opacity: 0.4; }
.tile.coach-tile { outline: 3px solid #7cfc9a; outline-offset: 1px; }
.tile.chosen-tile { outline: 3px solid var(--gold); outline-offset: 1px; }
.tile-badge {
  position: absolute;
  top: -10px;
  right: -6px;
  z-index: 2;
  background: #e5a50a;
  color: #000;
  font-size: 13px;
  font-weight: 800;
  border-radius: 9px;
  padding: 0 5px;
  line-height: 18px;
}
.gap { display: inline-block; width: calc(var(--hand-w) * 0.35); flex: none; }
/* 推荐概率：写在牌的正下方（听牌绿点的下面） */
.tile-prob {
  position: absolute;
  left: 50%;
  top: 100%;
  margin-top: calc(var(--w) * 0.3 + 4px);
  transform: translateX(-50%);
  font-size: clamp(10px, calc(var(--w) * 0.48), 13px);
  font-weight: 700;
  line-height: 1;
  color: var(--muted);
  white-space: nowrap;
  pointer-events: none;
}
.tile-prob.best { color: #7cfc9a; font-weight: 800; }

/* ---------- 牌桌 ---------- */
.table {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-areas: "left right" "center center" "me me";
  gap: var(--gap);
}
.seat-left { grid-area: left; }
.seat-right { grid-area: right; }
.seat-me { grid-area: me; }
.center { grid-area: center; }
/* 宽屏（含横屏手机）：左右两家在两边，中间是牌桌信息和我。lay-wide 由 orient.js 按横屏后的宽高设置 */
html.lay-wide .table {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr) minmax(0, 1fr);
  grid-template-areas: "left center right" "left me right";
  grid-template-rows: auto 1fr;
}

.seat {
  background: var(--panel);
  border: 2px solid var(--panel-line);
  border-radius: 12px;
  padding: 6px 8px 8px;
  min-width: 0;
}
.seat.active { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(255, 213, 74, 0.25), 0 0 18px rgba(255, 213, 74, 0.25); }
.seat.is-liang { background: rgba(142, 91, 216, 0.18); }
.seat-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 4px; }
.seat-name { font-weight: 800; font-size: 19px; }
.seat-score { font-weight: 800; margin-left: auto; }
.seat-count { color: var(--muted); font-size: 15px; }
.thinking { color: var(--gold); font-size: 15px; }
.badge { border-radius: 6px; padding: 0 6px; font-size: 14px; font-weight: 800; line-height: 22px; }
.badge-dealer { background: #b3261e; color: #fff; }
.badge-liang { background: var(--purple); color: #fff; }
.seat-hand, .seat-melds, .river, .waits, .backs, .hand-strip { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 3px; }
.seat-hand { margin-bottom: 6px; min-height: calc(var(--xs-w) * 1.4); }
.backs { gap: 1px; }
.seat-melds { margin-bottom: 6px; gap: 8px; }
.meld { display: inline-flex; align-items: flex-end; gap: 1px; position: relative; }
.meld-tag { font-size: 11px; color: var(--gold); margin-left: 2px; }
.waits { align-items: center; margin-bottom: 6px; color: #e3d2ff; font-weight: 700; }
.river { gap: 3px 2px; padding-top: 4px; border-top: 1px dashed var(--panel-line); min-height: calc(var(--mini-w) * 1.5); }
.river .tile.last { outline: 3px solid var(--gold); outline-offset: 1px; }
.river .tile.claimed { opacity: 0.3; }
.river .tile.liang-tile { outline: 2px solid #c39bff; }
.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 74px;
  padding: 6px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.15);
}
.banner { display: flex; align-items: center; gap: 10px; min-height: 48px; font-size: 21px; font-weight: 800; text-align: center; }
.wall-info { color: var(--muted); font-size: 15px; }

/* ---------- 对局页：整屏布局，牌桌区可滚动，操作区固定在底部 ---------- */
.screen.game {
  --pad-l: max(10px, env(safe-area-inset-left));
  --pad-r: max(10px, env(safe-area-inset-right));
  --pad-b: max(8px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding: 8px var(--pad-r) 0 var(--pad-l);
}
.game .topbar { flex: none; }
.game-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 6px; }
.rotate-tip { display: none; margin: 0 0 6px; text-align: center; font-size: 15px; color: var(--muted); }
@media (orientation: portrait) and (max-width: 560px) { .rotate-tip { display: block; } }

/* ---------- 底部操作区 ---------- */
.dock {
  flex: none;
  z-index: 5;
  margin: 0 calc(-1 * var(--pad-r)) 0 calc(-1 * var(--pad-l));
  padding: 6px var(--pad-r) var(--pad-b) var(--pad-l);
  background: linear-gradient(to top, rgba(10, 40, 27, 0.97) 75%, rgba(10, 40, 27, 0.6));
  border-top: 1px solid var(--panel-line);
}
.tingbar { min-height: 26px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 17px; }
.recbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-height: 30px; font-size: 17px; }
.recbar .rec-best { color: #7cfc9a; font-weight: 800; }
.recbar .rec-other { color: var(--muted); }
.recbar .btn-small { min-height: 30px; padding: 2px 10px; font-size: 15px; }
.ting-yes { color: #7cfc9a; font-weight: 800; }
.ting-wait { background: rgba(124, 252, 154, 0.15); border-radius: 6px; padding: 0 6px; }
.actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; min-height: 60px; padding: 4px 0; }
.status { font-size: 19px; color: var(--muted); }
.hand-area { padding: calc(var(--hand-w) * 0.34 + 14px) 6px calc(var(--hand-w) * 0.2); overflow-x: auto; }
.hand-area.with-probs { padding-bottom: calc(var(--hand-w) * 0.3 + 22px); }
.my-hand { display: flex; align-items: flex-end; justify-content: center; gap: 10px; min-width: min-content; margin: 0 auto; }
.my-melds { display: flex; gap: 6px; align-items: flex-end; }
.my-tiles { display: flex; align-items: flex-end; gap: 2px; }

.hint-panel {
  background: var(--ivory);
  color: var(--paper-ink);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 6px;
  max-height: calc(var(--app-h) * 0.34);
  overflow: auto;
}
.hint-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.hint-list { display: grid; gap: 6px; }
.hint-row {
  display: grid;
  grid-template-columns: minmax(7em, auto) 1fr;
  grid-template-areas: "label bar" "meta meta";
  gap: 2px 10px;
  align-items: center;
  padding: 6px 8px;
  border-radius: 8px;
  background: #f1ebdb;
}
.hint-row.best { background: #dff3e4; }
.hint-row.chosen { box-shadow: inset 0 0 0 2px #e5a50a; }
.hint-label { grid-area: label; font-weight: 800; }
.hint-meta { grid-area: meta; font-size: 14px; color: #55645a; }
.bar { grid-area: bar; height: 12px; background: #d9d1bc; border-radius: 6px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: #2e9d5b; width: 0; }

.gamelog { margin-top: 10px; background: var(--panel); border-radius: 10px; padding: 6px 12px; }
.gamelog summary { cursor: pointer; color: var(--muted); }
.gamelog ol { max-height: calc(var(--app-h) * 0.4); overflow: auto; margin: 6px 0; padding-left: 1.6em; font-size: 16px; }

/* ---------- 对话框 ---------- */
.dialog {
  width: min(600px, calc(var(--app-w) - 24px));
  max-height: calc(var(--app-h) - 24px);
  border: 0;
  border-radius: 16px;
  padding: 18px;
  background: var(--ivory);
  color: var(--paper-ink);
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.dialog h2 { font-size: 26px; text-align: center; margin-bottom: 10px; }
.dialog-buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.dialog-buttons .btn { flex: 1 1 140px; }
.dialog-buttons.vertical { flex-direction: column; }
.win-box { background: #f1ebdb; border-radius: 10px; padding: 8px 10px; margin-bottom: 10px; }
.win-box p { margin: 2px 0 6px; }
.win-tile { outline: 3px solid #e5a50a; outline-offset: 1px; }
.score-table { width: 100%; border-collapse: collapse; font-size: 18px; }
.score-table th, .score-table td { border-bottom: 1px solid #e0d8c2; padding: 6px 4px; text-align: center; }
.r-id { font-size: 14px; color: #6b7a70; text-align: center; margin: 8px 0 0; font-family: ui-monospace, Menlo, Consolas, monospace; }

/* ---------- 历史 ---------- */
.history { max-width: 760px; }
.open-by-id .row { display: flex; gap: 8px; }
.open-by-id input { flex: 1; min-width: 0; min-height: 46px; font-size: 18px; padding: 6px 10px; border: 2px solid #c9bfa5; border-radius: 10px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.open-by-id label { display: block; font-weight: 700; margin-bottom: 6px; }
.game-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.game-item { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--panel-line); border-radius: 12px; padding: 10px 12px; }
.gi-main { flex: 1; min-width: 0; }
.gi-title { font-weight: 700; }
.gi-id { font-size: 13px; color: var(--muted); font-family: ui-monospace, Menlo, Consolas, monospace; }
.gi-delta { font-weight: 800; font-size: 20px; min-width: 3em; text-align: right; }

/* ---------- 复盘 ---------- */
.replay-events { min-height: 30px; margin: 6px 0; font-size: 18px; text-align: center; color: var(--gold); }
.replay-hand { background: rgba(0, 0, 0, 0.15); border-radius: 12px; }
.replay-controls { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; margin: 8px 0; }
.replay-controls input[type="range"] { flex: 1 1 200px; min-width: 160px; height: 36px; }
.decision-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.decision-head select { min-height: 38px; border-radius: 8px; }
.summary { margin: 6px 0; font-size: 16px; }
.card .chip { color: #7a2a1a; background: #f6e3d6; border-color: #e3b9a0; font-weight: 700; }

/* ---------- 提示条 ---------- */
.toast {
  position: fixed;
  left: 50%;
  top: 14px;
  transform: translateX(-50%);
  z-index: 50;
  max-width: calc(100vw - 24px);
  background: #222;
  color: #fff;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 18px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}

/* ---------- 矮屏横屏（手机横屏，或者牌桌转过来之后）：压缩间距，多露出牌桌 ---------- */
/* lay-short 由 orient.js 按横屏后的宽高设置（高度不超过 520） */
html.lay-short {
  --mini-w: clamp(15px, calc(var(--app-w) * 0.021), 24px);
  --hand-w: clamp(26px, calc((var(--app-w) - 60px) / 15.5), 46px);
}
html.lay-short .screen.game { padding-top: 4px; }
html.lay-short .hand-area { padding: calc(var(--hand-w) * 0.3 + 6px) 6px 2px; }
html.lay-short .hand-area.with-probs { padding-bottom: calc(var(--hand-w) * 0.3 + 18px); }
html.lay-short .dock { padding-top: 2px; }
html.lay-short .tingbar:empty { display: none; }
html.lay-short .seat { padding: 4px 6px; }
html.lay-short .seat-name { font-size: 16px; }
html.lay-short .seat-head { margin-bottom: 2px; }
html.lay-short .seat-melds, html.lay-short .waits { margin-bottom: 3px; }
/* 别人的手牌背面一排排的很占地方，头上已经写了几张 */
html.lay-short .screen.game .seat-backs { display: none; }
html.lay-short .banner { font-size: 18px; min-height: 34px; }
html.lay-short .center { min-height: 44px; padding: 4px; }
html.lay-short .screen.game .wall-info { display: none; } /* 顶栏有「剩 N 张」 */
html.lay-short .btn-act { min-height: 48px; font-size: 19px; }
html.lay-short .actions { min-height: 50px; padding: 0; }
html.lay-short .hint-panel { max-height: calc(var(--app-h) * 0.3); }
html.lay-short .topbar { padding-bottom: 2px; }
html.lay-short .game .topbar .btn-small { min-height: 32px; padding: 2px 10px; font-size: 15px; }
html.lay-short .game .pill { font-size: 15px; padding: 0 10px; }
html.lay-short .game .topinfo .game-id { display: none; } /* 局号在菜单里能复制，结算时也有 */
html.lay-short .btn-small { min-height: 34px; }
html.lay-short .tingbar { min-height: 0; font-size: 15px; }
html.lay-short .recbar { min-height: 0; font-size: 15px; }
html.lay-short .review { padding: 2px 8px; margin-bottom: 2px; font-size: 14px; border-left-width: 4px; }
html.lay-short .review .btn { min-height: 26px; padding: 0 8px; font-size: 13px; }
html.lay-short .review-mark { font-size: 15px; }
html.lay-short .rotate-tip { display: none; }
/* 推荐和听牌信息放在左边，按钮放在右边，少占一行 */
html.lay-short .dock {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "panel panel" "review review" "rec act" "ting act" "hand hand";
  column-gap: 12px;
  align-items: center;
}
html.lay-short .dock > .hint-panel { grid-area: panel; }
html.lay-short .dock > .review { grid-area: review; }
html.lay-short .dock > .recbar { grid-area: rec; }
html.lay-short .dock > .tingbar { grid-area: ting; }
html.lay-short .dock > .actions { grid-area: act; justify-content: flex-end; }
html.lay-short .dock > .hand-area { grid-area: hand; }
/* 对话框：结算表格放右边，按钮矮一点，一屏放得下 */
html.lay-short .dialog { padding: 10px 14px; }
html.lay-short .dialog h2 { font-size: 21px; margin-bottom: 6px; }
html.lay-short .dialog.result { width: min(880px, calc(var(--app-w) - 24px)); }
html.lay-short .result-body { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); column-gap: 14px; align-items: start; }
html.lay-short .result-body > * { grid-column: 1; }
html.lay-short .result-body > .score-table { grid-column: 2; grid-row: 1 / span 4; font-size: 16px; }
html.lay-short .score-table th, html.lay-short .score-table td { padding: 3px 2px; }
html.lay-short .win-box { padding: 6px 8px; margin-bottom: 6px; }
html.lay-short .win-box .big { font-size: 18px; }
html.lay-short .r-id { margin-top: 4px; }
html.lay-short .dialog-buttons { margin-top: 8px; gap: 8px; }
html.lay-short .dialog .btn-big { min-height: 46px; font-size: 18px; }
html.lay-short .dialog-buttons.vertical { display: grid; grid-template-columns: 1fr 1fr; }

/* ---------- 牌桌转 90 度（手机竖着、浏览器不能锁横屏时）：手机横过来看就是正的 ---------- */
/* force-land 由 orient.js 设置；这时 --app-w 是手机的高、--app-h 是手机的宽 */
html.force-land, html.force-land body { overflow: hidden; }
html.force-land .screen.game {
  /* 转完之后：左边是原来的顶部（刘海），右边是原来的底部（横条） */
  --pad-l: max(10px, env(safe-area-inset-top));
  --pad-r: max(10px, env(safe-area-inset-bottom));
  --pad-b: 6px;
  position: fixed;
  top: 0;
  left: 0;
  width: var(--app-w);
  max-width: none;
  height: var(--app-h);
  transform-origin: 0 0;
  transform: translateX(var(--app-h)) rotate(90deg);
}
/* 弹出的对话框不在牌桌里面，单独转（比屏幕宽时 margin:auto 居中不了，改用 50% 定位） */
html.force-land dialog[open] {
  inset: auto;
  top: 50%;
  left: 50%;
  margin: 0;
  max-width: none;
  transform: translate(-50%, -50%) rotate(90deg);
}
html.force-land .toast {
  top: 50%;
  left: auto;
  right: 14px;
  max-width: calc(var(--app-w) - 24px);
  transform: translate(50%, -50%) rotate(90deg) translateY(50%);
}
html.force-land .rotate-tip { display: none; }

@media (max-width: 420px) {
  .btn.lv { font-size: 18px; }
  .game .topinfo .game-id { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .tile { transition: none; }
}

/* ---------- 每手评分 ---------- */
.review {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin-bottom: 4px;
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 16px;
  background: rgba(255, 255, 255, 0.08);
  border-left: 5px solid var(--muted);
}
.review .btn { margin-left: auto; min-height: 30px; font-size: 14px; }
.review-mark { font-weight: 900; font-size: 18px; }
.review-good { border-left-color: #3fbf6f; }
.review-good .review-mark { color: #3fbf6f; }
.review-ok { border-left-color: #b9cbbf; }
.review-warn { border-left-color: #f0b429; }
.review-warn .review-mark { color: #f0b429; }
.review-bad { border-left-color: #ff7a6e; }
.review-bad .review-mark { color: #ff7a6e; }
.eff-worse { color: #ffb4ab; }

/* ---------- 统计 ---------- */
.stats { max-width: 900px; }
.stats .source select { min-height: 38px; border-radius: 8px; }
.stat-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 8px 0; }
@media (max-width: 520px) {
  .stat-tile { padding: 10px; }
  .stat-value { font-size: 26px; }
  .stat-label, .stat-sub { font-size: 12px; }
  .data-table { font-size: 14px; }
  .data-table th, .data-table td { padding: 5px 4px; }
  .chart { padding-top: 62px; }
}
.stat-tile { background: var(--ivory); color: var(--paper-ink); border-radius: 14px; padding: 12px 16px; }
.stat-label { font-size: 15px; color: #52514e; }
.stat-value { font-size: 34px; font-weight: 600; line-height: 1.2; }
.stat-sub { font-size: 13px; color: #6b7a70; }
.data-table { width: 100%; border-collapse: collapse; font-size: 16px; }
.data-table th, .data-table td { padding: 6px 8px; border-bottom: 1px solid #e6dfcc; text-align: left; }
.data-table th { font-weight: 600; color: #52514e; font-size: 14px; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table tr.hot td { background: #fbe7dc; font-weight: 700; }
.data-details { margin-top: 8px; }
.data-details summary { cursor: pointer; color: #52514e; }

.viz-root {
  --surface-1: #fffaf0;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --series-1: #2a78d6;
  --grid: #e6dfcc;
  --axis: #b9b2a0;
}
.chart { position: relative; padding-top: 44px; }
.chart svg { display: block; max-width: 100%; height: auto; }
.chart .bar { fill: var(--series-1); }
.chart .bar.active { fill: #1f5fae; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--text-secondary); font-size: 12px; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart-tip {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: #222;
  color: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 14px;
  pointer-events: none;
  white-space: normal;
}
.mistakes { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.mistakes li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: #f1ebdb; }
.mk-main { flex: 1; min-width: 0; }
.mk-title { font-weight: 700; }
