/* --- stage_selection.css --- */
/* Стили для страницы выбора этапа */

body {
    background: var(--bg-grad-start, #d7c29e);
    background: linear-gradient(135deg, var(--bg-grad-start, #d7c29e), var(--bg-grad-end, #b9a178));
    padding-top: 30px;
    padding-bottom: 30px;
    min-height: 100vh;
}

.wrap {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}

.container {
    background: var(--paper-color, #faf3e0);
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12), 0 8px 20px rgba(0, 0, 0, 0.08);
    padding: 10px 20px;
    width: 100%;
    position: relative;
    border: none;
    backdrop-filter: blur(10px);
}

/* Блок "Назад" и "Общий счет" */
.header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 0 10px;
}

.btn-back {
    background: white;
    color: var(--accent-color);
    border: none;
    padding: 10px 24px;
    border-radius: 50px;
    font-size: 0.9em;
    cursor: pointer;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.btn-back:hover {
    background: var(--accent-color);
    color: white !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.global-score-display {
    text-align: right;
    line-height: 1.2;
    color: var(--text-color);
    font-size: 0.9em;
    flex-shrink: 0;
    white-space: nowrap;
    padding-left: 10px;
}

.global-score-display .score-value {
    font-size: 1.5em;
    font-weight: bold;
    color: var(--accent-color);
}

h1 {
    color: var(--accent-color);
    text-align: center;
    margin-bottom: 25px;
    margin-top: 10px;
    font-size: 2.2em;
    font-weight: 600;
}

/* Вкладки выбора ЭТАПА (Stage 1, 2, 3) */
.tabs {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 0;
    flex-wrap: wrap;
    border-bottom: 3px solid var(--accent-color);
    padding-bottom: 0;
    position: relative;
}

.stage-tab-btn {
    padding: 12px 28px 14px 28px;
    font-size: 1em;
    font-weight: 600;
    border: none;
    border-radius: 12px 12px 0 0;
    cursor: pointer;
    background-color: transparent;
    color: var(--muted);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    margin-bottom: -3px;
}

.stage-tab-btn::after {
    display: none;
}

.stage-tab-btn:hover:not(.active):not(:disabled) {
    background-color: rgba(255, 255, 255, 0.5);
    color: var(--accent-color);
}

.stage-tab-btn.active {
    background-color: white;
    color: var(--accent-color);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
}

.stage-tab-btn.active::after {
    display: none;
}

.stage-tab-btn:disabled,
.stage-tab-btn.disabled {
    color: #ccc;
    background-color: transparent;
    cursor: default;
    /* Было not-allowed, но для тултипов лучше default */
    opacity: 0.5;
}

/* Анимированный индикатор (плавающая полоска) */
.tab-indicator {
    position: absolute;
    bottom: -3px;
    height: 3px;
    background-color: var(--accent-hover);
    border-radius: 3px 3px 0 0;
    transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1), width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Карточки и панели должны выпускать тултипы подсказок наружу */
.stage-panel,
.stage-card,
.stage-cards-container {
    overflow: visible !important;
    /* КРИТИЧНО ДЛЯ ПОДСКАЗОК */
}

/* Контейнер для карточек (для переключения панелей) */
.stage-cards-container {
    overflow: visible !important;
    /* КРИТИЧНО ДЛЯ ПОДСКАЗОК */
    position: relative;
    min-height: 250px;
    margin-top: 25px;

    /* *** ИЗМЕНЕНИЕ (Плавная смена контента) *** */
    perspective: 1000px;
    /* *** КОНЕЦ ИЗМЕНЕНИЯ *** */
}

/* *** ИЗМЕНЕНИЕ (Плавная смена контента) *** */
.stage-panel {
    display: none;
    opacity: 1;
    /* Панель всегда непрозрачна */
}

.stage-panel.active {
    display: block;
    /* animation: ...; <-- Анимация отсюда УБРАНА */
}

/* Анимация применяется к самим карточкам, а не к панели */
.stage-panel.active .stage-cards {
    /* animation: smoothFadeIn 0.4s ease-out forwards;  <-- ОТКЛЮЧЕНО: Убираем "подпрыгивание" при загрузке */
    opacity: 1;
    transform: none;
}

/* *** КОНЕЦ ИЗМЕНЕНИЯ *** */


/* @keyframes smoothFadeIn { ... } - БОЛЬШЕ НЕ ИСПОЛЬЗУЕТСЯ */

/* Карточки ВЫБОРА ЯЗЫКА (cz, en, bilingual) */
.stage-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.stage-card {
    background: white;
    border: 3px solid transparent;
    /* PREVENT JUMP: Always have a border */
    border-radius: 20px;
    padding: 25px;
    /* COMPENSATE: 28px - 3px border = 25px */
    text-align: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    min-height: 240px;
}

.stage-card:hover {
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.10), 0 4px 12px rgba(0, 0, 0, 0.06);
}

/* Активный режим (выбранный) */
.language-card.active-mode {
    border-color: var(--gold-color, #FFD700);
    /* Only change color */
    box-shadow: 0 16px 48px rgba(255, 215, 0, 0.2), 0 8px 20px rgba(0, 0, 0, 0.12);
    transform: scale(1.02);
}

/* Убираем золотистость, когда фокус уходит наверх (на вкладки) */
.container.layer-tabs .language-card.active-mode {
    border-color: transparent;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.1), 0 4px 12px rgba(0, 0, 0, 0.06);
}

.stage-card h2 {
    font-size: 1.3rem;
    margin: 10px 0 15px 0;
    color: var(--accent-hover);
    line-height: 1.3;
}

.stage-card-stats {
    font-size: 0.9em;
    color: var(--muted);
    margin-bottom: 20px;
    min-height: 2.5em;
    line-height: 1.4;
    flex-grow: 1;
}



.stage-card-buttons .btn,
.stage-card-buttons a.btn {
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 1em;
    width: 100%;
    margin: 0;
    font-weight: 600;
    border: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    text-decoration: none;
}

.stage-card-buttons .btn:hover:not(:disabled),
.btn:hover:not(:disabled) {
    background: var(--accent-hover);
    /* Убрали принудительный белый цвет */
    transform: translateY(-1px);
}

.stage-card-buttons .btn.secondary,
.stage-card-buttons a.btn.secondary {
    background: linear-gradient(135deg, #f5f5f5, #e8e8e8);
    color: #555;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* ИЗМЕНЕНИЕ: Делаем ховер таким же ярким, как у основной кнопки */
.stage-card-buttons .btn.secondary:hover:not(:disabled),
.stage-card-buttons a.btn.secondary:hover:not(:disabled) {
    background: var(--accent-hover);
    /* Коричневый фон */
    color: white !important;
    /* Белый текст */
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
    border-color: transparent;
    /* Убираем рамку, если она была */
}

.stage-card-buttons .btn:disabled,
.stage-card-buttons .btn.disabled,
.stage-card-buttons a.btn:disabled,
.stage-card-buttons a.btn.disabled {
    pointer-events: none;
    background: #ddd;
    border: none;
    color: #999;
    opacity: 0.5;
    box-shadow: none;
}

/* Сообщение о блокировке */
.lock-message,
.loading-text {
    font-size: 1.1em;
    color: var(--muted);
    padding: 40px 20px;
    text-align: center;
    background-color: #fff;
    border-radius: 8px;
    border: 1px dashed #ddd;
    grid-column: 1 / -1;
}

.lock-message .lock-icon {
    font-size: 2em;
    display: block;
    margin-bottom: 10px;
}

.lock-message a {
    color: var(--accent-color);
    font-weight: 600;
}


/* Кнопки внизу */
.bottom-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #eee;
    flex-wrap: wrap;
}

.bottom-controls .btn,
.bottom-controls a.btn {
    width: auto;
    padding: 12px 24px;
    font-size: 0.95em;
    margin: 0;
    border-radius: 12px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    display: inline-block;
}

.bottom-controls .btn:hover,
.bottom-controls a.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

/* Бейдж (статус режима) */
.status-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 0.65em;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    white-space: nowrap;
}

.status-badge.available {
    background: linear-gradient(135deg, var(--accent-color), #8b6f47);
}

.status-badge.completed {
    background: linear-gradient(135deg, var(--success-color), #27ae60);
}

.status-badge.in-progress {
    background: linear-gradient(135deg, #f39c12, #e67e22);
}

.status-badge.locked {
    background: linear-gradient(135deg, #bbb, #999);
}


@media (max-width: 768px) {
    .wrap {
        padding: 5px;
    }

    .container {
        padding: 20px;
        border-radius: 20px;
    }

    .header-controls {
        padding: 0 5px;
    }

    .global-score-display {
        display: none;
    }

    .header-back-btn {
        position: static;
        transform: none;
    }

    h1 {
        font-size: 1.8em;
    }

    .tabs {
        gap: 5px;
    }

    .stage-tab-btn {
        font-size: 0.9em;
        padding: 10px 12px;
        flex-grow: 1;
        flex-basis: 0;
        text-align: center;
    }

    .stage-cards {
        grid-template-columns: 1fr;
    }

    .stage-card {
        min-height: 200px;
        padding: 20px;
    }

    .stage-card:hover {
        transform: translateY(-3px);
    }

    .bottom-controls {
        flex-direction: column;
        gap: 10px;
    }

    .bottom-controls .btn,
    .bottom-controls a.btn {
        width: 100%;
        font-size: 1em;
        padding: 14px;
    }
}


/* --- НОВАЯ ШАПКА (Grid Layout) --- */
.app-header-grid {
    display: grid;
    /* Лево (кнопка), Центр (заголовок), Право (счет) */
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 10px;
    margin-bottom: 25px;
    position: relative;
}

/* Центрирование заголовка (переопределяем старый h1) */
.app-header-grid h1 {
    margin: 0;
    font-size: 1.8em;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
    color: var(--text-color, #333);
}

/* Правая часть (Счет) */
.header-right-group {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    /* Прижимаем вправо */
}

/* --- СТИЛЬ КОМПАКТНЫХ КНОПОК (Круглые) --- */
.nav-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    background: rgba(255, 255, 255, 0.8);
    color: var(--text-color, #333);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);

    width: 44px;
    /* Размер кружка */
    height: 44px;
    border-radius: 50%;
}

/* Эффект наведения */
.nav-icon-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
    background: var(--accent-color, #5d4037);
    /* Коричневый */
    color: white !important;
    /* Белый текст */
}

/* Иконки внутри */
.nav-icon-btn svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    /* Цвет берется от текста */
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
    transition: stroke 0.2s;
}

.nav-icon-btn:hover svg {
    stroke: white !important;
    /* При наведении линии белые */
}

/* Исправление для обычных кнопок (чтобы текст белел) */
.btn:hover,
.btn.secondary:hover {
    color: white !important;
}

/* Скрываем старый header-controls, если он остался */
.header-controls {
    display: none;
}

/* --- stage_selection.css --- */

/* Модификация базового стиля кнопки (разрешаем ей растягиваться) */
.nav-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-color, #333);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);

    /* Базовые размеры (если контента нет, будет круг) */
    height: 44px;
    min-width: 44px;
    border-radius: 50%;
    /* По умолчанию круг */
    padding: 0;
}

/* --- НОВЫЙ СТИЛЬ: Широкая кнопка (ABC) --- */
.nav-style-wide {
    width: auto;
    /* Ширина по контенту */
    padding: 0 16px;
    /* Отступы по бокам */
    border-radius: 22px;
    /* Радиус = половина высоты для формы пилюли */
    gap: 8px;
    /* Расстояние между стрелкой и текстом */
}

/* Стиль текста ABC */
.abc-text {
    font-weight: 800;
    /* Жирный шрифт */
    font-size: 16px;
    letter-spacing: 0.5px;
    line-height: 1;
    padding-top: 1px;
    /* Микро-коррекция вертикали */
}

/* Эффект наведения (общий) */
.nav-icon-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
    background: var(--accent-color, #5d4037);
    color: white !important;
}

/* Иконка стрелки */
.nav-icon-btn svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    stroke-width: 2.5;
    /* Чуть жирнее стрелка */
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.nav-icon-btn:hover svg {
    stroke: white !important;
}

/* --- ЦВЕТНЫЕ ВКЛАДКИ (Stage Selection Modal) --- */

/* Базовый стиль вкладки */
/* --- ЦВЕТНЫЕ ВКЛАДКИ (Постоянный цвет) --- */

/* Базовый стиль */
.t-tab {
    flex: 1;
    text-align: center;
    padding: 12px;
    cursor: pointer;
    font-weight: 500;
    color: #aaa;
    /* Серый по умолчанию (если пусто) */
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    background: none;
    border: none;
    font-size: 0.95em;
}

/* 1. Если вкладка НЕ пустая -> СРАЗУ красим текст (даже если не выбрана) */

/* В работе -> Желтый */
.t-tab[data-tab="active"]:not(.empty) {
    color: #f39c12;
    font-weight: 600;
}

/* В очереди -> Синий */
.t-tab[data-tab="queued"] {
    color: #3498db;
    font-weight: 600;
}

/* Пройдено -> Зеленый */
.t-tab[data-tab="completed"]:not(.empty) {
    color: #27ae60;
    font-weight: 600;
}

/* 2. Если вкладка АКТИВНА (нажата) -> Добавляем фон и подчеркивание */

.t-tab[data-tab="active"].active {
    border-bottom-color: #f39c12;
    background: rgba(243, 156, 18, 0.05);
}

.t-tab[data-tab="queued"].active {
    border-bottom-color: #3498db;
    background: rgba(52, 152, 219, 0.05);
}

.t-tab[data-tab="completed"].active {
    border-bottom-color: #27ae60;
    background: rgba(39, 174, 96, 0.05);
}

/* Пустые вкладки */
.t-tab.empty {
    opacity: 0.6;
    cursor: default;
    pointer-events: none;
    /* Блокируем клики */
}

/* ВАЖНО: Вкладка "Очередь" ВСЕГДА доступна (даже если пустая) */
.t-tab[data-tab="queued"] {
    pointer-events: auto !important;
    cursor: pointer !important;
}

/* Эффект Dendy-запуска (мигание рамки) */
@keyframes dendy-flash {

    0%,
    100% {
        border-color: var(--gold-color, #FFD700);
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
        transform: scale(1.02);
    }

    50% {
        border-color: transparent;
        box-shadow: none;
        transform: scale(1.02);
    }
}

.card-activating {
    animation: dendy-flash 0.1s step-end infinite;
    /* Быстрое мигание */
    pointer-events: none;
    /* Блокируем повторные клики */
}





/* === СТИЛИ ФОКУСА НА ВКЛАДКАХ (Верхний ряд) === */

/* Убираем стандартную обводку браузера при клике */
.stage-tab-btn:focus {
    outline: none;
}

/* Когда управление на вкладках, активная вкладка получает золотую окантовку */
.container.layer-tabs .stage-tab-btn.active {
    color: var(--accent-color);
    /* Текст обычный (коричневый) */

    /* Золотая рамка */
    border: 2px solid var(--gold-color, #FFD700);
    border-bottom: none;
    /* Снизу открыто */

    background: #fff;
    box-shadow: 0 -4px 10px rgba(255, 215, 0, 0.2);
    transform: translateY(-2px);
    z-index: 2;

    padding-top: 10px;
    padding-left: 26px;
    padding-right: 26px;
}

/* Индикатор (полоска) всегда золотая, когда фокус наверху */
.container.layer-tabs .tab-indicator {
    background-color: var(--gold-color, #FFD700);
    height: 4px;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    z-index: 3;
}

/* БЛОК .container.layer-tabs .tabs { ... } НУЖНО УДАЛИТЬ, ЧТОБЫ ЛИНИЯ ОСТАЛАСЬ ЧЕРНОЙ */

/* Обычное состояние (когда фокус внизу на карточках) */
.container:not(.layer-tabs) .stage-tab-btn.active {
    border: none;
    color: var(--accent-color);
}



/* 3. THE "SLIDE DOWN" EFFECT (Target moves down) */
/* We use ::before to create space so the mouse stays over the element (prevents flickering) */
.batch-container::before {
    content: '';
    display: block;
    height: 0;
    transition: height 0.3s cubic-bezier(0.2, 0, 0, 1);
}

.batch-container.shift-down::before {
    height: 70px;
    /* Approx height of a collapsed batch */
}

.batch-container.shift-down {
    /* Optional: Highlight the target slightly */
    border-top: 2px solid var(--accent-color, #5d4037);
}

/* Hide the global buttons as requested */
.queue-global-header {
    display: none !important;
}

#batches-drag-container {
    display: flex;
    flex-direction: column;
    padding: 10px 0;
    min-height: 100px;
    /* Ensure drop zone exists */
}


/* === МЕХАНИКА ПОДСКАЗОК (SPOILER) - СТАБИЛЬНАЯ ВЕРСИЯ === */

/* 3. Стиль подсказки (Коричневая кнопка) */
.spoiler-container {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* Стиль коричневой кнопки */
    background: #8d6e63;
    /* Приятный коричневый цвет */
    color: #fff;
    /* Белый текст */
    padding: 6px 14px;
    /* Отступы внутри кнопки */
    border-radius: 6px;
    /* Слегка скругленные углы (прямоугольная форма) */
    cursor: pointer;
    position: relative;
    /* Важно для позиционирования цены */
    user-select: none;
    transition: background 0.2s, transform 0.1s;
    min-width: 90px;
    height: 36px;
    /* Чуть выше для кнопки */
    vertical-align: middle;
    font-weight: bold;
    font-size: 14px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    /* Небольшая тень для объема */
    overflow: visible;
    /* Важно! Чтобы цена могла появляться за пределами кнопки */
}

/* Эффект нажатия и наведения */
.spoiler-container:hover {
    z-index: 2000;
    /* Сама кнопка тоже всплывает */
}

.spoiler-container:active {
    transform: scale(0.98);
    /* Эффект нажатия */
}

/* Цена, которая появляется справа */


/* Текст "Подсказка" внутри кнопки */
.spoiler-text-label {
    pointer-events: none;
    /* Чтобы клик проходил сквозь текст */
}


.spoiler-overlay:hover {
    background: #6d4c41;
    /* Просто темнеет при наведении, не двигается */
    /* УБРАЛИ transform: scale */
}

/* Скрытый текст (Оригинальная надпись) */
.spoiler-text {
    display: none;
    color: var(--accent-color);
    font-weight: bold;
    font-size: 0.95em;
    padding: 4px 0;
    /* Подгоняем под высоту кнопки */
    line-height: 1.2;
}

/* Когда открыто */
/* Добавь это или замени существующий .spoiler-text.revealed */
.spoiler-container.revealed .spoiler-text {
    display: inline-block;
}

/* --- Состояние, когда слово открыто --- */
.spoiler-container.revealed {
    background: transparent;
    color: #333;
    /* Темный текст */
    box-shadow: none;
    cursor: default;
    border: 1px solid #ddd;
    /* Опционально: легкая рамка */
}

/* Скрываем цену и надпись "Подсказка", если слово уже открыто */
.spoiler-container.revealed .spoiler-price-tag,
.spoiler-container.revealed .spoiler-text-label {

    z-index: 9999 !important;
    /* Ультимативно высоко */

    display: none;
}

/* Всплывающая подсказка "Стоимость: 5 очков" (опционально) */
/* Сделали её проще, чтобы не перекрывала контент */
/* --- stage_selection.css --- */

/* Всплывающая подсказка "Стоимость: 5 очков" */
/* ИСПРАВЛЕНИЕ: Выводим подсказку СЛЕВА, чтобы она не обрезалась скроллом */
.spoiler-container:hover::after {
    content: "Цена: 5 очков";
    position: absolute;

    /* Центрируем по вертикали относительно кнопки */
    top: 50%;
    transform: translateY(-50%);

    /* Ставим СЛЕВА от кнопки */
    right: 100%;
    left: auto;

    /* Отступ от кнопки */
    margin-right: 12px;
    margin-top: 0;
    margin-bottom: 0;

    background: #333;
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: normal;
    /* Чтобы текст не был слишком жирным */
    white-space: nowrap;
    pointer-events: none;
    /* Мышь сквозь подсказку */
    display: block;

    /* Ультимативный Z-Index */
    z-index: 100000 !important;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
}

/* Стрелочка справа от тултипа (смотрит на кнопку) */
.spoiler-container:hover::before {
    content: '';
    position: absolute;

    /* Центрируем по вертикали */
    top: 50%;
    transform: translateY(-50%);

    /* Прилепляем к правому краю тултипа (то есть слева от кнопки) */
    right: 100%;
    left: auto;
    margin-right: 0px;
    /* Коррекция стыка */

    /* Рисуем стрелку, указывающую ВПРАВО (на кнопку) */
    border-width: 6px 0 6px 6px;
    border-style: solid;
    border-color: transparent transparent transparent #333;

    z-index: 100000 !important;
}

/* Не показывать, если уже открыто */
.spoiler-container.revealed:hover::after,
.spoiler-container.revealed:hover::before,
.spoiler-container.unlocked:hover::after,
.spoiler-container.unlocked:hover::before {
    display: none !important;
}

/* --- Стили для удаления сессии и слов --- */

/* Крестик сброса сессии на карточке */
.reset-session-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    color: #c0392b;
    border: 1px solid rgba(0, 0, 0, 0.1);
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    /* Поверх всего */
    transition: all 0.2s;
    font-size: 14px;
}

.reset-session-btn:hover {
    transform: scale(1.1);
    background: #c0392b;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Крестик удаления слова внутри списка */
.word-remove-btn {
    padding: 5px 10px;
    cursor: pointer;
    color: #e74c3c;
    /* Красный */
    font-size: 1.2em;
    font-weight: bold;
    opacity: 0.6;
    transition: all 0.2s;
    border-left: 1px solid #eee;
}

.word-remove-btn:hover {
    opacity: 1;
    background-color: #ffebee;
}

/* Контейнер статуса игрока (Сердца + Очки) */
/* Добавить в stage_selection.css */
.player-status-container {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid var(--accent-color, #3498db);
    border-radius: 20px;
    padding: 5px 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.status-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: bold;
}

.hearts-item {
    color: #e74c3c;
}

.score-item {
    color: var(--accent-color, #2980b9);
}

.status-divider {
    width: 1px;
    height: 20px;
    background-color: #ccc;
    margin: 0 12px;
}


/* --- НОВАЯ ШАПКА (Ported from profile_selection) --- */

/* Контейнер шапки */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--glass-bg, rgba(253, 245, 230, 0.65));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 8px 15px;
    border-radius: 16px;
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.4));
    margin-bottom: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    gap: 15px;
    flex-shrink: 0;
}

/* Стили кнопок в шапке */
.header-btn {
    background: var(--btn-base-bg, rgba(255, 255, 255, 0.6));
    color: var(--accent-color, #5d4037);
    border: 1px solid rgba(93, 64, 55, 0.3);
    padding: 0 16px;
    border-radius: 12px;
    font-size: 0.95em;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 38px;
    white-space: nowrap;
}

.header-btn:hover {
    background: var(--accent-color, #5d4037);
    color: white !important;
    /* Force white text on hover */
    border-color: var(--accent-color, #5d4037);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(93, 64, 55, 0.2);
}

.header-btn svg {
    fill: currentColor;
    /* Чтобы иконки красились вместе с текстом */
}

/* Центральная часть */
.top-bar-center {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    gap: 15px;
}

/* Постамент пользователя (Справа) */
.user-pedestal {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--pedestal-bg, rgba(255, 255, 255, 0.4));
    padding: 3px 5px 3px 15px;
    border-radius: 14px;
    border: 1px solid var(--pedestal-border, rgba(255, 255, 255, 0.6));
    height: 42px;
    width: 300px;
    /* Фиксируем ширину как в профиле */
    transition: background 0.3s ease;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}

.user-info-popup {
    display: none;
}

.user-name-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    max-width: 200px;
    overflow: hidden;
    white-space: nowrap;
    flex-grow: 1;
    margin-right: 5px;
    text-align: left;
    /* Важно для выравнивания текста */
}

.user-name-main {
    font-size: 0.95em;
    font-weight: 700;
    color: var(--accent-color, #5d4037);
    text-overflow: clip;
}

.user-email-full {
    font-size: 0.75em;
    color: var(--muted, #666);
    text-overflow: clip;
    overflow: visible;
    white-space: nowrap;
    display: block;
}

.logout-btn-text {
    padding: 0 12px;
    font-size: 0.85em;
    height: 32px;
    background: rgba(255, 255, 255, 0.5);
    flex-shrink: 0;
    color: var(--accent-color, #5d4037);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Адаптив для мобилок */
@media (max-width: 800px) {
    .top-bar {
        flex-direction: column;
        padding: 10px;
    }

    .top-bar-center {
        width: 100%;
        margin-bottom: 10px;
    }

    .user-pedestal {
        width: 100%;
    }
}

/* --- Новая структура заголовка уровня --- */
/* --- Исправленный заголовок уровня (Grid для точного центра) --- */
.level-header-row {
    display: grid;
    /* Три колонки: 
       1. Пустая (1fr) 
       2. Заголовок (auto - по ширине текста) 
       3. Очки (1fr - такой же ширины как первая, чтобы заголовок был в центре) 
    */
    grid-template-columns: 180px 1fr 180px;
    align-items: center;
    margin-bottom: 5px;

    padding-bottom: 5px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.header-side-spacer {
    width: 180px;
    height: 1px;
}

/* Заголовок строго по центру */
.level-header-row h1 {
    margin: 0;
    text-align: center;
    grid-column: 2;
    /* Вторая колонка */
    white-space: nowrap;
}

/* Блок очков справа */
#header-score-container {
    margin: 0;
    padding: 0;
    grid-column: 3;
    /* Третья колонка */
    justify-self: end;
    /* Прижать к правому краю */
    display: flex;
    justify-content: flex-end;
}

.global-score-display {
    text-align: right;
    line-height: 1.1;
}

.score-label {
    font-size: 0.75em;
    opacity: 0.8;
    text-transform: uppercase;
    display: block;
}

/* Шапка должна быть выше всего, чтобы ползунок не перекрывался карточками */
.top-bar {
    z-index: 1000;
    position: relative;
    overflow: visible !important;
    /* Разрешаем выпадать наружу */
}

/* Центр шапки для виджета */
/* Центр шапки (Виджет) - теперь растягивается */
.top-bar-center {
    flex: 1;
    /* Занимает всё свободное место в центре */
    display: flex;
    align-items: center;
    justify-content: center;
    /* Центрирует содержимое (виджет) */
    min-width: 150px;
}

/* Адаптив для мобильных */
@media (max-width: 600px) {
    .level-header-row {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .level-header-row h1 {
        text-align: center;
    }

    #header-score-container {
        justify-content: center;
    }
}

.tactical-menu-bar {
    margin-top: 15px;
    display: flex;
    justify-content: center;
    gap: 15px;
    width: 100%;
    margin-bottom: 15px;
}

.menu-btn {
    background: #fff;
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 0.9em;
    cursor: pointer;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    font-weight: 500;
}

.menu-btn:hover {
    background: var(--accent-color);
    color: #fff;
}

/* --- СТИЛИ ДЛЯ АКТИВНОЙ СЕССИИ (Возвращаем красивый вид) --- */
/* --- stage_selection.css (ИСПРАВЛЕНИЯ) --- */

/* 1. Пакет активной сессии (Сделали темнее и кликабельным) */
.session-info-compact {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    padding: 10px 12px;
    margin-top: 10px;
    text-align: left;
    /* Более выраженная граница */
    border: 1px solid #a1887f;
    max-width: 100%;
    box-sizing: border-box;
    cursor: pointer;
    /* Курсор руки на весь блок */
    transition: all 0.2s ease;
    position: relative;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

/* Эффект наведения на весь пакет */
.session-info-compact:hover {
    background: #fff;
    border-color: var(--accent-color);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

/* Мета-данные (дата и кол-во) */
.session-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 0.85em;
    color: #555;
    font-weight: 600;
}

/* Список слов (убрали подчеркивание, теперь это просто текст) */
.session-words-preview {
    font-size: 0.95em;
    color: #3e2723;
    /* Темный цвет текста */
    font-weight: 500;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    border: none;
    /* Убрали пунктир */
    text-decoration: none;
}

/* 2. Кнопка сброса (Крестик слева) */
.reset-session-btn {
    left: 10px !important;
    right: auto !important;
    top: 10px;
    display: none;
    /* JS сам включит display: flex */
    position: absolute;
    width: 24px;
    height: 24px;
    background: #fff;
    border: 1px solid #e57373;
    color: #e57373;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    z-index: 5;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.reset-session-btn:hover {
    background: #e57373;
    color: #fff;
}


.spoiler-container.unlocked .spoiler-overlay {
    display: none;
}

.spoiler-container.unlocked .spoiler-text {
    visibility: visible;
}


/* --- УВЕДОМЛЕНИЕ ОБ ОБНОВЛЕНИИ --- */
.toast-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(93, 64, 55, 0.95);
    color: #fff;
    padding: 10px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    font-size: 0.9em;
    z-index: 20000;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.4s ease;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast-notification.show {
    opacity: 1;
    transform: translateY(0);
}


/* --- Анимация обновления счета --- */
@keyframes scoreFlash {
    0% {
        transform: scale(1);
        color: inherit;
    }

    50% {
        transform: scale(1.3);
        color: #28a745;
        text-shadow: 0 0 10px rgba(40, 167, 69, 0.5);
    }

    100% {
        transform: scale(1);
        color: inherit;
    }
}

.score-update-anim {
    animation: scoreFlash 0.6s ease-out;
}

/* --- ИНТЕГРИРОВАННЫЙ АУДИО ВИДЖЕТ --- */

/* 2. СТИЛИ ВИДЖЕТА */

.audio-integrated-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 100%;
}

.audio-group {
    position: relative;
    display: flex;
    align-items: center;
}

.audio-btn {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(93, 64, 55, 0.2);
    color: var(--accent-color, #5d4037);
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.audio-btn:hover {
    background: var(--accent-color, #5d4037);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(93, 64, 55, 0.2);
}

/* --- ВЫПАДАЮЩИЙ ПОЛЗУНОК (ТЕПЕРЬ ГОРИЗОНТАЛЬНЫЙ) --- */
.volume-popup {
    position: absolute;
    top: 100%;
    /* Снизу от кнопки */
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    /* Центрируем */
    background: #fff;
    padding: 10px 15px;
    border-radius: 20px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(0, 0, 0, 0.05);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10000;
    /* Должен перекрывать всё */

    /* Горизонтальные размеры */
    width: 140px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Показываем при наведении на группу */
.audio-group:hover .volume-popup {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(5px);
}

/* Горизонтальный ползунок */
.volume-range {
    width: 100%;
    height: 6px;
    cursor: pointer;
    accent-color: var(--accent-color, #5d4037);
    -webkit-appearance: slider-horizontal;
    /* Стандарт */
}

/* --- НАЗВАНИЕ ТРЕКА (Tooltip) --- */
.track-popup {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: var(--accent-color, #5d4037);
    color: #fff;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.8em;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 10000;
    pointer-events: auto;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.audio-group:hover .track-popup {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(5px);
}

.track-popup:hover {
    background: #4e342e;
    text-decoration: underline;
}

/* --- ФИНАЛЬНЫЕ ПРАВКИ Z-INDEX (ВСТАВИТЬ В КОНЕЦ ФАЙЛА) --- */

/* 1. Исправление подсказок в карточках */
.stage-card {
    /* Важно: z-index должен меняться мгновенно, без анимации, иначе будет мелькать */
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.4s;
    z-index: 1;
    /* Базовый уровень */
}

.stage-card:hover {
    z-index: 500 !important;
    /* При наведении карточка становится главной на странице */
    transform: translateY(-5px);
    /* Чуть приподнимаем для красоты */
}

/* То же самое для активной карточки, чтобы она не перекрывалась */
.language-card.active-mode {
    z-index: 100;
}

/* 2. Исправление Аудио-виджета в шапке */
.top-bar-center {
    position: relative;
    /* Поднимаем центр шапки выше, чем правый блок (Пьедестал), 
       чтобы ползунок и названия треков ложились ПОВЕРХ имени пользователя */
    z-index: 2000 !important;
    overflow: visible !important;
}

/* Гарантируем, что обертки внутри тоже всё выпускают */
.audio-integrated-wrapper,
.audio-group {
    overflow: visible !important;
    position: relative;
    z-index: auto;
    /* Наследуем высокий индекс от top-bar-center */
}

/* Сам ползунок и тултип трека */
.volume-popup,
.track-popup {
    z-index: 10000 !important;
    /* Ультимативно высоко */
}



/* Стили для новой панели управления */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--glass-bg, rgba(253, 245, 230, 0.65));
    backdrop-filter: blur(10px);
    padding: 8px 15px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    margin-bottom: 0px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    gap: 10px;
    position: relative;
    z-index: 2000;
    margin-top: -25px;
    /* Смещаем вверх, чтобы компенсировать отступы родителя */

}

.top-bar-center {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

.header-btn {
    background: rgba(255, 255, 255, 0.6);
    color: var(--accent-color);
    border: 1px solid rgba(93, 64, 55, 0.3);
    padding: 0 16px;
    border-radius: 12px;
    font-size: 0.95em;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 38px;
    white-space: nowrap;
}

.header-btn:hover {
    background: var(--accent-color);
    color: white !important;
    transform: translateY(-1px);
}

/* Стили пьедестала пользователя */
.user-pedestal {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.4);
    padding: 4px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.user-name-main {
    font-weight: 700;
    color: var(--accent-color);
    font-size: 0.9em;
}

.user-score-val {
    font-size: 0.8em;
    opacity: 0.8;
    color: var(--accent-color);
    text-align: right;
}


/* --- ЭЛЕГАНТНЫЕ МОДАЛЬНЫЕ ОКНА (Smooth Update) --- */
.modal-overlay {
    /* Используем visibility вместо display для плавной анимации */
    display: flex !important;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    /* Чтобы не кликалось, пока скрыто */

    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(46, 34, 27, 0.65);
    backdrop-filter: blur(8px);
    /* Матовое стекло */
    z-index: 10000;
    justify-content: center;
    align-items: center;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Состояние при открытии */
.modal-overlay.visible {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: #fff8f0;
    width: 95%;
    max-width: 1150px;
    height: 88vh;
    border-radius: 30px;
    /* Более мягкие углы */
    position: relative;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4);

    /* Эффект выплывания: чуть ниже и чуть меньше */
    transform: translateY(30px) scale(0.96);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Контент при открытии (встает на место) */
.modal-overlay.visible .modal-content {
    transform: translateY(0) scale(1);
}

.modal-close-btn {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    cursor: pointer;
    font-size: 24px;
    z-index: 101;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
    color: var(--accent-color);
}

.modal-close-btn:hover {
    background: var(--accent-color);
    color: white;
    transform: rotate(90deg);
}

.modal-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
}

/* --- TIKER (Moved from JS Injection) --- */
/* 1. Limit stats block */
.stage-card-stats {
    width: 100%;
    min-width: 0;
    overflow: hidden;
}

/* 2. Ticker Container */
.word-ticker-container {
    position: relative;
    width: 200px;
    max-width: 100%;
    height: 26px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.08);
    /* Fallback */
    border-radius: 6px;
    margin-top: 8px;
    cursor: pointer;
    mask-image: linear-gradient(to right, transparent 0%, black 10%, black 90%, transparent 100%);
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 10%, black 90%, transparent 100%);
    transition: all 0.2s ease;
}

.word-ticker-container:hover {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(93, 64, 55, 0.3);
}

/* 3. Ticker Track */
.word-ticker-track {
    display: flex;
    align-items: center;
    height: 100%;
    width: max-content;
    will-change: transform;
    animation: ticker-scroll 20s linear infinite;
}

.word-ticker-track:hover {
    animation-play-state: paused;
}

.word-ticker-item {
    font-size: 0.85rem;
    font-weight: 600;
    color: #4e342e;
    padding-right: 2rem;
    white-space: nowrap;
}

@keyframes ticker-scroll {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-50%);
    }
}