/* Social layer — player list, interaction sheet, emotes, chat, map pings.
   Mobile-first, safe-area aware. Everything lives in #social-root. */

#social-root {
  --sc-bg: rgba(20, 10, 32, 0.78);
  --sc-bg2: rgba(40, 22, 60, 0.92);
  --sc-fg: #fff6e6;
  --sc-dim: rgba(255, 246, 230, 0.6);
  --sc-gold: #ffd166;
  --sc-top: calc(env(safe-area-inset-top, 0px) + 110px);
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 25;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--sc-fg);
  -webkit-tap-highlight-color: transparent;
}
#social-root[hidden] { display: none; }
#social-root button { font: inherit; color: inherit; cursor: pointer; -webkit-user-select: none; user-select: none; }
#social-root.sc-solo [data-mp] { display: none !important; }

.sc-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  background: var(--c, var(--sc-gold)); box-shadow: 0 0 8px var(--c, var(--sc-gold)); flex: none;
}

/* ───────── player list ───────── */
.sc-players {
  position: absolute; left: calc(env(safe-area-inset-left, 0px) + 10px); top: var(--sc-top);
  width: min(230px, 62vw); pointer-events: auto;
  background: var(--sc-bg); border: 1px solid rgba(255, 209, 102, 0.25); border-radius: 16px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  overflow: hidden; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}
