/* ——— 联网组队弹窗美化 ——— */
#teamModal .modal-panel {
  max-width: 520px;
}
.lock-overlay {
  position: fixed;
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 20;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(13,17,23,0.6);
  border: 1px solid #30363d;
  color: #cbd5e1;
  font-size: 14px;
  backdrop-filter: saturate(160%) blur(6px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.25);
  pointer-events: none; /* 不挡交互 */
  opacity: 0;
  transition: opacity .2s ease, transform .2s ease;
}
.lock-overlay.show { opacity: 1; transform: translate(-50%, -50%) translateY(-2px); }

/* 输入框容器与工具按钮 */
#teamModal .code-input-wrap {
  position: relative;
  width: 100%;
}
#teamModal .code-tools {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 6px;
}
#teamModal .icon-btn {
  border: 1px solid #30363d;
  background: rgba(255,255,255,0.03);
  color: #c9d1d9;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 16px;
  padding: 0;
}
#teamModal .icon-btn:active { transform: translateY(1px); }

#teamModal .modal-body .field.lbl {
  font-weight: 600;
  color: var(--muted);
}

#teamModal #roomCodeInput {
  width: 100%;
  box-sizing: border-box;
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: 2px;
  text-align: center;
  padding: 14px 16px;
  margin-top: 6px;
  border-radius: 12px;
  border: 1px solid var(--border, #2d333b);
  background: var(--panel, #0d1117);
  color: var(--text, #c9d1d9);
  transition: border-color .15s ease, box-shadow .15s ease, transform .06s ease;
}

#teamModal #roomCodeInput::placeholder {
  color: #8b949e;
  opacity: .8;
}

#teamModal #roomCodeInput:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,.25);
}

/* 输入框悬停与按下反馈 */
#teamModal #roomCodeInput:hover {
  border-color: #3b82f6aa;
}
#teamModal #roomCodeInput:active {
  transform: scale(0.998);
}

/* 操作按钮采用自适应网格布局，更紧凑对齐 */
#teamModal .custom .full {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

/* 关键按钮强调 */
#teamModal #createRoomBtn.primary {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  border: 1px solid #16a34a;
}

#teamModal #disbandBtn {
  border-color: #ff6b6b55;
}

/* 顶部状态行更易读 */
#teamModal #teamStatus {
  font-size: 14px;
}

/* 小屏优化：输入框和按钮间距适配 */
@media (max-width: 420px) {
  #teamModal #roomCodeInput {
    font-size: 18px;
    letter-spacing: 1.5px;
    padding: 12px 14px;
  }
}
/* --- 基础 --- */
:root {
  --blue: #1f6feb;
  --red: #d73a49;
  --bg: #0d1117;
  --text: #c9d1d9;
  --muted: #8b949e;
  --card: #161b22;
  --accent: #2ea043;
}

/* ===== 响应式增强 ===== */
/* 1) 极窄屏：设置行改为纵向堆叠（<=360px） */
@media (max-width: 360px) {
  .modal .target-row,
  .modal .custom,
  .modal .switch-row { grid-template-columns: 1fr; }
  .modal .target-row > label,
  .modal .custom .field.lbl { grid-column: 1 / -1; justify-content: flex-start; width: 100%; }
  .modal .target-row > select,
  .modal .custom input[type="number"],
  .modal .switch-row .switch { grid-column: 1 / -1; width: 100%; }
}

/* 2) 右上角胶囊在窄屏压缩；超窄时保留一个图标（优先保留设置） */
@media (max-width: 380px) {
  .fab-group { gap: 6px; padding: 4px 6px; }
  .fab-pill { padding: 6px 10px; font-size: 15px; }
}
@media (max-width: 340px) {
  #infoBtn { display: none; }
  .fab-group { padding: 4px; }
}

