/* Live Tournament — PWA (Premium Telegram Style) */
@media (max-width: 768px) {
    body.has-bottom-tab:has(#liveTournamentScreen:not(.hidden)) .bottom-tab {
        display: none !important;
    }

    body { padding: 0; margin: 0; background: transparent; }
    main { padding: 0 !important; }
    #contentArea { max-width: 100% !important; padding: 0 !important; }

    #liveTournamentScreen {
        height: 100%;
        padding: 0 !important;
        margin: 0;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        z-index: 30;
        background: transparent;
        overflow: hidden;
    }

    #liveTournamentScreen .max-w-4xl {
        max-width: 100% !important;
        width: 100% !important;
        display: flex;
        flex-direction: column;
        height: 100%;
        padding: 0;
        margin: 0;
    }

    .live-header {
        padding: 10px 12px;
        padding-top: calc(10px + env(safe-area-inset-top, 0px));
        margin: 0;
        background: transparent;
        flex-shrink: 0;
    }

    .players-row {
        padding: 0 12px;
        margin-bottom: 8px;
        flex-shrink: 0;
        max-height: 28px;
        overflow-x: auto;
        white-space: nowrap;
    }

    #content {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
        padding: 0;
    }

    .video-card {
        margin: 0 12px 8px;
        border-radius: 16px;
        flex-shrink: 0;
        position: relative;
        width: calc(100% - 24px);
        height: 220px;
        background: #000000;
        overflow: hidden;
    }

    .video-card iframe,
    .video-card #streamFrame {
        position: absolute;
        top: 50%; left: 50%;
        transform: translate(-50%, -50%) scale(1.15);
        width: 100% !important;
        height: 100% !important;
        border: none !important;
        border-radius: 16px !important;
        object-fit: cover;
    }

    .chat-title { display: none; }

    /* ЧАТ */
    .chat-container {
        flex: 1;
        min-height: 0;
        margin: 0 !important;
        padding: 0;
        display: flex;
        flex-direction: column;
        background: transparent !important;
        overflow: hidden;
        position: relative;
    }

    .chat-messages {
        flex: 1;
        min-height: 0;
        padding: 12px 10px 85px 10px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        display: flex;
        flex-direction: column;
        gap: 4px;
        position: relative;
        z-index: 1;
        scroll-behavior: smooth;
    }

    /* =========================================
       ОБЕРТКА СООБЩЕНИЯ (АВАТАРКА + ПУЗЫРЬ)
       ========================================= */
    .tg-message-wrapper {
        display: flex;
        align-items: flex-end;
        gap: 8px;
        margin-bottom: 8px;
        width: 100%;
    }

    .tg-message-wrapper.compact {
        margin-bottom: 2px;
    }

    .tg-avatar-slot {
        width: 32px;
        flex-shrink: 0;
    }

    .tg-avatar {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 14px;
        font-weight: 700;
        box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    }

    /* =========================================
       ПУЗЫРИ В СТИЛЕ ТЕЛЕГРАМ
       ========================================= */
    .tg-message {
        position: relative;
        max-width: 80%;
        padding: 6px 10px 6px 10px;
        border-radius: 12px;
        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
        box-shadow: 0 1px 2px rgba(0,0,0,0.15);
        display: flex;
        flex-direction: column;
        flex-shrink: 0;
    }

    /* Входящие (слева) */
    .tg-message:not(.is-mine) {
        background: #182533 !important;
        border-bottom-left-radius: 4px;
    }

    /* Исходящие (справа) */
    .tg-message.is-mine {
        background: #2b5278 !important;
        margin-left: auto; /* Прижимаем к правому краю */
        border-bottom-right-radius: 4px;
    }

    .tg-sender {
        font-size: 13.5px;
        font-weight: 600;
        margin-bottom: 2px;
        line-height: 1.2;
    }

    .tg-text {
        font-size: 15.5px;
        color: #ffffff !important;
        line-height: 1.3;
        word-break: break-word;
        margin-bottom: 4px;
    }

    .tg-text span {
        color: #64b5f6 !important;
        cursor: pointer;
    }

    .tg-meta {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 4px;
        margin-top: -8px;
        align-self: flex-end;
    }

    .tg-time {
        font-size: 11px;
        color: rgba(255, 255, 255, 0.5) !important;
    }

    .tg-message.is-mine .tg-time {
        color: rgba(255, 255, 255, 0.7) !important;
    }

    .tg-checks {
        display: flex;
        align-items: center;
        color: #5ca9d6 !important;
        margin-bottom: 1px;
    }

    .tg-reply {
        background: rgba(0, 0, 0, 0.2) !important;
        border-left: 3px solid #64b5f6 !important;
        border-radius: 4px;
        padding: 4px 8px;
        margin-bottom: 4px;
        display: flex;
        flex-direction: column;
    }

    .tg-reply-name {
        font-size: 13px;
        font-weight: 600;
        margin-bottom: 2px;
    }

    .tg-reply-text {
        font-size: 13.5px;
        color: rgba(255, 255, 255, 0.8) !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    .tg-edited {
        font-size: 12px;
        color: rgba(255, 255, 255, 0.5);
        margin-left: 4px;
    }

    /* =========================================
       ПОЛЕ ВВОДА
       ========================================= */
    .chat-input-row {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 6px 12px;
        padding-bottom: calc(15px + env(safe-area-inset-bottom, 15px));
        display: flex;
        gap: 8px;
        align-items: flex-end;
        justify-content: flex-end;
        background: transparent !important;
        z-index: 10;
        border-top: none !important;
    }

    .input-wrapper {
        flex: 0 1 auto;
        width: 82%;
        display: flex;
        flex-direction: column;
        background: rgba(28, 33, 43, 0.85) !important;
        backdrop-filter: blur(24px);
        -webkit-backdrop-filter: blur(24px);
        border-radius: 22px;
        min-height: 40px;
        border: none !important;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2) !important;
        overflow: visible;
        height: auto;
    }

    .reply-bar {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 14px;
        background: transparent !important;
        border: none !important;
        animation: fadeIn 0.15s ease-out;
    }

    .reply-bar.hidden { display: none !important; }

    .reply-bar-left {
        display: flex;
        align-items: stretch;
        flex: 1;
        overflow: hidden;
    }

    .reply-bar-line {
        width: 3px;
        background-color: #3b82f6;
        border-radius: 2px;
        margin-right: 10px;
        flex-shrink: 0;
    }

    .reply-bar-content {
        display: flex;
        flex-direction: column;
        overflow: hidden;
        flex: 1;
        justify-content: center;
    }

    .reply-bar-sender {
        font-size: 13px;
        font-weight: 600;
        color: #60a5fa;
        margin-bottom: 2px;
    }

    .reply-bar-text {
        font-size: 14px;
        color: rgba(255, 255, 255, 0.6);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    .reply-bar-close {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        border-radius: 50%;
        cursor: pointer;
        color: rgba(255, 255, 255, 0.5);
        background: transparent;
        transition: all 0.2s;
        flex-shrink: 0;
        margin-left: 8px;
    }

    .reply-bar-close:active {
        background: rgba(255, 255, 255, 0.1);
        color: #ffffff;
    }

    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }

    .chat-input {
        font-size: 15px !important;
        flex: 1;
        min-width: 0;
        height: auto;
        min-height: 24px;
        max-height: 120px;
        padding: 8px 14px;
        background: transparent !important;
        border: none !important;
        color: #ffffff;
        outline: none;
        resize: none;
        line-height: 1.35;
        font-family: inherit;
        overflow-y: hidden;
        word-break: break-word;
        white-space: pre-wrap;
    }
    .chat-input::placeholder { color: rgba(255,255,255,0.4); }

    .send-btn {
        display: flex !important;
        flex-shrink: 0;
        width: 38px;
        height: 38px;
        border-radius: 50%;
        background: #3b82f6;
        border: none;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
        margin-bottom: 3px;
    }

    /* =========================================
       КОНТЕКСТНОЕ МЕНЮ
       ========================================= */
    .context-menu {
        position: fixed !important;
        background: rgba(30, 30, 35, 0.95) !important;
        backdrop-filter: blur(20px) !important;
        -webkit-backdrop-filter: blur(20px) !important;
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
        border-radius: 14px !important;
        padding: 6px !important;
        display: flex;
        flex-direction: column;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5) !important;
        z-index: 1000 !important;
        min-width: 140px;
        animation: scaleIn 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }

    @keyframes scaleIn {
        from { opacity: 0; transform: scale(0.9) translateY(10px); }
        to { opacity: 1; transform: scale(1) translateY(0); }
    }

    .context-menu-item {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 10px 14px !important;
        background: transparent !important;
        border: none !important;
        border-radius: 8px !important;
        color: #ffffff !important;
        font-size: 14px !important;
        font-weight: 500 !important;
        text-align: left;
        cursor: pointer;
        transition: background 0.1s;
    }

    .context-menu-item:active {
        background: rgba(255, 255, 255, 0.1) !important;
    }

    .context-menu-item.delete {
        color: #ff453a !important;
    }
    .context-menu-item.delete:active {
        background: rgba(255, 69, 58, 0.15) !important;
    }

    /* =========================================
       ПОИСК ИГРОКОВ (@)
       ========================================= */
    #mentionDropdown {
        position: absolute !important;
        left: 12px !important;
        right: 12px !important;
        bottom: calc(100% + 8px) !important;
        background: rgba(28, 28, 38, 0.98) !important;
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
        border-radius: 12px !important;
        max-height: 220px !important;
        overflow-y: auto !important;
        display: none;
        z-index: 9999 !important;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5) !important;
        -webkit-overflow-scrolling: touch;
    }

    #mentionDropdown .mention-item {
        color: #ffffff !important;
        border-bottom: 1px solid rgba(255,255,255,0.05);
        padding: 10px 16px;
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 14px;
    }

    #mentionDropdown .mention-item:active {
        background: rgba(99, 102, 241, 0.15);
    }

    #mentionDropdown .mention-item:last-child {
        border-bottom: none;
    }
}

/* Плашка для @упоминания в тексте */
.tg-text .mention {
    color: #64b5f6;
    background: rgba(100, 181, 246, 0.15);
    padding: 2px 6px;
    border-radius: 6px;
    font-weight: 500;
    display: inline-block;
    margin-bottom: 4px;
}
.tg-text .mention:first-child {
    display: block;
    width: fit-content;
    margin-bottom: 6px;
}
/*v7*/