/* PercRewards floating chat: completely independent of document layout. */
#perc-chat {
  position: fixed;
  top: 82px;
  right: 12px;
  bottom: 12px;
  width: min(350px, calc(100vw - 24px));
  z-index: 9000;
  display: flex;
  flex-direction: column;
  min-height: 0;
  color: #e9eeff;
  background: linear-gradient(155deg, rgba(28,40,69,.98), rgba(13,23,42,.98));
  border: 1px solid rgba(117,143,255,.35);
  border-radius: 16px;
  box-shadow: -10px 12px 45px rgba(0,0,0,.4), 0 0 32px rgba(65,105,225,.13);
  font: 14px 'PolySans', 'Outfit', system-ui, sans-serif;
  transition: transform .24s ease;
  isolation: isolate;
}
#perc-chat, #perc-chat * { box-sizing: border-box; }
#perc-chat .pc-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-shrink: 0; padding: 16px 17px;
  border-bottom: 1px solid rgba(117,143,255,.2);
  background: linear-gradient(110deg,rgba(65,105,225,.18),rgba(104,121,239,.07));
  border-radius: 16px 16px 0 0;
  font-weight: 700; letter-spacing: .04em;
}
#perc-chat .pc-head > span { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
#perc-chat .pc-status { color: #9fb3d9; font-size: 11px; font-weight: 500; letter-spacing: 0; overflow-wrap: anywhere; }
#perc-chat .pc-messages {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 15px 14px; overflow-wrap: anywhere; scrollbar-width: thin;
  scrollbar-color: #50659e transparent;
}
#perc-chat .pc-message {
  margin: 0 0 10px; padding: 10px 11px; line-height: 1.5;
  background: rgba(13,24,47,.58); border: 1px solid rgba(128,151,235,.11);
  border-radius: 11px; font-size: 13px;
}
#perc-chat .pc-name { color: #8fc5ff; font-weight: 700; margin-right: 7px; }
#perc-chat .pc-source {
  display: inline-block; margin-right: 7px; padding: 2px 5px;
  color: #a5f3b7; background: rgba(83,185,111,.1);
  border: 1px solid rgba(83,185,111,.28); border-radius: 5px;
  font-size: 10px; font-weight: 700;
}
#perc-chat .pc-footer {
  flex-shrink: 0; padding: 14px 16px; color: #9fb0d0; font-size: 12px;
  border-top: 1px solid rgba(117,143,255,.2);
  background: rgba(9,17,34,.4); border-radius: 0 0 16px 16px;
}
#perc-chat .pc-close {
  flex-shrink: 0; border: 1px solid rgba(144,164,235,.25); border-radius: 8px;
  background: rgba(115,133,209,.12); color: #e9eeff; cursor: pointer;
  width: 32px; height: 32px; font-size: 21px; line-height: 1;
}
#perc-chat .pc-close:hover, #perc-chat .pc-open:hover { background: rgba(104,121,239,.34); }
#perc-chat .pc-open {
  display: none; position: absolute; right: 100%; top: 20px;
  padding: 12px 10px; border: 1px solid rgba(117,143,255,.4);
  border-right: 0; border-radius: 10px 0 0 10px;
  background: #1b2b4d; color: #f1f5ff; font: 700 12px 'PolySans',system-ui,sans-serif;
  box-shadow: -6px 5px 16px rgba(0,0,0,.2); cursor: pointer;
}
/* Never reserve page space: the chat overlays the page, it does not resize it. */
body.pc-chat-open { padding-right: 0 !important; }
#perc-chat.pc-hidden { transform: translateX(calc(100% + 12px)); }
#perc-chat.pc-hidden .pc-open { display: block; }
@media (max-width: 850px) {
  #perc-chat { top: 10px; right: 8px; bottom: 10px; width: min(350px, calc(100vw - 48px)); }
  #perc-chat.pc-hidden { transform: translateX(calc(100% + 8px)); }
  #perc-chat .pc-open { top: 75px; }
}
@media (prefers-reduced-motion: reduce) { #perc-chat { transition: none; } }

/* Unified website + Kick composer */
#perc-chat .pc-intro{padding:9px 14px;color:#bacaf1;font-size:12px;line-height:1.45;background:rgba(104,121,239,.09);border-bottom:1px solid rgba(117,143,255,.15)}
#perc-chat .pc-live{display:inline-block;width:7px;height:7px;border-radius:50%;background:#62d991;margin-right:6px;vertical-align:middle}
#perc-chat .pc-status{color:#9fb3d9}
#perc-chat .pc-source.pc-site{color:#bbbcff;background:rgba(104,121,239,.17);border-color:rgba(104,121,239,.45)}
#perc-chat .pc-composer{display:flex;gap:7px;align-items:center}
#perc-chat .pc-input{min-width:0;flex:1;padding:10px 11px;border:1px solid rgba(117,143,255,.3);border-radius:9px;background:#0d1931;color:#fff;font:inherit;outline:none}
#perc-chat .pc-input:focus{border-color:#809cff;box-shadow:0 0 0 2px rgba(104,121,239,.15)}
#perc-chat .pc-send{padding:10px 12px;background:#6879ef;border:0;border-radius:9px;color:#fff;font:700 12px 'PolySans',sans-serif;cursor:pointer}
#perc-chat .pc-send:disabled{opacity:.55;cursor:not-allowed}
#perc-chat .pc-hint{margin-top:8px;font-size:11px;color:#b6c5e5;line-height:1.35}
#perc-chat .pc-hint a{color:#9acaff}
#perc-chat .pc-footer{padding:12px 13px}
/* Kick emotes and animated GIF emotes */
#perc-chat .pc-emote {
  display: inline-block;
  width: auto;
  height: 28px;
  max-width: 60px;
  object-fit: contain;
  vertical-align: middle;
  margin: 0 2px;
  border: none;
}

