/* =============================================================================================
   SOCIAL — Friends & Chat, one page: Chats (your table, the World, private messages), Friends,
   Requests and Find players on the left, the open conversation on the right. In the game's
   violet-and-gold finish. Like Royal Hunt.
   ============================================================================================= */

/* ---------------------------------------------------------------- CHAT handle on the home screen */
.chat-hot { background: linear-gradient(180deg, rgba(132, 84, 236, 0.94), rgba(78, 36, 172, 0.92)); box-shadow: 0 calc(var(--cqw) * 0.3) 0 rgba(44, 16, 104, 0.75), 0 calc(var(--cqw) * 0.6) calc(var(--cqw) * 1) rgba(0, 0, 0, 0.35); }
.chat-hot .chat-tag { background: linear-gradient(180deg, #ffd96a, #f2a900); color: #3a2400; }
.chat-hot .badge { top: calc(var(--cqw) * -0.5); right: calc(var(--cqw) * -0.6); min-width: calc(var(--cqw) * 1.9); height: calc(var(--cqw) * 1.9); font-size: calc(var(--cqw) * 1); border: 2px solid #fff; animation: badgePop 0.4s var(--spring, ease-out); }
.chat-hot .badge.dot { min-width: calc(var(--cqw) * 1.2); width: calc(var(--cqw) * 1.2); height: calc(var(--cqw) * 1.2); padding: 0; font-size: 0; }
.online-bubble { position: absolute; left: calc(var(--cqw) * -0.6); top: calc(var(--cqw) * -0.5); min-width: calc(var(--cqw) * 1.9); height: calc(var(--cqw) * 1.9); padding: 0 calc(var(--cqw) * 0.4); border-radius: 999px; display: grid; place-items: center; font-size: calc(var(--cqw) * 0.95); font-weight: 900; color: #06300f; background: #4ade80; border: 2px solid #fff; }
@keyframes badgePop { from { scale: 0.3; } }
.screen-in .home-scene #chatHandle { animation: slideInLeft 0.5s var(--ease-out, ease-out) 0.25s backwards; }
@media (orientation: portrait) and (max-width: 800px) {
  /* Portrait: CHAT and LIVE side by side under the profile (CHAT left, LIVE right, as in landscape). */
  .home-scene #chatHandle { left: 4% !important; top: 11% !important; width: 23.5% !important; height: 5.5% !important; flex-direction: row; gap: 6px; border-radius: 20px; }
  .home-scene #liveBtn { left: 28.5% !important; width: 23.5% !important; }
  .home-scene #chatHandle .live-icon { font-size: 16px; }
  .home-scene #chatHandle .chat-tag { position: static; translate: none; transform: none; padding: 2px 7px; border-radius: 9px; font-size: 9px; }
  .home-scene #chatHandle .badge { min-width: 18px; height: 18px; font-size: 10px; top: -6px; right: -6px; }
  .home-scene #chatHandle .online-bubble { min-width: 18px; height: 18px; font-size: 10px; top: -6px; left: -6px; }
}
.lb-chat { position: relative; }
.lb-chat .badge { top: -6px; right: -6px; }
.badge.dot { min-width: 12px; width: 12px; height: 12px; padding: 0; font-size: 0; }


/* ---------------------------------------------------------------- the page ------------------ */
.so-head { gap: 10px; }
.so-head h2 { flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px; margin: 0; }
.so-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.so-head-ico { flex: none; display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 11px; font-size: 1rem; text-shadow: none; background: linear-gradient(180deg, rgba(132, 84, 236, 0.95), rgba(78, 36, 172, 0.95)); box-shadow: 0 2px 0 rgba(44, 16, 104, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.25); }
.so-online { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 0.74rem; font-weight: 900; color: #b6f5c9; background: rgba(74, 222, 128, 0.12); border: 1px solid rgba(74, 222, 128, 0.35); }
.so-online::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 6px #4ade80; animation: soPulse 2s ease-in-out infinite; }
@keyframes soPulse { 50% { opacity: 0.35; } }
@media (max-width: 420px) { .so-head-ico { display: none; } .so-online { padding: 3px 8px; font-size: 0.7rem; } }
.so-wrap { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 14px; }
.so-side { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 10px; }

/* Tabs: Chats · Friends · Requests · Find, with what's new on each. */
.so-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 16px; background: rgba(8, 4, 24, 0.5); border: 1px solid rgba(255, 255, 255, 0.07); box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5); }
.so-tabs button {
  position: relative; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 7px 2px 6px;
  border: 0; border-radius: 12px; background: transparent; color: var(--fin-ink-3, #a99fd0); font-weight: 900; font-size: 0.72rem; letter-spacing: 0.02em; cursor: pointer;
  transition: background 0.25s, color 0.25s, box-shadow 0.25s;
}
.so-tabs button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.so-tabs button i { font-style: normal; font-size: 1.1rem; line-height: 1.15; transition: scale 0.3s var(--spring, ease-out), translate 0.3s var(--spring, ease-out); }
.so-tabs button:hover:not(.on) { color: #fff; background: rgba(255, 255, 255, 0.06); }
.so-tabs button:hover:not(.on) i { translate: 0 -2px; }
.so-tabs button:focus-visible { outline: 2px solid var(--fin-gold-1, #ffe27a); outline-offset: 1px; }
.so-tabs button.on { background: linear-gradient(180deg, var(--fin-gold-1, #ffe27a), var(--fin-gold-2, #f2a900)); color: var(--fin-gold-ink, #3a2400); box-shadow: 0 2px 0 #a35a00, 0 5px 12px rgba(242, 169, 0, 0.28); }
.so-tabs button.on i { scale: 1.15; }
.so-n { position: absolute; top: -5px; right: -2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; display: grid; place-items: center; font-size: 0.62rem; font-weight: 900; color: #06300f; background: #4ade80; border: 1.5px solid #fff; }
.so-n.hot { color: #fff; background: #e5322d; animation: badgePop 0.4s var(--spring, ease-out); }
.so-n:empty:not(.dot) { display: none; }
.so-n.dot { top: -3px; right: 3px; min-width: 11px; width: 11px; height: 11px; padding: 0; }

/* The list. Rows come in one after another when a tab opens (not when it only updates). */
.so-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; display: flex; flex-direction: column; gap: 10px; padding: 2px 2px 10px; scrollbar-width: thin; scrollbar-color: rgba(214, 204, 245, 0.35) transparent; }
.so-list.so-enter > :not(.so-rows), .so-list.so-enter .so-rows > * { animation: rowIn 0.38s var(--ease-out, ease-out) backwards; animation-delay: calc(var(--i, 0) * 32ms); }
@keyframes rowIn { from { opacity: 0; translate: 0 10px; } }
/* An empty list says so just under its heading, not in the middle of the page. */
.so-list .cp-empty { flex: none; padding: 26px 12px 18px; }
.so-rows { display: grid; gap: 6px; grid-template-columns: minmax(0, 1fr); }
.social .fr-list { grid-template-columns: minmax(0, 1fr); }
.social .fr-sect { margin-bottom: -4px; }
/* The friend code fits on one line in the narrow list. */
.social .fr-code-card { gap: 8px; padding: 10px 12px; }
.social .fr-code { padding: 5px 10px; letter-spacing: 0.16em; }
.so-row:focus-visible { outline: 2px solid var(--fin-gold-1, #ffe27a); outline-offset: 2px; }
.so-row.on { border-color: rgba(255, 214, 120, 0.75); background: linear-gradient(90deg, rgba(255, 214, 90, 0.2), rgba(255, 255, 255, 0.05)); box-shadow: inset 3px 0 0 var(--fin-gold-1, #ffe27a); }
/* A green dot on the picture of someone who's online (only they get one). */
.social .avatar .dot { background: #4ade80; border-color: #24104f; box-shadow: 0 0 6px rgba(74, 222, 128, 0.7); }
.so-ico { position: relative; flex: none; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-size: 1.3rem; border: 1.5px solid rgba(255, 255, 255, 0.35); box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.3); }
.so-ico.world { background: radial-gradient(circle at 35% 30%, #67b4ff, #1f4fb5 70%); }
.so-ico.table { background: radial-gradient(circle at 35% 30%, #5be39a, #13703d 70%); }
.so-msg { position: relative; }
.so-msg .badge { top: -7px; right: -7px; min-width: 17px; height: 17px; font-size: 0.6rem; border: 1.5px solid #fff; animation: badgePop 0.4s var(--spring, ease-out); }

/* The conversation. */
.so-chat { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding: 10px 12px 12px; border-radius: 20px; background: rgba(8, 4, 24, 0.38); border: 1px solid var(--fin-line, rgba(255, 255, 255, 0.09)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05); }
.so-conv-head { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 0 2px 9px; border-bottom: 1px solid var(--fin-line, rgba(255, 255, 255, 0.09)); }
.so-conv-head .avatar { position: relative; flex: none; width: 40px; height: 40px; }
.so-conv-head .so-ico { width: 40px; height: 40px; font-size: 1.2rem; }
.so-conv-info { flex: 1; cursor: default; }
.so-conv-info.link { cursor: pointer; }
.so-conv-info.link:hover b { text-decoration: underline; text-underline-offset: 3px; }
.so-conv-acts { flex: none; display: flex; gap: 6px; }
.so-back { display: none; flex: none; }
.social.one-pane .so-back { display: grid; place-items: center; }
.cp-msgs.enter { animation: convIn 0.3s var(--ease-out, ease-out) both; }
@keyframes convIn { from { opacity: 0; translate: 0 8px; } }
.cp-input.locked { opacity: 0.55; }
.cp-body > .cp-lock { flex: none; }
.cp-input input:disabled { cursor: not-allowed; }

/* One column at a time where two don't fit: the list, or the conversation (with a back arrow). */
.social.one-pane .so-wrap { grid-template-columns: minmax(0, 1fr); }
.social.one-pane .so-chat { display: none; }
.social.one-pane.show-conv .so-chat { display: flex; animation: paneIn 0.34s var(--spring-soft, ease-out) both; }
.social.one-pane.show-conv .so-side { display: none; }
.so-side.pane-back { animation: paneBack 0.34s var(--spring-soft, ease-out) both; }
@keyframes paneIn { from { opacity: 0; translate: 36px 0; } }
@keyframes paneBack { from { opacity: 0; translate: -36px 0; } }

/* At a table: at the side of the screen, so the game stays in view (no dimmed backdrop). */
aside.drawer.tall.social.docked {
  z-index: 33; top: 0; bottom: 0; left: 0; right: auto; translate: none; margin: 0; width: min(420px, 94vw); height: auto; max-width: none;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 14px calc(12px + env(safe-area-inset-bottom, 0px)) calc(14px + env(safe-area-inset-left, 0px));
  border: 0; border-right: 1.5px solid var(--fin-trim, rgba(255, 214, 120, 0.55)); border-radius: 0 24px 24px 0;
  box-shadow: 18px 0 50px rgba(0, 0, 0, 0.6), inset -1px 0 0 rgba(255, 255, 255, 0.08);
  animation: chatIn 0.4s var(--spring-soft, ease-out) both;
  transition: opacity 0.2s var(--ease-out, ease-out), translate 0.24s var(--ease-in, ease-in), display 0.24s allow-discrete;
}
aside.drawer.tall.social.docked.hidden { translate: -48px 0; scale: 1; opacity: 0; }
@keyframes chatIn { from { opacity: 0; translate: -60px 0; } }

/* Short screens (phones on their side): tighter, and the tab icons sit beside their names. */
@media (max-height: 480px) {
  .social { gap: 6px; }
  .so-head { padding-bottom: 6px; margin-bottom: 0; }
  .so-head-ico { width: 26px; height: 26px; border-radius: 9px; font-size: 0.85rem; }
  .so-tabs button { flex-direction: row; gap: 5px; padding: 6px 2px; }
  .so-tabs button i { font-size: 0.95rem; }
  .so-chat { padding: 8px 10px 10px; gap: 6px; }
  .so-conv-head { min-height: 38px; padding-bottom: 6px; }
  .so-conv-head .avatar, .so-conv-head .so-ico { width: 34px; height: 34px; }
}

/* ---------------------------------------------------------------- messages --------------- */
.cp-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.cp-msgs { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px 2px 6px; scrollbar-width: thin; scrollbar-color: rgba(214, 204, 245, 0.35) transparent; }
.cp-msg { display: flex; align-items: flex-end; gap: 7px; max-width: 92%; }
.cp-msg .avatar { flex: none; width: 30px; height: 30px; font-size: 0.8rem; }
.cp-msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.cp-bubble { display: flex; flex-direction: column; gap: 2px; padding: 7px 10px; border-radius: 14px 14px 14px 4px; background: rgba(255, 255, 255, 0.09); border: 1px solid rgba(255, 255, 255, 0.1); min-width: 0; }
.cp-msg.mine .cp-bubble { border-radius: 14px 14px 4px 14px; background: linear-gradient(180deg, rgba(255, 214, 90, 0.28), rgba(242, 169, 0, 0.2)); border-color: rgba(255, 214, 120, 0.4); }
.cp-who { font-size: 0.72rem; color: var(--fin-gold-1, #ffe27a); cursor: pointer; }
.cp-txt { font-size: 0.88rem; line-height: 1.35; color: #fff; overflow-wrap: anywhere; }
.cp-t { align-self: flex-end; font-size: 0.62rem; color: var(--fin-ink-3, #a99fd0); }
.cp-msg.new { animation: msgIn 0.35s var(--spring, ease-out); }
@keyframes msgIn { from { opacity: 0; translate: 0 10px; scale: 0.96; } }
.cp-sys { align-self: center; max-width: 90%; padding: 3px 10px; border-radius: 999px; background: rgba(0, 0, 0, 0.25); color: var(--fin-ink-3, #a99fd0); font-size: 0.72rem; text-align: center; }
.cp-empty { flex: 1; display: grid; place-content: center; justify-items: center; gap: 10px; padding: 24px 12px; text-align: center; color: var(--fin-ink-3, #a99fd0); }
.cp-empty-ico { font-size: 2.2rem; animation: soBob 2.4s ease-in-out infinite; }
.cp-empty p { margin: 0; max-width: 260px; }
.cp-input { display: flex; gap: 8px; }
.cp-input input { flex: 1; min-width: 0; color: #fff; background: rgba(8, 4, 24, 0.55); border: 1px solid rgba(214, 204, 245, 0.22); border-radius: 12px; padding: 10px 12px; }
.cp-input input:focus { outline: none; border-color: var(--fin-gold-1, #ffe27a); box-shadow: 0 0 0 3px rgba(255, 214, 90, 0.2); }
.cp-input .btn { flex: none; padding: 9px 16px; font-weight: 900; border-radius: 12px; background: linear-gradient(180deg, #ffe58a, #f2a900); color: #3a2400; border: 0; box-shadow: 0 3px 0 #a35a00; }
@keyframes soBob { 50% { translate: 0 -5px; } }
.cp-back { width: 34px; height: 34px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.18); background: rgba(255, 255, 255, 0.08); color: #fff; font-size: 1.4rem; line-height: 1; cursor: pointer; transition: translate 0.2s; }
.cp-back:hover { translate: -2px 0; }
.cp-dm-info { display: flex; flex-direction: column; min-width: 0; cursor: pointer; }
.cp-dm-info b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-dm-info small { color: var(--fin-ink-3, #a99fd0); font-size: 0.72rem; }

/* ---------------------------------------------------------------- rows: chats and friends - */
.cf-tools { display: grid; gap: 8px; }
.cf-search { flex: 1; min-width: 0; color: #fff; background: rgba(8, 4, 24, 0.55); border: 1px solid rgba(214, 204, 245, 0.22); border-radius: 12px; padding: 9px 12px; }
.cf-search:focus { outline: none; border-color: var(--fin-gold-1, #ffe27a); }
.cf-seg { display: flex; gap: 4px; padding: 3px; border-radius: 12px; background: rgba(8, 4, 24, 0.45); }
.cf-seg button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 6px 4px; border: 0; border-radius: 9px; background: transparent; color: var(--fin-ink-3, #a99fd0); font-weight: 800; font-size: 0.78rem; cursor: pointer; transition: background 0.2s, color 0.2s; }
.cf-seg button.on { background: rgba(255, 255, 255, 0.14); color: #fff; }
.cf-seg em { font-style: normal; font-size: 0.66rem; padding: 0 5px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); }
.cf-seg em:empty { display: none; }
.cf-dot { width: 8px; height: 8px; border-radius: 50%; background: #8a83ad; }
.cf-dot.on { background: #4ade80; box-shadow: 0 0 6px #4ade80; }
.cf-list { flex: 1; min-height: 0; overflow-y: auto; display: grid; gap: 6px; align-content: start; padding-bottom: 4px; scrollbar-width: thin; }
.cf-row { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; text-align: left; color: #fff; cursor: pointer; border-radius: 14px; background: rgba(255, 255, 255, 0.055); border: 1px solid rgba(255, 255, 255, 0.08); transition: background 0.2s, border-color 0.2s, translate 0.2s; }
.cf-row:hover { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 214, 120, 0.3); translate: 2px 0; }
.cf-row.unread { border-color: rgba(255, 214, 120, 0.55); background: linear-gradient(90deg, rgba(255, 214, 90, 0.14), rgba(255, 255, 255, 0.05)); }
.cf-row .avatar { position: relative; width: 42px; height: 42px; }
.cf-mid { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cf-mid b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cf-last { color: var(--fin-ink-3, #a99fd0); font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cf-last em { font-style: normal; color: var(--fin-ink-2, #d6ccf5); }
.cf-row.unread .cf-last { color: #fff; font-weight: 700; }
.cf-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.cf-time { font-size: 0.66rem; color: var(--fin-ink-3, #a99fd0); }
.cf-time.new { color: var(--fin-gold-1, #ffe27a); font-weight: 800; }
.badge.static { position: static; }
.cf-invite { padding: 3px 9px; border-radius: 999px; font-size: 0.7rem; font-weight: 900; color: #06300f; background: linear-gradient(180deg, #8ef0a9, #3fbf62); cursor: pointer; }
.cf-none { color: var(--fin-ink-3, #a99fd0); text-align: center; margin: 18px 0; }

.fr-code-card { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 16px; background: linear-gradient(120deg, rgba(255, 214, 90, 0.16), rgba(255, 255, 255, 0.04)); border: 1px solid rgba(255, 214, 120, 0.35); }
.fr-code-label { color: var(--fin-ink-2, #d6ccf5); font-size: 0.8rem; font-weight: 700; }
.fr-code { padding: 6px 14px; border-radius: 12px; border: 1px dashed rgba(255, 214, 120, 0.7); background: rgba(8, 4, 24, 0.45); color: var(--fin-gold-1, #ffe27a); font: 900 1.15rem ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: 0.22em; cursor: pointer; }
.fr-code-card .btn { margin-left: auto; }
.fr-list { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) { .fr-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.fr-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 14px; background: rgba(255, 255, 255, 0.055); border: 1px solid rgba(255, 255, 255, 0.08); cursor: pointer; transition: background 0.2s, border-color 0.2s, translate 0.2s; }
.fr-row:hover { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 214, 120, 0.3); translate: 0 -1px; }
.fr-row.offline .avatar { filter: grayscale(0.6); opacity: 0.8; }
.fr-row .avatar { position: relative; width: 44px; height: 44px; }
.fr-mid { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fr-mid b { display: flex; align-items: center; gap: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fr-lv { flex: none; padding: 0 6px; border-radius: 999px; font-size: 0.64rem; font-weight: 900; color: #3a2400; background: linear-gradient(180deg, #ffe27a, #f2a900); }
.fr-line { color: var(--fin-ink-3, #a99fd0); font-size: 0.76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fr-side { display: flex; align-items: center; gap: 6px; }
.fr-more { font-size: 1.1rem; line-height: 1; padding: 4px 8px; }
.fr-sect { margin: 6px 2px 0; color: var(--fin-gold-1, #ffe27a); font-size: 0.72rem; font-weight: 900; letter-spacing: 0.14em; text-transform: uppercase; }
.fr-note { color: var(--fin-ink-3, #a99fd0); font-size: 0.82rem; margin: 2px; }
.fr-search { display: flex; gap: 8px; }
.fr-search input { flex: 1; min-width: 0; }

/* ---------------------------------------------------------------- menus: glass rows --------- */
.action-menu { position: fixed; z-index: 70; }
.seat-menu .sm-item, .action-menu .sm-item { background: rgba(255, 255, 255, 0.08); box-shadow: none; color: #fff; border: 1px solid rgba(255, 255, 255, 0.1); font-weight: 800; transition: background 0.2s, border-color 0.2s; }
.seat-menu .sm-item:hover, .action-menu .sm-item:hover { background: rgba(255, 255, 255, 0.16); border-color: rgba(255, 214, 120, 0.35); }
.seat-menu .sm-item.danger, .action-menu .sm-item.danger { background: rgba(229, 50, 45, 0.22); border-color: rgba(255, 120, 110, 0.4); color: #ffd3cf; }
