/* ============================================
   FRAME1 - Меню с кнопками (используется везде)
   Адаптивное: кнопки перестраиваются, но не уменьшаются
   ============================================ */

:root {
    --frame1-bg: #f2f2f2;
    --frame1-padding: 15px 20px;
    --frame1-z-index: 1001;
    --frame1-button-padding: 8px 16px;
    --frame1-button-font-size: 14px;
    --frame1-button-gap: 10px;
}

/* Основной контейнер Frame1 */
.frame1 {
    /* Позиционирование управляется через layout.css (fixed) */
    background: var(--color-bg) !important; /* Цвет фона сайта */
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    padding: 15px 40px;
    z-index: 10000 !important; /* Выше всего контента - кнопки должны быть поверх всего */
    /* Динамическая высота в зависимости от контента */
    height: auto;
    min-height: auto;
    transition: height 0.3s ease;
    will-change: height;
    box-sizing: border-box;
    width: 100%;
    pointer-events: auto; /* Гарантируем кликабельность */
    transform: translateY(0) !important;
    opacity: 1 !important;
}

/* Анимация скрытия/показа отключена - фрейм всегда виден */

/* Контент Frame1 */
.frame1-content {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: var(--frame1-button-gap);
    position: relative;
    box-sizing: border-box;
    padding: 0 24px; /* Фиксированные отступы от краев экрана */
    min-height: 48px; /* Минимальная высота для правильного центрирования */
}

/* Контейнер для кнопок */
.frame1-actions {
    display: flex;
    gap: var(--frame1-button-gap);
    align-items: center;
    justify-content: space-between; /* Разносим кнопки по краям */
    flex-wrap: wrap;
    width: 100%;
    min-height: auto;
    box-sizing: border-box;
    position: relative;
    z-index: 0; /* Ниже центрального контента */
}

/* На мобильных - выравниваем по краям */
@media (max-width: 767px) {
    .frame1-actions {
        justify-content: space-between !important;
        align-items: center !important;
    }
}

/* Левая группа кнопок */
.frame1-actions-left {
    display: flex;
    gap: var(--frame1-button-gap);
    align-items: center;
    flex-wrap: wrap;
    flex: 0 1 auto; /* Не растягивается, занимает только необходимое место */
    min-width: 0;
    box-sizing: border-box;
    max-width: calc(50% - 100px); /* Оставляем место для центрального контента */
}

/* Правая группа кнопок */
.frame1-actions-right {
    display: flex;
    gap: var(--frame1-button-gap);
    align-items: center;
    flex-wrap: wrap;
    flex-shrink: 0;
    box-sizing: border-box;
    max-width: calc(50% - 100px); /* Оставляем место для центрального контента */
}

/* Универсальная кнопка Frame1 */
.frame1-button,
button.frame1-button {
    display: inline-block;
    padding: var(--frame1-button-padding);
    background: var(--color-bg);
    border: 2px solid #393639;
    border-radius: 12px;
    color: #393639;
    text-decoration: none;
    font-family: 'Days One', sans-serif;
    font-size: var(--frame1-button-font-size);
    font-weight: 700;
    transition: all 0.3s;
    box-shadow: 
        0 2px 0px rgba(0, 0, 0, 0.2),
        0 4px 8px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
    cursor: pointer;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    line-height: 1.2;
    box-sizing: border-box;
    flex-shrink: 0;
    position: relative;
    z-index: 10001 !important; /* Выше Frame 1 для гарантированной кликабельности */
    pointer-events: auto !important; /* Гарантируем кликабельность */
    /* Размер кнопки НЕ меняется при адаптации */
}

.frame1-button:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 6px 0px rgba(0, 0, 0, 0.3),
        0 8px 16px rgba(0, 0, 0, 0.15);
    background: var(--color-bg);
    color: #393639 !important; /* Сохраняем цвет текста при hover */
}

.frame1-button:active {
    transform: translateY(0px);
}

/* Статус индикатор (для джойстика и т.д.) */
.frame1-status {
    font-family: 'Montserrat', sans-serif;
    font-size: var(--frame1-button-font-size);
    font-weight: 600;
    color: #393639;
    background: var(--color-bg);
    padding: var(--frame1-button-padding);
    border-radius: 12px;
    border: 2px solid #000;
    box-shadow: 
        0 2px 0px rgba(0, 0, 0, 0.2),
        0 4px 8px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
    flex-shrink: 0;
    box-sizing: border-box;
}

.frame1-status.connected {
    background: #2fb95d;
    color: #FFFFFF;
}

.frame1-status.disconnected {
    background: #ff7664;
    color: #FFFFFF;
}

/* Иконки игроков (для multiplayer) */
.frame1-player-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--frame1-button-padding);
    border-radius: 12px;
    font-family: 'Days One', sans-serif;
    font-size: var(--frame1-button-font-size);
    font-weight: 700;
    color: #FFFFFF;
    border: 2px solid;
    box-shadow: 
        0 2px 0px rgba(0, 0, 0, 0.2),
        0 4px 8px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
    cursor: default;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    transition: all 0.3s;
    min-width: auto;
    text-align: center;
    flex-shrink: 0;
    box-sizing: border-box;
}

.frame1-player-icon:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 6px 0px rgba(0, 0, 0, 0.3),
        0 8px 16px rgba(0, 0, 0, 0.15);
}

.frame1-player-icon.waiting {
    background: #ff7664;
    border-color: #ff7664;
}

.frame1-player-icon.ready {
    background: #00C159;
    border-color: #00C159;
}

