/* ============================================================
   7鬼523 正式客户端补充样式
   ------------------------------------------------------------
   只补原型样式表（proto.css / proto-table.css）里没有的生产界面零件：
   启动遮罩、我的房间列表、邀请分享、头像选择、等待房间的 AI 席位按钮、聊天行。
   原型已通过的牌桌 / 手牌 / 提示条 / 弹层样式一律不改动。
   ============================================================ */

/* ------------------------------------------------------------ 启动遮罩 */

.app-boot {
  position: fixed;
  inset: 0;
  z-index: 99;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: radial-gradient(120% 90% at 50% -12%, #4ad3bd 0%, #22a795 34%, #14837c 62%, #0b6266 100%);
  color: #eafaf6;
}
.app-boot .boot-card {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: #ffe9b8;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
}
.app-boot .boot-note { font-size: 13px; }
.dim { color: #a9cfc9; }

/* ------------------------------------------------------------ 大厅：我的房间 */

.panel.grow {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.room-list {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.room-item,
.history-match {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  min-height: var(--tap);
}
.room-item .ri-main,
.history-match .ri-main { flex: 1 1 auto; min-width: 0; }
.room-item .ri-title,
.history-match .ri-title {
  font-size: 13.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.room-item .ri-sub,
.history-match .ri-sub {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ri-state {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid var(--line);
}
.ri-state.waiting { background: rgba(111, 196, 255, 0.16); color: #d6ecff; }
.ri-state.playing { background: rgba(79, 211, 154, 0.16); color: #d7ffee; }

/* ------------------------------------------------------------ 等待房间：席位 + 聊天 */

.seat-card { flex-wrap: nowrap; }
.seat-card .seat-main { min-width: 0; flex: 1 1 auto; }
.seat-card .btn.sm { min-width: auto; padding: 0 8px; font-size: 12.5px; }
.seat-card.empty { opacity: 0.78; border-style: dashed; }
.seat-card.ai { background: rgba(255, 255, 255, 0.03); }

/* 等待房间：座位卡永不因下方内容过挤而被压扁（否则信息面板会盖住席位按钮） */
.screen .seats-row { flex: 0 0 auto; min-height: 64px; }

.chat-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.chat-row .chat-label { font-size: 12px; color: var(--text-dim); }
.chat-row .chat-last {
  flex: 1 1 100%;
  font-size: 12px;
  color: #ffe6a8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-row .btn.emoji { font-size: 16px; padding: 0 8px; }

/* ------------------------------------------------------------ 邀请分享 */

.share-grid { display: flex; flex-direction: column; gap: 8px; }
.share-field { display: flex; align-items: center; gap: 8px; }
.share-field .sf-k { font-size: 12.5px; color: var(--text-dim); min-width: 60px; }
.share-code {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: #ffe9b8;
}
.qr-box {
  align-self: center;
  width: 140px;
  height: 140px;
  padding: 6px;
  border-radius: 10px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #333;
}
.qr-box svg { width: 100%; height: 100%; }

/* ------------------------------------------------------------ 个人设置：头像选择 */

.avatar-grid { display: flex; gap: 6px; flex-wrap: wrap; }
.avatar-pick {
  padding: 0;
  border-radius: 999px;
  border: 2px solid transparent;
  background: transparent;
  line-height: 0;
  min-width: var(--tap);
  min-height: var(--tap);
}
.avatar-pick[aria-pressed="true"] { border-color: var(--gold); }

/* ------------------------------------------------------------ 竖屏：大厅同样给足入口 */

html[data-viewport="portrait"] .panel.grow { flex: 0 1 auto; }

/* ============================================================
   V4：房间管理与对局体验完善（观战 / 入座申请 / 房主菜单 / 结算 / 接管）
   ------------------------------------------------------------
   只新增生产界面需要的零件；横屏一屏约束不变：
   不新增常驻说明行，只有弹层与结算摘要面板内部滚动。
   ============================================================ */

/* ------------------------------------------------------------ 观战标识 */

.spectate-badge {
  background: rgba(111, 196, 255, 0.18);
  border-color: rgba(111, 196, 255, 0.5);
  color: #d6ecff;
}

.ri-state.spectating { background: rgba(111, 196, 255, 0.16); color: #d6ecff; }
.ri-state.aborted { background: rgba(255, 107, 98, 0.16); color: #ffd9d6; }

/* 观众没有操作权限的那一排按钮：隐藏而不是禁用（不占热区） */
.action-bar .btn[data-testid="spectate-seek-seat"]:disabled { opacity: 0.45; }

/* ------------------------------------------------------------ 创建页：字段多，紧凑三列 */

html[data-viewport="landscape"] .field-grid.create-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px 10px;
}
html[data-viewport="landscape"] .field-grid.create-grid .field > label { min-width: 40px; font-size: 12px; }
html[data-viewport="landscape"] .field-grid.create-grid .segment { padding: 2px; }
html[data-viewport="landscape"] .field-grid.create-grid .segment button {
  min-width: 40px;
  padding: 0 6px;
  font-size: 12.5px;
}
html[data-viewport="landscape"] .field-grid.create-grid .readonly-pill { font-size: 12px; padding: 0 8px; }
html[data-viewport="landscape"] .field-grid.create-grid .quick-btns { display: flex; gap: 4px; flex: 0 0 auto; }
html[data-viewport="landscape"] .field-grid.create-grid .qbtn { min-width: 30px; padding: 0 5px; font-size: 12px; }

/* 640×360：再抠一点间距，保证创建页所有字段都在一屏内 */
html[data-hband="xs"] .field-grid.create-grid { gap: 4px 8px; }
html[data-hband="xs"] .field-grid.create-grid .field { min-height: 40px; }
html[data-hband="xs"] .field-grid.create-grid .segment { padding: 1px; }
html[data-hband="xs"] .field-grid.create-grid .segment button { min-height: 38px; }
html[data-hband="xs"] .field-grid.create-grid input.ctl-input { min-height: 38px; }
html[data-hband="xs"] .field-grid.create-grid .readonly-pill { min-height: 30px; }

/* ------------------------------------------------------------ 等待房间：入座申请 + 换座 */

.seat-request-row {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 10px;
  min-height: 34px;
  overflow-x: auto;
  background: rgba(16, 76, 104, 0.45);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.seat-request-row[hidden] { display: none; }
.seat-request-row .sr-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.seat-request-row .sr-name { font-size: 12.5px; color: #d6ecff; }

.seat-card.swap-armed { border-color: var(--gold); background: rgba(247, 195, 61, 0.14); }

/* 座位卡里的操作塞在同一行：补 AI / 标记状态 / 移出 / 换座（不额外增加卡片高度） */
.seat-card .seat-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-wrap: nowrap;
  max-width: 100%;
}
.seat-card .seat-actions .btn.sm { min-width: auto; padding: 0 7px; font-size: 12.5px; }
.seat-card .seat-actions .btn.swap-btn { min-width: 32px; padding: 0 6px; }
.seat-card .seat-actions .swap-btn[data-armed="1"] { min-width: auto; }

/* 聊天快捷按钮不抢主按钮热区：只占一行，高度紧凑 */
.chat-row .btn.sm { min-height: 32px; padding: 0 8px; font-size: 12.5px; }

/* ------------------------------------------------------------ 结算：摘要面板内部滚动 */

.settle-screen .settle-summary {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.settle-screen .settle-summary h3 { margin: 0; }
.settle-screen .settle-summary .block.aborted {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 107, 98, 0.45);
  background: rgba(255, 107, 98, 0.12);
}
.settle-round-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  padding: 3px 6px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  font-size: 12px;
}
.settle-round-row .srr-head { font-weight: 700; color: #ffe9b8; white-space: nowrap; }
.settle-round-row .srr-win { color: #ccffe9; white-space: nowrap; }
.settle-round-row .srr-scores {
  color: var(--text-dim);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------------------------------------ 多设备接管 */

.sheet .takeover-note { font-size: 12px; color: var(--text-dim); }

/* ============================================================
   收尾（V4上线独立审核与收尾任务书）
   ------------------------------------------------------------
   1. 等待房间：房间条 + 规则行改成**固定行**，规则摘要完整露出、永不裁切；
      座位卡收紧（信息一个都不删），把高度让给固定行。
   2. 房间设置：常用/高级两页，每页一屏，不再靠滚动翻字段。
   3. 加入房间：按错误码只展示有效动作。
   ============================================================ */

/* ------------------------------------------------------------ 等待房间：固定房间条 */

.room-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  min-height: 48px;
  overflow: hidden;
  background: rgba(3, 28, 32, 0.45);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.room-bar .readonly-pill { min-height: 26px; font-size: 12px; padding: 0 8px; }
.room-bar .btn.sm { padding: 0 9px; font-size: 12.5px; }
.room-bar .spectate-badge { min-height: 26px; }

/* 规则摘要一行短句：短横线分隔，永远整行可见（不换行、不被底栏盖住） */
.room-rules {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 10px;
  min-height: 24px;
  font-size: 12px;
  color: var(--text-dim);
  background: rgba(3, 28, 32, 0.42);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  white-space: nowrap;
  overflow: hidden;
}
.room-rules .rr-item {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.room-rules .rr-item + .rr-item::before {
  content: '·';
  margin-right: 8px;
  color: rgba(255, 255, 255, 0.3);
}
html[data-hband="xs"] .room-rules { font-size: 11.5px; gap: 6px; padding: 1px 8px; }

/* 收尾2：固定状态行缩到一行短句（原文案里重复的"在等谁/能做的"已交给按钮表达） */
.reason-row {
  min-height: 24px;
  padding: 1px 10px;
  font-size: 12.5px;
}
.reason-row .status-main { font-size: 12.5px; }

/* ------------------------------------------------------------ 等待房间：座位卡收紧
   信息全保留（昵称 / 方位 / 玩家或 AI / 准备状态 / 房主操作），只压掉多余留白。
   3～4 人局改成"头像 + 文案"同行、房主操作另起一行：
   否则 44px 的补 AI/移出按钮会把竖排卡片撑高，把固定规则行挤出屏外（收尾2 的病根）。 */

.room-body { justify-content: center; }
html[data-viewport="landscape"] .screen .seat-card { padding: 5px 6px; gap: 3px; }
html[data-viewport="landscape"] .seats-row[data-seats="3"] .seat-card,
html[data-viewport="landscape"] .seats-row[data-seats="4"] .seat-card {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  text-align: left;
  gap: 2px 6px;
  padding: 4px 5px;
}
html[data-viewport="landscape"] .seats-row[data-seats="3"] .seat-card .seat-main,
html[data-viewport="landscape"] .seats-row[data-seats="4"] .seat-card .seat-main {
  /* flex-basis 必须是 0：用 auto 时会按"内容宽度"判断换行，长昵称（如"收尾一屏640x360"）
     会把文案挤到下一行、把卡片重新撑高（实测 121px → 溢出 14px）。basis 0 后不会再换行。 */
  width: auto;
  flex: 1 1 0;
  min-width: 0;
}
html[data-viewport="landscape"] .seats-row[data-seats="3"] .seat-card .seat-actions,
html[data-viewport="landscape"] .seats-row[data-seats="4"] .seat-card .seat-actions {
  flex: 1 1 100%;
}
html[data-viewport="landscape"] .screen .seat-card .avatar.md { width: 32px; height: 32px; }
html[data-viewport="landscape"] .screen .seat-card .nm { font-size: 12.5px; }
html[data-viewport="landscape"] .screen .seat-card .sub { font-size: 11.5px; }
html[data-viewport="landscape"] .screen .seat-card .state {
  font-size: 11.5px;
  padding: 2px 6px;
  min-height: 20px;
}
html[data-viewport="landscape"] .screen .chat-row .btn.sm { min-height: 30px; }
html[data-viewport="landscape"] .screen-body { padding: 6px 10px; gap: 6px; }
html[data-hband="xs"] .screen .seat-card .seat-actions .btn.sm { padding: 0 6px; }

/* ------------------------------------------------------------ 房间设置：常用 / 高级两页 */

.room-settings-tabs { align-self: flex-start; flex: 0 0 auto; }
.room-settings-tabs button { min-width: 64px; }
.room-settings-body { display: flex; flex-direction: column; gap: 6px; }
html[data-viewport="landscape"] .room-settings-body .field-grid { gap: 4px 10px; }
html[data-viewport="landscape"] .room-settings-body .field { min-height: 40px; }
html[data-viewport="landscape"] .room-settings-body .field > label { font-size: 12px; min-width: 44px; }
html[data-viewport="landscape"] .room-settings-body .segment { padding: 2px; }
html[data-viewport="landscape"] .room-settings-body .segment button { min-height: 36px; padding: 0 8px; font-size: 12.5px; }
html[data-viewport="landscape"] .room-settings-body input.ctl-input { min-height: 36px; font-size: 15px; }
html[data-viewport="landscape"] .room-settings-body .readonly-pill { min-height: 28px; font-size: 12px; }
html[data-viewport="landscape"] .room-settings-body .btn.sm { min-height: 36px; font-size: 12.5px; }
html[data-viewport="landscape"] .segment.room-settings-tabs button { min-height: 38px; }
html[data-viewport="landscape"] .sheet .field-grid { gap: 4px 10px; }

/* 竖屏（390×844）：固定房间条允许换行，绝不横向裁掉按钮与规则 */
html[data-viewport="portrait"] .room-bar {
  flex-wrap: wrap;
  overflow: visible;
  min-height: 0;
  padding: 4px 10px;
  row-gap: 4px;
}
html[data-viewport="portrait"] .room-rules {
  flex-wrap: wrap;
  white-space: normal;
  overflow: visible;
  min-height: 0;
  row-gap: 2px;
}
html[data-viewport="portrait"] .room-rules .rr-item { white-space: normal; }
html[data-viewport="portrait"] .reason-row { min-height: 0; }

/* ------------------------------------------------------------ 加入房间：按错误码分支 */

.join-actions { gap: 6px; }
.hint-line[data-testid="join-next-step"] { flex: 0 1 auto; }
input.ctl-input.need { border-color: rgba(247, 195, 61, 0.85); background: rgba(247, 195, 61, 0.12); }

