/* Основные стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: #0b0b0f;
    background-image: url('assets/bars.png');
    background-position: center top;
    background-repeat: no-repeat;
    background-size: cover; /* keep aspect, cover viewport */
    background-attachment: scroll;
    color: #333;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Top Bar */
.topbar {
    position: fixed;
    top: 8px;
    left: 12px; /* мобильное позиционирование по краям */
    right: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 2000;
}

.topbar-logo img {
    height: 28px;
    width: auto;
    display: block;
}

.top-progress {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255,255,255,0.14);
    border: 1px solid rgba(255,255,255,0.35);
    backdrop-filter: blur(8px);
}

.top-progress .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.7);
    background: transparent;
    box-shadow: inset 0 0 0 2px rgba(255,255,255,0.08);
}

.top-progress .dot.active { background: #fe4100; border-color: #fff; box-shadow: 0 0 0 3px rgba(254,65,0,0.22); }
.top-progress .dot.correct { background: #00d4aa; border-color: #fff; box-shadow: 0 0 0 3px rgba(0,212,170,0.22); }
.top-progress .dot.incorrect { background: #ff6b35; border-color: #fff; box-shadow: 0 0 0 3px rgba(255,107,53,0.25); }

/* Десктоп: прижимаем топбар к модулю по центру */
@media (min-width: 769px) {
    .topbar {
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        width: 720px; /* как .game-frame */
        padding: 0;
    }
    .topbar-logo img { height: 36px; }
    .top-progress { gap: 10px; padding: 8px 14px; }
    .top-progress .dot { width: 12px; height: 12px; }
}

/* Фоновые элементы как на оригинале */
body::before {
    position: fixed;
    top: 10%;
    left: 5%;
    font-size: 24px;
    color: rgba(255, 255, 255, 0.1);
    font-weight: bold;
    z-index: 1;
    pointer-events: none;
}

body::after {
    position: fixed;
    top: 20%;
    right: 10%;
    font-size: 18px;
    color: rgba(255, 255, 255, 0.08);
    font-weight: bold;
    z-index: 1;
    pointer-events: none;
}

/* Основной контейнер */
.main-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 64px 20px 20px; /* место для topbar */
    position: relative;
    z-index: 2;
}

/* Белый фрейм игры */
.game-frame {
    background: white;
    border-radius: 20px;
    padding: 32px;
    max-width: 720px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
}

/* Заголовок */
.game-header {
    text-align: center;
    margin-bottom: 30px;
}

.game-header h1 {
    font-size: 24px;
    font-weight: bold;
    color: #333;
    line-height: 1.3;
    margin-bottom: 15px;
}

.instruction {
    font-size: 16px;
    color: #666;
    margin-bottom: 0;
}

/* Основная игровая область */
.game-main {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

/* Видео контейнер */
.video-container {
    position: relative;
    width: 100%;
    max-width: 640px;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

/* Overlay для ручного запуска видео на iOS */
.play-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

.play-button {
    background: #007aff;
    color: #fff;
    border: none;
    padding: 12px 22px;
    border-radius: 999px;
    font-size: 16px;
    font-weight: 700;
    box-shadow: 0 8px 20px rgba(0,0,0,0.25);
    cursor: pointer;
}

/* Лоадер для видео */
.video-loading {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.35);
    z-index: 18;
}
.video-loading .spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: sp 0.8s linear infinite;
}
@keyframes sp { to { transform: rotate(360deg); } }

/* CTA контейнер и кнопка */
.cta-container {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 12;
}

.cta-button {
    display: inline-block;
    background: #fe4100;
    color: #fff;
    text-decoration: none;
    padding: 12px 20px;
    border-radius: 999px;
    font-weight: 700;
    box-shadow: 0 8px 20px rgba(254, 65, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.cta-button:hover {
    filter: brightness(1.05);
    transform: translateY(-2px);
}

/* Бейдж бренда (логотип) */
.brand-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 12;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    background: rgba(255,255,255,0.9);
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
    border: 1px solid rgba(0,0,0,0.06);
    backdrop-filter: blur(6px);
    text-decoration: none;
}

.brand-badge img {
    height: 44px;
    width: auto;
    display: block;
}

/* Скрываем индикатор режима — место занимает логотип */
.video-mode-indicator { display: none; }

/* Toast: результат ответа */
.answer-toast {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 11;
    padding: 8px 14px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 14px;
    background: #a7f3d0; /* green by default */
    color: #064e3b;
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
    opacity: 0;
    pointer-events: none;
}

.answer-toast.incorrect {
    background: #fecaca;
    color: #7f1d1d;
}

.answer-toast.show { opacity: 1; }

/* Индикатор режима видео */
.video-mode-indicator {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 10;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.video-mode-indicator.preview {
    background: rgba(255, 193, 7, 0.9);
    color: #000;
}

.video-mode-indicator.full {
    background: rgba(40, 167, 69, 0.9);
    color: white;
}

#gameVideo {
    width: 100%;
    height: auto;
    display: block;
}

/* Скрываем элементы управления видео */
#gameVideo::-webkit-media-controls {
    display: none !important;
}

#gameVideo::-webkit-media-controls-panel {
    display: none !important;
}

#gameVideo::-webkit-media-controls-play-button {
    display: none !important;
}

