/* ==========================================================
   五子棋在线游戏 - 主样式表
   深色主题: bg #0f0f1a, 面板 #1a1a2e, 强调 #667eea, 文字 #e0e0e0
   ========================================================== */

/* === Reset === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: #e0e0e0;
  background: #0f0f1a;
  line-height: 1.5;
  overflow-x: hidden;
}
a { color: #667eea; text-decoration: none; }
a:hover { color: #8b9cf7; }
ul, ol { list-style: none; }
img { max-width: 100%; height: auto; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* === Layout === */
#app { min-height: 100vh; }

/* === Header === */
#main-header {
  background: #1a1a2e;
  border-bottom: 1px solid #2a2a4a;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 200;
}
.header-left { display: flex; align-items: center; gap: 14px; }
.header-left h2 {
  font-size: 18px;
  background: linear-gradient(135deg, #667eea, #e91e63);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
}
.online-badge {
  background: rgba(39,174,96,.15);
  color: #27ae60;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
}
#main-nav { display: flex; gap: 4px; }
.nav-link {
  color: #999;
  padding: 8px 16px;
  border-radius: 8px;
  transition: all .2s;
  cursor: pointer;
  font-size: 13px;
  display: inline-block;
}
.nav-link:hover { color: #e0e0e0; background: rgba(102,126,234,.1); }
.nav-link.active { color: #fff; background: rgba(102,126,234,.2); font-weight: 600; }
.header-right { display: flex; align-items: center; gap: 12px; }
#current-user {
  color: #ccc;
  font-size: 13px;
  background: rgba(102,126,234,.1);
  padding: 4px 12px;
  border-radius: 16px;
}

/* === Mobile Bottom Nav === */
#mobile-nav { display: none; }
@media (max-width: 768px) {
  #mobile-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed; bottom: 0; left: 0; right: 0;
    background: #1a1a2e; border-top: 1px solid #2a2a4a;
    padding: 8px 8px; z-index: 100;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
  #mobile-nav a {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 4px; color: #999; font-size: 13px; padding: 10px 8px; border-radius: 10px;
    min-height: 52px;
  }
  #mobile-nav a.active { color: #667eea; }
  #mobile-nav a:active { background: rgba(102, 126, 234, 0.15); }
  #app { padding-bottom: 72px; }
  #main-nav { display: none; }
  #main-header { padding: 8px 12px; height: 48px; }
  .header-left h2 { font-size: 15px; }
}

/* === Page Views === */
.page-view { display: none; padding: 24px; max-width: 1100px; margin: 0 auto; }
.page-view.active { display: block; }
@media (max-width: 768px) {
  .page-view { padding: 16px 12px; }
  #room-page.active {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 92px);
    overflow: hidden;
  }
  body.in-room #room-page.active {
    height: calc(100vh - 32px);
  }
  #room-page.active .room-layout {
    flex: 1;
    min-height: 0;
  }
}
body.in-room #mobile-nav {
  display: none;
}

/* === Page Titles === */
.page-title {
  font-size: 22px;
  color: #fff;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid #2a2a4a;
}

/* === Buttons === */
.btn-primary {
  display: inline-block;
  padding: 10px 22px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  box-shadow: 0 2px 8px rgba(102,126,234,.25);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(102,126,234,.4); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-secondary {
  display: inline-block;
  padding: 8px 18px;
  border: none;
  border-radius: 8px;
  background: #2a2a4a;
  color: #ccc;
  font-size: 13px;
  cursor: pointer;
  transition: all .2s;
  border: 1px solid #3a3a5a;
}
.btn-secondary:hover { background: #3a3a5a; border-color: #667eea; }

.btn-danger {
  display: inline-block;
  padding: 10px 22px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  box-shadow: 0 2px 8px rgba(231,76,60,.25);
}
.btn-danger:hover { box-shadow: 0 4px 16px rgba(231,76,60,.4); }

.btn-small {
  padding: 5px 12px;
  font-size: 12px;
  border-radius: 6px;
  background: #2a2a4a;
  color: #ccc;
  border: 1px solid #3a3a5a;
  cursor: pointer;
  transition: all .15s;
}
.btn-small:hover { background: #3a3a5a; border-color: #667eea; }

button:disabled { opacity: .5; cursor: not-allowed; }

/* === Form Inputs === */
input[type="text"], input[type="password"] {
  width: 100%;
  padding: 12px 16px;
  background: #0f0f1a;
  border: 1px solid #3a3a5a;
  border-radius: 10px;
  color: #e0e0e0;
  font-size: 14px;
  outline: none;
  transition: all .2s;
}
input[type="text"]:focus, input[type="password"]:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102,126,234,.15);
}
input::placeholder { color: #555; }

/* === Beautified Search/Create Inputs (好友页搜索/创建群) === */
/* 群组搜索、添加好友搜索、创建群聊 */
#search-group-input,
#search-friend-input,
#new-group-name-input {
  width: 100%;
  padding: 12px 18px 12px 42px;
  background-color: #14142a !important;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667eea' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>");
  background-repeat: no-repeat;
  background-position: 14px center;
  background-size: 16px 16px;
  border: 1px solid #3a3a5a;
  border-radius: 24px;
  color: #e0e0e0 !important;
  font-size: 14px;
  outline: none;
  transition: all .2s;
  box-sizing: border-box;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.3);
  -webkit-appearance: none;
  appearance: none;
}
#new-group-name-input {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667eea' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2'/><circle cx='9' cy='7' r='4'/><path d='M23 21v-2a4 4 0 0 0-3-3.87'/><path d='M16 3.13a4 4 0 0 1 0 7.75'/></svg>");
}
#search-group-input::placeholder,
#search-friend-input::placeholder,
#new-group-name-input::placeholder {
  color: #6a6a85;
  font-size: 13px;
}
#search-group-input:hover,
#search-friend-input:hover,
#new-group-name-input:hover {
  border-color: #4a4a6a;
  background-color: #1a1a35 !important;
}
#search-group-input:focus,
#search-friend-input:focus,
#new-group-name-input:focus {
  border-color: #667eea;
  background-color: #1a1a35 !important;
  box-shadow: 0 0 0 3px rgba(102,126,234,.2), inset 0 1px 2px rgba(0,0,0,.3);
}