/* 3) 横屏时底栏更紧凑 */
@media (orientation: landscape) {
  .bottombar { padding: 8px 10px; border-radius: 12px; }
  .bottombar button { min-width: 96px; padding: 10px 12px; }
  .toast { bottom: calc(70px + env(safe-area-inset-bottom)); }
  /* 赛场：左右布局 */
  .court { grid-template-rows: 1fr; grid-template-columns: 1fr 1fr; padding-bottom: 0; }
  /* 外侧圆角随方向调整 */
  .side { border-radius: 0; }
  .side.blue { border-top-left-radius: 16px; border-bottom-left-radius: 16px; }
  .side.red  { border-top-right-radius: 16px; border-bottom-right-radius: 16px; }
}

/* —— 横屏纯比分展示（隐藏操作按钮） —— */
@media (orientation: landscape) {
  .fab-group { display: none !important; }
  .bottombar { display: none !important; }
  /* 隐藏底栏时，避免预留空间 */
  .court { padding-bottom: 0 !important; }
}

/* 宽屏（即使是竖屏设备横向很宽，也采用左右布局） */
@media (min-width: 900px) {
  .court { grid-template-rows: 1fr; grid-template-columns: 1fr 1fr; }
  .side { border-radius: 0; }
  .side.blue { border-top-left-radius: 16px; border-bottom-left-radius: 16px; }
  .side.red  { border-top-right-radius: 16px; border-bottom-right-radius: 16px; }
}

* { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", Arial, sans-serif;
  -webkit-text-size-adjust: 100%; /* 防止 iOS 自动放大字体 */
}

/* 确保带 hidden 属性的元素不会显示（覆盖 UA 与其他样式） */
[hidden] { display: none !important; }

/* 禁用双击放大的提示（现代浏览器） */
html, body, .court, .side, button { touch-action: manipulation; }

#app { min-height: 100dvh; display: flex; flex-direction: column; }

/* removed unused: topbar, scoreboard */

