/* ============================================================
   主题：暗色（默认）
   通过 [data-theme="light"] 切换为亮色
   ============================================================ */
:root,
[data-theme="dark"] {
  /* 背景层级 */
  --bg-body: #0f1115;
  --bg-page: #14161c;
  --bg-panel: rgba(28, 31, 40, 0.85);
  --bg-panel-solid: #1c1f28;
  --bg-elevated: #252a36;
  --bg-elevated-hover: #2f3441;
  --bg-input: #1a1d25;

  /* 文字 */
  --fg: #f0f2f5;
  --fg-muted: #a7adb8;
  --fg-dim: #6e7681;

  /* 强调色 */
  --accent: #4d9eff;
  --accent-glow: rgba(77, 158, 255, 0.35);
  --accent-2: #ffb84d;
  --accent-2-glow: rgba(255, 184, 77, 0.35);
  --danger: #ff5a5a;
  --danger-glow: rgba(255, 90, 90, 0.35);
  --success: #3ddc84;
  --success-glow: rgba(61, 220, 132, 0.35);
  --warning: #ffcc4d;

  /* 边框与阴影 */
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.45);
  --shadow-glow-accent: 0 0 24px var(--accent-glow);
  --shadow-glow-success: 0 0 24px var(--success-glow);

  /* 背景光晕 / 遮罩 / 特殊背景 */
  --body-glow-1: rgba(77, 158, 255, 0.06);
  --body-glow-2: rgba(255, 184, 77, 0.05);
  --modal-overlay-bg: rgba(0, 0, 0, 0.7);
  --hand-selected-bg: linear-gradient(145deg, #4a3b1f, #2f2614);
  --neutral-tile-bg: linear-gradient(135deg, #d0d0d0, #a8a8a8);
  --neutral-tile-fg: #333;
  --tile-text: rgba(0, 0, 0, 0.65);
  --cell-id-color: rgba(0, 0, 0, 0.75);

  /* 圆角 */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* 间距 */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;

  /* 字体 */
  --font-base: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  /* 过渡 */
  --transition-fast: 120ms ease;
  --transition-base: 180ms ease;

  /* 移动端外壳度量（由 ui.js 实测后同步；桌面不引用，保持默认值不影响布局）
     --board-avail-h 给一个兜底值，避免 JS 未执行时棋盘塌陷 */
  --topbar-h: 0px;
  --dock-h: 0px;
  --board-avail-h: 560px;
}

/* ============================================================
   主题：亮色
   ============================================================ */
[data-theme="light"] {
  --bg-body: #f4f6fa;
  --bg-page: #ffffff;
  --bg-panel: rgba(255, 255, 255, 0.82);
  --bg-panel-solid: #ffffff;
  --bg-elevated: #eef1f6;
  --bg-elevated-hover: #e2e6ee;
  --bg-input: #f0f2f7;

  --fg: #1a1d24;
  --fg-muted: #5a6271;
  --fg-dim: #9aa1ad;

  --accent: #2b7de9;
  --accent-glow: rgba(43, 125, 233, 0.28);
  --accent-2: #d98800;
  --accent-2-glow: rgba(217, 136, 0, 0.28);
  --danger: #e23b3b;
  --danger-glow: rgba(226, 59, 59, 0.28);
  --success: #1ba665;
  --success-glow: rgba(27, 166, 101, 0.28);
  --warning: #c98a00;

  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.14);
  --shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.12);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.16);
  --shadow-glow-accent: 0 0 24px var(--accent-glow);
  --shadow-glow-success: 0 0 24px var(--success-glow);

  --body-glow-1: rgba(43, 125, 233, 0.08);
  --body-glow-2: rgba(217, 136, 0, 0.06);
  --modal-overlay-bg: rgba(15, 23, 42, 0.45);
  --hand-selected-bg: linear-gradient(145deg, #f5d488, #e6a23d);
  --neutral-tile-bg: linear-gradient(135deg, #d8dce3, #b8bdc7);
  --neutral-tile-fg: #2c313a;
  --tile-text: rgba(0, 0, 0, 0.7);
  --cell-id-color: rgba(0, 0, 0, 0.78);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-base);
  background:
    radial-gradient(circle at 10% 20%, var(--body-glow-1) 0%, transparent 25%),
    radial-gradient(circle at 90% 80%, var(--body-glow-2) 0%, transparent 25%),
    var(--bg-body);
  color: var(--fg);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  /* 与 #app 保持一致：iOS Safari 的 100vh 含地址栏，会多出一段不可见高度 */
  min-height: 100dvh;
  padding: var(--space-lg);
  transition: background var(--transition-base), color var(--transition-base);
}

#app {
  max-width: 1440px;
  margin: 0 auto;
}

h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
h1 span {
  color: var(--accent);
  font-weight: 500;
  font-size: 15px;
  margin-left: 6px;
  opacity: 0.9;
}

h2 {
  font-size: 11px;
  font-weight: 700;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  gap: 6px;
}
h2 .icon {
  width: 14px;
  height: 14px;
}

/* ============================================================
   顶栏
   ============================================================ */
#topbar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}

.topbar-logo {
  height: 36px;
  width: auto;
  border-radius: var(--radius-md);
  object-fit: cover;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

#status {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

#status .status-player { color: var(--accent); }

#status .phase-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--accent), #357abd);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 8px var(--accent-glow);
}

#top-actions { display: flex; gap: var(--space-sm); }

/* ============================================================
   布局
   ============================================================ */
#layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

@media (max-width: 1040px) {
  #layout { grid-template-columns: 1fr; }
}

/* ============================================================
   面板
   ============================================================ */
.panel {
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
}

#sidebar { display: flex; flex-direction: column; gap: var(--space-md); }
#bottom-bar { display: flex; flex-direction: column; gap: var(--space-md); }

