/* 麻将记账系统 - 移动端优先样式 */

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

:root {
  --primary: #d4380d;
  --primary-light: #ff7a45;
  --primary-dark: #a82d0a;
  --secondary: #1890ff;
  --success: #52c41a;
  --warning: #faad14;
  --danger: #ff4d4f;
  --bg: #f5f5f5;
  --card-bg: #fff;
  --text: #333;
  --text-secondary: #999;
  --border: #e8e8e8;
  --dealer-color: #d4380d;
  --seat-colors: #1890ff, #52c41a, #722ed1, #faad14;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
}

#app {
  min-height: 100vh;
  background: var(--bg);
}

.view {
  display: none;
  min-height: 100vh;
}

.view.active {
  display: block;
}

/* ========== Header ========== */
.header {
  background: var(--card-bg);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header.compact {
  padding: 10px 16px;
  justify-content: center;
  gap: 8px;
}

.header h2 {
  font-size: 18px;
  font-weight: 600;
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius);
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  touch-action: manipulation;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:active {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--card-bg);
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-warning {
  background: var(--warning);
  color: #fff;
}

.btn-outline {
  background: #fff;
  color: #666;
  border: 1px solid #d9d9d9;
}

.btn-outline:active {
  background: #f0f0f0;
  border-color: #bbb;
}

.btn-block {
  width: 100%;
}

.btn-large {
  padding: 16px 32px;
  font-size: 18px;
  border-radius: 16px;
}

.btn-sm {
  padding: 6px 16px;
  font-size: 14px;
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-sm.btn-active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-back {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--secondary);
  cursor: pointer;
  padding: 4px 0;
}

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}

/* ========== Content ========== */
.content {
  padding: 16px;
}

.section {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.section > label {
  display: block;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  font-weight: 500;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 12px;
}

/* ========== Home ========== */
.home-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 24px;
  text-align: center;
}

.app-title {
  font-size: 36px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
}

.app-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 40px;
}

.home-actions {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 280px;
}

.home-info {
  margin-top: 40px;
  color: var(--text-secondary);
  font-size: 13px;
}

/* ========== Preset List ========== */
.preset-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preset-card {
  padding: 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.2s;
}

.preset-card:hover { border-color: var(--secondary); }
.preset-card.selected {
  border-color: var(--primary);
  background: #fff7e6;
}

.preset-card .preset-name {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
}

.preset-card .preset-desc {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ========== Player Inputs ========== */
.player-inputs {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.player-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.player-input-row.highlight {
  background: #fff7e6;
  padding: 8px;
  border-radius: 10px;
  border: 2px dashed var(--dealer-color);
}

.player-input-row input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
}

.seat-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  flex-shrink: 0;
}

