:root {
  --bg: #000;
  --text: #eee;
  --banker: #e61f19;
  --player: #1e88ff;
  --tie: #28a745;
  --road-bg: #ffffff;
  --road-grid: #d4d4d8;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --page-w: min(100vw, 560px);
  --strip-h: calc(var(--page-w) * 0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#app {
  width: var(--page-w);
  height: 100%;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-t);
  padding-bottom: var(--safe-b);
  background: #0b0b0d;
}

/* ---------- 视频 ---------- */

.video-wrap {
  position: relative;
  flex: none;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: #000;
  overflow: hidden;
}
.video-clip { position: absolute; inset: 0; overflow: hidden; background: #000; }
#video { width: 100%; height: 100%; object-fit: cover; object-position: center; background: #000; }

.video-meta {
  position: absolute;
  top: 6px;
  left: 8px;
  display: flex;
  gap: 6px;
  font-size: 12px;
  pointer-events: none;
}
.hidden-label { display: none; }
.video-status:empty { display: none; }
.video-status {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(160, 30, 30, 0.8);
  color: #fff;
  font-size: 11px;
}

.cam-btns { position: absolute; right: 8px; top: 8px; display: flex; gap: 6px; z-index: 2; }
.cam {
  border: none;
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: rgba(0, 0, 0, 0.45);
  cursor: pointer;
}
.cam.active { background: rgba(212, 175, 55, 0.9); color: #111; }
.max-exit { display: none; }

.video-wrap.is-max {
  position: fixed;
  inset: 0;
  z-index: 40;
  width: 100%;
  height: 100%;
  height: 100dvh;
  aspect-ratio: auto;
}
.video-wrap.is-max #video { object-fit: contain; }
.video-wrap.is-max .max-exit { display: inline-block; }
.video-wrap.is-max .cam-btns { right: calc(8px + var(--safe-r)); top: calc(8px + var(--safe-t)); }
body.is-video-max .name-bar,
body.is-video-max .banner-area,
body.is-video-max .dock { display: none; }

/* ---------- 桌名条 ---------- */

.name-bar {
  flex: none;
  height: 34px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  background: linear-gradient(180deg, #2a2a2e 0%, #18181b 100%);
  border-top: 1px solid #3a3a40;
  border-bottom: 1px solid #000;
}
#tableName {
  font-size: 15px;
  font-weight: 700;
  color: #e7c873;
  letter-spacing: 0.5px;
}
.shoe-info {
  margin-left: auto;
  display: flex;
  gap: 10px;
  font-size: 13px;
  color: #c9c9cf;
  font-variant-numeric: tabular-nums;
}
.shoe-info:empty { display: none; }
.shoe-info b { color: #e7c873; font-weight: 700; margin-left: 3px; }

/* ---------- 中间横幅 ---------- */

.banner-area {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: radial-gradient(ellipse at center, #1c1c22 0%, #0b0b0d 70%);
}
#banner {
  max-width: 82%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6);
}
.banner-area.empty #banner { display: none; }

/* ---------- 底部路单条 ---------- */

.dock {
  flex: none;
  height: var(--strip-h);
  background: var(--road-bg);
  border-top: 1px solid #c8c8cc;
}

.strip {
  height: 100%;
  display: flex;
  min-width: 0;
}

.panel { position: relative; min-width: 0; min-height: 0; overflow: hidden; }
.panel canvas { position: absolute; inset: 0; display: block; }

.bead-panel {
  flex: none;
  height: 100%;
  aspect-ratio: 4 / 6;
  border-right: 1px solid #b8b8bd;
}

.board-main {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  grid-template-rows: 2fr 1fr 1fr;
}
.big-panel, .eye-panel { border-bottom: 1px solid #b8b8bd; }
.bottom-derived { display: grid; grid-template-columns: 1fr 1fr; min-height: 0; }
.bottom-derived .panel + .panel { border-left: 1px solid #b8b8bd; }

/* 右侧：统计竖列 + 庄闲问路竖条 */
.side {
  flex: none;
  width: calc(var(--page-w) * 0.27);
  display: flex;
  gap: 3px;
  padding: 3px;
  background: #141418;
}

.stats {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  gap: 2px;
}
.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 3px;
  min-height: 0;
}
.stat-tag {
  flex: none;
  min-width: 2.6em;
  padding: 1px 4px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  color: #fff;
  background: #4a4a52;
}
.stat-n {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #e8e8ea;
}
.stat-row.all .stat-tag { background: #55555c; }
.stat-row.b .stat-tag, .stat-row.bp .stat-tag { background: var(--banker); }
.stat-row.p .stat-tag, .stat-row.pp .stat-tag { background: var(--player); }
.stat-row.t .stat-tag { background: var(--tie); }
.stat-row.b .stat-n, .stat-row.bp .stat-n { color: #ff6a64; }
.stat-row.p .stat-n, .stat-row.pp .stat-n { color: #6fb4ff; }
.stat-row.t .stat-n { color: #6fdc8a; }

.ask-bar {
  flex: none;
  width: 22px;
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 3px;
}
.ask {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  min-height: 0;
  border-radius: 11px;
  border: 1.5px solid var(--banker);
  background: #fff;
  cursor: pointer;
  padding: 2px 0;
}
.ask.player { border-color: var(--player); }
.ask.active, .ask[aria-pressed="true"] { box-shadow: 0 0 0 2px #ffd54f; }
.ask-label { font-size: 11px; font-weight: 700; line-height: 1; color: var(--banker); }
.ask.player .ask-label { color: var(--player); }
.ask-marks { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.ask-marks .m { width: 12px; height: 12px; display: block; }

/* 横屏 / 桌面：页面保持手机宽度居中 */
@media (orientation: landscape) and (max-height: 520px) {
  :root { --page-w: min(100vw, calc(100dvh * 0.9)); }
  .banner-area { display: none; }
}