/* Номер вопроса по центру (для игровых страниц) */
.frame1-question-number {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: #393639;
    opacity: 0.8;
    white-space: nowrap;
    display: none;
    z-index: 1;
}

/* Таймер справа (для игровых страниц) */
.frame1-timer {
    font-family: 'Days One', sans-serif;
    font-size: var(--frame1-button-font-size); /* Такой же размер шрифта как у кнопки */
    font-weight: 700;
    color: #393639;
    text-align: center;
    padding: var(--frame1-button-padding); /* Такой же padding как у кнопки */
    background: var(--color-bg);
    border: 2px solid #393639;
    border-radius: 12px; /* Такой же border-radius как у кнопки */
    box-shadow: 
        0 2px 0px rgba(0, 0, 0, 0.2),
        0 4px 8px rgba(0, 0, 0, 0.1);
    display: none;
    flex-shrink: 0;
    box-sizing: border-box;
    line-height: 1.2; /* Такой же line-height как у кнопки */
    white-space: nowrap;
    min-width: 40px;
    letter-spacing: 0.5px;
}

.frame1-timer.urgent {
    color: #ff7664;
    background: rgba(255, 118, 100, 0.15);
    border-color: #ff7664;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.frame1-timer.urgent {
    color: #ff7664;
    background: rgba(255, 118, 100, 0.15);
    border-color: #ff7664;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Меню персонажей */
.frame1-character-menu {
    position: relative;
    display: inline-block;
    z-index: var(--z-index-character-menu, 10001) !important; /* Выше Frame 1 (10000) */
    overflow: visible;
}

.frame1-character-menu-dropdown {
    position: fixed !important; /* Используем fixed вместо absolute, чтобы выйти из stacking context Frame1 */
    top: auto;
    left: auto;
    background: transparent;
    padding: 0;
    display: none !important; /* Меню скрыто */
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
    white-space: nowrap;
    width: auto;
    min-width: auto;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    max-height: 0;
    overflow: hidden;
    z-index: 10001 !important; /* Выше Frame 1 (10000), чтобы меню было на переднем плане */
    isolation: isolate; /* Создаем свой stacking context */
}

.frame1-character-menu-dropdown.active {
    display: none !important; /* Меню скрыто даже при активном состоянии */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    max-height: 0;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    overflow: hidden;
    z-index: 10001 !important; /* Выше Frame 1 (10000) при активном состоянии */
}

.frame1-character-option {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease, transform 0.3s ease, opacity 0.3s ease;
    background: transparent;
    position: relative;
    flex-shrink: 0;
    opacity: 0;
    transform: translateY(-20px);
    z-index: 10001 !important; /* Выше Frame 1 (10000) */
}

.frame1-character-menu-dropdown.active .frame1-character-option {
    opacity: 1;
    transform: translateY(0);
}

.frame1-character-option:hover {
    transform: translateY(0) scale(1.1);
}

/* Адаптивность для мобильных устройств */
@media (max-width: 767px) {
    .frame1-question-number {
        font-size: 12px;
    }
    
    /* Убираем padding у frame1-content на мобильных - отступы уже у frame-1 */
    .frame1-content {
        padding-left: 0 !important;
        padding-right: 0 !important;
        max-width: 100% !important;
    }
    
    /* Контейнер кнопок - растягиваем на всю ширину */
    .frame1-actions {
        width: 100% !important;
        justify-content: space-between !important;
        gap: 4px !important; /* Минимальный gap */
    }
    
    /* Группы кнопок - убираем ограничения ширины */
    .frame1-actions-left {
        flex: 0 1 auto !important;
        max-width: none !important;
        min-width: 0 !important;
        gap: 4px !important;
    }
    
    .frame1-actions-right {
        flex: 0 1 auto !important;
        max-width: none !important;
        min-width: 0 !important;
        gap: 4px !important;
        margin-left: auto !important; /* Выравниваем по правому краю */
    }
    
    /* Кнопки - увеличиваем размер, но остаемся в пределах границ */
    .frame1-button {
        flex-shrink: 1 !important; /* Разрешаем сжатие */
        min-width: 0 !important; /* Убираем минимальную ширину */
        padding: 10px 14px !important; /* Увеличенный padding */
        font-size: 13px !important; /* Увеличенный размер шрифта */
        white-space: normal !important; /* Разрешаем перенос текста */
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    /* Статус индикатор тоже адаптивный */
    .frame1-status {
        flex-shrink: 1 !important;
        min-width: 0 !important;
        padding: 10px 14px !important;
        font-size: 13px !important;
        white-space: normal !important;
        max-width: 100% !important;
    }
}

@media (max-width: 480px) {
    .frame1-question-number {
        font-size: 11px;
    }
    
    /* Убираем padding у frame1-content на очень маленьких экранах */
    .frame1-content {
        padding-left: 0 !important;
        padding-right: 0 !important;
        max-width: 100% !important;
    }
    
    /* Еще меньше gap на очень маленьких экранах */
    .frame1-actions {
        gap: 3px !important;
    }
    
    .frame1-actions-left,
    .frame1-actions-right {
        gap: 3px !important;
    }
    
    /* Кнопки на очень маленьких экранах - немного меньше, но все еще крупные */
    .frame1-button {
        padding: 8px 12px !important;
        font-size: 12px !important;
        letter-spacing: 0.3px !important;
    }
    
    .frame1-status {
        padding: 8px 12px !important;
        font-size: 12px !important;
    }
}

