:root {
  --bg-deep: #13100d;
  --bg-surface: rgba(33, 28, 24, 0.86);
  --bg-card: rgba(43, 36, 31, 0.74);
  --border-subtle: rgba(224, 189, 134, 0.16);
  --border-highlight: rgba(224, 189, 134, 0.38);
  --gold-primary: #dfb068;
  --gold-bright: #f2cb8b;
  --cinnabar: #d9383a;
  --jade: #3ca982;
  --amber: #e8a23a;
  --text-main: #f4ece1;
  --text-secondary: #b9aca0;
  --text-muted: #85786c;
  --shadow-heavy: 0 22px 54px rgba(0, 0, 0, 0.62);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
.hidden { display: none !important; }

body {
  min-height: 100vh;
  background: radial-gradient(circle at 22% 18%, #261e17 0%, #15110e 58%, #0d0b09 100%);
  color: var(--text-main);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  display: flex; align-items: center; justify-content: center;
  padding: 16px 20px; overflow-x: hidden; position: relative;
}

.ambient-glow { position: fixed; border-radius: 50%; filter: blur(110px); pointer-events: none; z-index: 0; }
.glow-warm { width: 460px; height: 460px; background: rgba(218, 162, 82, 0.11); top: -110px; left: 6%; }
.glow-jade { width: 400px; height: 400px; background: rgba(60, 169, 130, 0.07); bottom: -100px; right: 8%; }

/* 独立全屏登录/注册页 (#auth-view) */
.auth-view {
  position: relative; z-index: 2; width: 100%; min-height: calc(100vh - 32px);
  display: flex; align-items: center; justify-content: center; padding: 12px;
}
.auth-card {
  width: min(430px, 96vw); background: var(--bg-surface); backdrop-filter: blur(20px);
  border: 1px solid var(--border-highlight); border-radius: 20px; padding: 28px 26px;
  box-shadow: var(--shadow-heavy); display: flex; flex-direction: column; gap: 18px;
}
.auth-brand { display: flex; align-items: center; gap: 14px; }
.seal-mark {
  width: 46px; height: 46px; border-radius: 11px; flex-shrink: 0;
  background: linear-gradient(145deg, #cf3436, #991d1f); border: 1px solid rgba(255, 212, 204, 0.4);
  color: #fdf6ec; font-size: 1.38rem; font-weight: 700; display: grid; place-items: center;
  box-shadow: 0 6px 16px rgba(196, 45, 47, 0.36);
}
.auth-brand h1 { font-size: 1.32rem; letter-spacing: 0.05em; }
.auth-brand p { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

.auth-tabs, .lb-tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  background: rgba(15, 12, 10, 0.72); padding: 4px; border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.auth-tab, .lb-tab {
  appearance: none; border: 1px solid transparent; background: transparent;
  color: var(--text-secondary); font-size: 0.88rem; font-weight: 600;
  padding: 9px 10px; border-radius: 7px; cursor: pointer; font-family: inherit; transition: 0.18s;
}
.auth-tab.active, .lb-tab.active {
  background: linear-gradient(145deg, rgba(223, 176, 104, 0.25), rgba(166, 122, 58, 0.18));
  color: var(--gold-bright); border-color: var(--border-highlight);
}
.auth-form { display: flex; flex-direction: column; gap: 13px; }
.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-group label { font-size: 0.82rem; color: var(--text-secondary); }
.auth-input, .filter-input, .filter-select {
  background: rgba(15, 12, 10, 0.82); color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 9px;
  padding: 10px 13px; font-size: 0.9rem; font-family: inherit; transition: border-color 0.18s;
}
.auth-input:focus, .filter-input:focus, .filter-select:focus {
  outline: none; border-color: var(--gold-bright); box-shadow: 0 0 0 2px rgba(223, 176, 104, 0.2);
}
.auth-feedback { min-height: 18px; font-size: 0.82rem; color: #ff8e8f; }
.auth-feedback.ok { color: #6ee7b7; }
.auth-consent-tip { font-size: 0.74rem; color: var(--text-muted); text-align: center; line-height: 1.45; margin-top: 2px; }
.btn-block { width: 100%; padding: 12px; font-size: 0.95rem; }

/* 下棋主页面 (#game-view) */
.page-shell {
  position: relative; z-index: 1; display: flex; flex-direction: column;
  gap: 14px; max-width: 1120px; width: 100%; align-items: center;
}
.player-topbar {
  width: 100%; max-width: 1068px; display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; padding: 10px 16px; border-radius: 14px;
  background: rgba(33, 27, 22, 0.88); backdrop-filter: blur(14px);
  border: 1px solid var(--border-subtle); box-shadow: 0 10px 28px rgba(0, 0, 0, 0.42);
}
.topbar-left, .topbar-right { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.seal-mini {
  width: 28px; height: 28px; border-radius: 7px; background: linear-gradient(145deg, #cf3436, #991d1f);
  color: #fff; font-weight: 700; font-size: 0.92rem; display: grid; place-items: center;
}
.topbar-title { font-weight: 700; font-size: 1rem; color: var(--gold-bright); letter-spacing: 0.03em; }
.player-quick-stat {
  font-size: 0.78rem; color: var(--text-secondary); background: rgba(16, 13, 10, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08); padding: 4px 10px; border-radius: 999px;
}
.user-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px;
  border-radius: 999px; background: rgba(223, 176, 104, 0.14); border: 1px solid var(--border-subtle);
  font-size: 0.84rem; color: var(--gold-bright);
}
.user-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--jade); box-shadow: 0 0 6px var(--jade); }
.btn-topbar {
  appearance: none; border-radius: 8px; padding: 6px 12px; font-size: 0.82rem; font-weight: 600;
  font-family: inherit; cursor: pointer; border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.07); color: var(--text-main); transition: 0.18s;
}
.btn-leaderboard {
  background: linear-gradient(145deg, rgba(223, 176, 104, 0.25), rgba(168, 122, 54, 0.2));
  border-color: var(--border-highlight); color: var(--gold-bright);
}
.btn-logout:hover, .btn-topbar:hover { filter: brightness(1.12); border-color: var(--border-highlight); }
.btn-back-lobby {
  background: rgba(255, 255, 255, 0.09); border-color: rgba(224, 189, 134, 0.28); color: var(--gold-bright);
}
.seal-billiards { background: linear-gradient(145deg, #2d8a6a, #175440); }
.btn-jade {
  background: linear-gradient(145deg, #43b58c, #247b5c); color: #091c15;
  box-shadow: 0 6px 18px rgba(45, 138, 106, 0.3);
}
.btn-jade:hover:not(:disabled) { filter: brightness(1.08); }

/* 统一游戏大厅 (#lobby-view) 与台球占位舞台 */
.lobby-shell { gap: 22px; min-height: calc(100vh - 36px); justify-content: flex-start; padding-top: 8px; }
.lobby-hero { text-align: center; display: flex; flex-direction: column; gap: 6px; padding: 6px 12px 2px; }
.lobby-hero h2 { font-size: 1.65rem; letter-spacing: 0.06em; color: var(--gold-bright); }
.lobby-hero p { font-size: 0.9rem; color: var(--text-secondary); }
.lobby-cards-grid {
  width: 100%; max-width: 960px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px; align-items: stretch;
}
.lobby-game-card {
  background: var(--bg-surface); backdrop-filter: blur(18px); border: 1px solid var(--border-subtle);
  border-radius: 20px; padding: 24px 24px 22px; box-shadow: var(--shadow-heavy);
  display: flex; flex-direction: column; gap: 16px; cursor: pointer;
  transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
}
.lobby-game-card:hover { transform: translateY(-4px); border-color: var(--border-highlight); box-shadow: 0 26px 58px rgba(0, 0, 0, 0.7); }
.lobby-game-card.card-billiards:hover { border-color: rgba(67, 181, 140, 0.58); }
.game-card-top { display: flex; align-items: center; justify-content: space-between; }
.game-card-icon {
  width: 54px; height: 54px; border-radius: 14px; font-size: 1.55rem; font-weight: 800;
  display: grid; place-items: center; color: #fff8ee;
}
.icon-gomoku { background: linear-gradient(145deg, #d9383a, #941b1d); border: 1px solid rgba(255, 212, 204, 0.42); box-shadow: 0 8px 20px rgba(196, 45, 47, 0.36); }
.icon-billiards { background: radial-gradient(circle at 32% 28%, #34383e, #121417 72%); border: 2px solid #43b58c; box-shadow: 0 8px 20px rgba(45, 138, 106, 0.34); font-family: Consolas, sans-serif; }
.game-status-pill { font-size: 0.74rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.game-status-pill.online { background: rgba(223, 176, 104, 0.2); color: var(--gold-bright); border: 1px solid rgba(223, 176, 104, 0.4); }
.game-status-pill.jade { background: rgba(60, 169, 130, 0.2); color: #6ee7b7; border: 1px solid rgba(60, 169, 130, 0.42); }
.game-card-body { display: flex; flex-direction: column; gap: 10px; flex: 1; }
.game-card-body h3 { font-size: 1.28rem; color: var(--text-main); letter-spacing: 0.04em; }
.game-card-body p { font-size: 0.86rem; color: var(--text-secondary); line-height: 1.6; }
.game-card-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 4px; }
.game-tag { font-size: 0.74rem; color: var(--text-secondary); background: rgba(16, 13, 10, 0.65); border: 1px solid rgba(255, 255, 255, 0.08); padding: 3px 9px; border-radius: 999px; }
.game-card-footer { margin-top: 4px; }

.billiards-stage-placeholder { width: 100%; max-width: 780px; display: flex; justify-content: center; padding: 24px 0; }
.billiards-placeholder-card { width: 100%; align-items: center; text-align: center; padding: 40px 26px; gap: 14px; }
.billiards-placeholder-card h2 { font-size: 1.32rem; color: #6ee7b7; }
.billiards-placeholder-card p { font-size: 0.88rem; color: var(--text-secondary); max-width: 460px; line-height: 1.6; }

.app-layout {
  display: grid; grid-template-columns: auto 366px; gap: 26px;
  align-items: center; width: 100%; justify-content: center;
}
.board-stage { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.stage-topbar { width: 100%; max-width: 640px; display: flex; align-items: center; justify-content: space-between; padding: 0 4px; }
.turn-pill {
  display: inline-flex; align-items: center; gap: 9px; padding: 6px 14px; border-radius: 999px;
  background: rgba(40, 33, 28, 0.86); border: 1px solid var(--border-subtle); font-size: 0.88rem;
}
.stone-dot, .mini-stone { width: 13px; height: 13px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.stone-dot.black, .mini-stone.black { background: radial-gradient(circle at 32% 30%, #686c73, #1d1f22 65%, #090a0b 100%); }
.stone-dot.white, .mini-stone.white { background: radial-gradient(circle at 32% 30%, #ffffff, #ebe5dc 68%, #c7bfb2 100%); }
.coord-badge {
  font-family: Consolas, monospace; font-size: 0.82rem; color: var(--gold-bright);
  background: rgba(40, 33, 28, 0.72); border: 1px solid var(--border-subtle); padding: 5px 12px; border-radius: 999px;
}

.board-frame {
  position: relative; padding: 9px; border-radius: 15px;
  background: linear-gradient(145deg, #5b3c1e 0%, #3d2611 50%, #2b1a0b 100%);
  box-shadow: var(--shadow-heavy), inset 0 1px 1px rgba(255, 226, 179, 0.28);
}
#gomokuCanvas {
  display: block; width: min(72vh, 620px); height: min(72vh, 620px);
  border-radius: 8px; cursor: pointer; user-select: none;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
#gomokuCanvas.request-busy { cursor: wait; }
#gomokuCanvas.board-locked { cursor: not-allowed; }

/* 结算浮层 */
.settlement-overlay {
  position: absolute; inset: 9px; border-radius: 8px; background: rgba(14, 10, 7, 0.34);
  display: flex; align-items: flex-end; justify-content: center; padding: 20px 16px; z-index: 10;
}
.settlement-card {
  width: min(94%, 400px); padding: 18px 20px; border-radius: 15px;
  background: rgba(24, 19, 15, 0.88); backdrop-filter: blur(14px);
  border: 1px solid rgba(242, 203, 139, 0.5); display: flex; flex-direction: column; gap: 14px;
}
.settlement-header { display: flex; align-items: center; gap: 12px; }
.result-seal {
  width: 42px; height: 42px; border-radius: 10px; background: linear-gradient(135deg, #e04042, #ad2224);
  color: #fff; font-weight: 700; font-size: 1.2rem; display: grid; place-items: center; flex-shrink: 0;
}
.result-seal.seal-loss { background: linear-gradient(135deg, #5a524a, #342f2a); }
.result-content h2 { font-size: 1.06rem; color: var(--gold-bright); }
.result-content p { font-size: 0.78rem; color: var(--text-secondary); margin-top: 2px; }
.settlement-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-box {
  background: rgba(14, 11, 9, 0.65); border: 1px solid rgba(242, 203, 139, 0.16);
  border-radius: 10px; padding: 9px 11px; display: flex; flex-direction: column; gap: 2px;
}
.stat-label { font-size: 0.74rem; color: var(--text-muted); }
.stat-value { font-family: Consolas, monospace; font-size: 1rem; color: var(--gold-bright); }
.stat-sub { font-size: 0.72rem; color: var(--text-secondary); }
.settlement-actions { display: flex; gap: 10px; }
.btn-play-again { flex: 1; }

/* 控制面板 */
.control-panel {
  background: var(--bg-surface); backdrop-filter: blur(20px); border: 1px solid var(--border-subtle);
  border-radius: 18px; padding: 18px; box-shadow: var(--shadow-heavy);
  display: flex; flex-direction: column; gap: 12px;
}
.panel-card {
  background: var(--bg-card); border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px; padding: 13px 14px; display: flex; flex-direction: column; gap: 11px;
}
.card-header-inline { display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 0.84rem; font-weight: 600; color: var(--gold-primary); letter-spacing: 0.06em; }
.step-counter { font-size: 0.76rem; color: var(--text-secondary); background: rgba(255, 255, 255, 0.07); padding: 2px 9px; border-radius: 999px; }
.control-group { display: flex; flex-direction: column; gap: 6px; }
.group-label { font-size: 0.8rem; color: var(--text-secondary); }
.segmented-control { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: rgba(16, 13, 10, 0.65); padding: 4px; border-radius: 9px; }
.segmented-control.three-cols { grid-template-columns: repeat(3, 1fr); }
.segmented-control.four-cols { grid-template-columns: 0.8fr 0.8fr 0.8fr 1.6fr; gap: 4px; }
.seg-btn {
  appearance: none; border: 1px solid transparent; background: transparent; color: var(--text-secondary);
  font-size: 0.82rem; padding: 7px 6px; border-radius: 7px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px; font-family: inherit; white-space: nowrap;
}
.seg-btn.seg-btn-gm { color: #ff9e8a; }
.seg-btn.active {
  background: linear-gradient(145deg, rgba(223, 176, 104, 0.24), rgba(166, 122, 58, 0.18));
  color: var(--gold-bright); border-color: var(--border-highlight); font-weight: 600;
}
.seg-btn.seg-btn-gm.active {
  background: linear-gradient(145deg, rgba(196, 45, 47, 0.42), rgba(122, 24, 26, 0.36));
  color: #ffd89b; border-color: rgba(255, 138, 112, 0.62);
  box-shadow: 0 0 12px rgba(217, 56, 58, 0.32);
}

.settings-subgroup { display: flex; flex-direction: column; gap: 11px; }
.pvp-panel, .pvp-lobby, .pvp-room-active { display: flex; flex-direction: column; gap: 9px; }
.pvp-join-row { display: flex; gap: 7px; }
.pvp-code-input { flex: 1; text-transform: uppercase; letter-spacing: 0.18em; font-family: Consolas, monospace; font-weight: 700; text-align: center; padding: 8px 10px; }
.pvp-hint { font-size: 0.74rem; color: var(--text-muted); line-height: 1.4; }
.pvp-code-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 11px; border-radius: 10px; background: rgba(16, 13, 10, 0.75);
  border: 1px solid var(--border-highlight);
}
.pvp-code-meta { display: flex; flex-direction: column; gap: 2px; }
.pvp-code-label { font-size: 0.7rem; color: var(--text-muted); }
.pvp-code-value { font-family: Consolas, monospace; font-size: 1.24rem; letter-spacing: 0.16em; color: var(--gold-bright); }
.pvp-code-actions { display: flex; gap: 6px; }
.pvp-seats { display: flex; flex-direction: column; gap: 6px; }
.pvp-seat {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px;
  background: rgba(16, 13, 10, 0.56); border: 1px solid rgba(255, 255, 255, 0.06); font-size: 0.8rem;
}
.pvp-seat.active-turn { border-color: var(--border-highlight); background: rgba(223, 176, 104, 0.12); }
.pvp-seat-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pvp-seat-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex-shrink: 0; }
.pvp-seat-dot.online { background: var(--jade); box-shadow: 0 0 7px var(--jade); }
.pvp-room-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pvp-conn-pill { font-size: 0.72rem; color: #6ee7b7; background: rgba(60, 169, 130, 0.18); padding: 3px 9px; border-radius: 999px; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; padding-top: 4px; border-top: 1px solid rgba(255, 255, 255, 0.05); }
.toggle-info { display: flex; flex-direction: column; gap: 2px; }
.toggle-title { font-size: 0.84rem; }
.toggle-desc { font-size: 0.72rem; color: var(--text-muted); }
.switch { position: relative; width: 42px; height: 23px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background: rgba(15, 12, 10, 0.75); border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 999px; transition: 0.2s; }
.slider::before { position: absolute; content: ""; height: 17px; width: 17px; left: 2px; bottom: 2px; background: #cbbba8; border-radius: 50%; transition: 0.2s; }
.switch input:checked + .slider { background: rgba(223, 176, 104, 0.32); border-color: var(--gold-primary); }
.switch input:checked + .slider::before { transform: translateX(19px); background: var(--gold-bright); }

/* 胜率与遥测 */
.advantage-tag { font-size: 0.73rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); color: var(--text-secondary); }
.advantage-tag.black-lead { background: rgba(223, 176, 104, 0.2); color: var(--gold-bright); }
.advantage-tag.white-lead { background: rgba(255, 255, 255, 0.18); color: #fff; }
.winrate-numbers { display: flex; justify-content: space-between; align-items: center; }
.winrate-side { display: inline-flex; align-items: center; gap: 5px; font-size: 0.78rem; color: var(--text-secondary); }
.side-pct { font-family: Consolas, monospace; font-size: 0.94rem; color: var(--gold-bright); }
.winrate-bar-track { position: relative; height: 9px; border-radius: 999px; overflow: hidden; display: flex; background: #0f0c0a; }
.winrate-bar-black { height: 100%; background: linear-gradient(90deg, #1d1f24, #dfb068); transition: width 0.35s; }
.winrate-bar-white { height: 100%; background: linear-gradient(90deg, #dcd5ca, #f5f1ea); transition: width 0.35s; }
.winrate-bar-divider { position: absolute; top: 0; bottom: 0; width: 2px; background: #ffd460; transform: translateX(-50%); transition: left 0.35s; }

.ai-status-bar { display: flex; align-items: center; gap: 8px; padding: 8px 11px; border-radius: 8px; background: rgba(17, 14, 11, 0.65); }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--jade); box-shadow: 0 0 8px var(--jade); }
.ai-status-bar[data-state="thinking"] .pulse-dot { background: var(--amber); box-shadow: 0 0 10px var(--amber); }
.status-label { font-size: 0.78rem; color: var(--text-muted); }
.status-value { margin-left: auto; font-size: 0.84rem; }
.metrics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.metric-item { background: rgba(17, 14, 11, 0.55); border: 1px solid rgba(255, 255, 255, 0.05); border-radius: 8px; padding: 7px 10px; display: flex; flex-direction: column; gap: 3px; }
.metric-item.full-span { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: space-between; }
.metric-label { font-size: 0.74rem; color: var(--text-muted); }
.metric-value-wrap { display: flex; align-items: baseline; gap: 4px; }
.metric-value { font-family: Consolas, monospace; font-size: 1.08rem; color: var(--gold-bright); }
.metric-unit { font-size: 0.73rem; color: var(--text-muted); }
.book-badge, .vcf-badge { font-size: 0.74rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; width: fit-content; }
.book-badge.inactive, .vcf-badge.inactive { background: rgba(255, 255, 255, 0.07); color: var(--text-secondary); }
.book-badge.active { background: rgba(60, 169, 130, 0.22); color: #6ee7b7; }
.vcf-badge.active { background: rgba(217, 56, 58, 0.24); color: #ff9495; }

.action-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn {
  appearance: none; border: 1px solid transparent; border-radius: 10px; padding: 11px 14px;
  font-size: 0.88rem; font-weight: 600; font-family: inherit; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: 0.18s;
}
.btn-secondary { background: rgba(255, 255, 255, 0.07); border-color: rgba(255, 255, 255, 0.14); color: var(--text-main); }
.btn-secondary:disabled { opacity: 0.36; cursor: not-allowed; }
.btn-primary { background: linear-gradient(145deg, #e0b26b, #b6843c); color: #1c130a; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.toast-msg { min-height: 18px; font-size: 0.8rem; text-align: center; color: var(--gold-bright); opacity: 0; transition: opacity 0.2s; }
.toast-msg.visible { opacity: 1; }

/* 全站排行榜模态框 */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 9999; background: rgba(8, 6, 5, 0.76); backdrop-filter: blur(7px);
  display: flex; align-items: center; justify-content: center; padding: 14px;
}
.modal-dialog {
  width: min(720px, 96vw); max-height: 86vh; background: linear-gradient(165deg, #241d18, #16120e);
  border: 1px solid var(--border-highlight); border-radius: 18px; padding: 18px 20px;
  display: flex; flex-direction: column; gap: 13px; overflow: hidden; box-shadow: var(--shadow-heavy);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-bottom: 10px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.modal-title-wrap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.modal-title-wrap h2 { font-size: 1.12rem; color: var(--gold-bright); }
.sync-pill { font-size: 0.74rem; padding: 2px 9px; border-radius: 999px; background: rgba(60, 169, 130, 0.2); color: #6ee7b7; }
.modal-header-actions { display: flex; align-items: center; gap: 8px; }
.btn-modal-close { width: 32px; height: 32px; border-radius: 8px; background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.14); color: var(--text-main); font-size: 1.1rem; cursor: pointer; }

.lb-pane { display: flex; flex-direction: column; gap: 9px; min-height: 0; flex: 1; }
.lb-table-head, .lb-rank-row {
  display: grid; grid-template-columns: 48px 1.75fr 0.72fr 0.82fr 0.72fr 0.82fr;
  align-items: center; gap: 6px; padding: 8px 12px; font-size: 0.8rem;
}
.lb-table-head { color: var(--text-muted); border-bottom: 1px solid rgba(255, 255, 255, 0.08); font-weight: 600; }
.lb-list-body { overflow-y: auto; max-height: 48vh; display: flex; flex-direction: column; gap: 7px; padding-right: 4px; }
.lb-rank-row, .lb-match-row {
  border-radius: 10px; background: rgba(15, 12, 9, 0.66); border: 1px solid rgba(255, 255, 255, 0.06);
}
.lb-rank-row { cursor: pointer; transition: border-color 0.16s; }
.lb-rank-row:hover, .lb-rank-row.is-me { border-color: var(--border-highlight); background: rgba(223, 176, 104, 0.1); }
.rank-num { font-weight: 700; color: var(--gold-bright); }
.rank-player-cell { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 5px; min-width: 0; }
.me-tag { font-size: 0.7rem; background: var(--gold-primary); color: #1c130a; padding: 1px 6px; border-radius: 99px; font-weight: 700; }
.region-tag {
  font-size: 0.71rem; font-weight: 500; color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 1px 6px; border-radius: 5px; white-space: nowrap;
}

.lb-filter-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-select { min-width: 130px; }
.filter-input { flex: 1; min-width: 160px; }
.lb-match-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 9px 12px; font-size: 0.8rem; }
.match-meta-l, .match-meta-r { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge-pill { font-size: 0.73rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.badge-pill.win { background: rgba(60, 169, 130, 0.22); color: #6ee7b7; }
.badge-pill.loss { background: rgba(217, 56, 58, 0.22); color: #ff9495; }
.badge-pill.draw { background: rgba(255, 255, 255, 0.12); color: var(--text-secondary); }
.badge-pill.diff { background: rgba(223, 176, 104, 0.18); color: var(--gold-bright); }
.badge-pill.diff-grandmaster {
  background: linear-gradient(135deg, rgba(198, 42, 44, 0.38), rgba(138, 28, 30, 0.42));
  color: #ffd996; border: 1px solid rgba(255, 168, 120, 0.5);
  box-shadow: 0 0 8px rgba(217, 56, 58, 0.25);
}
.gm-win-highlight { color: #ffd996; font-weight: 700; }
.empty-hint { text-align: center; padding: 32px 14px; color: var(--text-muted); font-size: 0.85rem; }

/* 在线八球台球页面与组件 */
.billiards-shell { max-width: 1260px; }
.billiards-layout {
  width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px; align-items: start;
}
.billiards-stage { display: flex; flex-direction: column; gap: 10px; width: 100%; min-width: 0; }
.billiards-hud { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.billiards-turn-pill { border-color: rgba(60, 169, 130, 0.42); }
.billiards-cue-dot {
  width: 13px; height: 13px; border-radius: 50%; flex-shrink: 0;
  background: radial-gradient(circle at 32% 30%, #fff, #dfd6c7 75%, #aba08e);
  box-shadow: 0 0 8px rgba(255, 250, 238, 0.55);
}
.billiards-cue-dot.foul { background: radial-gradient(circle at 32% 30%, #ff8585, #d9383a); box-shadow: 0 0 10px rgba(217, 56, 58, 0.65); }
.billiards-solo-stats { display: inline-flex; align-items: center; gap: 8px; }

.billiards-racks-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.billiards-player-rack {
  background: rgba(24, 19, 15, 0.84); border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px; padding: 8px 11px; display: flex; flex-direction: column; gap: 6px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.billiards-player-rack.active {
  border-color: rgba(83, 212, 164, 0.62);
  box-shadow: 0 0 0 1px rgba(83, 212, 164, 0.22), 0 8px 18px rgba(0, 0, 0, 0.35);
}
.b-rack-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 0.82rem; }
.b-group-tag {
  font-size: 0.72rem; padding: 2px 8px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.08); color: var(--text-secondary);
}
.b-group-tag.solid { background: rgba(223, 176, 104, 0.2); color: var(--gold-bright); }
.b-group-tag.stripe { background: rgba(60, 169, 130, 0.22); color: #7ef0c2; }
.b-ball-slots { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; min-height: 22px; }
.b-mini-ball {
  width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.65rem; font-weight: 800; font-family: Consolas, monospace; color: #16120e;
  box-shadow: inset -2px -2px 4px rgba(0, 0, 0, 0.35), 0 2px 4px rgba(0, 0, 0, 0.45);
  position: relative; transition: opacity 0.2s, transform 0.2s;
}
.b-mini-ball.is-stripe { border: 2px solid #faf6ee; }
.b-mini-ball.is-eight { background: #14161a !important; color: #f6efe4; border: 1px solid rgba(255, 255, 255, 0.28); }
.b-mini-ball.pocketed { opacity: 0.22; transform: scale(0.84); filter: grayscale(0.75); }

.billiards-table-frame {
  position: relative; width: 100%; padding: 10px; border-radius: 20px;
  background: linear-gradient(145deg, #4b2f1c, #24150c);
  border: 1px solid rgba(223, 176, 104, 0.34);
  box-shadow: var(--shadow-heavy), inset 0 1px 0 rgba(255, 224, 172, 0.18);
  display: flex; align-items: center; justify-content: center;
}
#billiardsCanvas {
  display: block; width: 100%; height: auto; border-radius: 12px;
  cursor: crosshair; touch-action: none; user-select: none; -webkit-user-select: none;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.52);
}
.billiards-bih-banner {
  position: absolute; top: 18px; left: 50%; transform: translateX(-50%); z-index: 12;
  background: rgba(18, 14, 11, 0.9); border: 1px solid rgba(242, 203, 139, 0.65);
  color: var(--gold-bright); font-size: 0.8rem; font-weight: 600;
  padding: 6px 14px; border-radius: 999px; white-space: nowrap; pointer-events: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

.billiards-power-bar-wrap {
  background: rgba(24, 19, 15, 0.82); border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px; padding: 9px 12px; display: flex; flex-direction: column; gap: 6px;
}
.b-power-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 0.76rem; color: var(--text-secondary); }
.b-power-pct { font-family: Consolas, monospace; color: var(--gold-bright); white-space: nowrap; }
.b-power-track { height: 8px; border-radius: 999px; background: rgba(10, 8, 6, 0.85); overflow: hidden; }
.b-power-fill {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, #3ca982 0%, #e5b869 60%, #e64949 100%);
  transition: width 0.04s linear;
}

.segmented-control.three-cols { grid-template-columns: repeat(3, 1fr); }
.b-online-btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.b-seat-badge {
  font-size: 0.7rem; font-weight: 800; padding: 2px 6px; border-radius: 6px;
  background: rgba(60, 169, 130, 0.22); color: #7ef0c2; font-family: Consolas, monospace;
}
.spin-widget-wrap { display: flex; align-items: center; gap: 14px; }
#billiardsSpinCanvas {
  width: 112px; height: 112px; flex-shrink: 0; border-radius: 50%;
  cursor: pointer; touch-action: none;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.48), 0 0 0 1px rgba(223, 176, 104, 0.28);
}
.spin-legend { display: flex; flex-direction: column; gap: 5px; font-size: 0.76rem; color: var(--text-secondary); }
.spin-readout { font-size: 0.84rem; font-weight: 700; color: var(--gold-bright); }
.spin-tip { color: var(--text-muted); }
.spin-list { padding-left: 16px; display: flex; flex-direction: column; gap: 2px; line-height: 1.4; }
.b-rule-line { font-size: 0.78rem; color: var(--text-secondary); line-height: 1.55; }
.b-lb-head-winrate, .b-lb-row-winrate { grid-template-columns: 46px 1.8fr 0.7fr 0.75fr 0.85fr; }
.b-lb-head-solo, .b-lb-row-solo { grid-template-columns: 46px 1.65fr 0.95fr 0.78fr 0.62fr; }

/* 手机竖屏与平板自适应 */
@media (max-width: 1020px) {
  .billiards-layout { grid-template-columns: 1fr; justify-items: center; }
  .billiards-stage, .billiards-controls { width: 100%; max-width: min(96vw, 680px); }
}
@media (max-width: 980px) {
  body { padding: 10px; align-items: flex-start; }
  .app-layout { grid-template-columns: 1fr; justify-items: center; gap: 16px; }
  .lobby-cards-grid { grid-template-columns: 1fr; max-width: min(95vw, 560px); }
  .player-topbar, .control-panel, .stage-topbar { max-width: min(95vw, 560px); width: 100%; }
  #gomokuCanvas { width: min(90vw, 540px); height: min(90vw, 540px); }
}
@media (max-width: 560px) {
  .segmented-control.four-cols { grid-template-columns: 1fr 1fr; gap: 6px; }
  .seg-btn { padding: 9px 8px; font-size: 0.84rem; }
  .lb-table-head, .lb-rank-row { grid-template-columns: 36px 1.45fr 0.65fr 0.88fr 0.65fr 0.8fr; font-size: 0.72rem; padding: 7px 8px; }
  .b-lb-head-winrate, .b-lb-row-winrate { grid-template-columns: 34px 1.45fr 0.55fr 0.6fr 0.75fr; }
  .b-lb-head-solo, .b-lb-row-solo { grid-template-columns: 34px 1.35fr 0.88fr 0.65fr 0.52fr; }
  .billiards-racks-bar { grid-template-columns: 1fr; }
  .billiards-table-frame { padding: 6px; border-radius: 14px; }
  .billiards-bih-banner { font-size: 0.72rem; padding: 5px 10px; }
  .region-tag { font-size: 0.66rem; padding: 1px 4px; }
  .auth-card { padding: 22px 18px; }
}
