.qg-chess-live-dock[hidden],
.qg-chess-live-dock [hidden] { display: none !important; }

.qg-chess-live-dock {
  --qg-activity-bottom-offset: var(--qg-viewport-bottom-offset, 0px);
  position: fixed;
  z-index: 1180;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(max(80px, calc(72px + env(safe-area-inset-bottom, 0px))) + var(--qg-activity-bottom-offset));
  width: min(380px, calc(100vw - 24px));
  color: #e8f1fb;
  font-family: var(--qg-font-sans, Inter, system-ui, sans-serif);
  pointer-events: none;
}

.qg-chess-live-dock.is-open { width: min(410px, calc(100vw - 32px)); }
.qg-chess-live-launcher,
.qg-chess-live-drawer { pointer-events: auto; }

.qg-chess-live-launcher {
  position: relative;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto 14px;
  gap: 9px;
  align-items: center;
  width: 100%;
  min-height: 52px;
  padding: 6px 12px;
  border: 1px solid rgba(251, 113, 133, .48);
  border-radius: 16px;
  background: radial-gradient(circle at 20% 10%, rgba(251, 113, 133, .22), transparent 42%), #0c1b2e;
  box-shadow: 0 16px 42px rgba(2, 6, 23, .42), inset 0 1px rgba(255, 255, 255, .06);
  color: #ecf5ff;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.qg-chess-live-launcher:hover,
.qg-chess-live-launcher:focus-visible {
  border-color: #fda4af;
  outline: 2px solid rgba(251, 113, 133, .2);
  outline-offset: 2px;
}

.qg-chess-live-launcher-icon {
  position: relative;
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 50%;
  background: rgba(251, 113, 133, .14);
  color: #fda4af;
}

.qg-chess-live-launcher-icon::after {
  content: "";
  position: absolute;
  top: 2px;
  right: 2px;
  width: 7px;
  height: 7px;
  border: 2px solid #101d2f;
  border-radius: 50%;
  background: #fb7185;
  box-shadow: 0 0 10px rgba(251, 113, 133, .8);
  animation: qg-floating-spectate-pulse 1.8s ease-in-out infinite;
}

.qg-chess-live-launcher > span:nth-child(2) {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.qg-chess-live-launcher > span:nth-child(2) strong,
.qg-chess-live-launcher > span:nth-child(2) small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qg-chess-live-launcher > span:nth-child(2) strong {
  color: #fff;
  font-size: .82rem;
  line-height: 1.3;
}

.qg-chess-live-launcher > span:nth-child(2) small {
  color: #fecdd3;
  font-size: .72rem;
  line-height: 1.35;
}

.qg-chess-live-launcher > i:last-child {
  display: inline-block;
  color: #fecdd3;
  font-size: .72rem;
}

.qg-chess-live-launcher em {
  position: static;
  display: grid;
  min-width: 23px;
  min-height: 20px;
  place-items: center;
  padding: 3px 5px;
  border: 0;
  border-radius: 999px;
  background: #be3654;
  color: #fff;
  font-size: .6rem;
  font-style: normal;
  font-weight: 950;
  line-height: 1;
}

.qg-chess-live-drawer {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  display: grid;
  grid-template-rows: auto auto auto minmax(140px, 1fr) auto;
  overflow: hidden;
  width: min(410px, calc(100vw - 32px));
  max-height: min(72vh, 720px);
  border: 1px solid rgba(148, 163, 184, .26);
  border-radius: 17px;
  background: radial-gradient(circle at 100% 0%, rgba(251, 113, 133, .1), transparent 34%), rgba(7, 15, 27, .99);
  box-shadow: 0 26px 70px rgba(0, 0, 0, .48), inset 0 1px rgba(255, 255, 255, .05);
}

.qg-chess-live-drawer > header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 38px;
  gap: 9px;
  align-items: center;
  min-height: 58px;
  padding: 10px 12px 10px 15px;
  border-bottom: 1px solid rgba(148, 163, 184, .14);
  background: linear-gradient(110deg, rgba(24, 38, 58, .98), rgba(12, 22, 38, .96));
}

.qg-chess-live-drawer > header > span:first-child {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.qg-chess-live-drawer > header > span:first-child i { color: #fb7185; }
.qg-chess-live-drawer > header strong { font-size: .9rem; }
.qg-floating-spectate-total { color: #fecdd3; font-size: .7rem; font-weight: 900; }

.qg-chess-live-drawer > header button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(148, 163, 184, .2);
  border-radius: 10px;
  background: rgba(148, 163, 184, .07);
  color: #a9b9ca;
  cursor: pointer;
}

.qg-chess-live-drawer > p {
  margin: 0;
  padding: 10px 14px 0;
  color: #879ab1;
  font-size: .7rem;
  line-height: 1.55;
}

.qg-chess-spectate-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 10px 12px 8px;
}

.qg-chess-spectate-filters label { display: grid; gap: 4px; min-width: 0; }
.qg-chess-spectate-filters label > span { color: #7f93ab; font-size: .6rem; font-weight: 900; }
.qg-chess-spectate-filters select {
  width: 100%;
  min-height: 38px;
  padding: 6px 28px 6px 9px;
  border: 1px solid rgba(148, 163, 184, .2);
  border-radius: 9px;
  background: #0b1728;
  color: #e2edf8;
  font: inherit;
  font-size: .7rem;
  font-weight: 800;
}

.qg-floating-spectate-list {
  display: grid;
  align-content: start;
  gap: 7px;
  min-height: 140px;
  padding: 4px 11px 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.qg-floating-spectate-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  min-height: 62px;
  padding: 8px;
  border: 1px solid rgba(148, 163, 184, .14);
  border-radius: 10px;
  background: rgba(10, 20, 34, .88);
}

.qg-floating-spectate-row.is-viewer-match {
  border-color: rgba(61, 214, 198, .42);
  background: linear-gradient(100deg, rgba(20, 92, 91, .28), rgba(10, 20, 34, .9));
  box-shadow: inset 3px 0 0 rgba(61, 214, 198, .78);
}

.qg-floating-spectate-row > span:nth-child(2) { display: grid; gap: 3px; min-width: 0; }
.qg-floating-spectate-row strong,
.qg-floating-spectate-row small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qg-floating-spectate-row strong { color: #edf5fc; font-size: .74rem; }
.qg-floating-spectate-row small { color: #8296ad; font-size: .62rem; }
.qg-floating-spectate-signal {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: rgba(251, 113, 133, .13);
  color: #fb7185;
  font-size: .7rem;
}

.qg-floating-spectate-watch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 66px;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid rgba(61, 214, 198, .34);
  border-radius: 9px;
  background: rgba(61, 214, 198, .11);
  color: #e1fffb;
  font-size: .68rem;
  font-weight: 900;
  text-decoration: none;
}

.qg-floating-spectate-empty {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 140px;
  padding: 22px;
  color: #8fa3ba;
  font-size: .76rem;
  text-align: center;
}
.qg-floating-spectate-empty i { color: #fb7185; font-size: 1.1rem; }

.qg-floating-spectate-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border-top: 1px solid rgba(148, 163, 184, .14);
  background: rgba(8, 17, 30, .96);
  color: #8fa3ba;
  font-size: .68rem;
}

.qg-floating-spectate-pagination button {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid rgba(148, 163, 184, .2);
  border-radius: 9px;
  background: rgba(148, 163, 184, .08);
  color: #e2edf8;
  cursor: pointer;
  font: inherit;
  font-weight: 850;
}

body:has(.qg-mode-theater) .qg-chess-live-dock { display: none; }

/* Wide screens have enough room for both activity surfaces. When chat is
 * expanded, move observation to its left instead of hiding either panel. */
@media (min-width: 901px) {
  .qg-chess-live-dock:not(.is-open) {
    width: min(380px, calc(100vw - 24px));
  }

  .qg-chess-live-dock.is-open .qg-chess-live-launcher {
    width: min(380px, calc(100vw - 24px));
    margin-left: auto;
  }

  body:has(.qg-chess-live-dock.is-open) .qg-floating-chat,
  body:has(.qg-floating-chat.is-open) .qg-chess-live-dock {
    display: block !important;
  }

  body:has(.qg-floating-chat.is-open) .qg-chess-live-dock {
    right: max(412px, calc(396px + env(safe-area-inset-right)));
    bottom: calc(max(16px, env(safe-area-inset-bottom, 0px)) + var(--qg-activity-bottom-offset));
  }
}

/* Compact screens expose two small launchers but only one expanded surface. */
@media (max-width: 900px) {
  .qg-chess-live-dock:not(.is-open) {
    right: max(68px, calc(60px + env(safe-area-inset-right)));
    bottom: calc(max(8px, env(safe-area-inset-bottom, 0px)) + var(--qg-activity-bottom-offset));
    width: 48px;
  }

  .qg-chess-live-dock:not(.is-open) .qg-chess-live-launcher {
    grid-template-columns: 1fr;
    gap: 0;
    width: 48px;
    min-height: 48px;
    height: 48px;
    padding: 5px;
    border-radius: 50%;
  }

  .qg-chess-live-dock:not(.is-open) .qg-chess-live-launcher-icon {
    width: 36px;
    height: 36px;
  }

  .qg-chess-live-dock:not(.is-open) .qg-chess-live-launcher > span:nth-child(2),
  .qg-chess-live-dock:not(.is-open) .qg-chess-live-launcher > i:last-child {
    display: none;
  }

  .qg-chess-live-dock:not(.is-open) .qg-chess-live-launcher em {
    position: absolute;
    top: -5px;
    right: -7px;
    min-width: 23px;
    min-height: 20px;
    padding: 3px 5px;
    border: 2px solid #07101b;
    font-size: .52rem;
  }

  body:has(.qg-chess-live-dock.is-open) .qg-floating-chat { display: none !important; }
  body:has(.qg-floating-chat.is-open) .qg-chess-live-dock { display: none !important; }

  body:has(.qg-chess-live-dock) .qg-floating-chat:not(.is-open) {
    right: max(8px, env(safe-area-inset-right));
    bottom: calc(max(8px, env(safe-area-inset-bottom, 0px)) + var(--qg-activity-bottom-offset));
    left: auto;
    width: 48px;
  }

  body:has(.qg-chess-live-dock) .qg-floating-chat:not(.is-open) .qg-floating-chat-bar {
    display: flex;
    justify-content: center;
    width: 48px;
    min-height: 48px;
    height: 48px;
    padding: 6px;
    border-radius: 50%;
  }

  body:has(.qg-chess-live-dock) .qg-floating-chat:not(.is-open) .qg-floating-chat-bar-copy,
  body:has(.qg-chess-live-dock) .qg-floating-chat:not(.is-open) .qg-floating-chat-expand-icon {
    display: none;
  }

  body:has(.qg-chess-live-dock) .qg-floating-chat:not(.is-open) .qg-floating-chat-unread {
    position: absolute;
    top: -4px;
    right: -4px;
  }

  body:has(.qg-floating-chat) .qg-chess-live-dock:not(.is-open) {
    display: block;
    right: max(68px, calc(60px + env(safe-area-inset-right)));
    bottom: calc(max(8px, env(safe-area-inset-bottom, 0px)) + var(--qg-activity-bottom-offset));
    width: 48px;
  }
}

@keyframes qg-floating-spectate-pulse {
  50% { opacity: .48; transform: scale(.82); }
}

@media (max-width: 620px) {
  .qg-chess-live-dock,
  .qg-chess-live-dock:not(.is-open) {
    display: block;
    right: max(68px, calc(60px + env(safe-area-inset-right)));
    bottom: calc(max(12px, env(safe-area-inset-bottom, 0px)) + var(--qg-activity-bottom-offset));
    width: 48px;
  }

  .qg-chess-live-dock.is-open { right: max(8px, env(safe-area-inset-right)); }
  .qg-chess-live-launcher { width: 48px; min-height: 48px; height: 48px; }
  .qg-chess-live-launcher-icon { width: 36px; height: 36px; }
  .qg-chess-live-dock.is-open .qg-chess-live-launcher { display: none; }
  .qg-chess-live-drawer {
    position: fixed;
    right: max(8px, env(safe-area-inset-right));
    bottom: calc(max(8px, env(safe-area-inset-bottom, 0px)) + var(--qg-activity-bottom-offset));
    left: max(8px, env(safe-area-inset-left));
    width: auto;
    max-height: min(82dvh, 680px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .qg-chess-live-launcher-icon::after { animation: none; }
}