/* 可折叠面板：h2 可点击，带箭头指示器（仅移动端默认折叠，桌面保持展开） */
@media (max-width: 768px), (pointer: coarse) and (orientation: landscape) and (max-height: 620px) {
  .panel.collapsible > h2 { cursor: pointer; user-select: none; }
  .panel.collapsible > h2::after {
    content: '▾';
    margin-left: auto;
    color: var(--fg-dim);
    font-size: 12px;
    transition: transform var(--transition-fast);
    display: inline-block;
  }
  .panel.collapsible.expanded > h2::after { transform: rotate(180deg); }
}

/* ============================================================
   棋盘
   ============================================================ */
#board-wrap {
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  overflow: auto;
  box-shadow: var(--shadow-md);
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

#board {
  display: grid;
  grid-template-columns: 26px repeat(9, 1fr);
  grid-template-rows: 26px repeat(12, 1fr);
  gap: 4px;
  aspect-ratio: 9 / 12;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
}

/* 桌面宽屏：固定高度分区布局，侧栏独立滚动 */
@media (min-width: 1041px) {
  #layout {
    height: calc(100vh - 240px);
    min-height: 520px;
    overflow: hidden;
  }
  #sidebar {
    overflow-y: auto;
    padding-right: 4px;
  }
}

/* 横版棋盘（12列×9行）：桌面宽屏与横屏手机共用，类名由 JS 的 matchMedia 决定。
   刻意不包在媒体查询里——两种触发条件（宽屏 / 横屏矮屏）用同一组样式，
   且 #board.board-landscape 的特异性高于窄屏块里的 #board，可直接覆盖竖版网格。 */
#board.board-landscape {
  grid-template-columns: 26px repeat(12, 1fr);
  grid-template-rows: 26px repeat(9, 1fr);
  aspect-ratio: 12 / 9;
  max-width: 100%;
  gap: 5px;
}
#board.board-landscape .cell.tile { font-size: 11px; }
#board.board-landscape .cell .cell-id { font-size: 9px; }
#board.board-landscape .cell .cell-logo { max-width: 56px; max-height: 56px; }

.cell {
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--fg-dim);
  min-height: 0;
  min-width: 0;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
  border: 1px solid rgba(255, 255, 255, 0.03);
  position: relative;
}

.cell.label {
  background: transparent;
  font-weight: 700;
  color: var(--fg-muted);
  border: none;
}

.cell.tile {
  color: var(--tile-text);
  font-weight: 800;
  font-size: 9px;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), var(--shadow-sm);
  border: none;
}

.cell.tile.neutral {
  background: var(--neutral-tile-bg);
  color: var(--neutral-tile-fg);
}

.cell.tile.last {
  outline: 2px solid var(--accent-2);
  outline-offset: -2px;
  box-shadow: 0 0 16px var(--accent-2-glow), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  z-index: 2;
}

.cell.empty { background: var(--bg-input); }

.cell.playable {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
}
.cell.playable.interactable {
  cursor: pointer;
  animation: playablePulse 2.2s ease-in-out infinite;
}
@keyframes playablePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(77, 158, 255, 0); }
  50% { box-shadow: 0 0 12px 2px var(--accent-glow); }
}
.cell.playable.interactable:hover {
  animation: none;
  transform: scale(1.1);
  box-shadow: var(--shadow-md);
  z-index: 3;
}
.cell.playable.selected {
  background: linear-gradient(135deg, var(--accent-2), #e6a23d);
  color: #000;
  transform: scale(1.14);
  box-shadow: 0 0 20px var(--accent-2-glow);
  z-index: 4;
}

.cell.dead {
  opacity: 0.35;
  text-decoration: line-through;
  background: repeating-linear-gradient(45deg, var(--bg-input), var(--bg-input) 4px, var(--bg-elevated) 4px, var(--bg-elevated) 8px);
}

/* ============================================================
   连锁列表
   ============================================================ */
#chains { display: flex; flex-direction: column; gap: var(--space-sm); }

.chain-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.chain-row:hover { background: var(--bg-elevated); border-color: var(--border-strong); }
.chain-row.unfounded { opacity: 0.55; }

.chain-main { flex: 1; min-width: 0; }

.chain-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 13px;
}

/* 档位徽章：低/中/高 */
.tier-badge {
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 800;
  line-height: 1.5;
  flex-shrink: 0;
}
.tier-0 { background: var(--accent-glow); color: var(--accent); }
.tier-1 { background: var(--accent-2-glow); color: var(--accent-2); }
.tier-2 { background: var(--danger-glow); color: var(--danger); }

