.game-chat {
    --chat-violet: #6726db;
    --chat-violet-dark: #37146f;
    --chat-orange: #ff8a1f;
    --chat-ink: #1f1930;
    --chat-muted: #6f687c;
    position: fixed;
    z-index: 175;
    right: 22px;
    bottom: max(24px, env(safe-area-inset-bottom));
    pointer-events: none;
}

.game-chat button,
.game-chat input { font: inherit; }

.game-chat-launcher {
    min-height: 64px;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 4px 16px 4px 5px;
    border: 1px solid rgba(109, 40, 217, .22);
    border-radius: 999px;
    color: #fff;
    background: linear-gradient(120deg, #32125f, #6726db 64%, #8d3eee);
    box-shadow: 0 16px 38px rgba(49, 18, 95, .3);
    pointer-events: auto;
    cursor: pointer;
    transition: transform .2s ease, box-shadow .2s ease, opacity .2s ease;
}

.game-chat-launcher:hover,
.game-chat-launcher[aria-expanded="true"] {
    box-shadow: 0 19px 45px rgba(49, 18, 95, .38);
    transform: translateY(-2px);
}

.game-chat-launcher:focus-visible,
.game-chat button:focus-visible,
.game-chat input:focus-visible {
    outline: 3px solid rgba(255, 138, 31, .65);
    outline-offset: 3px;
}

.game-chat-launcher img {
    width: 54px;
    height: 54px;
    flex: 0 0 54px;
    object-fit: contain;
    filter: drop-shadow(0 5px 7px rgba(15, 5, 37, .24));
}

.game-chat-launcher > span { display: grid; min-width: 0; text-align: left; }
.game-chat-launcher strong { font-size: 12px; line-height: 1.2; }
.game-chat-launcher small { margin-top: 2px; color: #e9dcff; font-size: 9px; }

.game-chat-panel[hidden] { display: none !important; }

.game-chat-panel {
    position: absolute;
    right: 0;
    bottom: 76px;
    width: min(392px, calc(100vw - 28px));
    max-height: min(650px, calc(100vh - 115px));
    display: grid;
    grid-template-rows: auto minmax(150px, 1fr) auto auto auto auto;
    overflow: hidden;
    border: 1px solid rgba(91, 33, 182, .18);
    border-radius: 25px;
    color: var(--chat-ink);
    background: rgba(255, 255, 255, .99);
    box-shadow: 0 28px 75px rgba(27, 12, 54, .3);
    pointer-events: auto;
    animation: gameChatIn .22s ease-out both;
}

.game-chat-header {
    min-width: 0;
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 9px;
    padding: 11px 11px 10px 12px;
    color: #fff;
    background: radial-gradient(circle at 16% 5%, rgba(255, 138, 31, .3), transparent 26%), linear-gradient(125deg, #271044, #5f20ca 70%, #7b30df);
}

.game-chat-header > img {
    width: 56px;
    height: 56px;
    object-fit: contain;
    filter: drop-shadow(0 5px 8px rgba(0, 0, 0, .22));
}

.game-chat-header > div { min-width: 0; display: grid; }
.game-chat-header > div > span { display: flex; align-items: center; gap: 5px; color: #dcd0f5; font-size: 8px; font-weight: 750; }
.game-chat-header > div > span i { width: 7px; height: 7px; border-radius: 50%; background: #45e19a; box-shadow: 0 0 0 4px rgba(69, 225, 154, .14); }
.game-chat-header strong { margin-top: 3px; overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }

.game-chat-close,
.game-chat-bell {
    min-width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .17);
    border-radius: 11px;
    color: #fff;
    background: rgba(255, 255, 255, .1);
    cursor: pointer;
}

.game-chat-close { font-size: 22px; line-height: 1; }
.game-chat-bell { min-width: 43px; height: 42px; gap: 0; align-content: center; }
.game-chat-bell span { font-size: 18px; line-height: .9; }
.game-chat-bell small { font-size: 7px; }
.game-chat-bell[aria-pressed="true"] { border-color: #62e6a6; background: rgba(39, 193, 117, .24); }

.game-chat-log {
    min-width: 0;
    min-height: 0;
    display: grid;
    align-content: start;
    gap: 12px;
    overflow-y: auto;
    padding: 16px 14px 10px;
    background: linear-gradient(180deg, #f7f3ff, #fff 34%);
    scrollbar-width: thin;
}

.chat-message { min-width: 0; display: flex; align-items: flex-end; gap: 7px; }
.chat-message > img { width: 34px; height: 34px; flex: 0 0 34px; object-fit: contain; }
.chat-message > div { min-width: 0; max-width: 83%; padding: 10px 12px; border-radius: 15px 15px 15px 5px; background: #fff; box-shadow: 0 6px 18px rgba(42, 25, 73, .08); }
.chat-message strong { display: block; margin-bottom: 3px; color: #5b21b6; font-size: 8px; letter-spacing: .04em; text-transform: uppercase; }
.chat-message p { margin: 0; color: #4d4658; font-size: 11px; line-height: 1.48; overflow-wrap: anywhere; }
.chat-message--user { justify-content: flex-end; }
.chat-message--user > div { border-radius: 15px 15px 5px 15px; color: #fff; background: linear-gradient(120deg, #5720b7, #7b32df); }
.chat-message--user p { color: #fff; }

.chat-result-list { display: grid; gap: 7px; margin-top: 9px; }
.chat-result-card { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 8px; padding: 9px; border: 1px solid #e4daf6; border-radius: 11px; background: #fbf9ff; }
.chat-result-card > span { min-width: 0; display: grid; }
.chat-result-card b { overflow: hidden; color: #272130; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.chat-result-card small { color: #777080; font-size: 8px; }
.chat-result-actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.chat-result-actions a { min-height: 34px; display: inline-flex; align-items: center; justify-content: center; padding: 6px 8px; border: 1px solid #d6c7f2; border-radius: 9px; color: #5b21b6; background: #fff; font-size: 9px; font-weight: 850; text-align: center; }
.chat-result-actions a.chat-download-link { border-color: transparent; color: #fff; background: linear-gradient(115deg, #5c22c2, #8e36e7); }
.chat-result-actions a[aria-disabled="true"] { border-color: #e6e4e9; color: #8d8992; background: #efeff2; pointer-events: none; }

.game-chat-suggestions { display: flex; gap: 6px; overflow-x: auto; padding: 6px 14px 7px; scrollbar-width: none; }
.game-chat-suggestions:empty { display: none; }
.game-chat-suggestions::-webkit-scrollbar { display: none; }
.game-chat-suggestions button { flex: 0 0 auto; max-width: 150px; padding: 7px 10px; overflow: hidden; border: 1px solid #ded1f4; border-radius: 999px; color: #5c24b9; background: #faf7ff; font-size: 9px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }

.game-chat-form { min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 7px; padding: 10px 12px; border-top: 1px solid #ece7f3; background: #fff; }
.game-chat-form input { min-width: 0; min-height: 42px; padding: 8px 11px; border: 1px solid #ded9e8; border-radius: 12px; color: #241e2c; background: #fafafa; font-size: 12px; }
.game-chat-send,
.game-chat-mic { min-height: 42px; padding: 7px 12px; border: 0; border-radius: 12px; color: #fff; background: linear-gradient(120deg, #5c22c2, #8a37e1); cursor: pointer; }
.game-chat-send { display: inline-flex; align-items: center; gap: 7px; font-size: 10px; font-weight: 850; }
.game-chat-send b { font-size: 16px; }
.game-chat-mic { width: 42px; padding: 0; }
.game-chat-mic span { position: relative; font-size: 15px; }
.game-chat-mic.is-listening { background: #d92d58; animation: chatMicPulse 1s ease-in-out infinite; }

.game-chat-status,
.game-push-status { min-height: 0; margin: 0; padding: 0 14px; color: #8a4b00; font-size: 9px; font-weight: 750; }
.game-chat-status:empty,
.game-push-status:empty { display: none; }
.game-push-status { color: #087a4f; }
.game-chat-note { display: block; padding: 7px 14px 11px; color: #85808b; font-size: 8px; line-height: 1.35; }

body.install-prompt-visible .game-chat-launcher { opacity: 0; pointer-events: none; transform: translateY(12px); }

@keyframes gameChatIn {
    from { opacity: 0; transform: translateY(12px) scale(.98); }
    to { opacity: 1; transform: none; }
}

@keyframes chatMicPulse {
    50% { box-shadow: 0 0 0 5px rgba(217, 45, 88, .18); }
}

@media (max-width: 900px) {
    .game-chat { right: 10px; bottom: calc(88px + env(safe-area-inset-bottom)); }
    .game-chat-launcher { min-width: 58px; min-height: 58px; padding: 2px; }
    .game-chat-launcher img { width: 54px; height: 54px; }
    .game-chat-launcher > span { display: none; }
    .game-chat-panel { right: -2px; bottom: 68px; max-height: calc(100vh - 178px - env(safe-area-inset-top)); }
    body:has(.game-chat) .telegram-fab { right: 77px; bottom: calc(96px + env(safe-area-inset-bottom)); }
    body:has(.download-dock) .game-chat { bottom: calc(158px + env(safe-area-inset-bottom)); }
    body:has(.download-dock):has(.game-chat) .telegram-fab { bottom: calc(166px + env(safe-area-inset-bottom)); }
}

@media (max-width: 430px) {
    .game-chat-panel { width: calc(100vw - 16px); border-radius: 20px; }
    .game-chat-header { grid-template-columns: 49px minmax(0, 1fr) auto auto; gap: 6px; padding-left: 8px; }
    .game-chat-header > img { width: 49px; height: 49px; }
    .game-chat-close { min-width: 32px; width: 32px; }
    .game-chat-bell { min-width: 39px; }
    .game-chat-send { padding-inline: 10px; }
    .game-chat-send span { display: none; }
}

@media (display-mode: standalone) and (max-width: 900px) {
    .game-chat { bottom: calc(88px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
    .game-chat-panel,
    .game-chat-launcher,
    .game-chat-mic { animation: none !important; transition: none !important; }
}