/* Keep message content inside the chat box */
#perc-chat .pc-content {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Slightly smaller emotes on mobile */
@media (max-width: 850px) {
  #perc-chat .pc-emote {
    height: 24px;
    max-width: 50px;
  }
}
/* Kick role badges for both Kick and website messages */
#perc-chat .pc-badges {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  vertical-align: middle;
  margin-right: 4px;
}

#perc-chat .pc-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  font-size: 13px;
  line-height: 1;
  vertical-align: middle;
}

#perc-chat .pc-badge-moderator {
  color: #53c9a1;
}

#perc-chat .pc-badge-broadcaster,
#perc-chat .pc-badge-owner {
  color: #f5c451;
}

#perc-chat .pc-badge-verified {
  color: #62b8ff;
}

/* Seamless inline chat layout */
#perc-chat .pc-message {
  display: block !important;
  width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

#perc-chat .pc-badge {
  display: inline-block !important;
  width: 16px;
  height: 16px;
  margin-right: 2px;
  font-size: 13px;
  line-height: 16px;
  vertical-align: -2px;
  text-align: center;
}

#perc-chat .pc-name {
  display: inline !important;
  margin-right: 4px;
  white-space: nowrap;
}

#perc-chat .pc-content {
  display: inline !important;
  white-space: normal;
  overflow-wrap: anywhere;
}

#perc-chat .pc-source {
  vertical-align: baseline;
  white-space: nowrap;
}

/* Founder and VIP: use locally hosted SVG masks */
#perc-chat .pc-badge-mask {
  display: inline-block;
  width: 18px;
  height: 18px;
  vertical-align: -4px;
  margin-right: 3px;

  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}

/* Founder: bright gold */
#perc-chat .pc-badge-founder {
  background: #ffeb3b;
  -webkit-mask-image: url('/chat/badges/founder.svg');
  mask-image: url('/chat/badges/founder.svg');
}

/* VIP: bright lavender */
#perc-chat .pc-badge-vip {
  background: #ff8c00;
  -webkit-mask-image: url('/chat/badges/vip.svg');
  mask-image: url('/chat/badges/vip.svg');
}

/* Consistent vertical alignment for all Kick badges */
#perc-chat .pc-badge-image,
#perc-chat .pc-badge-mask {
  display: inline-block !important;
  width: 18px !important;
  height: 18px !important;
  min-width: 18px;
  min-height: 18px;
  max-width: 18px;
  max-height: 18px;
  vertical-align: middle !important;
  margin: 0 3px 0 0;
  padding: 0;
  line-height: 18px;
  object-fit: contain;
}

/* Align the KICK/SITE label with the badges */
#perc-chat .pc-source {
  vertical-align: middle !important;
}

/* Align usernames with the same text baseline */
#perc-chat .pc-name {
  vertical-align: middle;
}

/* Keep masked Founder and VIP badges consistent */
#perc-chat .pc-badge-mask {
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}

/* Align KICK/SITE, badges, username and message text */
#perc-chat .pc-message {
  line-height: 22px;
}

#perc-chat .pc-source,
#perc-chat .pc-name,
#perc-chat .pc-content {
  vertical-align: baseline !important;
}

/* Center badges relative to the text */
#perc-chat .pc-badge-image,
#perc-chat .pc-badge-mask {
  vertical-align: -4px !important;
}

/* Chat profile pictures */
#perc-chat .pc-avatar {
  display: inline-block;
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 7px;
  vertical-align: middle;
  margin-right: 8px;
}

/* Round profile pictures */
#perc-chat .pc-avatar {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  margin: 0;
}

/* Avatar left, content right */
#perc-chat .pc-message-layout {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

#perc-chat .pc-message-details {
  flex: 1;
  min-width: 0;
}

/* Badges and username on first row */
#perc-chat .pc-message-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 20px;
}

/* Message on second row */
#perc-chat .pc-message-text {
  margin-top: 4px;
  overflow-wrap: anywhere;
}

/* Small timestamp in bottom-right */
#perc-chat .pc-message-time {
  display: block;
  text-align: right;
  font-size: 10px;
  opacity: 0.45;
  margin-top: 3px;
  line-height: 12px;
}

