/* ═══════════ 全局主题 / 大厅 / 房间 / 弹层 / 聊天 ═══════════ */
:root {
  --bg: #171019;
  --bg2: #221620;
  --panel: #2b1d26;
  --panel-2: #362431;
  --gold: #d9a55a;
  --gold-bright: #f3c98a;
  --red: #a8231f;
  --red-bright: #c92b26;
  --text: #f3e9dc;
  --text-dim: #b9a998;
  --green: #1f6b46;
  --line: rgba(217, 165, 90, 0.35);
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  --radius: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(1200px 800px at 50% -10%, #3a2233 0%, var(--bg) 60%),
    var(--bg);
  color: var(--text);
  font-family: 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', sans-serif;
  user-select: none;
}

#app { height: 100%; position: relative; }

.screen {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}
.screen.active { display: flex; }

.panel {
  background: linear-gradient(180deg, var(--panel) 0%, #241a21 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  padding: 22px 26px;
}

/* ── 按钮 ── */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-2), #2a1c24);
  color: var(--text);
  padding: 9px 18px;
  border-radius: 9px;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.btn:hover { filter: brightness(1.15); box-shadow: 0 0 14px rgba(217, 165, 90, 0.25); }
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; filter: grayscale(0.6); }
.btn.primary {
  background: linear-gradient(180deg, #c92b26, #8e1512);
  border-color: rgba(255, 160, 120, 0.5);
  font-weight: bold;
}
.btn.gold {
  background: linear-gradient(180deg, #e8b46b, #b07833);
  border-color: rgba(255, 230, 170, 0.55);
  color: #2c1a08;
  font-weight: bold;
}
.btn.ghost { background: transparent; }
.btn.danger { background: linear-gradient(180deg, #6e2020, #4a1010); border-color: rgba(255, 120, 120, 0.4); }
.btn.small { padding: 5px 12px; font-size: 13px; }
.btn.big { padding: 13px 34px; font-size: 18px; }
.hidden { display: none !important; }

input, select {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 15px;
  outline: none;
}
input:focus, select:focus { border-color: var(--gold); }
select option { background: var(--panel); }

/* ── 大厅 ── */
.lobby-panel { width: min(560px, 94vw); max-height: 94vh; overflow-y: auto; }
.logo {
  text-align: center;
  font-size: 34px;
  font-weight: bold;
  letter-spacing: 6px;
  margin-bottom: 18px;
  color: var(--gold-bright);
  text-shadow: 0 2px 18px rgba(217, 165, 90, 0.4);
  font-family: 'KaiTi', 'STKaiti', serif;
}
.logo-red { color: #ff5a4e; text-shadow: 0 0 20px rgba(255, 90, 78, 0.55); }
.lobby-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.lobby-row label { color: var(--text-dim); white-space: nowrap; }
.lobby-row input { flex: 1; }
.lobby-actions { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.create-box, .join-box, .match-box { display: flex; gap: 8px; align-items: center; }
.create-box select, .match-box select { width: 96px; }
.join-box input { width: 110px; }
.rooms-box { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 12px; }
.rooms-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: rgba(0, 0, 0, 0.25); color: var(--text-dim); font-size: 13px; }
.rooms-list { max-height: 180px; overflow-y: auto; }
.room-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 14px; cursor: pointer;
}
.room-item:hover { background: rgba(217, 165, 90, 0.08); }
.room-item .rid { color: var(--gold-bright); font-weight: bold; letter-spacing: 1px; }
.room-item .cnt { margin-left: auto; color: var(--text-dim); }
.room-item .phase { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: rgba(31, 107, 70, 0.35); }
.room-item .phase.playing { background: rgba(168, 35, 31, 0.35); }
.empty-hint { padding: 18px; text-align: center; color: var(--text-dim); font-size: 13px; }
.lobby-foot { display: flex; justify-content: space-between; align-items: center; color: var(--text-dim); font-size: 13px; }
.conn-status { padding: 3px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.06); }
.conn-status.ok { color: #7fe0a8; }
.conn-status.bad { color: #ff8a80; }

/* ── 房间 ── */
.room-panel { width: min(760px, 96vw); max-height: 96vh; overflow-y: auto; }
.room-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.room-info { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-dim); flex-wrap: wrap; }
.room-info b { color: var(--gold-bright); letter-spacing: 1px; }
.room-head-btns { display: flex; gap: 8px; }
.room-seats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 12px; }
.seat-card {
  display: flex; align-items: center; gap: 12px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  padding: 12px 14px;
  min-height: 74px;
  transition: border-color 0.2s;
}
.seat-card.me { border-color: var(--gold); }
.seat-card.empty { justify-content: center; color: var(--text-dim); border-style: dashed; }
.seat-avatar {
  width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 21px; font-weight: bold; color: #fff;
  background: linear-gradient(135deg, #8e5a3a, #5a2d1a);
  border: 2px solid var(--gold);
  flex-shrink: 0;
}
.seat-info { flex: 1; min-width: 0; }
.seat-name { font-size: 15px; font-weight: bold; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-sub { font-size: 12px; color: var(--text-dim); margin-top: 3px; }
.seat-badges { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 8px; }
.badge.host { background: rgba(217, 165, 90, 0.2); color: var(--gold-bright); }
.badge.ready { background: rgba(31, 107, 70, 0.4); color: #7fe0a8; }
.badge.offline { background: rgba(120, 120, 120, 0.3); color: #ccc; }
.badge.trustee { background: rgba(168, 35, 31, 0.35); color: #ff9a8f; }
.badge.dealer { background: rgba(255, 80, 60, 0.3); color: #ffb0a5; }
.room-specs { color: var(--text-dim); font-size: 12px; margin-bottom: 8px; }
.host-rules { border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.hr-title { font-size: 13px; color: var(--gold); margin-bottom: 8px; }
.hr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 10px; }
.hr-grid label { font-size: 13px; color: var(--text-dim); display: flex; flex-direction: column; gap: 4px; }
.rules-summary { font-size: 13px; color: var(--text-dim); line-height: 1.9; margin-bottom: 12px; }
.rules-summary b { color: var(--gold-bright); font-weight: normal; }
.room-actions { display: flex; gap: 14px; justify-content: center; padding-top: 6px; }

/* ── 弹层 ── */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(10, 6, 10, 0.72);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }
.overlay .panel { animation: popIn 0.22s cubic-bezier(0.34, 1.56, 0.64, 1); max-height: 92vh; overflow-y: auto; }
.ov-title { font-size: 20px; font-weight: bold; color: var(--gold-bright); margin-bottom: 14px; text-align: center; }
.ov-btns { display: flex; gap: 12px; justify-content: center; margin-top: 16px; }
.set-grid { display: flex; flex-direction: column; gap: 12px; min-width: 260px; }
.set-grid .name-row { display: flex; gap: 8px; align-items: center; }
.set-grid .name-row input {
  flex: 1; min-width: 0; width: auto;
  background: var(--panel-2, rgba(255,255,255,0.06));
  border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); font-size: 14px; padding: 6px 10px; outline: none;
}
.set-grid .name-row input:focus { border-color: var(--gold); }
.set-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--text-dim); }
.set-grid label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.rules-body { max-width: 520px; font-size: 14px; line-height: 2; color: var(--text-dim); }
.rules-body h4 { color: var(--gold-bright); margin: 10px 0 4px; font-size: 15px; }
.rules-body b { color: var(--text); font-weight: normal; }
.rotate-panel { text-align: center; }
.rotate-icon { font-size: 44px; animation: rot 1.6s ease-in-out infinite; display: inline-block; }
@keyframes rot { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-90deg); } }
.rotate-text { margin: 12px 0 18px; color: var(--text-dim); }

/* ── 聊天面板 ── */
.chat-panel {
  position: fixed; top: 12px; right: 12px; bottom: 12px;
  width: 264px; z-index: 40;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, rgba(43, 29, 38, 0.96), rgba(28, 18, 26, 0.96));
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  transition: transform 0.25s ease, opacity 0.25s ease;
}
.chat-panel.collapsed { transform: translateX(calc(100% - 38px)); opacity: 0.85; }
.chat-panel.collapsed .chat-body { visibility: hidden; }
.chat-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 8px 8px 12px; font-size: 14px; font-weight: bold;
  color: var(--gold-bright);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.chat-messages { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.chat-msg { display: flex; flex-direction: column; gap: 2px; animation: msgIn 0.2s ease; }
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.chat-msg .meta { color: var(--text-dim); font-size: 11px; }
.chat-msg .meta .nick { color: var(--gold); }
.chat-msg .bubble {
  background: rgba(255, 255, 255, 0.07);
  border-radius: 9px;
  padding: 6px 10px;
  word-break: break-all;
  max-width: 100%;
}
.chat-msg.self .bubble { background: rgba(31, 107, 70, 0.3); }
.chat-msg.sys .bubble { background: rgba(217, 165, 90, 0.14); color: var(--gold-bright); font-size: 12px; }
.chat-chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 6px 10px; border-top: 1px solid rgba(255, 255, 255, 0.05); }
.chat-chips .chip { font-size: 11px; padding: 3px 9px; border-radius: 10px; background: rgba(255, 255, 255, 0.08); cursor: pointer; }
.chat-chips .chip:hover { background: rgba(217, 165, 90, 0.25); }
.chat-rows { display: flex; gap: 6px; padding: 8px 10px 0; }
.chat-quick, .chat-emojis { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chat-quick::-webkit-scrollbar, .chat-emojis::-webkit-scrollbar { display: none; }
.chat-quick button { flex-shrink: 0; font-size: 11px; padding: 4px 8px; border-radius: 8px; background: rgba(255, 255, 255, 0.07); border: 1px solid transparent; color: var(--text-dim); cursor: pointer; }
.chat-quick button:hover { color: var(--text); border-color: var(--line); }
.chat-emojis button { flex-shrink: 0; font-size: 16px; background: none; border: none; cursor: pointer; padding: 2px; }
.chat-input-row { display: flex; gap: 6px; padding: 8px 10px 10px; }
.chat-input-row input { flex: 1; min-width: 0; font-size: 13px; padding: 7px 10px; }

/* ── Toast / 弹窗 ── */
#toasts {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%);
  z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: rgba(30, 20, 28, 0.95);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px 20px; border-radius: 10px; font-size: 14px;
  box-shadow: var(--shadow);
  animation: toastIn 0.25s ease;
  max-width: 80vw;
}
.toast.warn { border-color: rgba(255, 160, 80, 0.6); color: #ffd9a0; }
.toast.error { border-color: rgba(255, 100, 90, 0.6); color: #ffb3aa; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.toast.out { transition: opacity 0.3s; opacity: 0; }

#modal-root .overlay { z-index: 90; }
.modal-panel { min-width: 300px; text-align: center; }
.modal-text { font-size: 15px; line-height: 1.8; margin-bottom: 16px; }
.modal-panel .m-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); font-size: 15px; padding: 8px 12px; outline: none;
  box-sizing: border-box;
}
.modal-panel .m-input:focus { border-color: var(--gold); }
.boot-status { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); color: var(--text-dim); font-size: 13px; z-index: 100; }
.boot-status.error { color: #ff8a80; }
