.chat{
    position: absolute;
    bottom: 40px;
    left: 20px;
    width: 320px;
    max-width: 50%;
    pointer-events: none;
    z-index: 3;
}

.history-game .chat{
    display: none;
}

.chat .input{
    display: flex;
    gap: 10px;
    align-items: center;
    width: 100%;
    pointer-events: auto;
}

.chat .input > .text-input{
    flex: 1 1 auto;
    font-size: 12px;
    border: none;
    outline: none;
    color: var(--tex-secondary);
    padding: 8px;
    border-radius: 8px;
    background-color: #121214;
}

.chat .input > button[data-id="send"]{
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    background-color: #121214;
    border-radius: 16px;
    background-image: url(/images/sendchat.svg);
    background-repeat: no-repeat;
    background-size: 14px;
    background-position: top 50% left 60%;
    border: none;
    outline: none;
    cursor: pointer;
}

.chat .input > button[data-id="send"]:hover{
    background-color: #29292e;
}

.chat .input > .text-input:focus,
.chat .input > button[data-id="emo"]:focus,
.chat .input > button[data-id="emo"]:hover,
.chat .input > button[data-id="send"]:hover,
.chat .input > label[data-id="collapse"]:hover{
    background-color: #222223;
}

.chat .input > .text-input[placeholder]:empty:before{
    content: attr(placeholder);
    color: #46464f;
}
.chat .input > label[data-id="collapse"]{
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    background-color: #121214;
    border-radius: 16px;
    border: none;
    outline: none;
    cursor: pointer;
    position: relative;
    background-image: url(/images/collapse.svg);
    background-repeat: no-repeat;
    background-size: 14px;
    background-position: 50%;
}

.chat .input > label[data-id="collapse"] > input{
    display: none;
}

.chat:has(label[data-id="collapse"] > input:checked){

    .input{
        width: fit-content;
    }
    .input > label[data-id="collapse"]{
        background-image: url(/images/chat.svg);
        background-color: #121214;
    }
    .input > .text-input{
        display: none;
    }
    button{
        display: none;
    }
    .messages{
        display: none;
    }
}

.chat .input > button[data-id="emo"]{
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    background-color: #121214;
    border-radius: 16px;
    border: none;
    outline: none;
    cursor: pointer;
    position: relative;
    text-align: center;
}

.chat .input > button[data-id="emo"]::before{
    content: attr(data-emo-icon);

}

.chat .input > button[data-id="emo"] > div{
    display: none;
}

.chat .input > button[data-id="emo"]:focus > div{
    position: absolute;
    background-color: #121214;
    border-radius: 16px;
    bottom: 40px;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 5px;
    font-size: 20px;
    padding: 8px;
}

.chat .messages{
    display: flex;
    flex-direction: column-reverse;
    gap: 6px;
    padding: 6px 0;
    width: fit-content;
    pointer-events: none;

    padding-top: 20px;
   
    -webkit-mask-image: linear-gradient(
        to bottom,
        transparent 0%,
        black 20%,
        black 50%
    );

    mask-image: linear-gradient(
        to bottom,
        transparent 0%,
        black 20%,
        black 50%
    );

}

.chat .messages::-webkit-scrollbar {
  display: none;
}

.chat .messages > div{
    display: flex;
    gap: 6px;
    align-items: flex-start;
    width: fit-content;
    max-width: 100%;
}

.chat .messages > div > .chat-avatar{
    position: relative;
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    overflow: hidden;
    background: #1e1e1e;
    color: #f4f4f5;
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 600;
    pointer-events: auto;
    cursor: pointer;
}

.chat .messages > div > .chat-avatar::after{
    content: attr(data-initials);
}

.chat .messages > div > .chat-avatar[data-photo-state="photo"]::after{
    display: none;
}