/* 规模进度条：0-41 格，11 格处为安全刻度 */
.chain-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 5px;
}
.chain-progress {
  position: relative;
  flex: 1;
  height: 5px;
  background: var(--bg-elevated);
  border-radius: 3px;
}
.chain-progress > i {
  display: block;
  height: 100%;
  border-radius: 3px;
  transition: width var(--transition-base);
}
.chain-progress::after {
  content: '';
  position: absolute;
  left: 26.8%; /* 11/41 安全链刻度 */
  top: -1px;
  bottom: -1px;
  width: 2px;
  border-radius: 1px;
  background: var(--fg-dim);
  opacity: 0.55;
}
.chain-size-text {
  font-size: 11px;
  color: var(--fg-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.chain-row.unfounded .chain-size-text { color: var(--fg-dim); }

/* 亮色主题下增强公司规模进度条可见性：加深填充色、给轨道加边框、安全刻度线更明显 */
[data-theme="light"] .chain-progress {
  box-shadow: inset 0 0 0 1px var(--border-strong);
}
[data-theme="light"] .chain-progress > i {
  filter: brightness(0.82) saturate(1.2);
}
[data-theme="light"] .chain-progress::after {
  background: var(--fg-muted);
  opacity: 0.75;
}

.chain-price {
  color: var(--accent-2);
  font-weight: 800;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  flex-shrink: 0;
}
.chain-price .price-sub {
  display: block;
  font-size: 10px;
  color: var(--fg-dim);
  font-weight: 600;
}

.chain-safe-icon {
  width: 13px;
  height: 13px;
  color: var(--success);
  flex-shrink: 0;
}

/* ============================================================
   玩家列表
   ============================================================ */
#players { display: flex; flex-direction: column; gap: var(--space-sm); }

.player-row {
  padding: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  border-left: 3px solid transparent;
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}
.player-row:hover { transform: translateX(2px); }
.player-row.current {
  border-left-color: var(--accent);
  background: linear-gradient(90deg, rgba(77, 158, 255, 0.12), var(--bg-input));
  animation: currentGlow 2.4s ease-in-out infinite;
}
@keyframes currentGlow {
  0%, 100% { box-shadow: 0 0 8px var(--accent-glow); }
  50% { box-shadow: 0 0 20px var(--accent-glow); }
}
.player-row.you { border-left-color: var(--success); }

/* 联机：已掉线的真人玩家 */
.player-row.offline {
  border-left-color: var(--danger);
  opacity: 0.62;
}
.player-row.offline .player-name { text-decoration: line-through; text-decoration-color: var(--danger); }
.player-offline {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 6px;
  margin-left: 5px;
  background: var(--danger-glow);
  color: var(--danger);
  font-weight: 700;
  text-transform: none;
}

.player-name {
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.player-name .identity {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.player-name .identity-icon {
  width: 14px;
  height: 14px;
}
.player-name .identity-icon.human { color: var(--accent); }
.player-name .identity-icon.ai { color: var(--fg-dim); }

.you-badge {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 6px;
  background: var(--success-glow);
  color: var(--success);
  font-weight: 800;
  letter-spacing: 0.5px;
}
.ai-badge {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 6px;
  background: var(--accent-2-glow);
  color: var(--fg-dim);
  font-weight: 700;
  letter-spacing: 0.5px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.ai-badge svg { width: 11px; height: 11px; }

.player-cash { color: var(--success); font-weight: 800; font-variant-numeric: tabular-nums; }

/* 净资产估算（现金 + 持股现值） */
.player-worth {
  font-size: 11px;
  color: var(--fg-dim);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}
.player-worth b { color: var(--fg-muted); font-weight: 700; }

.player-shares {
  font-size: 11px;
  color: var(--fg-muted);
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.share-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px 2px 2px;
  border-radius: 10px;
  font-weight: 700;
  color: var(--fg);
  font-size: 10px;
  border: 1px solid transparent;
}
.share-chip .chip-logo { width: 14px; height: 14px; }
.share-chip .chip-logo .logo-text { font-size: 8px; }

/* 亮色主题下持股徽章底色偏浅，叠加 subtle 暗层提升可见性 */
[data-theme="light"] .share-chip {
  box-shadow: inset 0 0 0 100px rgba(0, 0, 0, 0.08);
}

/* ============================================================
   手牌
   ============================================================ */
#hand { display: flex; flex-wrap: wrap; gap: var(--space-sm); }

.hand-tile {
  width: 52px;
  height: 52px;
  background: linear-gradient(145deg, var(--bg-elevated), var(--bg-input));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  color: var(--fg);
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
  position: relative;
}
.hand-tile::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 50%);
  pointer-events: none;
}
.hand-tile:hover {
  border-color: var(--accent);
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 6px 16px var(--accent-glow);
}
.hand-tile.dead {
  opacity: 0.4;
  cursor: not-allowed;
  text-decoration: line-through;
  background: var(--bg-input);
  box-shadow: none;
}
.hand-tile.dead:hover { transform: none; box-shadow: none; border-color: var(--border); }
.hand-tile.selected {
  border-color: var(--accent-2);
  background: var(--hand-selected-bg);
  box-shadow: 0 0 18px var(--accent-2-glow);
  transform: translateY(-4px);
}

/* 键盘焦点可见性（无障碍） */
button:focus-visible,
.hand-tile:focus-visible,
.cell.playable:focus-visible,
.chain-btn:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:focus:not(:focus-visible),
.hand-tile:focus:not(:focus-visible),
.chain-btn:focus:not(:focus-visible) { outline: none; }

/* ============================================================
   操作区
   ============================================================ */
#actions { display: flex; flex-direction: column; gap: var(--space-sm); }

.action-hint {
  color: var(--fg-muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.action-hint .icon {
  width: 14px;
  height: 14px;
  color: var(--accent);
  flex-shrink: 0;
}

/* 顶栏主题切换按钮：根据当前主题显示对应图标 */
#theme-toggle { padding: 8px 10px; flex-shrink: 0; }
#theme-toggle .icon { width: 16px; height: 16px; }
#theme-toggle .icon-moon { display: none; }
[data-theme="light"] #theme-toggle .icon-sun { display: none; }
[data-theme="light"] #theme-toggle .icon-moon { display: inline-block; }

/* ============================================================
   按钮
   ============================================================ */
button {
  background: linear-gradient(135deg, var(--accent), #357abd);
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: filter var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
  font-family: inherit;
  box-shadow: 0 3px 10px var(--accent-glow);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
button:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 5px 14px var(--accent-glow);
}
button:active { transform: scale(0.97); }
button:disabled {
  background: var(--bg-elevated);
  color: var(--fg-dim);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}
button:disabled:hover { filter: none; transform: none; box-shadow: none; }

button .icon {
  width: 14px;
  height: 14px;
}

button.secondary {
  background: var(--bg-elevated);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
}
button.secondary:hover {
  background: var(--bg-elevated-hover);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

button.danger { background: linear-gradient(135deg, var(--danger), #c44545); box-shadow: 0 3px 10px var(--danger-glow); }
button.danger:hover { box-shadow: 0 5px 14px var(--danger-glow); }

button.danger.pulse { animation: pulse-end 1.2s ease-in-out infinite; }
@keyframes pulse-end {
  0%, 100% { transform: scale(1); box-shadow: 0 3px 10px var(--danger-glow); }
  50% { transform: scale(1.06); box-shadow: 0 6px 20px var(--danger-glow); }
}

.end-hint { color: var(--danger); font-weight: 600; margin-left: 8px; font-size: 0.9em; }

/* 联机：对局中有玩家掉线的等待提示 */
.offline-hint {
  color: var(--warning);
  font-weight: 600;
  margin-left: 8px;
  font-size: 0.9em;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

button.success { background: linear-gradient(135deg, var(--success), #2ab06a); box-shadow: 0 3px 10px var(--success-glow); color: #062d1a; }
button.success:hover { box-shadow: 0 5px 14px var(--success-glow); }

.btn-row { display: flex; gap: var(--space-sm); flex-wrap: wrap; }

.qty-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: var(--radius-sm);
}

/* ============================================================
   买股控件
   ============================================================ */
.buy-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: var(--space-sm);
  align-items: center;
  padding: 5px 0;
  font-size: 13px;
}
.buy-row .qty {
  width: 32px;
  text-align: center;
  font-weight: 800;
  color: var(--accent-2);
  font-variant-numeric: tabular-nums;
}
.buy-total {
  font-weight: 800;
  color: var(--success);
  margin-top: 4px;
  padding: 8px 10px;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ============================================================
   日志
   ============================================================ */
#log-panel {
  max-height: 180px;
  overflow-y: auto;
  padding: var(--space-md);
}
#log {
  font-size: 12px;
  color: var(--fg-muted);
  display: flex;
  flex-direction: column-reverse;
  gap: 4px;
}
#log div {
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border-left: 2px solid transparent;
}
#log div.highlight {
  color: var(--accent-2);
  background: rgba(255, 184, 77, 0.08);
  border-left-color: var(--accent-2);
}
#log div.system {
  color: var(--fg-dim);
  background: transparent;
  padding-left: 8px;
}
/* 日志分类：成立 / 吞并 / 奖金 / 买股 / 终局 */
#log div.found { border-left-color: var(--accent); color: var(--accent); }
#log div.merge { border-left-color: var(--accent-2); color: var(--accent-2); }
#log div.bonus {
  border-left-color: var(--accent-2);
  color: var(--accent-2);
  background: rgba(255, 184, 77, 0.08);
  font-weight: 700;
}
#log div.buy { border-left-color: var(--success); color: var(--success); }
#log div.end {
  border-left-color: var(--danger);
  color: var(--danger);
  font-weight: 700;
  background: rgba(255, 90, 90, 0.08);
}

/* ============================================================
   弹窗
   ============================================================ */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--modal-overlay-bg);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: var(--space-lg);
  opacity: 1;
  transition: opacity var(--transition-base);
}
#modal-overlay.hidden { opacity: 0; pointer-events: none; }

/* 关闭按钮容器：零高度 + 粘顶。#modal 自身是滚动区，直接 absolute 的关闭按钮
   会跟着内容滚走，长弹窗（更新日志 1500px）就只能滚到末尾才能关 */
#modal .modal-close-bar {
  position: sticky;
  top: 0;
  height: 0;
  z-index: 12;
}

#modal {
  position: relative;
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(0);
  transition: transform var(--transition-base);
}
#modal-overlay.hidden #modal { transform: translateY(16px); }