.seat-badge.dealer { background: var(--dealer-color); }
.seat-badge.seat-1 { background: #1890ff; }
.seat-badge.seat-2 { background: #52c41a; }
.seat-badge.seat-3 { background: #722ed1; }

/* ========== Room Code ========== */
.room-code-display {
  text-align: center;
  padding: 24px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}

.room-code-display > p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.room-code {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: 8px;
  color: var(--primary);
}

.input-room-code {
  width: 100%;
  padding: 14px;
  font-size: 24px;
  text-align: center;
  letter-spacing: 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-weight: 600;
}

/* ========== Player List (waiting) ========== */
.player-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  background: var(--bg);
}

.player-item .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.player-item .status-dot.ready { background: var(--success); }
.player-item .status-dot.waiting { background: var(--border); }

.player-item .player-name {
  flex: 1;
  font-size: 15px;
}

.player-item .player-status {
  font-size: 12px;
  color: var(--text-secondary);
}

.waiting-hint {
  text-align: center;
  color: var(--text-secondary);
  margin: 20px 0;
  font-size: 14px;
}

/* ========== Join ========== */
.join-players {
  margin-top: 16px;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.join-players > label {
  display: block;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.join-player-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px;
  margin-bottom: 6px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  font-size: 15px;
  cursor: pointer;
}

.join-player-btn:active {
  border-color: var(--primary);
  background: #fff7e6;
}

.join-player-btn.taken {
  opacity: 0.5;
  cursor: not-allowed;
}

.join-player-btn .seat-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ========== 我的状态（分数 + 庄家） ========== */
.my-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: linear-gradient(135deg, #f6f8fb 0%, #eef1f6 100%);
  border-bottom: 1px solid #e8e8e8;
}

.my-score-container {
  display: flex;
  flex-direction: column;
}

.my-label {
  font-size: 11px;
  color: #999;
  margin-bottom: 2px;
}

.my-score {
  font-size: 32px;
  font-weight: 800;
  color: #262626;
}

.my-score.positive { color: var(--success); }
.my-score.negative { color: var(--danger); }

.dealer-info {
  text-align: right;
  font-size: 13px;
  color: #666;
  background: #fff;
  border: 1px solid var(--dealer-color);
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 600;
  color: var(--dealer-color);
}

/* ========== 游戏内 Tab 切换 ========== */
.game-tabs {
  display: flex;
  background: var(--card-bg);
  border-bottom: 2px solid var(--border);
  margin: 0 16px;
}

.game-tab {
  flex: 1;
  padding: 10px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.game-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.game-tab-panel {
  display: none;
}

.game-tab-panel.active {
  display: block;
}

.game-tab-panel .dealer-section,
.game-tab-panel .ledger-section,
.game-tab-panel .rounds-section {
  padding-top: 0;
}

/* ========== 记账日志（完整对账信息） ========== */
.rounds-section {
  padding: 12px 16px 16px;
}

.rounds-section .section-title {
  font-size: 14px;
  font-weight: 700;
  color: #333;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* 全屏查看按钮 */
.btn-journal-full {
  font-size: 12px;
  font-weight: 500;
  color: #1890ff;
  background: #e6f7ff;
  border: 1px solid #91d5ff;
  border-radius: 6px;
  padding: 3px 10px;
  cursor: pointer;
}

.btn-journal-full:active {
  background: #bae7ff;
}

/* 全屏弹窗 */
.journal-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 100;
  background: #f5f5f5;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.journal-modal-hd {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 16px;
  background: #fff;
  border-bottom: 1px solid #e8e8e8;
  position: sticky;
  top: 0;
  z-index: 2;
}

.journal-modal-title {
  font-size: 17px;
  font-weight: 700;
  color: #333;
}

.journal-modal-close {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: none;
  background: #f5f5f5;
  border-radius: 50%;
  font-size: 16px;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.journal-modal-close:active {
  background: #e8e8e8;
}

.journal-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 24px;
  -webkit-overflow-scrolling: touch;
}

/* 每把卡片 */
.jrnl-round {
  margin-bottom: 10px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  overflow: hidden;
}

.jrnl-round.jrnl-round-curr {
  box-shadow: 0 0 0 1px #d4380d, 0 2px 6px rgba(212,56,13,0.15);
}

/* 把头 */
.jrnl-round-hd {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #fafbfc;
  flex-wrap: wrap;
}

.jrnl-round-curr .jrnl-round-hd {
  background: #fff7e6;
}

.jrnl-round-num {
  font-size: 14px;
  font-weight: 700;
  color: #333;
}

.jrnl-juquan {
  font-size: 11px;
  color: #999;
  background: #f5f5f5;
  padding: 1px 6px;
  border-radius: 8px;
}

.jrnl-round-dealer {
  font-size: 12px;
  color: #888;
  background: #f0f0f0;
  padding: 2px 10px;
  border-radius: 10px;
}

.jrnl-curr {
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: #d4380d;
  padding: 2px 7px;
  border-radius: 8px;
}

.jrnl-dealer-chg {
  font-size: 11px;
  color: #d48806;
  background: #fffbe6;
  border: 1px solid #ffe58f;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 4px;
}

/* 把体 */
.jrnl-round-body {
  border-top: 1px solid #f0f0f0;
}

/* 每把事件 */
.jrnl-event {
  padding: 10px 14px;
  border-bottom: 1px solid #f5f5f5;
}

.jrnl-event:last-child {
  border-bottom: none;
}

/* 事件顶行：把号 + 徽章 + 描述 + 时间 */
.jrnl-ev-top {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.jrnl-ba {
  font-size: 11px;
  color: #aaa;
  flex-shrink: 0;
}

.jrnl-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

.jrnl-badge.hu      { background: #fff1f0; color: #cf1322; }
.jrnl-badge.zi_mo   { background: #fff7e6; color: #d48806; }
.jrnl-badge.ming_gang { background: #e6f7ff; color: #096dd9; }
.jrnl-badge.an_gang { background: #f9f0ff; color: #531dab; }
.jrnl-badge.dian_pao { background: #f6ffed; color: #389e0d; }

.jrnl-desc {
  font-size: 13px;
  color: #333;
  font-weight: 500;
  flex: 1;
  min-width: 0;
}

.jrnl-time {
  font-size: 11px;
  color: #bbb;
  flex-shrink: 0;
  margin-left: auto;
}

/* 牌型信息 */
.jrnl-ev-pattern {
  font-size: 11px;
  color: #888;
  margin-top: 3px;
  padding-left: 2px;
}

/* 明细规则 */
.jrnl-ev-detail {
  font-size: 12px;
  color: #999;
  margin-top: 2px;
  padding-left: 2px;
}

/* 规则摘要 */
.jrnl-ev-rules {
  font-size: 12px;
  color: #888;
  margin-top: 3px;
  padding-left: 2px;
}

/* 计分步骤链 */
.jrnl-ev-steps {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  margin-top: 4px;
  padding-left: 2px;
}

.jrnl-step {
  display: inline-block;
  font-size: 11px;
  color: #666;
  background: #fafafa;
  border: 1px solid #e8e8e8;
  border-radius: 4px;
  padding: 1px 8px;
  line-height: 1.8;
  white-space: nowrap;
}

.jrnl-arr {
  font-size: 10px;
  color: #bbb;
  margin: 0 2px;
}

/* 时间 */
.jrnl-ev-time {
  font-size: 11px;
  color: #bbb;
  margin-top: 2px;
  padding-left: 2px;
}

/* 四人分数行 */
.jrnl-scores {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
  padding: 6px 8px;
  background: #fafafa;
  border-radius: 6px;
}

.jrnl-score-cell {
  font-size: 12px;
  white-space: nowrap;
}

.jrnl-score-cell b {
  font-weight: 600;
  color: #555;
}

.jrnl-plus {
  color: #cf1322;
  font-weight: 700;
}

.jrnl-minus {
  color: #389e0d;
  font-weight: 700;
}

.jrnl-zero {
  color: #bbb;
  font-weight: 500;
}

/* 累计行 */
.jrnl-running {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding: 2px 8px;
  font-size: 11px;
  color: #888;
}

.jrnl-running-label {
  color: #bbb;
  font-size: 10px;
  flex-shrink: 0;
  margin-right: 2px;
}

.jrnl-running .jrnl-plus,
.jrnl-running .jrnl-minus,
.jrnl-running .jrnl-zero {
  font-size: 11px;
}

/* 本把合计 */
.jrnl-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px 14px;
  border-top: 1px dashed #e8e8e8;
  background: #fafbfc;
}

.jrnl-sub-label {
  font-size: 12px;
  font-weight: 700;
  color: #666;
  flex-shrink: 0;
  margin-right: 4px;
}

.jrnl-sub .jrnl-score-cell {
  font-size: 12px;
  padding: 2px 6px;
  background: #fff;
  border-radius: 4px;
}

/* ========== Record Form ========== */
.dealer-section {
  padding: 0 16px;
  margin-bottom: 16px;
}

.record-form {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.form-row {
  margin-bottom: 12px;
}

.form-row > label {
  display: block;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  cursor: pointer;
  color: var(--text);
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.input-tile-point {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 18px;
  text-align: center;
}

.pattern-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pattern-tag {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  background: var(--card-bg);
  transition: all 0.2s;
}

.pattern-tag:active,
.pattern-tag.selected {
  background: var(--primary-light);
  color: #fff;
  border-color: var(--primary-light);
}

/* ========== 规则展示（只读） ========== */
.rule-display-section {
  background: #fafbfc;
  border-bottom: 1px solid #e8e8e8;
  padding: 0 16px;
}

.rule-display-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  cursor: pointer;
  user-select: none;
}

.rule-display-title {
  font-size: 12px;
  font-weight: 600;
  color: #888;
}

.rule-display-toggle {
  font-size: 11px;
  color: var(--secondary);
}

.rule-display-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding-bottom: 8px;
}

.rule-tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 11px;
  background: #e8e8e8;
  color: #555;
  white-space: nowrap;
}

.rule-display-body {
  padding-bottom: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
}

.rule-detail-row {
  display: flex;
  gap: 4px;
  font-size: 12px;
  padding: 2px 0;
}

.rule-detail-label {
  color: #999;
  flex-shrink: 0;
}

.rule-detail-val {
  color: #444;
  font-weight: 500;
}

/* ========== 自定义参数面板 ========== */
.custom-params-header {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.custom-params-title {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

.custom-params-hint {
  font-size: 12px;
  color: var(--primary);
  font-weight: 500;
  flex: 1;
}

.toggle-arrow {
  font-size: 12px;
  color: var(--secondary);
  flex-shrink: 0;
}

.custom-params-body {
  margin-top: 12px;
}

.param-section {
  margin-bottom: 12px;
}

.param-cat-title {
  font-size: 12px;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid #f0f0f0;
}

.param-sub-title {
  font-size: 12px;
  font-weight: 600;
  color: #999;
  margin: 8px 0 6px;
}

.param-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.param-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  background: #fafafa;
  border-radius: 6px;
  min-height: 36px;
}

.param-row-wide {
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}

.param-label {
  font-size: 13px;
  color: #555;
  flex-shrink: 0;
  margin-right: 8px;
}

.param-input {
  width: 70px;
  padding: 4px 8px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  font-size: 13px;
  text-align: center;
  background: #fff;
}

.param-input:focus {
  border-color: var(--secondary);
  outline: none;
  box-shadow: 0 0 0 2px rgba(24,144,255,0.1);
}

.param-select {
  padding: 4px 8px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  font-size: 13px;
  background: #fff;
  min-width: 100px;
}

/* Toggle Switch */
.param-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.param-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #ccc;
  border-radius: 24px;
  transition: 0.2s;
}

.switch-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}

.param-switch input:checked + .switch-slider {
  background: var(--primary);
}

.param-switch input:checked + .switch-slider::before {
  transform: translateX(20px);
}

.param-pattern-grid {
  margin-bottom: 4px;
}

/* ========== 牌型定价表 ========== */
.hand-prices-table {
  border: 1px solid #e8e8e8;
  border-radius: 6px;
  overflow: hidden;
}

.hp-header {
  display: flex;
  align-items: center;
  background: #fafafa;
  padding: 6px 10px;
  font-size: 12px;
  color: #666;
  font-weight: 600;
  border-bottom: 1px solid #e8e8e8;
}

.hp-row {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  border-bottom: 1px solid #f0f0f0;
}

.hp-row:last-child {
  border-bottom: none;
}

.hp-label {
  flex: 0 0 60px;
  font-size: 13px;
  color: #333;
}

.hp-col {
  flex: 1;
  text-align: center;
  font-size: 12px;
}

.hp-input {
  flex: 1;
  margin: 0 4px;
  max-width: 80px;
}

/* ========== 我的账本（A+ 微信红包增强版 含余额/牌型/规则明细） ========== */
.ledger-section {
  padding: 0 16px;
  margin-bottom: 12px;
}

.ledger-section .section-title {
  font-size: 14px;
  font-weight: 700;
  color: #333;
  margin-bottom: 10px;
}

.ledger-list {
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* 把号+庄家分隔 */
.ldger-date-hd {
  padding: 8px 14px;
  font-size: 12px;
  color: #888;
  background: #fafbfc;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ldger-dealer-tag {
  font-size: 11px;
  color: #d4380d;
  background: #fff2f0;
  padding: 1px 8px;
  border-radius: 10px;
}

.ldger-juquan {
  font-size: 11px;
  color: #999;
}

/* 交易行 */
.ldger-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid #f5f5f5;
}

.ldger-row:last-child {
  border-bottom: none;
}

.ldger-row.in {
  background: #fff7f7;
}

.ldger-row.out {
  background: #f6ffed;
}

/* 左侧图标圈 */
.ldger-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  margin-top: 2px;
}

.licon-hu { background: #f5222d; }
.licon-zm { background: #cf1322; }
.licon-mg { background: #1890ff; }
.licon-ag { background: #722ed1; }
.licon-dp { background: #fa8c16; }

/* 中间信息区 */
.ldger-info {
  flex: 1;
  min-width: 0;
}

.ldger-title {
  font-size: 14px;
  color: #333;
  line-height: 1.4;
}

.ldger-title b {
  font-weight: 600;
  color: #222;
}

.ldger-meta {
  font-size: 12px;
  color: #888;
  margin-top: 2px;
}

/* 规则明细 */
.ldger-detail {
  font-size: 12px;
  color: #999;
  margin-top: 3px;
  line-height: 1.5;
}

.ldger-detail em {
  font-style: normal;
  color: #666;
}

/* 记账明细规则 + 计分步骤链 (账本) */
.ldger-rules {
  font-size: 12px;
  color: #888;
  margin-top: 3px;
  padding-left: 2px;
}

.ldger-steps {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  margin-top: 4px;
  padding-left: 2px;
}

.ldger-step {
  display: inline-block;
  font-size: 11px;
  color: #666;
  background: #fafafa;
  border: 1px solid #e8e8e8;
  border-radius: 4px;
  padding: 1px 8px;
  line-height: 1.8;
  white-space: nowrap;
}

.ldger-arr {
  font-size: 10px;
  color: #bbb;
  margin: 0 2px;
}

/* 右侧金额+余额 */
.ldger-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex-shrink: 0;
  gap: 2px;
}

.ldger-amt {
  font-size: 16px;
  font-weight: 700;
}

.ldger-amt.in {
  color: #cf1322;
}

.ldger-amt.out {
  color: #389e0d;
}

.ldger-balance {
  font-size: 11px;
  color: #999;
}

/* ========== Game Actions ========== */
.game-actions {
  padding: 0 16px 16px;
}

/* ========== Transaction List ========== */
.recent-section {
  margin: 12px 0;
}

.recent-section label {
  font-size: 13px;
  font-weight: 600;
  color: #333;
}

.recent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.tx-toggle {
  background: none;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  padding: 2px 10px;
  font-size: 12px;
  color: #666;
  cursor: pointer;
}

.tx-toggle:active {
  background: #f5f5f5;
}

.tx-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
}

.tx-card {
  border-radius: 10px;
  border-left: 4px solid #ccc;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  overflow: hidden;
}

.tx-card.hu { border-left-color: #cf1322; }
.tx-card.zi_mo { border-left-color: #d48806; }
.tx-card.dian_pao { border-left-color: #389e0d; }

/* Gong (subsidiary) record — compact, lighter, no side accent */
.tx-sub {
  border-radius: 6px;
  background: #fafafa;
  border: 1px dashed #e0e0e0;
  box-shadow: none;
}

.tx-sub .tx-badge {
  font-size: 9px;
  padding: 1px 5px;
}

.tx-sub .tx-wname {
  font-size: 13px;
}

.tx-sub .tx-wscore {
  font-size: 14px;
  color: #d4380d;
}

.tx-sub .tx-loser-line {
  font-size: 11px;
  color: #aaa;
}

.tx-sub .tx-ls b {
  color: #73d13d;
}

.tx-sub .tag-off-dealer {
  font-size: 9px;
}

.tx-sub .tx-card-body {
  padding: 6px 10px;
}

.tx-card-body {
  padding: 10px 12px;
}

.tx-winner-line {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
}

.tx-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  margin-right: 8px;
  flex-shrink: 0;
}

.tx-badge.hu { background: #fff1f0; color: #cf1322; }
.tx-badge.zi_mo { background: #fff7e6; color: #d48806; }
.tx-badge.ming_gang { background: #e6f7ff; color: #096dd9; }
.tx-badge.an_gang { background: #f9f0ff; color: #531dab; }
.tx-badge.dian_pao { background: #f6ffed; color: #389e0d; }

.tx-wname {
  font-size: 15px;
  font-weight: 700;
  color: #222;
  flex: 1;
}

.tx-wscore {
  font-size: 18px;
  font-weight: 800;
  color: #cf1322;
  flex-shrink: 0;
}

.tx-loser-line {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  font-size: 12px;
  color: #888;
  padding-top: 4px;
  border-top: 1px dashed #f0f0f0;
}

.tx-ls b {
  color: #52c41a;
  font-weight: 700;
  margin-left: 1px;
}

.tx-empty {
  text-align: center;
  color: #bbb;
  padding: 20px;
  font-size: 13px;
}

.tag-off-dealer {
  display: inline-block;
  background: #fff2e8;
  color: #d4380d;
  border: 1px solid #ffbb96;
  border-radius: 3px;
  padding: 0 4px;
  font-size: 10px;
  font-weight: 600;
  margin: 0 2px;
  vertical-align: middle;
}

/* ========== Settlement ========== */
.settle-balances {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.balance-card {
  flex: 1 1 calc(50% - 4px);
  min-width: 120px;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
}

.balance-card .bal-name {
  font-size: 14px;
  margin-bottom: 4px;
}

.balance-card .bal-amount {
  font-size: 20px;
  font-weight: 700;
}

.balance-card .bal-amount.positive { color: var(--success); }
.balance-card .bal-amount.negative { color: var(--danger); }

.settle-transfers {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.transfer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px;
  background: #fff7e6;
  border-radius: var(--radius);
  border: 1px solid #ffe58f;
  font-size: 15px;
}

.transfer-item .transfer-arrow {
  font-size: 20px;
  margin: 0 4px;
}

.transfer-item .transfer-amount {
  margin-left: auto;
  font-weight: 700;
  font-size: 18px;
  color: var(--primary);
}

/* ========== Room Badge ========== */
.room-badge {
  font-size: 13px;
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--text-secondary);
}

.preset-badge {
  font-size: 13px;
  color: var(--secondary);
}

/* ========== Pulsing shadow for dealer record button ========== */
@keyframes pulse-shadow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212, 56, 13, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(212, 56, 13, 0); }
}

#submit-record-btn {
  animation: pulse-shadow 2s infinite;
}

/* ========== Toast ========== */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.3s;
}

.toast.show { opacity: 1; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--secondary); }

/* ========== 本把待提交记录（卡片式） ========== */
.local-pending-area {
  margin-top: 12px;
  background: #fffbe6;
  border: 2px dashed #faad14;
  border-radius: var(--radius);
  overflow: hidden;
}

.local-pending-hd {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  background: #fff8cc;
  border-bottom: 1px solid #ffe58f;
}

.local-pending-title {
  font-size: 13px;
  font-weight: 700;
  color: #ad6800;
}

.local-pending-list {
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.local-tx-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #fffdf0;
  border-radius: 8px;
  border: 1px solid #ffe58f;
}

.local-tx-info {
  flex: 1;
  min-width: 0;
}

.local-tx-desc {
  font-size: 14px;
  font-weight: 600;
  color: #333;
}

.local-tx-meta {
  font-size: 11px;
  color: #999;
  margin-top: 2px;
}

.local-tx-score {
  font-size: 16px;
  font-weight: 800;
  color: #cf1322;
  white-space: nowrap;
}

.local-tx-del {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid #ffccc7;
  background: #fff2f0;
  color: #ff4d4f;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
  transition: all 0.15s;
}

.local-tx-del:active {
  background: #ff4d4f;
  color: #fff;
  border-color: #ff4d4f;
}

.local-pending-act {
  padding: 10px 14px;
  border-top: 1px solid #ffe58f;
  background: #fff8cc;
}

.last-round-undo-area {
  margin-top: 10px;
}

/* 旧样式保留兼容 */
.jrnl-round-local {
  border: 2px dashed #faad14;
  background: #fffbe6;
}

.jrnl-local-badge {
  font-size: 11px;
  background: #faad14;
  color: #fff;
  padding: 1px 8px;
  border-radius: 10px;
  font-weight: 600;
  margin-left: auto;
}

.jrnl-event-local {
  opacity: 0.85;
  background: #fffdf0;
  border-left: 3px solid #faad14;
  padding-left: 8px;
  margin: 4px 0;
}

.jrnl-local-pending {
  font-size: 10px;
  background: #fff7e6;
  color: #d48806;
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid #ffe58f;
  margin-left: 6px;
  font-weight: 500;
}

/* 账本中的待提交记录 */
.ldger-row-local {
  border-left: 3px solid #faad14;
}

.ldger-pending-badge {
  font-size: 10px;
  background: #fff7e6;
  color: #d48806;
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid #ffe58f;
  font-weight: 500;
  vertical-align: middle;
}

/* ========== 离场替换弹窗 ========== */
.replace-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.replace-modal-hd {
  width: 100%;
  max-width: 340px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.replace-modal-title {
  color: #fff;
  font-size: 18px;
  font-weight: 600;
}

.replace-modal-close {
  width: 36px; height: 36px;
  border: none;
  background: rgba(255,255,255,0.15);
  color: #fff;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.replace-modal-body {
  background: #fff;
  border-radius: 12px;
  padding: 24px 20px;
  max-width: 340px;
  width: 100%;
  text-align: center;
}

.replace-hint {
  font-size: 14px;
  color: #555;
  margin-bottom: 16px;
}

.replace-qr-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

.replace-qr-wrap canvas {
  border-radius: 8px;
}

.replace-info {
  font-size: 14px;
  color: #333;
  font-weight: 500;
  margin-bottom: 8px;
}

.replace-timer {
  font-size: 13px;
  color: #999;
}

/* ========== 替补加入页 ========== */
.replace-join-section {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.replace-join-section h3 {
  font-size: 20px;
  margin-bottom: 8px;
  color: #333;
}

.replace-join-info {
  font-size: 14px;
  color: #666;
  margin-bottom: 20px;
  text-align: center;
}

.replace-join-form {
  width: 100%;
  max-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
