/* ===== Realtime / live lobby UI ===== */
.net-status{
  font-size:12px; font-weight:700; padding:6px 10px; border-radius:10px;
  margin:6px 0 2px; display:inline-block; letter-spacing:.2px;
}
.net-status.online{ background:rgba(61,220,132,.16); color:#3ddc84; }
.net-status.connecting{ background:rgba(255,194,75,.16); color:#ffc24b; }
.net-status.demo{ background:rgba(255,255,255,.07); color:#9aa3b8; }

.friend .you-badge,
.friend .host-badge,
.friend .bot-badge{
  font-size:10px; font-weight:800; padding:2px 6px; border-radius:6px;
  margin-left:6px; vertical-align:middle;
}
.friend .you-badge{ background:rgba(124,92,255,.22); color:#b9a6ff; }
.friend .host-badge{ background:rgba(255,194,75,.2); color:#ffc24b; }
.friend .bot-badge{ background:rgba(154,163,184,.18); color:#c2c9da; letter-spacing:.5px; }
.msg .bot-badge{
  display:inline-flex; align-items:center; margin-left:4px; padding:1px 5px;
  border-radius:6px; background:rgba(99,229,255,.13); color:#86ecff;
  font-size:9px; font-weight:900; letter-spacing:.45px; vertical-align:middle;
}

/* ===== Party Lobby sizing ===== */
.friends{
  height:calc(100dvh - 63px); max-height:calc(100dvh - 63px); overflow:hidden;
}
.friends-head{
  flex:0 1 auto; max-height:48%; overflow-y:auto; overscroll-behavior:contain;
}
.friends-head-title{ display:flex; align-items:center; justify-content:space-between; gap:8px; }
.friends-head-title h3{ min-width:0; }
.chat-size-toggle{ flex:0 0 auto; white-space:nowrap; }
.lobby-support{ display:block; }
.lobby-tools{ margin-top:8px; }
.lobby-tools summary{
  width:max-content; padding:5px 2px; color:var(--muted); cursor:pointer;
  font-size:11px; font-weight:800; letter-spacing:.2px;
}
.lobby-tools summary:hover{ color:var(--ink); }
.lobby-actions{
  display:flex; align-items:center; flex-wrap:wrap; gap:8px; padding-top:7px;
}
.friend-list{
  flex:0 1 auto; max-height:26%; overflow-y:auto; overscroll-behavior:contain;
}
.chat{ min-height:0; overflow:hidden; }
.chat-log{ min-height:0; overscroll-behavior:contain; }

/* Expanded chat is an overlay, so opening it never compresses the active game. */
.friends.chat-expanded{
  position:fixed; top:75px; right:12px; bottom:12px; z-index:110;
  width:min(460px,calc(100vw - 24px)); height:auto; max-height:none;
  border:1px solid var(--line); border-radius:16px; box-shadow:-16px 18px 55px rgba(0,0,0,.55);
}
.friends.chat-expanded .friends-head{ flex:0 0 auto; max-height:none; padding:12px 14px 7px; overflow:visible; }
.friends.chat-expanded .lobby-support{ display:none; }
.friends.chat-expanded .lobby-tools{ margin-top:3px; }
.friends.chat-expanded .lobby-tools summary{ padding:4px 1px; }
.friends.chat-expanded .lobby-actions{ max-height:116px; overflow-y:auto; padding:7px 3px 4px; }
.friends.chat-expanded .friend-list{
  display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:5px;
  flex:0 0 auto; max-height:112px; padding:7px 10px;
}
.friends.chat-expanded .friend{ min-width:0; padding:5px 7px; gap:7px; }
.friends.chat-expanded .friend .avatar{ width:28px; height:28px; }
.friends.chat-expanded .friend .st{ white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.friends.chat-expanded .chat{ flex:1 1 auto; min-height:0; }
.friends.chat-expanded .chat-log{ flex:1 1 auto; }

.join-divider{
  display:flex; align-items:center; gap:10px; margin:18px 0 12px;
  color:#7c869c; font-size:12px; font-weight:600;
}
.join-divider::before, .join-divider::after{
  content:""; flex:1; height:1px; background:rgba(255,255,255,.12);
}
.join-row{ display:flex; gap:8px; }
.join-row input{
  flex:1; padding:11px 13px; border-radius:11px; color:#fff; font:inherit;
  border:1px solid rgba(255,255,255,.16); background:rgba(255,255,255,.05);
}
.join-row input:focus{ outline:none; border-color:#7c5cff; }
.spectating-note{
  margin-top:8px; font-size:12px; color:#ffc24b; font-weight:600;
}

/* ===== Chat composer (overflow-safe) ===== */
.chat .chat-input{ display:flex; gap:8px; align-items:center; }
.chat .chat-input input{ flex:1 1 auto; min-width:0; }
.chat .chat-input .btn{ flex:0 0 auto; white-space:nowrap; }

/* ===== Typing indicator ===== */
.typing-row{
  height:0; overflow:hidden; opacity:0; font-size:12px; color:#9aa3b8;
  font-style:italic; padding:0 4px; transition:opacity .15s ease;
}
.typing-row.show{ height:auto; padding:2px 4px 4px; opacity:1; }

/* ===== Unread badge ===== */
.unread{
  display:none; min-width:16px; height:16px; line-height:16px; padding:0 4px;
  border-radius:9px; background:#ff4d8d; color:#fff; font-size:10px;
  font-weight:800; margin-left:4px; vertical-align:middle; text-align:center;
}
.unread.show{ display:inline-block; }
.icon-btn{ min-width:34px; }
.friends-head .btn:disabled{
  opacity:.45; cursor:not-allowed; transform:none; box-shadow:none;
}
.turnstile-slot{
  min-height:68px; display:flex; align-items:center; justify-content:center;
  margin:0 0 14px; padding:8px; border-radius:12px;
  background:rgba(255,255,255,.04); border:1px solid rgba(255,255,255,.1);
}

/* ===== History messages ===== */
.msg.history{ opacity:.6; }

/* ===== Profile editor ===== */
.profile-name{
  width:100%; padding:11px 13px; border-radius:11px; color:#fff; font:inherit;
  border:1px solid rgba(255,255,255,.16); background:rgba(255,255,255,.05);
  margin-bottom:4px; box-sizing:border-box;
}
.profile-name:focus{ outline:none; border-color:#7c5cff; }
.picker-label{ font-size:12px; font-weight:700; color:#7c869c; margin:12px 0 6px; }
.av-grid{ display:grid; grid-template-columns:repeat(10,1fr); gap:6px; }
.av-opt{
  font-size:18px; padding:6px 0; border-radius:9px; cursor:pointer;
  border:1px solid rgba(255,255,255,.1); background:rgba(255,255,255,.04); color:#fff;
}
.av-opt:hover{ background:rgba(255,255,255,.09); }
.av-opt.on{ border-color:#7c5cff; background:rgba(124,92,255,.22); }
.col-grid{ display:flex; gap:8px; flex-wrap:wrap; }
.col-opt{ width:30px; height:30px; border-radius:50%; border:2px solid transparent; cursor:pointer; }
.col-opt.on{ border-color:#fff; box-shadow:0 0 0 2px rgba(255,255,255,.25); }

/* ===== Message actions / reactions / replies ===== */
.msg{ position:relative; }
.msg-actions{
  position:absolute; top:-10px; right:6px; display:none; gap:2px;
  background:rgba(20,22,38,.96); border:1px solid rgba(255,255,255,.12);
  border-radius:9px; padding:2px; box-shadow:0 4px 14px rgba(0,0,0,.4); z-index:4;
}
.msg:hover .msg-actions,
.msg:focus-within .msg-actions{ display:flex; }
.msg-actions button{
  background:none; border:none; cursor:pointer; font-size:13px; padding:3px 5px;
  border-radius:6px; color:#cdd3e3; line-height:1;
}
.msg-actions button:hover{ background:rgba(255,255,255,.12); }
.msg.deleted{ opacity:.5; font-size:12px; font-style:italic; }
.msg .edited{ font-size:10px; color:#7c869c; }
.msg.mention-me{
  background:rgba(124,92,255,.14); border-left:3px solid #7c5cff;
  padding-left:7px; border-radius:8px;
}
.reply-quote{
  border-left:3px solid rgba(255,255,255,.25); padding:2px 8px; margin:2px 0 4px;
  font-size:11px; color:#9aa3b8; background:rgba(255,255,255,.04); border-radius:6px;
}
.reply-quote b{ color:#b9a6ff; }
.reacts{ display:flex; gap:4px; flex-wrap:wrap; margin-top:4px; }
.rc{
  font-size:11px; padding:1px 7px; border-radius:11px; cursor:pointer;
  border:1px solid rgba(255,255,255,.14); background:rgba(255,255,255,.05); color:#cdd3e3;
}
.rc.on{ border-color:#7c5cff; background:rgba(124,92,255,.22); color:#fff; }
.msg a{ color:#7cc4ff; text-decoration:underline; word-break:break-all; }
.mention{ color:#b9a6ff; font-weight:700; }
.media{ margin-top:5px; }
.media img, .media iframe{ max-width:100%; max-height:200px; border-radius:9px; display:block; border:0; }

/* ===== Reaction popover ===== */
.react-pop{
  position:absolute; display:none; gap:2px; z-index:90;
  background:rgba(20,22,38,.97); border:1px solid rgba(255,255,255,.14);
  border-radius:12px; padding:4px; box-shadow:0 8px 22px rgba(0,0,0,.5);
}
.react-pop.show{ display:flex; }
.react-pop button{ background:none; border:none; font-size:17px; cursor:pointer; padding:3px 5px; border-radius:7px; }
.react-pop button:hover{ background:rgba(255,255,255,.12); }

/* ===== Composer hint (reply / edit) ===== */
.composer-hint{
  display:none; align-items:center; gap:8px; font-size:12px; color:#9aa3b8;
  padding:6px 9px; margin:0 0 6px; border-radius:9px;
  background:rgba(124,92,255,.12); border:1px solid rgba(124,92,255,.25);
}
.composer-hint.show{ display:flex; }
.composer-hint b{ color:#cdd3e3; }
.composer-hint button{ margin-left:auto; background:none; border:none; color:#9aa3b8; cursor:pointer; font-size:13px; }
.gif-btn{ font-weight:800; letter-spacing:.5px; }

/* ===== Friend host controls ===== */
.friend{ position:relative; }
.f-main{ flex:1; min-width:0; }
.friend .avatar{ position:relative; flex:0 0 auto; }
.avatar-bot-icon{
  position:absolute; right:-7px; bottom:-6px; display:grid; place-items:center;
  width:17px; height:17px; border:1px solid var(--line); border-radius:50%;
  background:var(--panel); font-size:10px; line-height:1;
}
.friend.is-bot .status-dot{ background:#63e5ff; box-shadow:0 0 7px #63e5ff; }
.msg.bot{ border-left:3px solid #63e5ff; }
.host-ctrl{ display:flex; gap:2px; margin-left:auto; }
.host-ctrl button{
  background:rgba(255,255,255,.06); border:1px solid rgba(255,255,255,.12);
  border-radius:7px; cursor:pointer; font-size:12px; padding:3px 5px;
}
.host-ctrl button:hover{ background:rgba(255,255,255,.14); }

/* ===== GIF picker ===== */
.gif-results{
  display:grid; grid-template-columns:repeat(3,1fr); gap:6px;
  max-height:300px; overflow-y:auto; margin:12px 0;
}
.gif-pick{ width:100%; height:90px; object-fit:cover; border-radius:9px; cursor:pointer; border:2px solid transparent; }
.gif-pick:hover{ border-color:#7c5cff; }
.gif-hint{ grid-column:1/-1; color:#9aa3b8; font-size:13px; text-align:center; padding:18px 0; }

/* ===== Mobile slide-over drawer ===== */
.drawer-close{
  display:none; position:absolute; top:10px; right:10px; z-index:5;
  background:rgba(255,255,255,.08); border:1px solid rgba(255,255,255,.14);
  color:#fff; border-radius:8px; cursor:pointer; font-size:14px; padding:4px 9px;
}
@media (max-width:760px){
  .friends{
    position:fixed; top:0; right:0; height:100%; width:88%; max-width:360px;
    z-index:80; transition:transform 220ms cubic-bezier(.32,.72,0,1); box-shadow:-12px 0 40px rgba(0,0,0,.5);
  }
  .friends-head{ padding-top:46px; max-height:45%; }
  .friends.chat-expanded{
    inset:0; width:100%; height:100dvh; max-width:none; border-radius:0;
    border-width:0; box-shadow:none; z-index:110;
  }
  .friends.chat-expanded .friends-head{ padding:46px 12px 7px; }
  .friends.chat-expanded .friend-list{ grid-template-columns:1fr; max-height:94px; }
  .friends.collapsed{ transform:translateX(105%); }
  .friends:not(.collapsed){ transform:translateX(0); }
  .drawer-close{ display:block; }
}

@media (hover:none){
  .msg-actions{
    position:static; display:flex; width:max-content; margin-top:5px;
    background:transparent; border:0; box-shadow:none; padding:0;
  }
  .msg-actions button{ min-width:30px; min-height:30px; border:1px solid rgba(255,255,255,.12); }
}

@media (prefers-reduced-motion:reduce){
  .friends,.msg.bot{ transition:none; animation:none; }
}
.reduce-motion .friends,
.reduce-motion .msg.bot{ transition:none; animation:none; }

/* ===== Live leaderboard ===== */
.lb-body{ margin:12px 0 4px; max-height:52vh; overflow-y:auto; display:flex; flex-direction:column; gap:16px; }
.lb-game h4{ margin:0 0 6px; font-size:13px; color:#cdd3e3; letter-spacing:.3px; }
.lb-row{
  display:flex; justify-content:space-between; align-items:center; gap:10px;
  font-size:13px; padding:6px 10px; border-radius:9px; color:#e8ebf5; margin-bottom:4px;
  background:rgba(255,255,255,.04); border:1px solid rgba(255,255,255,.08);
}
.lb-row span:last-child{ font-weight:800; color:#ffc24b; }
.rk{ display:inline-block; min-width:26px; font-weight:800; color:#b9a6ff; }
.lb-empty{ color:#9aa3b8; font-size:13px; text-align:center; padding:22px 8px; line-height:1.5; }
