/* Futpixel social UI (social-ui.js). Colours and type are custom properties so
   a theme can restyle the Online hub, lobby invites, toasts and badge. */
:root {
  --social-surface: #0d0f14;
  --social-surface-2: #151922;
  --social-surface-3: #1d2230;
  --social-line: #ffffff1c;
  --social-ink: #f3f5f8;
  --social-muted: #9aa3b4;
  --social-accent: #e1142d;
  --social-accent-hover: #f0304a;
  --social-gold: #f5c518;
  --social-online: #2fd67b;
  --social-match: #f5c518;
  --social-away: #f08a24;
  --social-offline: #5b6272;
  --social-danger: #ff6b7d;
  --social-font: "Bahnschrift", "DIN Condensed", "Roboto Condensed", "Arial Narrow", sans-serif;
}

/* The hub header already says who is connected; the generic intro gives its space to the tabs. */
.fm-content:has(.social-hub) > .fm-online-intro { display: none; }
.social-hub { display: flex; flex-direction: column; gap: 14px; margin: 4px 0 18px; font-family: var(--social-font); color: var(--social-ink); min-width: 0; }
.social-hub *, .social-lobby *, .social-toasts * { box-sizing: border-box; }
.social-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 18px; padding: 14px 16px; background: linear-gradient(100deg, var(--social-surface-2), var(--social-surface)); border: 1px solid var(--social-line); border-left: 4px solid var(--social-accent); }
.social-hub .social-identity { display: flex; align-items: center; gap: 14px; margin: 0; min-width: 0; flex: 1 1 260px; }
.social-hub .social-identity > div { display: flex; flex-direction: column; min-width: 0; }
.social-hub .social-identity strong { font-size: 22px; letter-spacing: .3px; overflow-wrap: anywhere; }
.social-handle { color: var(--social-gold); font-size: 14px; font-weight: 700; letter-spacing: .6px; overflow-wrap: anywhere; }
.social-status { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; }
.social-pill { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 999px; background: var(--social-surface-3); color: var(--social-muted); font-weight: 700; letter-spacing: .5px; text-transform: uppercase; font-size: 11px; }
.social-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--social-offline); }
.social-pill[data-state="online"] { color: var(--social-ink); }
.social-pill[data-state="online"]::before { background: var(--social-online); box-shadow: 0 0 8px var(--social-online); }
.social-pill[data-state="connecting"]::before, .social-pill[data-state="offline"]::before { background: var(--social-away); }
.social-online { color: var(--social-muted); font-weight: 600; }