#modal .modal-close {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--fg-muted);
  cursor: pointer;
  z-index: 10;
  box-shadow: none;
  transition: background var(--transition-base), color var(--transition-base);
}
#modal .modal-close:hover {
  background: var(--bg-elevated);
  color: var(--fg);
  filter: none;
  transform: none;
  box-shadow: none;
}
#modal .modal-close .icon {
  width: 18px;
  height: 18px;
}

#modal h3 {
  margin-bottom: var(--space-md);
  font-size: 18px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}
#modal h3 .icon {
  width: 22px;
  height: 22px;
  color: var(--accent-2);
}
#modal p { color: var(--fg-muted); margin-bottom: var(--space-md); font-size: 13px; line-height: 1.6; }
#modal .modal-cover {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-md);
  box-shadow: var(--shadow-sm);
}
#modal .modal-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
  margin-top: var(--space-lg);
  flex-wrap: wrap;
}

.chain-btn {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  text-align: left;
  padding: 12px;
  margin-bottom: var(--space-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--fg);
  font-size: 14px;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}
.chain-btn:hover {
  background: var(--bg-elevated);
  border-color: var(--accent);
  transform: translateX(3px);
}
.chain-btn .swatch {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 2px 4px rgba(0, 0, 0, 0.25);
}
.chain-btn .info {
  color: var(--fg-muted);
  font-size: 12px;
  margin-left: auto;
  font-weight: 500;
}