.sc-players-head {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 12px;
  background: none; border: 0; font-size: 14px; font-weight: 700;
}
.sc-rtt { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--sc-dim); }
.sc-rtt.good { color: #06d6a0; } .sc-rtt.ok { color: #ffd166; } .sc-rtt.bad { color: #ff6b6b; }
.sc-caret { transition: transform 0.2s; font-size: 12px; opacity: 0.7; }
.sc-players.collapsed .sc-caret { transform: rotate(-90deg); }
.sc-players.collapsed .sc-list, .sc-players.collapsed .sc-invite { display: none; }
.sc-list { list-style: none; margin: 0; padding: 0 6px 4px; max-height: 46vh; overflow-y: auto; }
.sc-list li {
  display: flex; align-items: center; gap: 7px; padding: 7px 6px; border-radius: 10px;
  font-size: 13.5px; cursor: pointer; min-height: 34px;
}
.sc-list li:active { background: rgba(255, 255, 255, 0.08); }
.sc-list li.me { cursor: default; background: rgba(255, 209, 102, 0.08); }
.sc-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-name i { color: var(--sc-dim); font-style: normal; font-size: 11.5px; }
.sc-talk { font-size: 12px; opacity: 0; transition: opacity 0.15s; }
.sc-talk.on { opacity: 1; animation: sc-pulse 0.6s ease-in-out infinite alternate; }
@keyframes sc-pulse { from { transform: scale(0.9); } to { transform: scale(1.25); filter: drop-shadow(0 0 4px #06d6a0); } }
.sc-ms { font-size: 10.5px; color: var(--sc-dim); min-width: 0; }
.sc-mute {
  background: rgba(255, 255, 255, 0.08); border: 0; border-radius: 8px; padding: 3px 6px; font-size: 13px;
}
.sc-mute.on { background: rgba(255, 107, 107, 0.3); }
.sc-invite {
  display: block; width: calc(100% - 12px); margin: 2px 6px 8px; padding: 9px 10px;
  border: 0; border-radius: 12px; font-weight: 700; font-size: 13.5px;
  background: linear-gradient(135deg, #ff9f1c, #ff6b6b); color: #fff; box-shadow: 0 3px 12px rgba(255, 107, 107, 0.4);
}

/* ───────── floating buttons ───────── */
.sc-fabs {
  position: absolute; left: calc(env(safe-area-inset-left, 0px) + 12px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 180px);
  display: flex; flex-direction: column; gap: 10px; pointer-events: auto;
}
.sc-fab {
  position: relative; width: 50px; height: 50px; border-radius: 50%; font-size: 24px;
  background: var(--sc-bg); border: 1px solid rgba(255, 209, 102, 0.35);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.sc-fab:active { transform: scale(0.92); }
.sc-unread {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 9px; background: #ff6b6b; font-size: 11px; font-weight: 800; line-height: 18px; text-align: center;
}
.sc-unread[hidden] { display: none; }

/* ───────── chat ───────── */
.sc-chatlog {
  position: absolute; left: calc(env(safe-area-inset-left, 0px) + 72px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 184px);
  width: min(320px, calc(100vw - 150px)); display: flex; flex-direction: column; gap: 4px;
  pointer-events: none;
}
.sc-chatting .sc-chatlog { bottom: calc(env(safe-area-inset-bottom, 0px) + 236px); }
.sc-line {
  align-self: flex-start; max-width: 100%; padding: 5px 10px; border-radius: 12px;
  background: var(--sc-bg); border-left: 3px solid var(--c); font-size: 13px; line-height: 1.3;
  word-wrap: break-word; transition: opacity 0.3s; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}
.sc-line b { color: var(--c); margin-right: 4px; }
.sc-line.sys { font-size: 12px; color: var(--sc-dim); border-left-style: dashed; }
.sc-chatbar {
  position: absolute; left: calc(env(safe-area-inset-left, 0px) + 10px); right: calc(env(safe-area-inset-right, 0px) + 10px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 180px); max-width: 520px;
  display: flex; gap: 6px; pointer-events: auto; margin-left: 62px;
}
.sc-chatbar[hidden] { display: none; }
.sc-chatin {
  flex: 1; min-width: 0; padding: 12px 14px; border-radius: 24px; border: 1px solid rgba(255, 209, 102, 0.5);
  background: var(--sc-bg2); color: var(--sc-fg); font-size: 16px; /* 16px: no iOS zoom */ outline: none;
}
.sc-send {
  width: 46px; border-radius: 50%; border: 0; font-size: 18px;
  background: linear-gradient(135deg, #ff9f1c, #ff6b6b); color: #fff;
}
.sc-chatting .sc-fab-chat { box-shadow: 0 0 0 2px var(--sc-gold), 0 4px 16px rgba(0, 0, 0, 0.4); }

/* ───────── interaction / emote sheet ───────── */
.sc-sheet {
  position: absolute; inset: 0; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(10, 4, 20, 0.35); pointer-events: auto; animation: sc-fade 0.15s; z-index: 2;
}
.sc-sheet[hidden] { display: none; }
.sc-sheet-card {
  width: 100%; max-width: 520px; padding: 14px 14px calc(env(safe-area-inset-bottom, 0px) + 16px);
  background: var(--sc-bg2); border-radius: 22px 22px 0 0; border-top: 1px solid rgba(255, 209, 102, 0.35);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5); animation: sc-up 0.2s ease-out;
}
.sc-sheet-head { display: flex; align-items: center; gap: 10px; margin: 0 4px 12px; font-size: 17px; }
.sc-sheet-head .sc-dot { width: 14px; height: 14px; }
.sc-sheet-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-x { background: rgba(255, 255, 255, 0.1); border: 0; width: 34px; height: 34px; border-radius: 50%; font-size: 15px; }
.sc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.sc-act {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 14px;
  font-size: 12.5px; font-weight: 600;
}
.sc-act:active { transform: scale(0.94); background: rgba(255, 209, 102, 0.2); }
.sc-e { font-size: 28px; line-height: 1; }
@keyframes sc-up { from { transform: translateY(40px); opacity: 0; } }
@keyframes sc-fade { from { opacity: 0; } }

/* ───────── map pings ───────── */
.sc-pings { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.sc-ping, .sc-arrow { position: absolute; left: 0; top: 0; opacity: 0; will-change: transform; transition: opacity 0.2s; }
.sc-ping { width: 0; height: 0; }
.sc-ping-pin {
  position: absolute; left: -9px; top: -26px; width: 18px; height: 18px;
  background: var(--c); border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  box-shadow: 0 0 14px var(--c); border: 2px solid #fff;
}
.sc-ping-ring {
  position: absolute; left: -18px; top: -9px; width: 36px; height: 18px; border-radius: 50%;
  border: 2px solid var(--c); animation: sc-ring 1.2s ease-out infinite;
}
@keyframes sc-ring { from { transform: scale(0.4); opacity: 1; } to { transform: scale(2.2); opacity: 0; } }
.sc-ping-label {
  position: absolute; left: 0; top: -58px; transform: translateX(-50%); white-space: nowrap;
  padding: 4px 10px; border-radius: 12px; background: var(--sc-bg2); border: 1px solid var(--c);
  font-size: 12.5px; font-weight: 700;
}
.sc-arrow { display: flex; flex-direction: column; align-items: center; margin: -16px 0 0 -16px; width: 32px; }
.sc-arrow-tip {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--c); color: #1a0d26; font-size: 16px; box-shadow: 0 0 12px var(--c);
}
.sc-arrow-label { margin-top: 2px; font-size: 11px; font-weight: 700; white-space: nowrap; text-shadow: 0 1px 3px #000; }

@media (min-width: 900px) {
  .sc-fabs { bottom: calc(env(safe-area-inset-bottom, 0px) + 140px); }
  .sc-chatlog { bottom: calc(env(safe-area-inset-bottom, 0px) + 144px); }
  .sc-chatbar { bottom: calc(env(safe-area-inset-bottom, 0px) + 140px); }
  .sc-chatting .sc-chatlog { bottom: calc(env(safe-area-inset-bottom, 0px) + 196px); }
}
@media (prefers-reduced-motion: reduce) {
  .sc-talk.on, .sc-ping-ring { animation: none; }
}