#gameVideo::-webkit-media-controls-timeline {
    display: none !important;
}

#gameVideo::-webkit-media-controls-current-time-display {
    display: none !important;
}

#gameVideo::-webkit-media-controls-time-remaining-display {
    display: none !important;
}

#gameVideo::-webkit-media-controls-mute-button {
    display: none !important;
}

#gameVideo::-webkit-media-controls-volume-slider {
    display: none !important;
}

#gameVideo::-webkit-media-controls-fullscreen-button {
    display: none !important;
}

/* Для Firefox */
#gameVideo::-moz-media-controls {
    display: none !important;
}

/* Для других браузеров */
#gameVideo::-ms-media-controls {
    display: none !important;
}

/* Интерактивные игроки на видео */
.video-players {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
}

.video-player {
    position: absolute;
    width: 60px;
    height: 40px;
    border: 2px solid white;
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    pointer-events: all;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 18px;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    transition: all 0.3s ease;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.video-player:hover {
    transform: scale(1.05);
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

.video-player.selected {
    border-color: #28a745;
    background: rgba(40, 167, 69, 0.8);
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(40, 167, 69, 0.8);
}

.video-player.team-barcelona {
    border-color: white;
}

.video-player.team-real {
    border-color: white;
}

/* Контейнер для картинки */
.image-container {
    position: relative;
    width: 100%;
    max-width: 640px;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

#gameImage {
    width: 100%;
    height: auto;
    display: block;
}

/* Интерактивные игроки на картинке */
.image-players {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
}

.image-player {
    position: absolute;
    width: 60px;
    height: 40px;
    border: 2px solid white;
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    pointer-events: all;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 18px;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    transition: all 0.3s ease;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.image-player:hover {
    transform: scale(1.05);
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

.image-player.selected {
    border-color: #28a745;
    background: rgba(40, 167, 69, 0.8);
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(40, 167, 69, 0.8);
}

.image-player.team-barcelona {
    border-color: white;
}

.image-player.team-real {
    border-color: white;
}

/* Финальный экран результатов */
/* Новый финальный экран */
.final-screen {
    position: fixed;
    inset: 0;
    background: radial-gradient(1200px 700px at 50% -200px, rgba(255,255,255,0.25), rgba(255,255,255,0) 60%),
                linear-gradient(180deg, #7a1010, #551313 40%, #7a1010);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 80px;
    padding-bottom: 24px; /* место снизу под контент */
    overflow-y: auto; /* скролл внутри оверлея */
    -webkit-overflow-scrolling: touch; /* инерционный скролл на iOS */
    overscroll-behavior: contain; /* не прокручивать фон */
    z-index: 1000;
}

.final-card {
    width: 94%;
    max-width: 380px;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.25);
    padding: 18px 18px 20px;
    margin-bottom: 20px; /* чтобы нижний край не прилипал */
}

.final-score {
    font-size: 42px;
    font-weight: 800;
    color: #8a0e0e;
    text-align: center;
}

.final-underline {
    width: 52px;
    height: 6px;
    background: #b31313;
    border-radius: 999px;
    margin: 6px auto 12px;
}

.final-banner img { width: 100%; height: auto; display: block; border-radius: 12px; }

.final-description { text-align: center; padding: 14px 8px 6px; }
.final-description h3 { font-size: 18px; font-weight: 800; color: #222; line-height: 1.25; margin-bottom: 10px; }
.final-description p { font-size: 14px; color: #444; line-height: 1.4; }
.final-description .final-note { font-size: 13px; color: #6b7280; margin-top: 8px; }

.final-cta-row { display: flex; justify-content: center; margin-top: 16px; }
.final-cta {
    display: inline-block;
    text-align: center;
    background: #fe4100;
    color: #fff;
    text-decoration: none;
    padding: 12px 16px;
    border-radius: 12px;
    font-weight: 800;
    box-shadow: 0 8px 24px rgba(254,65,0,0.3);
}

.final-actions-row { display: flex; justify-content: center; margin-top: 12px; }
.btn-play-again.small { padding: 10px 14px; border-radius: 10px; font-size: 14px; }

.score-display {
    display: flex;
    justify-content: center;
    align-items: baseline;
    margin-bottom: 30px;
}

.score-number {
    font-size: 72px;
    font-weight: bold;
    color: #333;
    line-height: 1;
}

.score-total {
    font-size: 36px;
    font-weight: bold;
    color: #666;
    margin-left: 5px;
}

.final-message h2 {
    font-size: 28px;
    font-weight: bold;
    color: #333;
    margin-bottom: 15px;
    line-height: 1.2;
}

.final-message p {
    font-size: 16px;
    color: #666;
    line-height: 1.4;
    margin-bottom: 30px;
}

.final-actions {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.btn-subscribe {
    background: #000;
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-subscribe:hover {
    background: #333;
    transform: translateY(-2px);
}

.btn-play-again {
    background: white;
    color: #333;
    border: 2px solid #333;
    padding: 15px 30px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-play-again:hover {
    background: #333;
    color: white;
    transform: translateY(-2px);
}

/* Блок выбора игрока */
.player-selection {
    margin: 20px 0;
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Тост в блоке выбора */
.selection-toast {
    margin: 0 auto 14px;
    display: inline-block;
    padding: 8px 14px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 14px;
    background: #a7f3d0; /* green by default */
    color: #064e3b;
    box-shadow: 0 6px 16px rgba(0,0,0,0.12);
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity .2s ease, transform .2s ease;
}

.selection-toast.incorrect { background: #fecaca; color: #7f1d1d; }
.selection-toast.show { opacity: 1; transform: translateY(0); }

.selection-title {
    font-size: 20px;
    font-weight: bold;
    color: #333;
    margin-bottom: 20px;
}

.selection-options {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.selection-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 22px;
    border-radius: 28px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
    min-width: 120px;
}

.selection-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.selection-btn:active {
    transform: translateY(-1px);
}

.selection-btn.selected {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

.selection-btn.correct {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

.selection-btn.incorrect {
    background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
    box-shadow: 0 6px 20px rgba(244, 67, 54, 0.4);
}

/* Навигация по вопросам */
.question-navigation {
    margin-top: 30px;
    text-align: center;
    position: relative;
}

.question-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.question-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.3);
    color: #666;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.question-btn:hover {
    background: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
}

.question-btn.active {
    background: linear-gradient(45deg, #ff6b35, #00d4aa);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.3);
}

.question-btn.completed {
    background: #00d4aa;
    color: white;
}

.question-btn.correct {
    background: #00d4aa;
    color: white;
    box-shadow: 0 4px 15px rgba(0, 212, 170, 0.5);
    border: 1px solid #00d4aa;
}

.question-btn.incorrect {
    background: #ff6b35;
    color: white;
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.5);
    border: 1px solid #ff6b35;
}

/* Тост рядом с цифрами вопросов */
.nav-toast {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translate(-50%, -12px);
    padding: 6px 12px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 13px;
    background: #a7f3d0;
    color: #064e3b;
    box-shadow: 0 6px 16px rgba(0,0,0,0.12);
    opacity: 0;
    transition: opacity .2s ease, transform .2s ease;
    pointer-events: none;
}

.nav-toast.incorrect { background: #fecaca; color: #7f1d1d; }
.nav-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Футбольное поле (скрыто по умолчанию) */
.field-container {
    width: 100%;
    max-width: 600px;
    position: relative;
}

.football-field {
    width: 100%;
    height: 400px;
    background: linear-gradient(90deg, #2d5016 0%, #4a7c59 50%, #2d5016 100%);
    border: 3px solid #fff;
    border-radius: 10px;
    position: relative;
    overflow: hidden;
}

/* Разметка поля */
.football-field::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: white;
    transform: translateY(-50%);
}

.football-field::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60px;
    height: 60px;
    border: 2px solid white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

/* Ворота */
.goal {
    position: absolute;
    width: 20px;
    height: 80px;
    border: 3px solid white;
    top: 50%;
    transform: translateY(-50%);
}

.barcelona-goal {
    left: 0;
    border-right: none;
}

.real-goal {
    right: 0;
    border-left: none;
}

/* Игроки на поле */
.player {
    position: absolute;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 3px solid transparent;
    font-size: 12px;
    font-weight: bold;
}

.player:hover {
    transform: scale(1.1);
    border-color: #ff6b35;
    box-shadow: 0 0 20px rgba(255, 107, 53, 0.5);
}

.player.selected {
    border-color: #00d4aa;
    box-shadow: 0 0 25px rgba(0, 212, 170, 0.7);
    transform: scale(1.15);
}

.player.barcelona {
    background: linear-gradient(45deg, #a50044, #004d98);
    color: white;
}

.player.real-madrid {
    background: linear-gradient(45deg, #ffffff, #f0f0f0);
    color: #333;
    border-color: #333;
}

.player-number {
    font-size: 14px;
    font-weight: bold;
}

.player-name {
    font-size: 10px;
    margin-top: 2px;
}

/* Результат (скрыт) */
.result-container {
    display: none !important;
}

.result-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 500px;
    border: 2px solid #ff6b35;
    color: #333;
}

.result-content h2 {
    font-size: 2.5em;
    margin-bottom: 20px;
}

.result-content h2.correct {
    color: #00d4aa;
}

.result-content h2.incorrect {
    color: #ff6b35;
}

.result-content p {
    font-size: 1.2em;
    margin-bottom: 30px;
    color: #666;
}

/* Кнопки */
.btn-start, .btn-next, .btn-restart {
    background: linear-gradient(45deg, #ff6b35, #00d4aa);
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 18px;
    font-weight: bold;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-start:hover, .btn-next:hover, .btn-restart:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 107, 53, 0.4);
}

/* Скрытые элементы управления */
.hidden-controls {
    position: absolute;
    top: -9999px;
    left: -9999px;
}

/* Адаптивность */
@media (max-width: 768px) {
    .main-container { padding: 56px 8px 8px; }
    .game-frame { padding: 16px; border-radius: 14px; }
    .game-header h1 { font-size: 18px; }
    .instruction { font-size: 13px; }
    .brand-badge { padding: 6px 10px; }
    .brand-badge img { height: 34px; }
    .answer-toast { top: 10px; font-size: 12px; padding: 6px 10px; }
    .video-player { width: 42px; height: 28px; font-size: 14px; }
    .image-player { width: 42px; height: 28px; font-size: 14px; }
    .player-selection { padding: 18px; }
    .selection-title { font-size: 18px; }
    .selection-options { gap: 12px; }
    .selection-btn { padding: 10px 16px; font-size: 14px; min-width: 100px; }
    .cta-container { bottom: 10px; }
    .cta-button { padding: 10px 16px; font-size: 14px; }
    .question-navigation { background: transparent; border: none; padding: 0; backdrop-filter: none; }
    .question-buttons { gap: 8px; }
    .question-btn { width: 30px; height: 30px; font-size: 12px; border-radius: 8px; }
    .nav-toast { font-size: 12px; padding: 5px 10px; }
    .final-content { padding: 28px; }
    .score-number { font-size: 56px; }
    .score-total { font-size: 28px; }
}

@media (min-width: 480px) {
    .final-card { max-width: 460px; }
    .final-score { font-size: 48px; }
}

@media (min-width: 769px) {
    .final-card { max-width: 560px; }
    .final-score { font-size: 56px; }
}

@media (max-width: 480px) {
    .game-frame { padding: 12px; border-radius: 12px; }
    .game-header h1 { font-size: 16px; }
    .instruction { font-size: 12px; }
    .brand-badge img { height: 28px; }
    .selection-title { font-size: 16px; }
    .selection-btn { padding: 8px 14px; font-size: 13px; min-width: 88px; }
    .video-player { width: 36px; height: 24px; font-size: 12px; }
    .image-player { width: 36px; height: 24px; font-size: 12px; }
    .cta-button { padding: 8px 14px; font-size: 13px; }
    .question-navigation { padding: 0; }
    .question-buttons { gap: 6px; }
    .question-btn { width: 26px; height: 26px; font-size: 11px; border-width: 1px; border-radius: 8px; }
    .nav-toast { font-size: 11px; }
}