.disp-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: var(--space-sm);
  align-items: center;
  margin-bottom: var(--space-sm);
  padding: 8px 10px;
  background: var(--bg-input);
  border-radius: var(--radius-md);
}
.disp-row label { font-size: 13px; color: var(--fg); }
.disp-row .val {
  width: 40px;
  text-align: center;
  font-weight: 800;
  color: var(--accent-2);
  font-variant-numeric: tabular-nums;
}
.disp-hint {
  font-size: 12px;
  color: var(--fg-muted);
  margin: var(--space-sm) 0;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* 游戏结束 */
.end-ranking { list-style: none; margin: var(--space-md) 0; }
.end-ranking li {
  padding: 12px;
  margin-bottom: var(--space-sm);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  border: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15px;
  font-weight: 600;
}
.end-ranking li.first {
  background: linear-gradient(90deg, rgba(255, 184, 77, 0.18), var(--bg-input));
  border-left: 4px solid var(--accent-2);
  box-shadow: 0 0 16px var(--accent-2-glow);
}
.end-ranking li .rank { color: var(--fg-muted); font-weight: 700; }
.end-ranking li .amount { color: var(--success); font-weight: 800; }

/* 全服排行榜 */
.end-ranking.lb-list li { flex-wrap: wrap; gap: 4px; }
.end-ranking li.you {
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-2-glow);
}
.lb-meta { font-size: 11px; color: var(--fg-dim); font-weight: 400; }

/* ============================================================
   滚动条
   ============================================================ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--fg-dim); }

/* ============================================================
   动画
   ============================================================ */
@keyframes popIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

#modal { animation: popIn 220ms ease; }

/* ============================================================
   移动端优化（窄竖屏 / 横屏矮触屏）
   - 整体改为纵向 flex，棋盘按可用高度缩放，首屏看得到全棋盘
   - 手牌 + 操作固定底部（fixed + 占位），不遮挡棋盘与折叠面板入口
   - 连锁 / 玩家 / 日志面板默认折叠，点击 h2 展开
   - 触摸目标放大，字号适配，弹窗近全屏
   断点除宽度外还纳入「横屏 + 触屏 + 高度很矮」：横屏手机宽度上像平板，
   但落到桌面布局会变成多屏滚动且没有 sticky 底栏，体验更差。
   ============================================================ */