.social-tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--social-accent); overflow-x: auto; scrollbar-width: none; }
.social-tabs::-webkit-scrollbar { display: none; }
.social-btn.social-tab { flex: 1 0 auto; min-height: 46px; padding: 10px 16px; background: var(--social-surface-2); border: 1px solid var(--social-line); border-bottom: 0; border-radius: 0; color: var(--social-muted); font-size: 14px; letter-spacing: 1.1px; text-transform: uppercase; }
.social-btn.social-tab.is-active, .social-btn.social-tab.is-active:hover:not(:disabled) { background: var(--social-accent); color: #fff; border-color: var(--social-accent); }
.social-count { margin-left: 8px; padding: 1px 7px; border-radius: 999px; background: var(--social-surface-3); color: var(--social-ink); font-size: 11px; letter-spacing: 0; }
.social-count[data-alert="true"] { background: var(--social-gold); color: #111; }
.social-count[hidden] { display: none; }
.social-panel { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.social-panel[hidden] { display: none; }
.social-panel .fm-online-panels { margin-top: 0; }

.social-btn { font: inherit; font-family: var(--social-font); display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 14px; border: 1px solid var(--social-line); border-radius: 2px; background: var(--social-surface-3); color: var(--social-ink); font-weight: 700; font-size: 13px; letter-spacing: .4px; cursor: pointer; touch-action: manipulation; white-space: nowrap; box-shadow: none; transition: background-color .08s, border-color .08s, color .08s; }
.social-btn:hover:not(:disabled) { border-color: #ffffff55; background: #262c3c; }
.social-btn.is-primary { background: var(--social-accent); border-color: var(--social-accent); color: #fff; }
.social-btn.is-primary:hover:not(:disabled) { background: var(--social-accent-hover); }
.social-btn.is-danger, .social-btn.is-confirm { border-color: var(--social-danger); color: var(--social-danger); background: transparent; }
.social-btn:disabled { opacity: .45; cursor: not-allowed; }
.social-btn:focus-visible, .social-hub input:focus-visible, .social-lobby .social-btn:focus-visible, .social-toast .social-btn:focus-visible { outline: 3px solid var(--social-gold); outline-offset: 3px; }

.social-card { padding: 18px; background: var(--social-surface-2); border: 1px solid var(--social-line); min-width: 0; }
.social-card h2 { font-size: 24px; margin: 6px 0 8px; letter-spacing: .3px; }
.social-eyebrow { display: block; color: var(--social-gold); font-size: 11px; font-weight: 700; letter-spacing: 2.2px; }
.social-hint { color: var(--social-muted); font-size: 13px; line-height: 1.55; margin: 0; }
.social-empty { color: var(--social-muted); font-size: 13px; margin: 6px 0; list-style: none; }
.social-message { margin: 0; padding: 9px 12px; font-size: 13px; background: #2fd67b1a; border-left: 3px solid var(--social-online); }
.social-message[data-error="true"] { background: #e1142d22; border-left-color: var(--social-accent); }
.social-message[hidden] { display: none; }

.social-quick-card { display: grid; grid-template-columns: 1fr auto; gap: 4px 20px; align-items: center; border-left: 4px solid var(--social-gold); }
.social-quick-card > :not(.social-btn) { grid-column: 1; }
.social-quick-card > .social-btn { grid-column: 2; grid-row: 1 / span 4; min-width: 200px; min-height: 52px; font-size: 15px; }
.social-queue-state { margin: 6px 0 0; font-weight: 700; font-size: 14px; }
.social-queue-state[data-state="searching"], .social-queue-state[data-state="matching"] { color: var(--social-gold); }

.social-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--social-line); min-width: 0; }
.social-row:first-of-type { border-top: 0; }
.social-row-copy { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.social-row-copy strong { font-size: 16px; overflow-wrap: anywhere; }
.social-row-copy small { color: var(--social-muted); font-size: 12px; overflow-wrap: anywhere; }
.social-row-handle { color: var(--social-gold) !important; }
.social-row-status[data-status="online"] { color: var(--social-online) !important; }
.social-row-status[data-status="in-match"] { color: var(--social-match) !important; }
.social-row-status[data-status="away"] { color: var(--social-away) !important; }
.social-row-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.social-avatar-wrap { position: relative; flex: none; display: inline-flex; }
.social-avatar { display: block; flex: none; image-rendering: pixelated; background: var(--social-surface-3); }
.social-avatar.is-small { width: 32px; height: 40px; }
.social-avatar.is-large { width: 72px; height: 90px; border: 2px solid var(--social-gold); }
.social-avatar-fallback { display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.social-dot { position: absolute; right: -3px; bottom: -3px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--social-surface-2); background: var(--social-offline); }
.social-dot[data-status="online"] { background: var(--social-online); }
.social-dot[data-status="in-match"] { background: var(--social-match); }
.social-dot[data-status="away"] { background: var(--social-away); }

.social-add { display: flex; align-items: flex-end; gap: 10px; }
.social-field { display: flex; flex-direction: column; gap: 6px; flex: 1 1 auto; min-width: 0; }
.social-field > span { font-size: 11px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--social-muted); }
.social-hub input[type="text"] { width: 100%; min-width: 0; min-height: 44px; padding: 9px 12px; border: 1px solid #ffffff33; border-radius: 2px; background: var(--social-surface); color: var(--social-ink); font: inherit; font-size: 15px; }
.social-add .social-btn, .social-chat-form .social-btn { min-height: 44px; }
.social-friend-lists { display: flex; flex-direction: column; gap: 12px; }
.social-list { padding: 12px 16px; background: var(--social-surface-2); border: 1px solid var(--social-line); }
.social-list h3 { display: flex; align-items: center; gap: 10px; margin: 0 0 4px; font-size: 13px; letter-spacing: 1.6px; text-transform: uppercase; color: var(--social-muted); }
.social-list-count { color: var(--social-gold); }
.social-decline-all { display: flex; justify-content: flex-end; padding-top: 10px; border-top: 1px solid var(--social-line); }
.social-name-gate { border-left: 4px solid var(--social-gold); }
.social-name-gate[hidden] { display: none; }
.social-name-gate .social-btn { margin-top: 12px; }
.social-quick-code > strong { letter-spacing: 2px; overflow-wrap: anywhere; }

.social-chat-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.social-chat-head h2 { margin: 0; font-size: 24px; }
.social-chat-body { display: flex; flex-direction: column; gap: 10px; }
.social-chat-body[hidden], .social-chat-hidden[hidden] { display: none; }
.social-chat-hidden { padding: 16px; background: var(--social-surface-2); border: 1px dashed var(--social-line); display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.social-chat-hidden p { margin: 0; color: var(--social-muted); }
.social-chat-log { list-style: none; margin: 0; padding: 8px 12px; height: min(46vh, 420px); min-height: 200px; overflow-y: auto; overscroll-behavior: contain; background: var(--social-surface); border: 1px solid var(--social-line); }
/* Stacked accents never paint over neighbouring messages. */
.social-msg { padding: 7px 0; border-bottom: 1px solid #ffffff0d; overflow: hidden; contain: paint; }
.social-msg-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.social-msg-name { font-size: 14px; color: #d8dde6; overflow-wrap: anywhere; }
.social-msg.is-friend .social-msg-name { color: var(--social-gold); }
.social-msg.is-self .social-msg-name { color: #ff8a98; }
.social-msg-tag { color: var(--social-muted); font-size: 12px; font-weight: 700; letter-spacing: .4px; }
.social-msg.is-friend .social-msg-tag { color: var(--social-gold); opacity: .75; }
.social-msg-time { color: var(--social-muted); font-size: 11px; }
.social-msg-text { margin: 2px 0 0; font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; white-space: pre-wrap; font-family: "Segoe UI", Arial, sans-serif; }
.social-msg.is-system { color: var(--social-muted); font-style: italic; font-size: 13px; }
.social-msg.is-system .social-msg-text { font-size: 13px; }
.social-btn.social-more { margin-left: auto; min-height: 28px; min-width: 36px; padding: 0 8px; background: transparent; font-size: 16px; line-height: 1; }
.social-msg-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.social-msg-actions .social-btn { min-height: 34px; font-size: 12px; }
.social-chat-form { display: flex; align-items: center; gap: 10px; }
.social-chat-form input { flex: 1 1 auto; }
.social-counter { color: var(--social-muted); font-size: 12px; min-width: 52px; text-align: right; }

.social-profile-top { display: flex; align-items: center; gap: 18px; }
.social-profile-copy h2 { margin: 4px 0 2px; font-size: 28px; overflow-wrap: anywhere; }
.social-profile-handle { margin: 0; color: var(--social-gold); font-size: 18px; font-weight: 700; letter-spacing: .6px; overflow-wrap: anywhere; }
.social-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin: 16px 0; }
.social-facts > div { padding: 10px 12px; background: var(--social-surface); border: 1px solid var(--social-line); min-width: 0; }
.social-facts dt { font-size: 11px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--social-muted); }
.social-facts dd { margin: 4px 0 0; display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 700; overflow-wrap: anywhere; min-width: 0; }
.social-crest { width: 24px; height: 24px; object-fit: contain; image-rendering: pixelated; }
.social-profile-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }

.social-lobby { margin: 16px 0; font-family: var(--social-font); color: var(--social-ink); border-left: 4px solid var(--social-gold); }
.social-lobby h2 { font-size: 20px; }
.social-lobby-list { display: flex; flex-direction: column; }

.social-toasts { position: fixed; z-index: 2147483000; top: 112px; right: 14px; display: flex; flex-direction: column; gap: 10px; width: min(360px, calc(100vw - 28px)); pointer-events: none; font-family: var(--social-font); }
.social-toast { position: relative; pointer-events: auto; padding: 12px 40px 12px 14px; background: var(--social-surface); color: var(--social-ink); border: 1px solid var(--social-line); border-left: 4px solid var(--social-gold); box-shadow: 0 10px 30px #000a; animation: social-in .18s ease-out; }
.social-toast[data-kind="invite"] { border-left-color: var(--social-accent); }
.social-toast[data-kind="error"] { border-left-color: var(--social-danger); }
.social-toast strong { display: block; font-size: 15px; letter-spacing: .4px; }
.social-toast p { margin: 3px 0 0; font-size: 13px; color: #c9cfda; overflow-wrap: anywhere; }
.social-toast-actions { display: flex; gap: 8px; margin-top: 10px; }
.social-btn.social-toast-close { position: absolute; top: 6px; right: 6px; min-height: 28px; min-width: 28px; padding: 0; background: transparent; border: 0; font-size: 18px; color: var(--social-muted); }
.social-badge { position: fixed; z-index: 2147483000; top: 10px; right: 10px; padding: 4px 10px; border-radius: 999px; background: #0d0f14cc; color: var(--social-gold); border: 1px solid #f5c51855; font: 700 11px var(--social-font); letter-spacing: .6px; pointer-events: none; }
.social-badge[hidden] { display: none; }
/* Compact and touch: a slim pill in the free strip under the TV bug, clear of the HUD buttons. */
@media (max-width: 900px), (pointer: coarse) { .social-badge { top: 62px; right: auto; left: 8px; padding: 2px 8px; font-size: 10px; } }
@media (max-width: 600px) { .social-toasts { top: auto; bottom: 8px; flex-direction: column-reverse; } }
@media (max-height: 650px) and (min-width: 601px) { .social-toasts { top: 80px; } }
.account-handle { color: var(--social-gold); font-weight: 700; letter-spacing: .5px; }
@keyframes social-in { from { opacity: 0; transform: translateY(-6px); } }
@media (prefers-reduced-motion: reduce) { .social-toast { animation: none; } }

@media (max-width: 700px) {
  .social-quick-card { grid-template-columns: 1fr; }
  .social-quick-card > .social-btn { grid-column: 1; grid-row: auto; width: 100%; min-width: 0; margin-top: 8px; }
  .social-row { flex-wrap: wrap; }
  .social-row-actions { width: 100%; justify-content: flex-start; padding-left: 44px; }
}
@media (max-width: 480px) {
  .social-bar { padding: 12px; }
  .social-hub .social-identity strong { font-size: 18px; }
  .social-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; overflow: visible; }
  .social-btn.social-tab { padding: 8px 10px; font-size: 12px; letter-spacing: .6px; min-height: 42px; }
  .social-count { margin-left: 4px; padding: 0 5px; }
  .social-card { padding: 14px; }
  .social-card h2, .social-chat-head h2 { font-size: 20px; }
  .social-add { flex-direction: column; align-items: stretch; }
  .social-chat-form { flex-wrap: wrap; }
  .social-chat-form input { flex-basis: 100%; }
  .social-chat-form .social-btn { flex: 1 1 auto; }
  /* Keep the message box on screen under the hub header and tabs. */
  .social-chat-log { height: clamp(150px, calc(100dvh - 400px), 46vh); min-height: 150px; }
  .social-row-actions { padding-left: 0; }
  .social-row-actions .social-btn { flex: 1 1 auto; }
  .social-profile-top { gap: 12px; }
  .social-avatar.is-large { width: 56px; height: 70px; }
  .social-toasts { top: auto; bottom: 8px; right: 8px; width: calc(100vw - 16px); flex-direction: column-reverse; }
}