.controls { display: flex; gap: 12px; }
button {
  border: 1px solid transparent;
  background: var(--card);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 16px;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
button.primary { background: var(--accent); color: #fff; border-color: #20934e; }
button.ghost { background: transparent; border-color: #30363d; color: var(--muted); }
button:active { transform: translateY(1px); }
button.large { padding: 14px 18px; font-size: 18px; }
button.ghost.large { background: rgba(255,255,255,0.02); }

/* 目标分选择器 */
.target { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.target select, .target input[type="number"] {
  background: var(--card);
  color: var(--text);
  border: 1px solid #30363d;
  border-radius: 12px;
  padding: 10px 36px 10px 12px; /* 右侧为下拉箭头预留空间 */
  font-size: 14px;
  min-width: 84px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%238a939f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 18px;
  color-scheme: dark; /* 让原生下拉菜单使用深色方案（支持的浏览器） */
}
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }

/* 下拉选项（支持的浏览器会应用） */
.target select option { background: var(--card); color: var(--text); }

/* 交互态 */
.target select:hover { border-color: #3a424a; }
.target select:focus { outline: none; border-color: #2ea043; box-shadow: 0 0 0 3px rgba(46,160,67,0.25); }

/* --- 球场/左右区域 --- */
.court {
  flex: 1;
  display: grid;
  grid-template-rows: 1fr 1fr; /* 改为上下两部分 */
  grid-template-columns: 1fr;
  min-height: 0;
  position: relative;
  padding-bottom: calc(64px + env(safe-area-inset-bottom)); /* 给底部栏留空 */
  perspective: 900px; /* 为翻页倾斜提供透视 */
}

.side {
  -webkit-tap-highlight-color: transparent;
  appearance: none;
  border: none;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #fff;
  position: relative; /* 便于内部动画定位 */
  touch-action: none; /* 禁止浏览器默认滚动，允许自定义滑动手势 */
  will-change: transform;
}

.side.blue { background: linear-gradient(135deg, #1f6feb 0%, #316dca 100%); }
.side.red  { background: linear-gradient(135deg, #d73a49 0%, #f85149 100%); }

.label { font-size: 20px; opacity: 0.9; }
.bigscore { font-size: clamp(320px, 28vh, 500px); font-weight: 900; line-height: 1; text-shadow: 0 2px 8px rgba(0,0,0,0.35); }

/* 分数轻微弹跳动画 */
.bigscore.bump { animation: bump 180ms ease-out; }
@keyframes bump {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

/* removed unused: flip-up/down animations */

/* 跟手时的动态阴影叠加，通过 --flip-shadow 控制强度 */
.side::after {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(0,0,0,0.2), rgba(0,0,0,0));
  opacity: calc(var(--flip-shadow, 0) * 0.6);
  transition: opacity 120ms ease;
  border-radius: inherit;
}

/* ===== 布局覆写（放在基础规则之后，确保覆盖） ===== */
@media (orientation: landscape) {
  .court { grid-template-rows: 1fr !important; grid-template-columns: 1fr 1fr !important; padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
  .side { border-radius: 0; }
  .side.blue { border-top-left-radius: 16px; border-bottom-left-radius: 16px; }
  .side.red  { border-top-right-radius: 16px; border-bottom-right-radius: 16px; }
}
@media (min-width: 900px) {
  .court { grid-template-rows: 1fr !important; grid-template-columns: 1fr 1fr !important; }
  .side { border-radius: 0; }
  .side.blue { border-top-left-radius: 16px; border-bottom-left-radius: 16px; }
  .side.red  { border-top-right-radius: 16px; border-bottom-right-radius: 16px; }
}

/* 点击 +1 漂浮动画 */
.plusOne {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -30%);
  font-weight: 800;
  font-size: 40px;
  opacity: 0;
  pointer-events: none;
  text-shadow: 0 2px 8px rgba(0,0,0,0.35);
  animation: rise 600ms ease-out forwards;
}
@keyframes rise {
  0%   { opacity: 0; transform: translate(-50%, -10%) scale(0.9); }
  20%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -80%) scale(1.1); }
}

/* --- 结束遮罩 --- */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(28px, 6vw, 48px);
  font-weight: 800;
  color: #fff;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(2px);
}

.overlay.win { background: rgba(0,0,0,0.35); }
.overlay.win .msg { 
  padding: 16px 22px; 
  border-radius: 16px; 
  background: rgba(0,0,0,0.35); 
  box-shadow: 0 6px 30px rgba(0,0,0,0.45);
}

/* 右上角并排小胶囊 */
.fab-group {
  position: fixed;
  right: 14px;
  top: calc(14px + env(safe-area-inset-top));
  z-index: 25;
  display: flex;
  gap: 8px;
  background: rgba(13,17,23,0.85);
  border: 1px solid #30363d;
  border-radius: 999px;
  padding: 8px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.35);
  backdrop-filter: saturate(180%) blur(6px);
}
.fab-pill {
  background: transparent;
  color: #fff;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 14px;
}
.fab-pill:active { transform: translateY(1px); }

/* 竖屏/窄屏：右侧按钮组默认收缩，仅显示设置图标 */
.fab-group.collapsed {
  gap: 0;
  padding: 6px;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  cursor: pointer; /* 整个容器作为开关 */
}
.fab-group.collapsed .fab-pill { display: none; }
.fab-group.collapsed:not(.peek) .fab-pill { pointer-events: none; }
.fab-group.collapsed #settingsBtn {
  display: inline-flex;
  padding: 0;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
}

/* 点击预览详情：临时展开（脚本加 .peek 时可配合去除宽高限制） */
.fab-group.peek {
  width: auto;
  height: 44px;
  align-items: center;
  white-space: nowrap;
  box-sizing: border-box;
}
/* 收缩+预览并存时：恢复间距并显示所有按钮 */
.fab-group.collapsed.peek {
  gap: 8px;
  padding: 8px;
  height: 44px;
  align-items: center;
  white-space: nowrap;
  box-sizing: border-box;
}
.fab-group.collapsed.peek .fab-pill { display: inline-flex; }

/* 模拟徽标的平滑展开：使用过渡，而非关键帧 */
.fab-group {
  transition: all .18s ease;
}
.fab-group.collapsed { transform: translateZ(0); }
/* 顶部联网状态徽标 */
.team-badge {
  position: fixed;
  left: 14px;
  top: calc(14px + env(safe-area-inset-top));
  z-index: 26; /* 高于胶囊组，低于 toast */
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(13,17,23,0.85);
  border: 1px solid #30363d;
  color: #c9d1d9;
  box-shadow: 0 6px 16px rgba(0,0,0,0.35);
  backdrop-filter: saturate(180%) blur(6px);
  font-size: 14px;
  pointer-events: auto;
  transition: all .18s ease;
}
.team-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: block; /* 防止内联基线导致的垂直偏移 */
}
.team-badge .dot.on { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.25); }
.team-badge .dot.off { background: #6b7280; }
/* 离线（未联网）红色状态 */
.team-badge .dot.offline { background: #ef4444; box-shadow: 0 0 0 3px rgba(239,68,68,.25); }
.team-badge .role {
  color: #8b949e;
}

.team-badge.collapsed {
  padding: 6px;
  padding: 0;
  width: 44px;
  height: 44px;
  gap: 0;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border-radius: 999px;
  overflow: hidden; /* 防止文本在容器内挤压导致的错位 */
  line-height: 0;   /* 避免行高影响垂直居中 */
  font-size: 0;    /* 避免残余文本节点占位 */
}
.team-badge.collapsed span:not(.dot) { display: none; }
.team-badge.collapsed .dot { margin: 0; }
.team-badge.collapsed .dot { width: 12px; height: 12px; box-shadow: 0 0 0 3px rgba(34,197,94,.25); display: block; }
/* 收缩态离线时的红色外环 */
.team-badge.collapsed .dot.offline { box-shadow: 0 0 0 3px rgba(239,68,68,.25); }
.team-badge.collapsed .role { display: none; }

/* 点击预览详情：临时展开（在脚本中加/删 .peek 类） */
.team-badge.peek { font-size: 14px; padding: 8px 12px; width: auto; height: 44px; gap: 8px; align-items: center; white-space: nowrap; box-sizing: border-box; }
/* 收缩态 + 预览：需要恢复文字显示与正常行高/点尺寸 */
.team-badge.collapsed.peek { font-size: 14px; line-height: normal; width: auto; height: 44px; gap: 8px; padding: 8px 12px; align-items: center; white-space: nowrap; box-sizing: border-box; }
.team-badge.collapsed.peek span:not(.dot) { display: inline; }
.team-badge.collapsed.peek .role { display: inline; }
.team-badge.collapsed.peek .dot { width: 8px; height: 8px; }

/* 组内已统一布局，无需竖屏单独定位 */

/* —— 组队输入校验 —— */
#teamModal .field-help {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted, #8b949e);
  min-height: 16px;
}
#teamModal .field-help.error {
  color: #ef4444; /* 红色错误提示 */
}
#teamModal #roomCodeInput.is-invalid {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239,68,68,0.2);
}
/* --- Toast 浮窗 --- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(86px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: rgba(0,0,0,0.78);
  color: #fff;
  padding: 10px 14px;
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.35);
  font-size: 14px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 200ms ease, transform 200ms ease;
  z-index: 100; /* 高于 .fab-group(z=25) 与 .modal(z=30) */
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --- Action Bar（翻页后提示） --- */
/* removed action-bar */

/* --- 底部操作栏 --- */
.bottombar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: transparent;
}
.bottombar .controls {
  justify-content: center;
  align-items: center;
  gap: 14px;
  background: rgba(13,17,23,0.85);
  backdrop-filter: saturate(180%) blur(8px);
  border: 1px solid #30363d;
  border-radius: 16px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.35);
  padding: 10px 12px;
}
.bottombar button { min-width: 120px; }