@media (max-width: 768px), (pointer: coarse) and (orientation: landscape) and (max-height: 620px) {
  /* 取消桌面外边距，让 app 撑满 */
  body { padding: 0; font-size: 14px; }
  #app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    max-width: 100%;
    /* 给 fixed 底栏留出等高占位，滚到底时最后一个面板才不会被盖住 */
    padding-bottom: var(--dock-h);
  }

  /* ---- 顶栏：两行（标题+主题 / 按钮+阶段）+ sticky + 安全区适配 ---- */
  #topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
    padding: 6px var(--space-md);
    padding-top: calc(6px + env(safe-area-inset-top));
    flex-wrap: wrap;
    row-gap: 4px;
    column-gap: var(--space-sm);
    box-shadow: var(--shadow-sm);
  }
  .topbar-logo { height: 26px; order: 1; }
  h1 { font-size: 15px; order: 2; flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  h1 span { display: none; }
  #theme-toggle { order: 3; margin-left: auto; padding: 6px 9px; min-height: 30px; }
  #theme-toggle .icon { width: 15px; height: 15px; }
  /* 次要入口收成图标，省下的横向空间让「阶段」与按钮同行显示 */
  #top-actions { order: 4; flex: 0 1 auto; min-width: 0; gap: 6px; }
  #top-actions button { padding: 6px 10px; font-size: 12px; min-height: 32px; }
  #top-actions button.icon-only { padding: 6px 9px; }
  #top-actions button.icon-only .btn-label { display: none; }
  #top-actions button.icon-only .icon { width: 17px; height: 17px; }
  #status { font-size: 12px; min-width: 0; flex: 1 1 auto; order: 5; justify-content: flex-end; text-align: right; }
  #status .phase-tag { font-size: 10px; padding: 2px 8px; }

  /* ---- 布局：拍平 layout 与 sidebar，统一在 #app 内排序 ---- */
  #layout {
    display: contents;
    margin-bottom: 0;
  }
  #sidebar { display: contents; }

  /* 子项排序 */
  #board-wrap { order: 1; }
  #chains-panel { order: 2; }
  #players-panel { order: 3; }
  #log-panel { order: 4; }

  /* ---- 棋盘：按「视口 - 顶栏 - 底栏 - 折叠面板」的可用高度缩放 ---- */
  #board-wrap {
    flex: 1 1 auto;
    min-height: 0;
    padding: var(--space-sm);
    border-radius: 0;
    border-left: none;
    border-right: none;
    overflow: auto;
    box-shadow: none;
    align-items: center;
  }
  #board {
    grid-template-columns: 16px repeat(9, 1fr);
    grid-template-rows: 16px repeat(12, 1fr);
    gap: 2px;
    max-width: 100%;
    /* 高度优先：可用高度反推宽度（竖版 9:12），宽度不足时仍占满一行；
       320px 下限保证格子不至于不可读，超出部分交给 #board-wrap 滚动兜底 */
    width: min(100%, max(320px, calc(var(--board-avail-h) * 0.75)));
  }
  #board.board-landscape {
    gap: 2px;
    width: min(100%, max(320px, calc(var(--board-avail-h) * 1.3333)));
  }
  #board.board-landscape .cell .cell-logo { max-width: 24px; max-height: 24px; }
  .cell { border-radius: 4px; }
  /* 地块字号：屏幕小不等于可以读不清，比桌面只降一档（配合已恢复的双指缩放） */
  .cell.tile { font-size: 9px; }
  .cell .cell-id { font-size: 8px; bottom: 0; right: 1px; }
  .cell .cell-logo { max-width: 24px; max-height: 24px; width: 80%; height: 80%; }
  .cell .cell-logo .logo-text { font-size: 9px; }
  .cell.playable.interactable:active { transform: scale(0.96); } /* 触摸反馈替代 hover */

  /* ---- 可折叠信息面板：默认折叠，点击展开 ---- */
  #chains-panel, #players-panel, #log-panel {
    padding: var(--space-xs) var(--space-md);
    border-radius: 0;
    border-left: none;
    border-right: none;
    box-shadow: none;
    background: var(--bg-panel-solid);
  }
  #log-panel { border-top: 1px solid var(--border); }
  /* 默认（未 .expanded）隐藏内容容器；用 ID 提升特异性以覆盖 #chains/#players/#log 的 display:flex */
  .panel.collapsible:not(.expanded) > #chains,
  .panel.collapsible:not(.expanded) > #players,
  .panel.collapsible:not(.expanded) > #log { display: none; }
  /* 日志要限高：展开后整块面板会跟随日志条数无限长（JS 保留最近 30 条 ≈ 1000px），
     必须限高内部滚动；h2 粘顶保证收起入口始终可达 */
  #log-panel.expanded {
    max-height: 42vh;
    max-height: 42dvh;
    overflow-y: auto;
  }
  #log-panel.expanded > h2 {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bg-panel-solid);
  }
  .panel.collapsible.expanded #chains,
  .panel.collapsible.expanded #players { padding: var(--space-xs) 0 var(--space-sm); }
  .panel.collapsible > h2 { margin-bottom: 0; padding: var(--space-xs) 0; }
  .panel.collapsible.expanded > h2 { margin-bottom: var(--space-sm); }

  /* ---- 底部手牌 + 操作栏：fixed 不遮挡内容（占位由 #app padding-bottom 提供） ---- */
  #bottom-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 25;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    background: var(--bg-panel-solid);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-strong);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.25);
    padding: var(--space-sm) var(--space-md);
    padding-bottom: calc(var(--space-sm) + env(safe-area-inset-bottom));
  }
  #hand-panel, #action-panel {
    padding: 0;
    border: none;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
  }
  #hand-panel > h2, #action-panel > h2 { margin-bottom: var(--space-xs); font-size: 10px; }
  /* 买股面板上限就是底栏上限：38vh 会把棋盘下半部分顶掉，降到 28vh 并靠内部滚动兜底 */
  #action-panel { max-height: 28vh; max-height: 28dvh; overflow-y: auto; }

  /* ---- 手牌：横向滚动，拇指可滑 ---- */
  #hand {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 4px;
    gap: var(--space-sm);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  .hand-tile {
    width: 48px;
    height: 48px;
    font-size: 14px;
    flex-shrink: 0;
  }
  .hand-tile:active { transform: scale(0.95); }

  /* ---- 按钮：放大触摸目标 ---- */
  button { padding: 11px 18px; font-size: 14px; min-height: 40px; }
  button .icon { width: 15px; height: 15px; }
  .btn-row { gap: var(--space-sm); }
  .btn-row button { flex: 1; }
  .chain-btn { padding: 12px; min-height: 48px; }
  .chain-btn .btn-logo { width: 26px; height: 26px; }
  /* 数量加减、关闭、开关都是最小可点区域不达标的重灾区 */
  .qty-btn { width: 44px; height: 44px; min-height: 44px; }
  #modal .modal-close { width: 44px; height: 44px; top: 2px; right: 2px; }
  #modal .modal-close .icon { width: 20px; height: 20px; }
  .setting-toggle { min-height: 40px; }
  /* 带 #actions：后面的基础规则 .setting-toggle input 同特异度且源序在后会把它盖回 16px */
  #actions .setting-toggle input { width: 22px; height: 22px; }

  /* ---- 买股界面紧凑化（配合 #action-panel 限高） ---- */
  .buy-row { grid-template-columns: 1fr auto auto auto; gap: 6px; padding: 2px 0; }
  .buy-total { padding: 6px 10px; }
  .disp-row { padding: 8px 10px; }
  #actions .action-hint { font-size: 12px; }

  /* ---- 弹窗：近全屏 ---- */
  #modal-overlay { padding: var(--space-sm); }
  #modal {
    max-width: 100%;
    width: 100%;
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    padding: calc(var(--space-lg) + env(safe-area-inset-top)) var(--space-lg) calc(var(--space-lg) + env(safe-area-inset-bottom));
  }
  #modal h3 { font-size: 16px; }
  #modal .modal-actions { justify-content: stretch; }
  #modal .modal-actions button { flex: 1; min-height: 44px; }
  .end-ranking li { padding: 10px; font-size: 14px; }
  /* 16px 防 iOS 聚焦时自动放大页面；必须带 #modal 提升特异性，
     否则会被后面同特异度的基础规则 .lobby-row input[type="text"] 按源序覆盖回 15px */
  #modal .lobby-row input[type="text"] { font-size: 16px; padding: 12px 14px; }

  /* ---- 连锁列表紧凑化 ---- */
  .chain-row { padding: 7px 8px; font-size: 12px; gap: 6px; }
  .chain-logo { width: 18px; height: 18px; }
  .chain-title { font-size: 12px; }
  .chain-size-text { font-size: 10px; }
  .chain-price { font-size: 12px; }

  /* ---- 玩家列表紧凑化 ---- */
  .player-row { padding: 8px 10px; }
  .player-name { font-size: 13px; }
  .player-shares { font-size: 10px; gap: 3px; }
  .share-chip { padding: 2px 6px 2px 2px; font-size: 9px; }

  /* ---- 触屏没有真正的 hover：取消悬停位移，避免点完“粘”在悬停态 ---- */
  button:hover,
  button.secondary:hover,
  .chain-btn:hover,
  .player-row:hover,
  .chain-row:hover,
  .hand-tile:not(.selected):hover,
  .cell.playable.interactable:hover { transform: none; }
  /* 原本靠 hover 才暂停的呼吸动画，触屏上反而因“悬停”丢了提示，这里保持动画 */
  .cell.playable.interactable:hover { animation: playablePulse 2.2s ease-in-out infinite; }

  /* ---- 断线横幅：下移到 sticky 顶栏之下，不压住 logo 与标题 ---- */
  .net-banner { top: calc(var(--topbar-h) + 8px); }
}