.chat .messages > div > .chat-avatar > img{
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat .messages > div > .chat-message-body{
    min-width: 0;
}

.chat .messages > div > div .chat-author{
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
}

.chat .messages > div > div .name{
    min-width: 0;
    font-size: 10px;
    font-weight: 400;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat .messages > div > div .rank{
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 3px;
    width: auto;
    margin: 0;
    padding: 1px 5px 1px 3px;
    border-radius: 999px;
    background: var(--rank-pill-bg, rgba(238, 231, 215, .14));
    box-shadow: none;
    color: #a7a7a7;
    font-size: 10px;
    font-weight: 500;
}

.chat .messages > div > div .rank[data-rank="1"]{ color: #22BBFE; --rank-pill-bg: rgba(34,187,254,.13); }
.chat .messages > div > div .rank[data-rank="2"]{ color: #EEE7D7; --rank-pill-bg: rgba(238,231,215,.14); }
.chat .messages > div > div .rank[data-rank="3"]{ color: #EF0F27; --rank-pill-bg: rgba(239,15,39,.14); }
.chat .messages > div > div .rank[data-rank="4"]{ color: #FFDB3A; --rank-pill-bg: rgba(255,219,58,.14); }
.chat .messages > div > div .rank[data-rank="5"]{ color: #EE9902; --rank-pill-bg: rgba(238,153,2,.16); }
.chat .messages > div > div .rank[data-rank="6"]{ color: #0074B1; --rank-pill-bg: rgba(203,238,255,.88); }
.chat .messages > div > div .rank[data-rank="7"]{ color: #AC5D03; --rank-pill-bg: rgba(255,229,194,.86); }

.chat .messages > div > div .rank img{
    flex: 0 0 12px;
    width: 12px;
    height: 12px;
    object-fit: contain;
}

.chat .messages > div > div .message{
    font-size: 12px;
    font-weight: 400;
    color: #d0d0d0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.chat .messages > div.is-pending > .chat-message-body .message{
    color: #a7a7a7;
}

.chat-pending-loader{
    position: relative;
    display: inline-grid;
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    align-items: center;
    justify-content: center;
    place-items: center;
    border: 1px solid #313131;
    border-radius: 50%;
    background: #141414;
    box-sizing: border-box;
}

.chat-pending-loader::after{
    content: '';
    position: absolute;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: #6798ff;
    opacity: .9;
}

.chat-pending-loader > i{
    display: block;
    width: 15px;
    height: 15px;
    border: 2px solid rgba(103, 152, 255, .18);
    border-top-color: #6798ff;
    border-right-color: rgba(103, 152, 255, .68);
    border-radius: 50%;
    box-sizing: border-box;
    animation: chat-pending-spin .85s linear infinite;
}

@keyframes chat-pending-spin{
    to{ transform: rotate(360deg); }
}

.chat-pending-loader,
.chat-pending-loader *{
    pointer-events: none;
}

.chat .messages > .pin{
    /*margin-top: 30px;*/
}

.chat .messages > div.system{
    font-size: 10px;
    background-color: rgb(22, 22, 22);
    color: #fff;
    border-radius: 5px;
    padding: 5px 8px;
    width: fit-content;
    align-items: center;
}

.chat .messages > div.system.moderation-rejected{
    max-width: 280px;
    padding: 5px 8px;
    border: 1px solid #313131;
    border-radius: 8px;
    background: #141414;
    color: #a7a7a7;
    overflow-wrap: anywhere;
}

.chat .messages > div.system.moderation-rejected::before{
    content: '×';
    display: inline-grid;
    place-items: center;
    width: 13px;
    height: 13px;
    margin-right: 5px;
    border-radius: 50%;
    background: #252525;
    color: #a7a7a7;
    font-size: 10px;
}

.chat .messages > div.system.clickable{
    cursor: pointer;
    pointer-events: auto;
}

.chat .messages > div.system.clickable:hover{
    background-color: rgb(30, 30, 30);
}

.chat .messages > div.system > .time{
    margin-left: 6px;
    color: var(--tex-secondary, #a9acb8);
    font-size: 9px;
}

.chat .messages > div.system > .profit{
    margin-left: 6px;
    font-weight: 700;
}

.chat .messages > div.system > .profit[data-positive="true"]{
    color: #16C784;
}

.chat .messages > div.system > .profit[data-positive="false"]{
    color: #EA364F;
}

.chat-admin-menu{
    position: fixed;
    z-index: 1001;
    min-width: 190px;
    padding: 5px;
    background: #19191A;
    border: 1px solid #2b2b2e;
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(0,0,0,0.45);
}

.chat-admin-menu button{
    display: block;
    width: 100%;
    border: none;
    background: transparent;
    color: #FAFAFC;
    text-align: left;
    font-size: 12px;
    padding: 9px 10px;
    border-radius: 7px;
    cursor: pointer;
}

.chat-admin-menu button:hover{
    background: #272729;
}

.chat-admin-menu button:disabled{
    opacity: .42;
    cursor: default;
}

.chat-admin-menu button:disabled:hover{
    background: transparent;
}

.chat-admin-menu button[data-act="delete"],
.chat-admin-menu button[data-act="mute"]{
    color: #EA364F;
}

.chat-mute-modal{
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.55);
}

.chat-mute-modal > div{
    width: min(420px, 92vw);
    background: #19191A;
    border: 1px solid #2b2b2e;
    border-radius: 14px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-mute-modal h2{
    margin: 0;
    font-size: 15px;
}

.chat-mute-modal p{
    margin: 0;
    color: var(--tex-secondary);
    font-size: 12px;
}

.chat-mute-modal label{
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: #DADDE4;
    font-size: 12px;
}

.chat-mute-modal select,
.chat-mute-modal textarea{
    width: 100%;
    background: #121214;
    border: 1px solid #2b2b2e;
    border-radius: 10px;
    color: #FAFAFC;
    outline: none;
    padding: 9px 10px;
}

.chat-mute-modal textarea{
    min-height: 92px;
    resize: vertical;
}

.chat-mute-actions{
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.chat-mute-actions button{
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    color: #fff;
    cursor: pointer;
}

.chat-mute-actions button[data-act="cancel"]{
    background: #272729;
    color: #c9c9cc;
}

.chat-mute-actions button[data-act="apply"]{
    background: #EA364F;
}