/* 目标分组布局（默认横向） */
.target.group { display: flex; align-items: center; gap: 10px; }
.target.group .field { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.target.group .field.small input { width: 84px; }
.target.group .field.inline { gap: 6px; }
.custom { display: flex; align-items: center; gap: 10px; }

/* 在设置弹窗内，改为纵向堆叠，避免拥挤 */
.modal .target.group { flex-direction: column; align-items: stretch; gap: 14px; width: 100%; background: transparent; }
.modal .target.group .field { justify-content: flex-start; }
.modal .custom {
  display: grid;
  grid-template-columns: 72px 1fr; /* 左：标签 右：输入 */
  gap: 10px 12px;
  align-items: center;
}
.modal .target-row { display: grid; grid-template-columns: 72px 1fr; gap: 10px 12px; align-items: center; width: 100%; background: transparent; border: 0; padding: 0; border-radius: 0; }
.modal .target-row > label { grid-column: 1 / 2; margin: 0; padding: 0; }
.modal .target-row > select { grid-column: 2 / 3; width: 100%; display: block; }
.modal .target-row .field.lbl { background: transparent; border: 0; }
.modal .switch-row { display: grid; grid-template-columns: 72px 1fr; gap: 10px 12px; align-items: center; }
.modal .target-row .field.lbl,
.modal .custom .field.lbl { width: 72px; display: flex; align-items: center; justify-content: flex-end; margin: 0; padding: 0; white-space: nowrap; color: var(--muted); }
.modal select, .modal input[type="number"] { height: 40px; }
.modal select, .modal input[type="number"] { width: 100%; box-sizing: border-box; }
.modal .custom .field.lbl { justify-content: flex-end; color: var(--muted); }
.modal .custom input[type="number"] { width: 100%; background-image: none; padding: 10px 12px; }
.modal .target.group .field.small input { width: 100%; }
.modal .target.group .field.inline { justify-content: flex-start; }
.modal .custom .full { grid-column: 2 / -1; display: flex; align-items: center; gap: 8px; margin: 0; padding: 0; }
.modal .custom .full input[type="checkbox"] { margin: 0; }
@media (max-width: 420px) {
  .modal .custom { grid-template-columns: 64px 1fr; }
}

/* iOS风格开关 */
.switch { position: relative; display: inline-block; width: 52px; height: 30px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0;
  background: #3a3f45; border-radius: 999px; transition: background 0.2s ease;
  border: 1px solid #30363d;
}
.slider:before {
  content: ""; position: absolute; left: 4px; top: 3px; width: 24px; height: 24px;
  background: #fff; border-radius: 50%; transition: transform 0.2s ease;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.switch input:checked + .slider { background: #2ea043; border-color: #2ea043; }
.switch input:checked + .slider:before { transform: translateX(22px); }

/* --- 设置弹窗（底部抽屉） --- */
.modal { position: fixed; inset: 0; z-index: 30; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(2px);
}
.modal-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: rgba(13,17,23,0.98);
  border-top-left-radius: 18px; border-top-right-radius: 18px;
  box-shadow: 0 -10px 30px rgba(0,0,0,0.45);
  padding: 14px 16px 18px;
  max-width: 560px; /* 大屏时居中更窄 */
  margin: 0 auto;
  transform: translateY(100%);
  transition: transform 220ms ease;
  max-height: 80vh; overflow: auto;
}
.modal.show .modal-panel { transform: translateY(0); }
.modal-header { display: flex; align-items: center; justify-content: space-between; }
.modal-header h2 { font-size: 18px; margin: 0; }
.modal-header .icon { border-radius: 10px; padding: 8px 10px; }
.modal-body { margin-top: 8px; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 12px; }

/* --- 小屏优化 --- */
@media (max-width: 640px) {
  .topbar { padding: 6px 12px; }
  .controls button { padding: 12px 14px; }
}

/* --- 聊天面板 --- */
.chat-notice {
  background: rgba(13,17,23,0.6);
  border: 1px solid #30363d;
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--muted, #8b949e);
  margin-bottom: 10px;
}
.chat-wrap { display: grid; grid-template-rows: 1fr auto; gap: 10px; min-height: 260px; }
.chat-list {
  border: 1px solid #30363d; border-radius: 12px; padding: 10px; background: rgba(13,17,23,0.6);
  max-height: 42vh; overflow: auto;
  display: flex; flex-direction: column; gap: 8px;
}
.chat-msg { display: grid; grid-template-columns: 1fr; gap: 4px; }
.chat-meta { font-size: 12px; color: var(--muted, #8b949e); }
.chat-bubble { display: inline-block; padding: 10px 12px; border-radius: 12px; background: #1f2937; border: 1px solid #30363d; max-width: 86%; word-break: break-word; white-space: pre-wrap; font-size: 14px; line-height: 1.55; }
.chat-self { align-items: flex-end; }
.chat-self .chat-bubble { background: #0b5; border-color: #0b5; color: #fff; }
.chat-others { align-items: flex-start; }
.chat-compose { display: grid; grid-template-rows: auto auto auto; gap: 8px; }
.nick-row { display: grid; grid-template-columns: 64px 1fr auto; gap: 10px 12px; align-items: center; }
#chatNick { height: 36px; }
#chatInput { width: 100%; box-sizing: border-box; padding: 10px 12px; border-radius: 10px; border: 1px solid #30363d; background: rgba(13,17,23,0.6); color: #c9d1d9; resize: none; }
.compose-actions { display: flex; gap: 10px; justify-content: space-between; align-items: center; }
.nick-inline { display: flex; align-items: center; gap: 10px; }
.nick-inline .field.lbl { width: auto; color: var(--muted); }
.actions-right { display: flex; align-items: center; gap: 10px; position: relative; }

/* 按钮旁浮动提示（非气泡，仅文字） */
.hint-float {
  position: absolute;
  right: 100%;
  margin-right: 8px;
  top: 50%;
  transform: translateY(-50%) translateY(4px);
  opacity: 0;
  transition: opacity .18s ease, transform .18s ease;
  pointer-events: none;
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--muted, #cbd5e1);
  font-size: 12px;
  white-space: nowrap;
  z-index: 31; /* above modal content */
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.hint-float.show { opacity: 1; transform: translateY(-50%) translateY(0); }
.hint-float .icon { filter: saturate(120%); }
.hint-float.warn { color: #f87171; }

/* --- 直播风格淡淡聊天浮层 --- */
.chat-overlay {
  position: fixed;
  left: 14px;
  bottom: calc(90px + env(safe-area-inset-bottom));
  z-index: 15; /* 低于 toast(100) 和 modal(30)，高于场地 */
  max-width: min(60vw, 480px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none; /* 不挡交互 */
}
.chat-overlay .item {
  font-size: 13px;
  line-height: 1.4;
  color: #e5e7eb;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  backdrop-filter: none;
}
.chat-overlay .name { color: #93c5fd; margin-right: 6px; }
.chat-overlay .name.self { color: #86efac; }
.chat-overlay .text { color: #e5e7eb; word-break: break-word; white-space: pre-wrap; }

/* 字号可调 */
.chat-overlay.font-sm .item { font-size: 12px; }
.chat-overlay.font-md .item { font-size: 13px; }
.chat-overlay.font-lg .item { font-size: 15px; }

/* 可隐藏 */
.chat-overlay.hidden { display: none; }
.chat-overlay.inactive { display: none; }

@media (max-width: 520px) {
  .chat-overlay { max-width: 84vw; left: 10px; bottom: calc(84px + env(safe-area-inset-bottom)); }
  .chat-overlay .item { font-size: 12px; }
}
