:root {
    /* Телевизионная палитра "Миллионера" */
    --bg-dark: #00071c;
    --bg-stage: radial-gradient(circle at center 30%, #15286b 0%, #00030a 80%);
    --btn-bg: linear-gradient(180deg, #0f348c 0%, #04123b 100%);
    --btn-bg-hover: linear-gradient(180deg, #1b49bb 0%, #082163 100%);
    
    --text-color: #ffffff;
    --gold: #ffc107;
    --primary: #1e459e;
    --window-bg: rgba(4, 12, 36, 0.9);
    
    --correct: linear-gradient(180deg, #00b894 0%, #006b56 100%);
    --wrong: linear-gradient(180deg, #d63031 0%, #7a1515 100%);
    
    --font: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --transition: 0.3s ease;
}

[data-theme="light"] {
    --bg-stage: radial-gradient(circle at center 30%, #4b6cb7 0%, #182848 80%);
    --window-bg: rgba(255, 255, 255, 0.95);
    --text-color: #111;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: var(--font); }

body {
    background: var(--bg-dark);
    background-image: var(--bg-stage);
    color: var(--text-color);
    overflow: hidden; /* Оставляем скрытым для body, чтобы не было двойных полос */
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    height: 100dvh; /* Новая фишка для мобилок: учитывает вылезающую панель браузера */
}

/* Экраны - теперь умеют прокручиваться, если контент не влезает */
.screen {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Элементы идут сверху вниз */
    align-items: center;
    overflow-y: auto; /* Включаем внутренний скролл */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease, transform 0.5s ease;
    transform: scale(0.95);
    padding: 20px 10px; /* Отступы от краев экрана */
}

.screen.active {
    opacity: 1;
    pointer-events: all;
    transform: scale(1);
    z-index: 10;
}

/* Контейнеры и окна */
.container { 
    margin: auto; /* Гениальный трюк: выравнивает по центру, если места много, и прижимает вверх, если мало */
    text-align: center; 
    width: 100%; 
    max-width: 600px; 
}

.window {
    background: var(--window-bg);
    padding: 30px;
    border-radius: 15px;
    border: 2px solid #3258a8;
    box-shadow: 0 0 30px rgba(0, 150, 255, 0.3);
}

/* Игровой экран */
#screen-game { 
    margin: auto;
    max-width: 1000px; 
    width: 100%; 
}

/* Контейнеры и окна */
.container { text-align: center; width: 100%; max-width: 600px; padding: 20px; }
.window {
    background: var(--window-bg);
    padding: 30px;
    border-radius: 15px;
    border: 2px solid #3258a8;
    box-shadow: 0 0 30px rgba(0, 150, 255, 0.3);
}

/* Заголовок в стиле шоу */
.logo-container {
    margin-bottom: 40px;
    position: relative;
}
.logo-subtitle {
    color: var(--gold);
    font-size: 0.9rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 5px;
}
.game-title { 
    font-size: 4.5rem; 
    font-weight: 900; 
    line-height: 1.1;
    text-shadow: 0 0 20px rgba(0, 150, 255, 0.8);
}
.game-title span { color: var(--gold); }
h2 { font-size: 2rem; margin-bottom: 20px; }

/* Кнопки меню */
.btn {
    display: block;
    width: 100%;
    padding: 18px;
    margin: 15px 0;
    border-radius: 50px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    background: var(--btn-bg);
    color: #fff;
    border: 2px solid #678be8;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5), 0 5px 15px rgba(0,0,0,0.4);
    transition: all var(--transition);
}
.btn:hover { background: var(--btn-bg-hover); border-color: #fff; transform: scale(1.02); }

/* Игровой экран */
#screen-game { justify-content: flex-start; padding: 20px; width: 100%; max-width: 1000px; margin: 0 auto; }

.game-header {
    display: flex; justify-content: space-between; width: 100%;
    font-size: 1.2rem; font-weight: bold; margin-bottom: 20px; margin-top: 30px;
    background: rgba(0, 0, 0, 0.5);
    padding: 15px 30px;
    border-radius: 50px;
    border: 1px solid #3258a8;
}
.timer-box { color: var(--gold); font-size: 1.5rem; display: flex; align-items: center; gap: 10px;}

/* Блок вопроса (Стиль "Миллионер") */
.question-container { width: 100%; margin-top: 20px; }
.question-container h2 {
    font-size: 1.6rem;
    text-align: center;
    background: var(--btn-bg);
    border: 3px solid #fff;
    border-radius: 50px;
    padding: 25px 40px;
    margin-bottom: 40px;
    box-shadow: 0 0 20px rgba(0, 150, 255, 0.4);
    position: relative;
}

/* Линии по бокам блока вопроса для эффекта сцены */
.question-container h2::before, .question-container h2::after {
    content: ''; position: absolute; top: 50%; width: 50vw; height: 3px; background: #fff; z-index: -1;
}
.question-container h2::before { right: 100%; }
.question-container h2::after { left: 100%; }

/* Сетка ответов */
.answers-grid { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 20px 40px; 
    width: 100%; 
}

/* Кнопки ответов (Стиль "Миллионер") */
.answer-btn {
    position: relative;
    padding: 15px 30px; 
    font-size: 1.2rem; 
    background: var(--btn-bg);
    border: 2px solid #fff;
    border-radius: 50px; 
    color: #fff;
    cursor: pointer; 
    transition: all 0.2s;
    display: flex;
    align-items: center;
    text-align: left;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}

/* Линии от кнопок наружу */
.answer-btn:nth-child(odd)::before {
    content: ''; position: absolute; right: 100%; top: 50%; width: 50vw; height: 2px; background: #fff; z-index: -1;
}
.answer-btn:nth-child(even)::after {
    content: ''; position: absolute; left: 100%; top: 50%; width: 50vw; height: 2px; background: #fff; z-index: -1;
}

.answer-btn .letter {
    color: var(--gold);
    font-weight: 800;
    margin-right: 15px;
    font-size: 1.4rem;
}

.answer-btn:hover:not(:disabled) { background: var(--btn-bg-hover); border-color: var(--gold); transform: scale(1.02); }

/* Подсветка ответов */
.answer-btn.correct { background: var(--correct); border-color: #00ffcc; box-shadow: 0 0 20px #00ffcc; }
.answer-btn.correct .letter { color: #fff; }
.answer-btn.wrong { background: var(--wrong); border-color: #ff4d4d; }
.answer-btn.wrong .letter { color: #fff; }

/* Поля ввода */
input[type="text"], select {
    width: 100%; padding: 12px; margin: 15px 0;
    border: 2px solid var(--primary); border-radius: 8px;
    background: rgba(0,0,0,0.5); color: #fff; font-size: 1rem;
}

/* Прогресс бар */
.progress-bar { width: 100%; height: 6px; background: #111; border-radius: 4px; overflow: hidden; margin-bottom: 30px;}
#ui-progress { height: 100%; background: var(--gold); width: 0%; transition: width 0.3s; }

/* Адаптивность */
@media(max-width: 768px) {
    .answers-grid { grid-template-columns: 1fr; gap: 15px; }
    .game-title { font-size: 3rem; }
    .question-container h2 { font-size: 1.2rem; padding: 15px; }
    .answer-btn { padding: 12px 20px; font-size: 1rem; }
    .answer-btn::before, .answer-btn::after, .question-container h2::before, .question-container h2::after { display: none; } /* Убираем линии на мобилках */
}

/* --- Кнопка выхода из игры --- */
.btn-exit {
    background: rgba(214, 48, 49, 0.2);
    color: #ff4d4d;
    border: 1px solid #ff4d4d;
    border-radius: 30px;
    padding: 5px 15px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
}
.btn-exit:hover { background: #ff4d4d; color: #fff; box-shadow: 0 0 15px rgba(255, 77, 77, 0.6); }

/* --- Аватарки --- */
.avatar-grid {
    display: flex; justify-content: center; gap: 10px; margin-bottom: 20px; flex-wrap: wrap;
}
.avatar-item {
    font-size: 2rem; width: 60px; height: 60px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.05); border: 2px solid transparent;
    border-radius: 50%; cursor: pointer; transition: transform 0.2s, border 0.2s;
}
.avatar-item:hover { transform: scale(1.1); background: rgba(255,255,255,0.1); }
.avatar-item.selected {
    border-color: var(--gold); background: rgba(255, 193, 7, 0.15);
    box-shadow: 0 0 15px rgba(255, 193, 7, 0.5); transform: scale(1.1);
}

/* --- Красивые блоки настроек --- */
.settings-block {
    background: rgba(0, 0, 0, 0.4); padding: 20px; border-radius: 15px;
    margin-bottom: 15px; border: 1px solid #3258a8;
}
.settings-block h3 { text-align: center; margin-bottom: 15px; font-size: 1.2rem; color: var(--gold); }
.setting-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; font-size: 1.1rem; }
.setting-row:last-child { margin-bottom: 0; }

/* --- Переключатели (Тумблеры iOS style) --- */
.toggle-switch { position: relative; display: inline-block; width: 50px; height: 26px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255, 255, 255, 0.2); transition: .4s; border-radius: 26px;
}
.slider:before {
    position: absolute; content: ""; height: 18px; width: 18px; left: 4px; bottom: 4px;
    background-color: white; transition: .4s; border-radius: 50%;
}
input:checked + .slider { background-color: #00b894; box-shadow: 0 0 10px #00b894; }
input:checked + .slider:before { transform: translateX(24px); }

/* --- Выпадающий список (Select) --- */
.styled-select {
    background: var(--bg-dark); color: #fff; border: 2px solid var(--primary);
    padding: 8px 15px; border-radius: 10px; width: auto; outline: none; cursor: pointer;
}

/* --- Кнопка "Пропустить" --- */
.btn-skip {
    background: rgba(255, 193, 7, 0.2);
    color: var(--gold);
    border: 1px solid var(--gold);
    border-radius: 30px;
    padding: 5px 15px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
}
.btn-skip:hover { background: var(--gold); color: #000; box-shadow: 0 0 15px rgba(255, 193, 7, 0.6); }

/* --- Редактор вопросов --- */
.custom-q-item { 
    background: rgba(0, 0, 0, 0.4); 
    padding: 15px; 
    border-radius: 10px; 
    margin-bottom: 15px; 
    border: 1px solid #3258a8; 
}
.custom-q-item input { 
    margin: 5px 0; 
    padding: 10px; 
    background: rgba(255,255,255,0.05); 
}
.custom-q-actions { 
    display: flex; 
    gap: 10px; 
    margin-top: 10px; 
}
.btn-small { 
    padding: 10px; 
    font-size: 1rem; 
    border-radius: 8px; 
    flex: 1; 
    cursor: pointer; 
    border: 2px solid; 
    background: transparent; 
    transition: 0.2s; 
    font-weight: bold;
}
.btn-delete { color: #ff4d4d; border-color: #ff4d4d; }
.btn-delete:hover { background: rgba(255, 77, 77, 0.2); }
.btn-save-edit { color: #00b894; border-color: #00b894; }
.btn-save-edit:hover { background: rgba(0, 184, 148, 0.2); }

/* --- Адаптивность для экранов с МАЛЕНЬКОЙ ВЫСОТОЙ --- */
@media(max-height: 750px) {
    .game-title { font-size: 2.8rem; margin-bottom: 10px; }
    .logo-subtitle { margin-bottom: 5px; font-size: 0.8rem; }
    .logo-container { margin-bottom: 15px; }
    h2 { font-size: 1.5rem; margin-bottom: 10px; }
    .btn { padding: 12px; margin: 8px 0; font-size: 1.1rem; }
    .question-container h2 { font-size: 1.2rem; padding: 15px; margin-bottom: 20px; }
    .answer-btn { padding: 10px 15px; font-size: 1rem; }
    .game-header { margin-top: 5px; padding: 10px 15px; margin-bottom: 10px; }
    .progress-bar { margin-bottom: 15px; }
    .avatar-item { width: 50px; height: 50px; font-size: 1.5rem; }
    .window { padding: 20px; }
}