/* === Avatar === */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  background: linear-gradient(135deg, #667eea, #764ba2);
}
.avatar.small { width: 28px; height: 28px; font-size: 11px; }
.avatar.large { width: 64px; height: 64px; font-size: 24px; }

/* === Lobby === */
.lobby-actions { display: flex; gap: 10px; margin-bottom: 24px; flex-wrap: wrap; }
#rooms-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
@media (max-width: 768px) {
  #rooms-list { grid-template-columns: 1fr; }
}

.room-card {
  background: #1a1a2e;
  border: 1px solid #2a2a4a;
  border-radius: 12px;
  padding: 18px;
  cursor: pointer;
  transition: all .25s;
}
.room-card:hover {
  border-color: #667eea;
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102,126,234,.15);
}
.room-name { font-size: 15px; font-weight: 600; color: #fff; margin-bottom: 8px; }
.room-meta { font-size: 12px; color: #888; display: flex; gap: 14px; flex-wrap: wrap; }
.room-status { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.status-waiting { background: rgba(39,174,96,.15); color: #27ae60; }
.status-playing { background: rgba(102,126,234,.15); color: #667eea; }

/* === Modal === */
.modal {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.65);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}
.modal.show { display: flex; }
.modal-content {
  background: #1a1a2e;
  border-radius: 14px;
  padding: 28px;
  width: 400px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  border: 1px solid #2a2a4a;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border: none;
  background: rgba(255,255,255,0.1);
  border-radius: 50%;
  color: #888;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.modal-close:hover {
  background: rgba(255,255,255,0.2);
  color: #fff;
}
.modal-content h3 { font-size: 18px; color: #fff; margin-bottom: 18px; }
.modal-content input { margin-bottom: 10px; }
.modal-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
@media (max-width: 768px) { .modal-content { width: 92%; padding: 20px; } }

/* === User Info Modal === */
.user-info-content {
  text-align: center;
}
.user-info-avatar-wrap {
  margin-bottom: 16px;
}
.user-info-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #667eea;
}
.user-info-avatar-text {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  font-size: 32px;
  font-weight: 700;
  border: 3px solid #667eea;
}
.user-info-name {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
}
.user-info-id {
  font-size: 14px;
  color: #888;
  margin-bottom: 24px;
  font-family: monospace;
}
.user-info-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.user-info-actions .btn {
  padding: 10px 24px;
  font-size: 14px;
}
.user-info-rank {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
}
.rank-icon-sm {
  width: 24px;
  height: 24px;
}
.rank-name {
  font-size: 16px;
  font-weight: 600;
}
.user-info-stats {
  margin-bottom: 20px;
}
.user-info-loading {
  color: #888;
  font-size: 14px;
  padding: 10px;
}
.user-info-error {
  color: #ff6b6b;
  font-size: 14px;
  padding: 10px;
}
.user-info-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 12px;
}
.stat-item {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 10px 8px;
}
.stat-label {
  display: block;
  font-size: 12px;
  color: #888;
  margin-bottom: 4px;
}
.stat-value {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}
.stat-value.win {
  color: #10b981;
}
.stat-value.loss {
  color: #ef4444;
}
.stat-value.draw {
  color: #f59e0b;
}

/* === Table === */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: auto; }
.data-table th, .data-table td {
  padding: 12px 14px; text-align: left; border-bottom: 1px solid #2a2a4a;
  white-space: nowrap;
}
.data-table th { color: #888; font-weight: 600; font-size: 12px; background: #14142a; }
.data-table tbody tr:hover { background: rgba(102,126,234,.04); }
.table-wrap { width: 100%; overflow-x: auto; border-radius: 10px; border: 1px solid #2a2a4a; }

@media (max-width: 768px) {
  .table-wrap {
    -webkit-overflow-scrolling: touch;
  }
  .data-table {
    font-size: 12px;
    min-width: 500px;
  }
  .data-table th, .data-table td {
    padding: 8px 10px;
  }
}

/* === Toast === */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 20px; border-radius: 8px; font-size: 14px; color: #fff;
  animation: toastIn .3s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
  max-width: 360px;
}
.toast.success { background: #27ae60; }
.toast.error { background: #e74c3c; }
.toast.info { background: #667eea; }
.toast.warning { background: #f39c12; }
@keyframes toastIn { from { opacity:0; transform:translateX(40px); } to { opacity:1; transform:translateX(0); } }
@keyframes toastOut { from { opacity:1; transform:translateX(0); } to { opacity:0; transform:translateX(40px); } }
@media (max-width: 768px) {
  .toast-container { top: auto; bottom: 80px; left: 10px; right: 10px; align-items: center; }
  .toast { max-width: 100%; font-size: 13px; }
}

/* === Room === */
.room-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 16px;
  padding: 8px 0; border-bottom: 1px solid #2a2a4a;
  flex-shrink: 0;
  flex-wrap: wrap;
}
#room-name-display {
  font-size: 17px; font-weight: 600; color: #fff; flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
.room-header-actions {
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
}
.room-id { flex-shrink: 0; }

@media (max-width: 768px) {
  .room-header {
    gap: 6px;
    padding: 6px 0;
    margin-bottom: 10px;
  }
  #room-name-display { font-size: 14px; }
  .room-id { font-size: 10px; }
  .room-header .btn-secondary,
  .room-header .btn-small {
    padding: 5px 8px;
    font-size: 12px;
    border-radius: 6px;
  }
  .room-header-actions { gap: 6px; }
}

@media (max-width: 480px) {
  .room-header {
    gap: 4px;
  }
  .room-header .btn-secondary,
  .room-header .btn-small {
    padding: 4px 6px;
    font-size: 11px;
    border-radius: 5px;
  }
  #room-name-display { font-size: 13px; }
}

.room-layout {
  display: flex; flex-direction: column;
  gap: 16px;
  flex: 1;
  min-height: 0;
}

.room-seats-panel {
  background: #1a1a2e;
  border-radius: 12px;
  padding: 16px;
  border: 1px solid #2a2a4a;
  display: flex;
  flex-direction: column;
}
.seats-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-shrink: 0;
}
.room-seats-panel h4 { font-size: 14px; color: #fff; margin-bottom: 0; flex-shrink: 0; }
.room-seats-panel .btn-primary,
.room-seats-panel .btn-secondary,
.room-seats-panel .btn-danger {
  margin-top: 8px; width: 100%;
}
.game-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.game-controls .btn-secondary,
.game-controls .btn-danger {
  margin-top: 8px; width: 100%;
}
.room-game-panel {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.room-chat-panel {
  background: #1a1a2e;
  border-radius: 12px;
  padding: 16px;
  border: 1px solid #2a2a4a;
  display: flex; flex-direction: column;
  min-height: 220px;
  flex: 1;
}
.chat-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  flex-shrink: 0;
}
.room-chat-panel h4 { font-size: 14px; color: #fff; margin-bottom: 0; flex-shrink: 0; }
.chat-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}
#room-volume-slider {
  width: 80px;
  accent-color: #667eea;
  cursor: pointer;
}
@media (max-width: 768px) {
  #room-volume-slider { width: 60px; }
}
.game-info-bar { display: flex; justify-content: space-between; width: 100%; font-size: 14px; }

@media (max-width: 768px) {
  /* 房间布局 - 紧凑排列 */
  .room-layout {
    gap: 6px;
    min-height: 0;
  }
  /* 座位面板 - 让所有座位都能显示，麦下区域单独滚动 */
  .room-seats-panel {
    padding: 6px;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    flex-shrink: 0;
  }
  .room-seats-panel h4 { margin-bottom: 6px; }
  /* 座位网格改为3列，容纳更多座位 */
  #seats-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  .seat-slot {
    gap: 2px;
    padding: 3px;
  }
  .seat-avatar-circle {
    width: 40px;
    height: 40px;
    border-width: 1px;
  }
  .avatar-initial { font-size: 16px; }
  .seat-label { font-size: 9px; }
  .mic-btn { width: 14px; height: 14px; font-size: 7px; border-width: 1px; }
  .mini-btn { width: 14px; height: 14px; font-size: 8px; border: none; }
  .seat-info {
    max-width: none;
    gap: 2px;
    flex-wrap: wrap;
    justify-content: center;
  }
  .seat-name { font-size: 10px; max-width: none; }
  .seat-status { font-size: 9px; }
  .badge { font-size: 8px; padding: 1px 3px; border-radius: 2px; }
  /* 房主位不再跨整行，改为正常网格项 */
  .seat-slot.host-seat {
    grid-column: auto;
    justify-self: auto;
  }
  /* 麦下区域 - 手机端更小高度限制 */
  .spectators-panel {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #2a2a4a;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
  }
  .spectators-panel.expanded {
    max-height: 100px;
  }
  .spectators-header h4 { font-size: 12px; }
  .spectators-count { font-size: 10px; }
  .spectators-list {
    max-height: 60px;
  }
  /* 游戏面板 - 棋盘保持正方形，自适应但不变形 */
  #game-panel.show {
    width: 100%;
    flex-shrink: 0;
  }
  #game-board {
    width: 100% !important;
    height: auto !important;
    max-width: calc(100vw - 24px) !important;
    aspect-ratio: 1 / 1;
  }
  /* 聊天面板 - 固定在底部 */
  .room-chat-panel {
    padding: 6px;
    min-height: 100px;
    max-height: 25vh;
    flex-shrink: 0;
  }
}
#game-status { color: #667eea; font-weight: 500; }
#turn-timer { color: #e67e22; }

/* === Seats === */
#seats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 768px) {
  #seats-grid { gap: 4px; }
  .seat-slot { gap: 2px; padding: 2px; }
  .seat-avatar-circle { width: 36px; height: 36px; border-width: 1px; }
  .avatar-initial { font-size: 14px; }
  .seat-label { font-size: 8px; }
  .mic-btn { width: 12px; height: 12px; font-size: 6px; border-width: 1px; }
  .seat-info { max-width: 46px; gap: 1px; }
  .seat-name { font-size: 9px; max-width: 28px; }
  .seat-status { font-size: 8px; }
  .badge { font-size: 7px; padding: 0 2px; border-radius: 2px; }
  .mini-btn { width: 12px; height: 12px; font-size: 7px; border: none; }
}

.seat-slot {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 6px;
  cursor: default;
  transition: transform .15s;
}
.seat-slot.seat-empty { opacity: .65; }
.seat-slot.seat-clickable { cursor: pointer; }
.seat-slot.seat-clickable:hover { opacity: 1; }
.seat-slot.seat-clickable:hover .seat-avatar-circle { border-color: #667eea; }
.seat-slot.seat-occupied .seat-avatar-circle { border-color: #667eea; }
.seat-slot.seat-me .seat-avatar-circle { border-color: #27ae60 !important; }

.seat-slot.host-seat {
  grid-column: 1 / -1;
  justify-self: center;
}

.seat-avatar-circle {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: #14142a;
  border: 2px solid #2a2a4a;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.seat-avatar-img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.avatar-initial {
  font-size: 22px; font-weight: 700; color: #e0e0e0;
  user-select: none;
}
.seat-label {
  font-size: 11px; color: #888; font-weight: 600;
  user-select: none;
}

.seat-info {
  display: flex; align-items: center; justify-content: center;
  gap: 3px;
  max-width: 100px;
}
.seat-name {
  font-size: 12px; color: #e0e0e0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 60px;
}
.seat-status { font-size: 11px; color: #666; }

.mic-btn {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid #1a1a2e;
  background: rgba(39,174,96,.9);
  color: #fff;
  cursor: pointer;
  font-size: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
  transition: all .15s;
  flex-shrink: 0;
  vertical-align: middle;
}
.mic-btn:hover { transform: scale(1.08); }
.mic-btn.on { background: rgba(39,174,96,.9); }
.mic-btn.off { background: rgba(231,76,60,.9); }

.mini-btn {
  width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid #2a2a4a; background: transparent;
  color: #999; cursor: pointer; font-size: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0; transition: all .15s; flex-shrink: 0;
}
.mini-btn:hover { background: #2a2a4a; color: #fff; }
.speaker-btn.muted { background: rgba(231,76,60,.2); border-color: #e74c3c; color: #e74c3c; }
.kick-btn:hover { background: rgba(231,76,60,.2) !important; border-color: #e74c3c !important; color: #e74c3c !important; }
.admin-btn:hover { background: rgba(102,126,234,.2) !important; border-color: #667eea !important; color: #667eea !important; }

.badge { display: inline-block; font-size: 10px; padding: 1px 5px; border-radius: 4px; font-weight: 600; flex-shrink: 0; }
.badge-host { background: rgba(230,126,34,.2); color: #e67e22; }
.badge-admin { background: rgba(102,126,234,.2); color: #667eea; }

.spectator-notice {
  grid-column: 1 / -1;
  text-align: center; color: #e67e22; font-size: 12px;
  padding: 8px 16px; background: rgba(230,126,34,.08); border-radius: 8px; margin: 8px 0 0;
  width: 100%;
  box-sizing: border-box;
  white-space: nowrap;
}

/* === Board === */
#game-panel { display: none; }
#game-panel.show { display: flex; flex-direction: column; align-items: center; gap: 10px; }
#game-board { border-radius: 8px; box-shadow: 0 4px 20px rgba(0,0,0,.4); max-width: 100%; }
@media (max-width: 768px) { #game-board { max-width: 100% !important; height: auto !important; } }

/* === Chat === */
#chat-messages {
  flex: 1; overflow-y: auto; padding: 4px 0;
  display: flex; flex-direction: column; gap: 6px;
  min-height: 120px;
}
.chat-msg { font-size: 13px; line-height: 1.4; word-break: break-all; }
.chat-msg .msg-user { color: #667eea; font-weight: 600; }
.chat-msg .msg-time { color: #555; font-size: 10px; margin-left: 6px; }
.chat-msg .msg-text { color: #ccc; }
.chat-input-area {
  display: flex; gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #2a2a4a;
}
.chat-input-area input {
  flex: 1;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 20px;
  border: 1px solid #2a2a4a;
  background: #14142a;
  color: #e0e0e0;
  font-size: 14px;
  outline: none;
}
.chat-input-area input:focus { border-color: #667eea; }
.chat-input-area .btn-small {
  white-space: nowrap;
  min-height: 40px;
  border-radius: 20px;
  padding: 0 20px;
}
.chat-input-area .chat-tool-btn {
  width: 40px; min-width: 40px; height: 40px;
  border-radius: 50%;
  padding: 0; margin: 0;
}
@media (max-width: 768px) {
  .chat-input-area {
    margin-top: 8px;
    padding-top: 8px;
    gap: 6px;
  }
  .chat-input-area input {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 13px;
    border-radius: 16px;
  }
  .chat-input-area .btn-small {
    min-height: 32px;
    padding: 0 12px;
    font-size: 12px;
    border-radius: 16px;
  }
  .chat-input-area .chat-tool-btn {
    width: 32px; min-width: 32px; height: 32px;
    border-radius: 50%;
  }
  #chat-messages {
    min-height: 0;
    gap: 4px;
  }
  .chat-msg { font-size: 12px; line-height: 1.35; }
}

/* === Page Header with Back Button === */
.page-header-with-back {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}
.page-header-with-back .spacer { flex: 1; }

/* === Profile === */
.profile-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding: 24px;
  background: #1a1a2e;
  border-radius: 14px;
  border: 1px solid #2a2a4a;
}
.profile-header-info { 
  flex: none; 
  text-align: center;
}
.profile-header-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.profile-nickname {
  display: inline;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
}
.profile-username {
  display: block;
  font-size: 14px;
  color: #aaa;
  margin-top: 4px;
}
.profile-user-id {
  display: block;
  font-size: 14px;
  color: #667eea;
  margin-top: 4px;
  font-family: monospace;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dashed;
  text-underline-offset: 2px;
}
.profile-user-id:hover {
  color: #7c8eea;
  text-decoration-style: solid;
}
.profile-rank {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  margin-top: 4px;
  padding: 4px 10px;
  border-radius: 12px;
  background: rgba(102, 126, 234, 0.15);
  border: 1px solid rgba(102, 126, 234, 0.3);
}
.profile-history-btn {
  width: 100%;
  padding: 14px;
  font-size: 15px;
  margin-bottom: 20px;
}
.profile-info {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}
.profile-stat {
  background: #1a1a2e;
  border-radius: 12px;
  padding: 18px 12px;
  text-align: center;
  border: 1px solid #2a2a4a;
  transition: all .2s;
}
.profile-stat:hover { border-color: #667eea; transform: translateY(-2px); }
.stat-val { font-size: 24px; font-weight: 700; color: #667eea; }
.stat-label { font-size: 11px; color: #888; margin-top: 6px; }

.profile-edit {
  background: #1a1a2e;
  border-radius: 12px;
  padding: 20px;
  border: 1px solid #2a2a4a;
  max-width: 420px;
  margin-bottom: 16px;
}
.profile-edit h4 { font-size: 15px; color: #fff; margin-bottom: 14px; }
.profile-edit input { margin-bottom: 10px; }

.profile-logout { max-width: 420px; }
.profile-logout .btn-danger { width: 100%; }

@media (max-width: 768px) {
  .profile-header { flex-direction: column; text-align: center; padding: 16px; }
  .profile-info { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .profile-stat { padding: 14px 8px; }
  .stat-val { font-size: 20px; }
  .profile-edit, .profile-logout { max-width: 100%; }
  /* 历史战绩手机端适配 */
  #profile-history-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  #profile-history-wrap .data-table {
    font-size: 11px;
    table-layout: fixed;
    width: 100%;
    min-width: 0;
  }
  #profile-history-wrap .data-table th,
  #profile-history-wrap .data-table td {
    padding: 6px 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-all;
  }
  #profile-history-wrap .data-table th { font-size: 10px; }
  #profile-history-wrap .data-table th:nth-child(1),
  #profile-history-wrap .data-table td:nth-child(1) { width: 22%; }
  #profile-history-wrap .data-table th:nth-child(2),
  #profile-history-wrap .data-table td:nth-child(2) { width: 18%; }
  #profile-history-wrap .data-table th:nth-child(3),
  #profile-history-wrap .data-table td:nth-child(3) { width: 18%; }
  #profile-history-wrap .data-table th:nth-child(4),
  #profile-history-wrap .data-table td:nth-child(4) { width: 14%; }
  #profile-history-wrap .data-table th:nth-child(5),
  #profile-history-wrap .data-table td:nth-child(5) { width: 18%; }
  #profile-history-wrap .data-table th:nth-child(6),
  #profile-history-wrap .data-table td:nth-child(6) { width: 10%; }
  #profile-history-wrap .data-table td { font-size: 10px; line-height: 1.3; }
  #profile-history-wrap .btn-small { padding: 3px 6px; font-size: 10px; }
}

/* === Replay === */
.replay-btn { cursor: pointer; }
.replay-content { width: 640px; max-width: 90vw; }
#replay-canvas { display: block; margin: 0 auto; border-radius: 8px; max-width: 100%; }
.replay-controls { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 12px; }
.replay-controls span { font-size: 13px; color: #aaa; }
.replay-btns { display: flex; gap: 8px; margin-top: 4px; }
#close-replay { display: block; margin: 14px auto 0; }
@media (max-width: 768px) {
  .replay-btns .btn-small { padding: 4px 8px; font-size: 11px; min-width: 32px; }
  .replay-btns .btn-primary { padding: 5px 12px; font-size: 12px; }
  .replay-btns { gap: 6px; }
  #close-replay { min-width: 88px; padding: 6px 18px; font-size: 12px; }
}

/* === Empty State === */
.empty-state { text-align: center; padding: 40px 20px; color: #666; font-size: 14px; }

.spectators-panel {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #2a2a4a;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.spectators-panel.expanded {
  max-height: 300px;
}
.spectators-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.spectators-header h4 {
  font-size: 13px;
  color: #fff;
  margin: 0;
}
.spectators-count {
  font-size: 12px;
  color: #888;
}
.spectators-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-height: 120px;
  overflow-y: auto;
}
.spectators-empty {
  width: 100%;
  text-align: center;
  color: #666;
  font-size: 12px;
  padding: 10px;
}
.spectator-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  transition: all .15s;
  position: relative;
  min-width: 48px;
}
.spectator-item:hover {
  background: rgba(102,126,234,.1);
}
.spectator-item.muted {
  opacity: .6;
}
.spectator-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #14142a;
  border: 2px solid #2a2a4a;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.spectator-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.spectator-initial {
  font-size: 14px;
  font-weight: 700;
  color: #e0e0e0;
}
.spectator-name {
  font-size: 11px;
  color: #aaa;
  max-width: 48px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.spectator-muted {
  position: absolute;
  top: 0;
  right: 0;
  font-size: 10px;
}

.seat-avatar-circle.clickable {
  cursor: pointer;
}
.seat-avatar-circle.clickable:hover {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102,126,234,.2);
}

.user-action-menu {
  position: fixed;
  z-index: 1100;
  background: #1a1a2e;
  border: 1px solid #3a3a5a;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0,0,0,.5);
  min-width: 140px;
  padding: 6px 0;
  transform: translate(-50%, 0);
}
.user-action-title {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  border-bottom: 1px solid #2a2a4a;
  text-align: center;
}
.user-action-item {
  padding: 9px 14px;
  font-size: 13px;
  color: #e0e0e0;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.user-action-item:hover {
  background: rgba(102,126,234,.15);
  color: #fff;
}
.user-action-item.danger-item {
  color: #e74c3c;
}
.user-action-item.danger-item:hover {
  background: rgba(231,76,60,.15);
  color: #ff6b6b;
}

.muted-toggle-wrapper {
  position: relative;
  width: 44px;
  height: 24px;
  cursor: pointer;
}
.muted-toggle-wrapper input[type="checkbox"] {
  opacity: 0;
  position: absolute;
  width: 100%;
  height: 100%;
  cursor: pointer;
  z-index: 2;
}
.muted-toggle-slider {
  position: absolute;
  width: 100%;
  height: 100%;
  background: #3a3a5a;
  border-radius: 12px;
  transition: background .25s ease;
}
.muted-toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform .25s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,.2);
}
.muted-toggle-wrapper input[type="checkbox"]:checked + .muted-toggle-slider {
  background: #667eea;
}
.muted-toggle-wrapper input[type="checkbox"]:checked + .muted-toggle-slider::before {
  transform: translateX(20px);
}
.muted-toggle-wrapper input[type="checkbox"]:disabled + .muted-toggle-slider {
  background: #2a2a4a;
  cursor: not-allowed;
}
.muted-toggle-wrapper input[type="checkbox"]:disabled + .muted-toggle-slider::before {
  background: #666;
}
.user-action-item.disabled {
  color: #666;
  cursor: default;
  pointer-events: none;
}
.spec-picker-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  font-size: 11px;
}
.user-action-item.disabled {
  color: #666;
  cursor: default;
}
.user-action-item.disabled:hover {
  background: transparent;
}

@media (max-width: 768px) {
  .spectators-list {
    gap: 6px;
  }
  .spectator-avatar {
    width: 30px;
    height: 30px;
  }
  .spectator-initial {
    font-size: 12px;
  }
  .spectator-name {
    font-size: 9px;
    max-width: 36px;
  }
  .user-action-menu {
    min-width: 120px;
  }
  .user-action-item {
    padding: 8px 12px;
    font-size: 12px;
  }
}

/* === Room Settings Modal === */
.setting-field {
  margin-bottom: 14px;
}
.setting-field label {
  display: block;
  font-size: 13px;
  color: #aaa;
  margin-bottom: 6px;
  font-weight: 500;
}
#room-settings-modal .modal-content input {
  margin-bottom: 0;
}

/* === Gomoku Settings Modal === */
#gomoku-settings-modal .modal-content input[type="number"] {
  width: 100%;
  padding: 12px 16px;
  background: #0f0f1a;
  border: 1px solid #3a3a5a;
  border-radius: 10px;
  color: #e0e0e0;
  font-size: 14px;
  outline: none;
  transition: all .2s;
}
#gomoku-settings-modal .modal-content input[type="number"]:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102,126,234,.15);
}
#gomoku-settings-modal .modal-content small {
  display: block;
  margin-top: 6px;
}

/* === Undo Request Modal === */
#undo-request-message { color: #e0e0e0; font-size: 15px; line-height: 1.6; margin-bottom: 20px; }

/* === Mobile Game Popup === */
.mobile-game-popup {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 500;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  touch-action: manipulation;
}
.mobile-game-popup.show {
  display: flex;
}
.mobile-game-popup-header {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 300px;
  pointer-events: auto;
}
.mobile-game-popup-header .btn-secondary {
  width: 100%;
  padding: 12px 20px;
  font-size: 15px;
}
.mobile-game-popup-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 600px;
  pointer-events: auto;
}
.mobile-game-popup-inner #game-panel {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}
.mobile-game-popup-inner #game-board {
  width: 100% !important;
  height: auto !important;
  max-width: 100% !important;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.6);
  background: #dbb46d; /* fallback in case draw not ready */
}
.mobile-game-popup-inner .game-info-bar {
  width: 100%;
  justify-content: center;
  gap: 16px;
  font-size: 16px;
  margin-top: 4px;
}
.mobile-game-popup-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 300px;
  pointer-events: auto;
}
.game-controls-mobile {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.game-controls-mobile .btn-secondary,
.game-controls-mobile .btn-danger {
  width: 100%;
  padding: 12px 20px;
  font-size: 15px;
}

/* Floating toggle button */
.mobile-game-toggle-btn {
  display: none;
  position: fixed;
  bottom: 90px;
  right: 16px;
  z-index: 501;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border: 2px solid rgba(255,255,255,.25);
  color: #fff;
  font-size: 26px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(102,126,234,.45);
  align-items: center;
  justify-content: center;
  transition: transform .2s, box-shadow .2s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.mobile-game-toggle-btn.show {
  display: flex !important;
}
.mobile-game-toggle-btn:active {
  transform: scale(0.9);
  box-shadow: 0 2px 10px rgba(102,126,234,.3);
}

/* Desktop: hide mobile popup and toggle completely */
@media (min-width: 769px) {
  .mobile-game-popup,
  .mobile-game-toggle-btn {
    display: none !important;
  }
}

/* Mobile adjustments */
@media (max-width: 768px) {
  /* When popup is showing, hide the original game panel from room flow only */
  body.mobile-popup-active .room-layout > #game-panel {
    display: none !important;
  }
  /* Quick minimize hint at top of popup */
  .mobile-game-popup::before {
    content: '点击空白处收起';
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,.45);
    font-size: 13px;
    pointer-events: none;
    z-index: 1;
  }
}

/* ==========================================================
   Friends / Group / Chat 样式
   ========================================================== */

/* === Friends Tabs === */
.friends-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 20px;
  background: #14142a;
  border-radius: 10px;
  padding: 4px;
  border: 1px solid #2a2a4a;
}
.friends-tab {
  flex: 1;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: #999;
  font-size: 13px;
  border-radius: 8px;
  cursor: pointer;
  transition: all .2s;
  position: relative;
  white-space: nowrap;
}
.friends-tab:hover { color: #e0e0e0; }
.friends-tab.active {
  background: #667eea;
  color: #fff;
  font-weight: 600;
}
.badge-count {
  position: absolute;
  top: 2px;
  right: 2px;
  background: #e74c3c;
  color: #fff;
  font-size: 10px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.friends-panel { display: none; }
.friends-panel.active { display: block; }

/* === Friend Item === */
.friend-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: #1a1a2e;
  border: 1px solid #2a2a4a;
  border-radius: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all .2s;
}
.friend-item:hover { border-color: #667eea; background: rgba(102,126,234,.05); }
.friend-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #14142a;
  border: 2px solid #2a2a4a;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.friend-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.friend-avatar-text {
  font-size: 16px;
  font-weight: 700;
  color: #e0e0e0;
}
.friend-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.friend-name {
  font-size: 14px;
  color: #fff;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.friend-meta {
  font-size: 11px;
  color: #888;
}
.friend-item-actions {
  display: flex;
  gap: 4px;
}

/* === Group Avatar === */
.group-avatar {
  font-size: 20px;
  background: linear-gradient(135deg, #667eea, #e91e63);
}
.group-avatar .friend-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.group-avatar-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #14142a;
  border: 2px solid #2a2a4a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  transition: border-color .2s;
}
.group-avatar-circle:hover {
  border-color: #667eea;
}

/* === Groups Actions === */
.groups-actions {
  margin-bottom: 8px;
  text-align: center;
}

/* === Private Chat === */
.private-chat-content {
  width: 480px;
  max-width: 95vw;
  display: flex;
  flex-direction: column;
  height: 560px;
  max-height: 85vh;
}
.private-chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-shrink: 0;
}
#private-chat-title {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}
.danger-btn { background: rgba(231,76,60,.15) !important; border-color: #e74c3c !important; color: #e74c3c !important; }
.danger-btn:hover { background: rgba(231,76,60,.3) !important; }

/* === Collapsible Section === */
.collapse-toggle { cursor: pointer; user-select: none; }
.collapse-toggle:hover { color: #ccc !important; }
.collapse-arrow { font-size: 10px; margin-right: 4px; }
.table-wrap.collapsed { display: none; }

/* === Chat Message List === */
.chat-message-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 0;
  min-height: 0;
}
.chat-empty-hint {
  text-align: center;
  color: #666;
  padding: 40px;
  font-size: 13px;
}
.chat-system-msg {
  text-align: center;
  color: #888;
  font-size: 12px;
  padding: 4px 0;
}

/* Chat Bubble */
.chat-bubble {
  max-width: 75%;
  display: flex;
  flex-direction: column;
}
.chat-bubble-me {
  align-self: flex-end;
}
.chat-bubble-other {
  align-self: flex-start;
}
.chat-bubble-text {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
}
.chat-bubble-me .chat-bubble-text {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-bubble-other .chat-bubble-text {
  background: #2a2a4a;
  color: #e0e0e0;
  border-bottom-left-radius: 4px;
}
.chat-bubble-sender {
  font-size: 11px;
  color: #888;
  margin-bottom: 2px;
  padding: 0 4px;
}
.chat-bubble-time {
  font-size: 10px;
  color: #666;
  margin-top: 2px;
  padding: 0 4px;
}
.chat-bubble-me .chat-bubble-time {
  text-align: right;
}
.chat-bubble-me .chat-bubble-sender {
  text-align: right;
}

/* === Chat Tool Buttons (图片/语音) === */
.chat-tool-btn {
  width: 36px; height: 36px;
  min-width: 36px;
  padding: 0;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}

/* === Image Message === */
.chat-image-msg {
  max-width: 220px;
  max-height: 220px;
  border-radius: 10px;
  cursor: pointer;
  object-fit: cover;
  border: 1px solid #3a3a5a;
}
.chat-image-msg:hover { border-color: #667eea; }

/* === Voice Message === */
.chat-voice-msg {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  background: #2a2a4a;
  border-radius: 14px;
  cursor: pointer;
  min-width: 80px;
}
.chat-voice-msg:hover { background: #3a3a6a; }
.voice-icon { font-size: 18px; }
.voice-dur { font-size: 13px; color: #ccc; }

/* === Quote Reply === */
#group-quote-bar, #private-quote-bar {
  display: none;
  align-items: center; gap: 8px;
  padding: 8px 12px;
  background: #1a1a2e;
  border-left: 3px solid #667eea;
  margin: 0 0 6px;
  border-radius: 4px;
  font-size: 12px;
}
#group-quote-bar span, #private-quote-bar span { flex: 1; color: #aaa; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#group-quote-bar button, #private-quote-bar button { flex-shrink: 0; padding: 2px 6px; font-size: 12px; min-width: auto; }

.chat-quote-bubble {
  background: rgba(102,126,234,0.1);
  border-left: 2px solid #667eea;
  padding: 6px 8px;
  border-radius: 4px;
  margin-bottom: 4px;
  cursor: pointer;
  font-size: 12px;
  max-width: 100%;
}
.chat-quote-bubble:hover { background: rgba(102,126,234,0.2); }
.chat-quote-sender { color: #667eea; font-size: 11px; font-weight: 600; }
.chat-quote-text { color: #888; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* === Context Menu === */
.msg-context-menu {
  position: fixed;
  z-index: 9999;
  background: #1a1a2e;
  border: 1px solid #3a3a5a;
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.6);
  min-width: 130px;
  padding: 4px 0;
}
.msg-context-item {
  padding: 10px 16px;
  font-size: 13px;
  color: #e0e0e0;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}
.msg-context-item:hover { background: rgba(102,126,234,.15); }
.msg-context-item.danger-item { color: #e74c3c; }
.msg-context-item.danger-item:hover { background: rgba(231,76,60,.15); }

/* Group Invite Actions */
.group-invite-actions {
  display: flex;
  gap: 6px;
}
.chat-group-invite {
  background: rgba(102,126,234,.08);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
}

/* Invite Group Picker */
.invite-group-picker {
  border-top: 1px solid #2a2a4a;
  padding-top: 8px;
  margin-top: 8px;
}
.invite-group-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: #e0e0e0;
  transition: background .15s;
}
.invite-group-item:hover {
  background: rgba(102,126,234,.1);
}

/* === Group Chat Page === */
#group-chat-page {
  display: none;
  flex-direction: column;
  height: calc(100vh - 56px);
  padding-top: 0;
}
#group-chat-page.active {
  display: flex;
}
.group-chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid #2a2a4a;
  margin-bottom: 12px;
  flex-shrink: 0;
}
.group-avatar-header {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #14142a;
  border: 2px solid #2a2a4a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
#group-chat-name {
  flex: 1;
  font-size: 17px;
  font-weight: 600;
  color: #fff;
}
#group-chat-name.muted-all-label {
  color: #e74c3c;
  font-size: 12px;
  font-weight: 400;
  margin-left: 4px;
}

/* === Group Settings === */
.group-members-list {
  max-height: 260px;
  overflow-y: auto;
}
.group-member-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #2a2a4a;
}

@media (max-width: 768px) {
  .friends-tabs {
    flex-wrap: wrap;
  }
  .friends-tab {
    font-size: 12px;
    padding: 8px 6px;
  }
  .private-chat-content {
    width: 100%;
    height: 90vh;
    max-height: 90vh;
    border-radius: 0;
  }
  .friend-item {
    padding: 10px;
    gap: 8px;
  }
  .friend-avatar {
    width: 34px;
    height: 34px;
  }
  .chat-bubble {
    max-width: 85%;
  }
  .chat-bubble-text {
    font-size: 13px;
    padding: 8px 12px;
  }
  .chat-tool-btn { width: 32px; height: 32px; min-width: 32px; font-size: 14px; }
  .chat-image-msg { max-width: 160px; max-height: 160px; }
  .chat-voice-msg { min-width: 60px; padding: 8px 12px; }
  .voice-icon { font-size: 16px; }
  .voice-dur { font-size: 12px; }
  .msg-context-menu { min-width: 110px; }
  .msg-context-item { padding: 10px 14px; font-size: 13px; }
  #group-chat-page {
    height: calc(100vh - 92px);
  }
  body.in-room #group-chat-page.active {
    height: calc(100vh - 32px);
  }
}

.mini-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  vertical-align: middle;
  margin-right: 6px;
}

.mini-avatar-initial {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #14142a;
  color: #e0e0e0;
  font-size: 12px;
  font-weight: 700;
  vertical-align: middle;
  margin-right: 6px;
}

.player-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.player-cell .mini-avatar,
.player-cell .mini-avatar-initial {
  margin-right: 0;
}

.player-name {
  font-size: 13px;
  color: #e0e0e0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100px;
}

.player-id {
  font-size: 11px;
  color: #666;
  font-family: monospace;
  white-space: nowrap;
}