/* 极窄屏（<380px）：进一步收紧 */
@media (max-width: 380px) {
  #board {
    grid-template-columns: 14px repeat(9, 1fr);
    grid-template-rows: 14px repeat(12, 1fr);
    gap: 1px;
  }
  /* 顶栏在这个宽度上“图标按钮 + 阶段”挤不进一行，会多出一行吃掉 34px；
     连“新游戏”也降为图标（带 title/aria-label），换回一行棋盘可见高度 */
  #top-actions button .btn-label { display: none; }
  #top-actions button { padding: 6px 9px; }
  #top-actions button .icon { width: 17px; height: 17px; }
  .hand-tile { width: 42px; height: 42px; font-size: 12px; }
  h1 { font-size: 14px; }
  #status { font-size: 11px; }
  .cell .cell-logo { max-width: 20px; max-height: 20px; }
  .cell .cell-id { font-size: 7px; }
}

/* ============================================================
   公司 logo（地块 / 连锁列表 / 弹窗 / 买股行通用）
   - PNG 为 128x128 自包含圆形图标（品牌色圆+白边+粗体白字）
   - 容器透明，让 PNG 自带的白边与彩色圆完整显示
   - 图片加载失败时 fallback 到 CSS 彩色圆+白色首字
   ============================================================ */
.logo {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  background: transparent;
  line-height: 1;
  vertical-align: middle;
}
.logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  image-rendering: -webkit-optimize-contrast;
  /* 确保在高DPI屏幕也清晰 */
  image-rendering: -moz-crisp-edges;
}
.logo .logo-text {
  display: none;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0,0,0.5);
}
/* 加载失败时：CSS 圆形品牌色背景+白字 */
.logo.logo-fallback { border-radius: 50%; }
.logo.logo-fallback img { display: none; }
.logo.logo-fallback .logo-text { display: inline-flex; align-items:center; justify-content:center; width:100%; height:100%; border-radius:50%; }

/* 棋盘格子上的 logo：占格子主体，tile id 缩到角落 */
.cell.tile { position: relative; display: flex; align-items: center; justify-content: center; }
.cell .cell-logo {
  width: 88%;
  height: 88%;
  max-width: 48px;
  max-height: 48px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}
.cell .cell-logo .logo-text { font-size: 14px; }
.cell .cell-id {
  position: absolute;
  bottom: 1px;
  right: 3px;
  font-size: 8px;
  font-weight: 700;
  color: rgba(0, 0, 0, 0.75);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
  line-height: 1;
  pointer-events: none;
  z-index: 2;
}

/* 连锁列表中的 logo */
.chain-logo {
  width: 24px;
  height: 24px;
}
.chain-logo .logo-text { font-size: 12px; }

/* 弹窗按钮 / 买股行中的 logo */
.btn-logo {
  width: 28px;
  height: 28px;
}
.btn-logo .logo-text { font-size: 14px; }

/* 弹窗按钮：logo + 名称垂直对齐 */
.chain-btn { align-items: center; gap: 10px; }
.chain-btn .btn-name { flex: 1; }
.buy-row .buy-name { display: inline-flex; align-items: center; gap: 6px; }

/* 小屏：缩小地块 logo */
@media (max-width: 720px) {
  .cell .cell-logo { max-width: 26px; max-height: 26px; width: 82%; height: 82%; }
  .cell .cell-logo .logo-text { font-size: 10px; }
  .cell .cell-id { font-size: 7px; }
  .chain-logo { width: 20px; height: 20px; }
  .btn-logo { width: 22px; height: 22px; }
}

/* ============================================================
   大厅 / 联机 UI
   ============================================================ */
.modal-section-title {
  margin: 14px 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.chain-btn.online-btn { border-style: dashed; }
.emoji-ic { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; font-size: 16px; }

/* 模式切换（经典 / 大亨） */
.mode-toggle { display: flex; gap: 6px; margin-bottom: 4px; }
.mode-btn {
  flex: 1; padding: 8px 12px; border: 1px solid var(--border-strong);
  border-radius: 8px; background: var(--bg-elevated); color: var(--fg-muted);
  font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.15s;
  font-family: inherit;
}
.mode-btn:hover { border-color: var(--accent); color: var(--fg); }
.mode-btn.active { border-color: var(--accent); background: var(--accent-glow); color: var(--accent); }
.mode-desc { font-size: 12px; color: var(--fg-dim); margin: 4px 0 8px; }

/* 设置开关（checkbox + 文字） */
.setting-toggle {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--fg-muted); cursor: pointer;
  padding: 8px 0;
}
.setting-toggle input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); }
.mode-tag {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  background: var(--accent-glow); color: var(--accent); font-size: 11px; font-weight: 600;
}

.lobby-row { margin-bottom: var(--space-md); }
.lobby-row input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--fg);
  font-size: 15px;
  font-family: inherit;
  box-sizing: border-box;
}
.lobby-row input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.btn-row-vertical { display: flex; flex-direction: column; gap: var(--space-sm); }
.btn-row-vertical .chain-btn { width: 100%; justify-content: flex-start; }