/* Timestamp directly after username */
#perc-chat .pc-message-time {
  display: inline;
  text-align: left;
  font-size: 10px;
  opacity: 0.45;
  margin: 0 0 0 5px;
  line-height: inherit;
  white-space: nowrap;
}

/* Hide messages until avatar has loaded */
#perc-chat .pc-message-loading {
  opacity: 0;
}

/* Smoothly reveal the complete message */
#perc-chat .pc-message-ready {
  opacity: 1;
  transition: opacity 0.2s ease-in;
}

/* Reply button: floats without shifting message layout */
#perc-chat .pc-message {
  position: relative;
}

#perc-chat .pc-reply-button {
  position: absolute;
  top: 5px;
  right: 6px;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 7px;
  background: #293b60;
  color: #dce8ff;
  font-size: 19px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s;
  z-index: 2;
}

#perc-chat .pc-message:hover .pc-reply-button,
#perc-chat .pc-reply-button:focus-visible {
  opacity: 1;
}

@media (hover: none) {
  #perc-chat .pc-reply-button {
    opacity: 1;
  }
}

/* Reply preview above message input */
#perc-chat .pc-reply-preview:not([hidden]) {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  margin-bottom: 9px;
  background: rgba(104,121,239,.12);
  border-left: 3px solid #809cff;
  border-radius: 7px;
}

#perc-chat .pc-reply-preview[hidden] {
  display: none !important;
}

#perc-chat .pc-reply-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

#perc-chat .pc-reply-target {
  color: #a8caff;
  font-size: 11px;
}

#perc-chat .pc-reply-snippet {
  color: #aab8d5;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#perc-chat .pc-reply-cancel {
  border: 0;
  background: transparent;
  color: #c4d2ee;
  font-size: 21px;
  cursor: pointer;
}

/* Original message preview inside a reply */
#perc-chat .pc-reply-reference {
  margin-top: 5px;
  margin-bottom: 5px;
  padding: 5px 8px;
  border-left: 2px solid #809cff;
  background: rgba(104,121,239,.08);
  border-radius: 0 5px 5px 0;
}

#perc-chat .pc-reply-reference-name {
  color: #a8caff;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
}

#perc-chat .pc-reply-reference-text {
  color: #aab8d5;
  font-size: 11px;
  opacity: .8;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

/* Reply reference above username */
#perc-chat .pc-reply-reference {
  margin-top: 0;
  margin-bottom: 7px;
}

/* Compact, single-line reply preview */
#perc-chat .pc-reply-reference {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin: 0 0 6px;
  padding: 3px 7px;
  border-left: 2px solid #809cff;
  background: rgba(104,121,239,.07);
  border-radius: 0 4px 4px 0;
  overflow: hidden;
}

#perc-chat .pc-reply-reference-text {
  display: block;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow-wrap: normal;
  font-size: 10px;
  line-height: 16px;
  color: #a8b9da;
  opacity: .85;
}

/* Align the avatar with the sender, not the reply preview */
#perc-chat .pc-message-layout:has(.pc-reply-reference) > .pc-avatar {
  margin-top: 27px;
}

/* Keep sender and message close together */
#perc-chat .pc-message-header {
  min-height: 20px;
}

#perc-chat .pc-message-text {
  margin-top: 2px;
}

/* Full-width reply preview above avatar and message */
#perc-chat .pc-message > .pc-reply-reference {
  width: 100%;
  max-width: 100%;
  margin: 0 0 8px;
}

/* Avatar now aligns normally with username */
#perc-chat .pc-message-layout:has(.pc-reply-reference) > .pc-avatar {
  margin-top: 0;
}

/* MOBILE ONLY — move chat below header so close button stays visible */
@media (max-width: 1100px) {

    body #perc-chat {
        position: fixed !important;
        top: 72px !important;
        bottom: 0 !important;
        height: calc(100dvh - 72px) !important;
        max-height: calc(100dvh - 72px) !important;
        z-index: 999999 !important;
    }

    body #perc-chat .pc-header {
        position: relative !important;
        z-index: 2 !important;
    }

}

/* PERRCOS KICK LIVE / OFFLINE INDICATOR */

#perc-chat .pc-stream-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    width: fit-content;
    margin-top: 3px;
    padding: 5px 9px;
    border-radius: 7px;
    background: rgba(255,255,255,0.05);
    color: #aebbd6;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-decoration: none;
}

#perc-chat .pc-stream-dot {
    width: 8px;
    height: 8px;
    flex-shrink: 0;
    border-radius: 50%;
    background: #888;
}

#perc-chat .pc-stream-status.is-live {
    color: #78ffab;
    background: rgba(35, 200, 100, 0.1);
}

#perc-chat .pc-stream-status.is-live .pc-stream-dot {
    background: #23e66c;
    box-shadow: 0 0 9px #23e66c;
    animation: pc-stream-pulse 1.5s infinite;
}

#perc-chat .pc-stream-status.is-offline {
    color: #aebbd6;
}

#perc-chat .pc-stream-status.is-offline .pc-stream-dot {
    background: #888;
}

@keyframes pc-stream-pulse {
    50% {
        opacity: 0.4;
    }
}