/* 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 16px 85px 16px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        display: flex;
        flex-direction: column;
        gap: 8px;
        position: relative;
        z-index: 1;
        scroll-behavior: smooth;
    }

    .chat-messages > .chat-message:first-child {
        margin-top: auto;
    }

    /* =========================================
       ПРЕМИАЛЬНЫЕ ПУЗЫРИ
       ========================================= */
    .chat-message {
        position: relative;
        display: flex;
        flex-direction: column;
        max-width: 85%;
        padding: 8px 12px !important;
        border-radius: 18px !important;
        border-bottom-left-radius: 4px !important;
        flex-shrink: 0;
        align-self: flex-start !important;
        background: rgba(28, 28, 38, 0.95) !important;
        border: 1px solid rgba(255, 255, 255, 0.05) !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
    }

    .chat-message.is-mine {
        align-self: flex-end !important;
        background: linear-gradient(135deg, #6366f1, #4f46e5) !important;
        border-radius: 18px !important;
        border-bottom-right-radius: 4px !important;
        border-bottom-left-radius: 18px !important;
        border: 1px solid rgba(255, 255, 255, 0.15) !important;
        box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3) !important;
    }

    .chat-sender {
        font-size: 12px !important;
        font-weight: 600 !important;
        color: #a5b4fc !important;
        margin-bottom: 2px !important;
        display: block !important;
    }
    .chat-message.is-mine .chat-sender { display: none !important; }

    .chat-text {
        font-size: 14.5px !important;
        color: #e4e4e7 !important;
        line-height: 1.35 !important;
        word-break: break-word !important;
        margin-bottom: 2px !important;
    }
    .chat-message.is-mine .chat-text { color: #ffffff !important; }

    .chat-time {
        font-size: 10px !important;
        color: rgba(255, 255, 255, 0.4) !important;
        align-self: flex-end !important;
        margin-top: 2px !important;
    }
    .chat-message.is-mine .chat-time { color: rgba(255, 255, 255, 0.7) !important; }

    .chat-time span { display: none !important; }

    /* =========================================
       ПОЛЕ ВВОДА (Единый блок как в TG)
       ========================================= */
    .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;

        /* Цвет "грязного стекла" как в TG */
        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: hidden;
        /* Важно: убираем жесткую высоту, чтобы блок рос вместе с textarea */
        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; }
    }

    /* НОВЫЙ СТИЛЬ ДЛЯ TEXTAREA (с авто-расширением) */
    .chat-input {
        font-size: 15px !important;
        flex: 1;
        min-width: 0;
        /* Убираем жесткую высоту, чтобы JS мог управлять ей */
        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;
        /* Позволяем скроллить, когда достигнут max-height */
        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;
        bottom: 65px !important;
        left: 12px !important;
        right: 12px !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: 200px !important;
        overflow-y: auto !important;
        display: none;
        z-index: 40 !important;
    }
    #mentionDropdown .mention-item {
        color: #ffffff !important;
        border-bottom: 1px solid rgba(255,255,255,0.05);
    }
}
/*v4*/