.seats-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--space-md);
}
.seat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.seat-row.you { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
.seat-row.offline { opacity: 0.5; }
.seat-name { font-weight: 600; color: var(--fg); }
.seat-tag { font-size: 12px; color: var(--fg-muted); }
.lobby-actions { margin-top: var(--space-sm); }
.lobby-actions button { width: 100%; margin-top: 6px; }
.lobby-actions .action-hint { display: block; text-align: center; color: var(--fg-dim); font-size: 12px; padding: 8px; }

.room-code {
  display: inline-block;
  padding: 2px 8px;
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  font-family: monospace;
  font-size: 16px;
  letter-spacing: 0.15em;
  user-select: all;
}

.btn-remove-ai { font-size: 12px !important; padding: 6px 10px !important; }

/* ============================================================
   股价参考表（顶栏弹窗）
   ============================================================ */
.price-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin: var(--space-sm) 0 var(--space-md);
}
.price-table th, .price-table td {
  padding: 6px 6px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.price-table th {
  color: var(--fg-muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.price-table td {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--fg-muted);
}
.price-table td.t0 { color: var(--accent); }
.price-table td.t1 { color: var(--accent-2); }
.price-table td.t2 { color: var(--danger); }
.price-table td.pt-size { color: var(--fg); font-weight: 800; }
.price-table tr.row-active { background: var(--bg-elevated); border-radius: 4px; }
.price-table tr.row-active td.pt-size { color: var(--accent-2); }
.price-note {
  font-size: 11px;
  color: var(--fg-dim);
  display: flex;
  align-items: center;
  gap: 5px;
  line-height: 1.6;
}
/* 股价表中的档位公司 logo（放在价格旁边，水平排列） */
.pt-cell-content { display: inline-flex; align-items: center; justify-content: center; gap: 4px; white-space: nowrap; }
.pt-tier-logos { display: inline-flex; gap: 2px; align-items: center; }
.price-table td .pt-logo { width: 14px; height: 14px; }
.pt-logo .logo-text { font-size: 8px; }

/* ============================================================
   更新日志（顶栏弹窗）
   ============================================================ */
.changelog-version { margin-bottom: var(--space-lg); }
.changelog-version:last-of-type { margin-bottom: var(--space-sm); }
.changelog-ver-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid var(--border);
}
.changelog-ver-tag {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent);
  font-family: var(--font-mono);
}
.changelog-ver-date {
  font-size: 12px;
  color: var(--fg-dim);
  font-variant-numeric: tabular-nums;
}
.changelog-list { list-style: none; display: flex; flex-direction: column; gap: var(--space-xs); }
.changelog-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  border-left: 3px solid transparent;
  font-size: 13px;
  line-height: 1.5;
}
.changelog-item-icon { flex-shrink: 0; margin-top: 1px; }
.changelog-item-icon .icon { width: 14px; height: 14px; display: inline-flex; }
.changelog-item-type {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 8px;
  line-height: 1.6;
  white-space: nowrap;
}
.changelog-item-text { color: var(--fg-muted); flex: 1; }
/* 类型色彩：修复=红 / 优化=蓝 / 新增=绿，与日志面板分类一致 */
.changelog-fix { border-left-color: var(--danger); }
.changelog-fix .changelog-item-icon { color: var(--danger); }
.changelog-fix .changelog-item-type { background: var(--danger-glow); color: var(--danger); }
.changelog-improve { border-left-color: var(--accent); }
.changelog-improve .changelog-item-icon { color: var(--accent); }
.changelog-improve .changelog-item-type { background: var(--accent-glow); color: var(--accent); }
.changelog-feature { border-left-color: var(--success); }
.changelog-feature .changelog-item-icon { color: var(--success); }
.changelog-feature .changelog-item-type { background: var(--success-glow); color: var(--success); }


/* ============================================================
   断线重连提示条（联机中网络状态展示）
   ============================================================ */
.net-banner {
  position: fixed;
  top: var(--space-md);
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  max-width: min(92vw, 480px);
  background: var(--bg-elevated);
  border: 1px solid var(--warning);
  border-radius: 999px;
  padding: 8px 16px;
  color: var(--fg);
  font-size: 13px;
  box-shadow: var(--shadow-md);
}

.net-banner.hidden { display: none; }

.net-banner-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.net-banner-retry {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 3px 12px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: none;
  transition: background var(--transition-base), border-color var(--transition-base);
}

.net-banner-retry:hover { background: var(--bg-elevated-hover); border-color: var(--accent); }

.net-banner-retry.hidden { display: none; }

/* ============================================================
   轻提示条（取代 alert）
   - 底部居中、挂在固定底栏上方（--dock-h 仅移动端非 0，桌面就是 16px 边距）
   - pointer-events 只给卡片本身，不阻塞棋盘点击；点卡片可提前收起
   ============================================================ */
#toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(var(--dock-h) + var(--space-lg) + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-xs);
  width: min(92vw, 420px);
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  color: var(--fg);
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
  animation: toastIn 180ms ease;
  transition: opacity 180ms ease, transform 180ms ease;
}
.toast .icon { width: 16px; height: 16px; flex-shrink: 0; color: var(--accent); }
.toast.error { border-color: var(--danger); }
.toast.error .icon { color: var(--danger); }
.toast.success { border-color: var(--success); }
.toast.success .icon { color: var(--success); }
.toast.hide { opacity: 0; transform: translateY(8px); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   降低动态效果偏好：关掉循环动画与弹窗入场，但保留可识别性
   （可落子格不能只靠呼吸动画提示，改成静态描边）
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  #modal,
  .toast,
  .cell.playable.interactable,
  .cell.playable.interactable:hover,
  button.danger.pulse { animation: none; }
  .cell.playable.interactable { box-shadow: 0 0 0 2px var(--accent); }
  * { transition-duration: 1ms !important; }
}

/* ============================================================
   站点页脚（SEO 友好的文字说明 + 内链）
   ============================================================ */
#site-footer {
  max-width: 1440px;
  margin: var(--space-md) auto 0;
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
  color: var(--fg-dim);
  font-size: 12px;
  line-height: 1.6;
}
#site-footer p { margin: 0; }
#site-footer a { color: var(--fg-muted); text-decoration: underline; }
#site-footer a:hover { color: var(--accent); }
