/* ============================================ */
/* БАЗОВЫЕ СТИЛИ И СБРОС                        */
/* ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-image: url('../img/clouds.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #2d3748;
    position: relative;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    padding-bottom: 50px;
    transition: background-color 0.4s ease, color 0.4s ease;
}

body::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.4);
    z-index: 0;
    pointer-events: none;
    transition: background 0.4s ease;
}

.start-screen,
.container,
.site-footer {
    position: relative;
    z-index: 1;
}

/* ============================================ */
/* TOAST УВЕДОМЛЕНИЯ (ВСПЛЫВАЮЩИЕ)              */
/* ============================================ */
.toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: white;
    color: #2d3748;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0;
    transform: translateY(-20px);
    animation: toastIn 0.3s forwards;
    pointer-events: auto;
    max-width: 90vw;
    text-align: center;
    border-left: 5px solid #667eea;
}

.toast.error { border-left-color: #e53e3e; }
.toast.success { border-left-color: #48bb78; }

@keyframes toastIn {
    to { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-20px); }
}

/* ============================================ */
/* ВЕРХНИЕ КНОПКИ (ТЕМА / ЗВУК) - ИСПРАВЛЕНО    */
/* ============================================ */
.top-controls {
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 100;
    display: flex;
    gap: 10px;
}

.control-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.5);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

    /* Скрываем любой текст внутри кнопки */
    color: transparent !important;
    font-size: 0 !important;
    line-height: 0 !important;

    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    padding: 0;
    position: relative;
    overflow: visible;
}

/* Псевдоэлемент для иконок через data-атрибут */
.control-btn::before {
    content: attr(data-icon); /* Берет иконку из атрибута data-icon */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);

    /* Принудительные стили для иконки */
    color: #ffffff !important;
    font-size: 24px !important;
    line-height: 1 !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
}

.control-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.control-btn:active {
    transform: scale(0.95);
}

/* ============================================ */
/* МОДАЛЬНЫЕ ОКНА                               */
/* ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-card {
    background: linear-gradient(145deg, #ffffff 0%, #f7fafc 100%);
    padding: 50px 45px;
    border-radius: 20px;
    border-top: 6px solid #667eea;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3);
    max-width: 450px;
    width: 100%;
    text-align: center;
    animation: modalIn 0.3s ease-out;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-title {
    font-size: 28px;
    font-weight: 800;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.15);
}

.modal-subtitle {
    color: #718096;
    font-size: 16px;
    margin-bottom: 30px;
    line-height: 1.5;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.name-input {
    width: 100%;
    padding: 16px 24px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 17px;
    color: #2d3748;
    background: #f7fafc;
    outline: none;
    transition: border-color 0.2s ease;
    margin-bottom: 25px;
    text-align: center;
    font-weight: 600;
}

.name-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-buttons-row {
    flex-direction: row;
    justify-content: center;
}

.restore-info {
    color: #4a5568;
    font-size: 14px;
    margin-bottom: 20px;
    padding: 12px;
    background: #edf2f7;
    border-radius: 10px;
    line-height: 1.5;
}

/* ============================================ */
/* СТАРТОВЫЙ ЭКРАН                              */
/* ============================================ */
.start-screen {
    width: 100%;
    max-width: 700px;
    padding: 40px 20px;
    text-align: center;
}

.card {
    background: linear-gradient(145deg, #ffffff 0%, #f7fafc 100%);
    padding: 70px 60px;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow:
            0 30px 80px rgba(0, 0, 0, 0.25),
            0 15px 40px rgba(0, 0, 0, 0.15),
            0 5px 15px rgba(0, 0, 0, 0.1),
            inset 0 3px 0 rgba(255, 255, 255, 1),
            inset 0 -3px 10px rgba(0, 0, 0, 0.08);
    border-top: 10px solid #667eea;
    transition: background 0.4s ease, border-color 0.4s ease;
}

.doc-title {
    font-size: 24px;
    color: #1a202c;
    line-height: 1.6;
    margin-bottom: 25px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 700;
    text-shadow:
            2px 2px 4px rgba(0, 0, 0, 0.2),
            3px 3px 6px rgba(0, 0, 0, 0.15);
    transition: color 0.4s ease;
}

.doc-meta {
    color: #718096;
    font-size: 15px;
    margin-bottom: 35px;
    line-height: 1.7;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.2);
    transition: color 0.4s ease;
}

.test-title {
    font-size: 42px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 50px;
    font-weight: 800;
    filter: drop-shadow(4px 4px 6px rgba(0, 0, 0, 0.3));
}

.primary-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 22px 60px;
    border-radius: 14px;
    font-size: 22px;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    box-shadow:
            0 8px 0 #4c51bf,
            0 12px 25px rgba(0, 0, 0, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.3);
    transition: all 0.1s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.primary-btn:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
}

.primary-btn:active {
    transform: translateY(8px);
    box-shadow:
            0 0 0 #4c51bf,
            0 5px 10px rgba(0, 0, 0, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* ============================================ */
/* ВЫБОР СЛОЖНОСТИ                              */
/* ============================================ */
.difficulty-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.difficulty-btn {
    padding: 20px 30px;
    border: 3px solid #e2e8f0;
    border-radius: 12px;
    background: white;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 4px 0 #cbd5e0, 0 6px 10px rgba(0, 0, 0, 0.05);
}

.difficulty-btn.easy {
    border-color: #48bb78;
    color: #276749;
}

.difficulty-btn.medium {
    border-color: #ed8936;
    color: #c05621;
}

.difficulty-btn.hard {
    border-color: #fc8181;
    color: #c53030;
}

.difficulty-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
}

.difficulty-btn.easy:hover {
    background: #c6f6d5;
    border-color: #38a169;
}

.difficulty-btn.medium:hover {
    background: #feebc8;
    border-color: #dd6b20;
}

.difficulty-btn.hard:hover {
    background: #fed7d7;
    border-color: #e53e3e;
}

.difficulty-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #cbd5e0, 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* ============================================ */
/* QR-КОД                                      */
/* ============================================ */
.qr-section {
    margin: 30px 0;
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border-radius: 12px;
    border: 2px solid #e2e8f0;
}

.qr-section h3 {
    color: #4a5568;
    margin-bottom: 15px;
    font-size: 18px;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

#qrcode {
    display: inline-block;
    padding: 15px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin: 10px 0;
}

#qrcode img {
    display: block;
    margin: 0 auto;
}

.qr-hint {
    color: #718096;
    font-size: 14px;
    margin-top: 10px;
    text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.8);
}

/* ✅ СПЕЦИФИЧНЫЕ СТИЛИ ДЛЯ QR НА СТАРТОВОМ ЭКРАНЕ */
.start-qr-section {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 1px solid rgba(0,0,0,0.1);

    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 100%;
}

#qrcode-start {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
    background: white;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

#qrcode-start img {
    display: block !important;
    margin: 0 auto !important;
}

/* Ссылка на лидерборд на стартовом экране */
.start-leaderboard-link {
    display: inline-block;
    margin-top: 25px;
    color: #667eea;
    text-decoration: none;
    font-weight: 700;
    font-size: 16px;
    padding: 12px 24px;
    border: 2px solid #667eea;
    border-radius: 10px;
    transition: all 0.2s ease;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    text-align: center;
}

.start-leaderboard-link:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* ============================================ */
/* ССЫЛКА НА ЛИДЕРБОРД (в выборе сложности)     */
/* ============================================ */
.leaderboard-link {
    display: block;
    text-align: center;
    color: #667eea;
    text-decoration: none;
    font-weight: 700;
    font-size: 16px;
    margin-top: 20px;
    padding: 14px 24px;
    border: 2px solid #667eea;
    border-radius: 10px;
    transition: all 0.2s ease;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
}

.leaderboard-link:hover {
    background: #667eea;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.leaderboard-link:active {
    transform: translateY(2px);
}

/* ============================================ */
/* КОНТЕЙНЕР ТЕСТА                              */
/* ============================================ */
.container {
    background: linear-gradient(145deg, #ffffff 0%, #f7fafc 100%);
    padding: 50px 45px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow:
            0 20px 50px rgba(0, 0, 0, 0.15),
            0 8px 20px rgba(0, 0, 0, 0.1),
            inset 0 2px 0 rgba(255, 255, 255, 1),
            inset 0 -2px 5px rgba(0, 0, 0, 0.05);
    width: 100%;
    max-width: 650px;
    text-align: center;
    min-height: 550px;
    max-height: calc(100vh - 100px);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transition: background 0.4s ease, border-color 0.4s ease;
}

.container::-webkit-scrollbar {
    width: 8px;
}

.container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.container::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
}

.container::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #5568d3 0%, #6a42a0 100%);
}

.quiz-header {
    font-size: 24px;
    margin-bottom: 15px;
    color: #1a202c;
    font-weight: 700;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.15);
    transition: color 0.4s ease;
}

/* ============================================ */
/* ПРОГРЕСС-БАР                                 */
/* ============================================ */
.progress-bar-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
}

.progress-bar-container {
    flex-grow: 1;
    height: 12px;
    background: #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    transition: width 0.4s ease;
    position: relative;
}

.progress-bar::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
            90deg,
            transparent 0%,
            rgba(255, 255, 255, 0.3) 50%,
            transparent 100%
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-text {
    font-size: 14px;
    font-weight: 700;
    color: #667eea;
    min-width: 36px;
    text-align: right;
}

/* ============================================ */
/* ВОПРОС И ВАРИАНТЫ                            */
/* ============================================ */
.question-text {
    font-size: 22px;
    color: #1a202c;
    margin-bottom: 35px;
    line-height: 1.6;
    font-weight: 700;
    min-height: 90px;
    display: flex;
    align-items: center;
    text-align: left;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.15);
    transition: color 0.4s ease;
}

.options-grid {
    display: grid;
    gap: 15px;
    margin-bottom: 30px;
    flex-grow: 1;
}

.answer-btn {
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8eb 100%);
    border: 1px solid #e2e8f0;
    padding: 18px 24px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 17px;
    color: #2d3748;
    transition: all 0.15s ease;
    text-align: left;
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.9);
    box-shadow: 0 4px 0 #cbd5e0, 0 6px 10px rgba(0, 0, 0, 0.05);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-height: 52px;
    word-wrap: break-word;
}

.answer-btn:hover {
    filter: brightness(1.02);
    border-color: #667eea;
}

.answer-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #cbd5e0, 0 2px 4px rgba(0, 0, 0, 0.05);
}

.answer-btn.selected {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.4);
    box-shadow: 0 4px 0 #4c51bf, 0 6px 15px rgba(102, 126, 234, 0.4);
}

.answer-btn.selected:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #4c51bf, 0 2px 5px rgba(102, 126, 234, 0.4);
}

.option-main-text {
    font-weight: 700;
}

.option-hint {
    font-weight: 500;
    color: #718096;
    font-size: 0.9em;
    margin-left: 6px;
}

.answer-btn.selected .option-hint {
    color: rgba(255, 255, 255, 0.9);
}

/* ============================================ */
/* КНОПКИ ДЕЙСТВИЙ                              */
/* ============================================ */
.quiz-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: auto;
    flex-direction: row-reverse;
}

.action-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 16px 36px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 17px;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.4);
    box-shadow: 0 5px 0 #4c51bf, 0 8px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.1s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-height: 52px;
}

.action-btn:hover {
    filter: brightness(1.05);
}

.action-btn:active {
    transform: translateY(5px);
    box-shadow: 0 0 0 #4c51bf, 0 3px 5px rgba(0, 0, 0, 0.2);
}

.action-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Кнопка "Не знаю" */
.action-btn-skip {
    background: linear-gradient(135deg, #f6ad55 0%, #ed8936 100%);
    box-shadow: 0 5px 0 #c05621, 0 8px 15px rgba(237, 137, 54, 0.3);
}

.action-btn-skip:active {
    box-shadow: 0 0 0 #c05621, 0 3px 5px rgba(237, 137, 54, 0.3);
}

/* Кнопка PDF */
.action-btn-pdf {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    box-shadow: 0 5px 0 #276749, 0 8px 15px rgba(72, 187, 120, 0.3);
}

.action-btn-pdf:active {
    box-shadow: 0 0 0 #276749, 0 3px 5px rgba(72, 187, 120, 0.3);
}

.action-btn-restart {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.action-btn-finish {
    background: linear-gradient(135deg, #a0aec0 0%, #718096 100%);
    box-shadow: 0 5px 0 #4a5568, 0 8px 15px rgba(113, 128, 150, 0.3);
}

.action-btn-finish:active {
    box-shadow: 0 0 0 #4a5568, 0 3px 5px rgba(113, 128, 150, 0.3);
}

/* ============================================ */
/* ✅ КНОПКА ЛИДЕРБОРДА В РЕЗУЛЬТАТАХ           */
/* ============================================ */
.leaderboard-result-btn {
    background: linear-gradient(135deg, #f6ad55 0%, #ed8936 100%);
    box-shadow: 0 5px 0 #c05621, 0 8px 15px rgba(237, 137, 54, 0.3);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    color: white;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.4);
    gap: 6px;
}

.leaderboard-result-btn:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
}

.leaderboard-result-btn:active {
    transform: translateY(5px);
    box-shadow: 0 0 0 #c05621, 0 3px 5px rgba(237, 137, 54, 0.3);
}

/* ============================================ */
/* КОНТЕЙНЕР КНОПОК В РЕЗУЛЬТАТАХ               */
/* ============================================ */
.controls-row {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    margin-top: auto;
    width: 100%;
    padding-top: 20px;
    gap: 10px;
    flex-wrap: nowrap;
}

.controls-row .action-btn,
.controls-row .leaderboard-result-btn {
    flex: 1;
    min-width: 0;
    text-align: center;
    padding: 16px 10px;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ============================================ */
/* УЛУЧШЕННЫЙ АДАПТИВ ДЛЯ КНОПОК РЕЗУЛЬТАТОВ    */
/* ============================================ */
@media screen and (max-width: 600px) {
    .controls-row {
        flex-wrap: wrap;
        gap: 8px;
    }

    .controls-row .action-btn,
    .controls-row .leaderboard-result-btn {
        flex: 1 1 calc(50% - 8px);
        min-width: 120px;
        font-size: 14px;
        padding: 12px 8px;
        white-space: normal;
    }
}

/* ============================================ */
/* ТАЙМЕР И СЧЁТЧИК                             */
/* ============================================ */
.timer-box {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 14px 32px;
    border-radius: 50px;
    display: inline-block;
    font-weight: 700;
    font-size: 17px;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.4);
    box-shadow: 0 4px 0 #4c51bf, 0 6px 15px rgba(102, 126, 234, 0.3);
}

.question-counter {
    font-size: 19px;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.15);
}

/* ============================================ */
/* РЕЗУЛЬТАТЫ                                   */
/* ============================================ */
.result-title {
    font-size: 36px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 15px;
    margin-top: 0;
    font-weight: 800;
    filter: drop-shadow(3px 3px 4px rgba(0, 0, 0, 0.2));
}

.player-name-display {
    font-size: 19px;
    color: #718096;
    margin-bottom: 25px;
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.stats {
    margin: 30px 0;
    text-align: left;
    color: #4a5568;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8eb 100%);
    padding: 28px;
    border-radius: 12px;
    font-size: 17px;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.05);
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.9);
    transition: background 0.4s ease, color 0.4s ease;
}

.stats p {
    margin-bottom: 10px;
    line-height: 1.6;
}

.stats p:last-child {
    margin-bottom: 0;
}

.stats strong {
    color: #667eea;
    font-weight: 800;
}

/* Статистика по времени */
.time-stats-block {
    margin: 20px 0;
    padding: 20px;
    background: linear-gradient(135deg, #ebf4ff 0%, #c3dafe 100%);
    border: 2px solid #a3bffa;
    border-radius: 12px;
    text-align: left;
}

.time-stats-block h3 {
    color: #4c51bf;
    margin-bottom: 12px;
    font-size: 16px;
}

.time-stats-block ul {
    list-style: none;
    padding-left: 0;
}

.time-stats-block li {
    padding: 8px 0;
    border-bottom: 1px solid rgba(163, 191, 250, 0.5);
    font-size: 14px;
    color: #2d3748;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.time-stats-block li:last-child {
    border-bottom: none;
}

.time-stat-label {
    font-weight: 600;
    color: #4a5568;
}

.time-stat-value {
    font-weight: 700;
    color: #667eea;
    font-family: 'Courier New', monospace;
}

.time-stat-skip {
    color: #ed8936;
    font-style: italic;
}

/* Блок ошибок */
.errors-block {
    display: none;
    margin: 20px 0;
    padding: 25px;
    background: linear-gradient(135deg, #fff5f5 0%, #fed7d7 100%);
    border: 2px solid #fc8181;
    border-radius: 12px;
    text-align: left;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.05);
}

.errors-block h3 {
    color: #c53030;
    margin-bottom: 15px;
    font-weight: 700;
    font-size: 18px;
}

.errors-block ul {
    margin-top: 10px;
    padding-left: 0;
    list-style: none;
}

.errors-block li {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 2px solid #fed7d7;
    color: #2d3748;
    line-height: 1.6;
}

.errors-block li:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.err-question-num {
    color: #667eea;
    font-weight: 800;
    display: block;
    margin-bottom: 8px;
    font-size: 16px;
}

.err-question-context {
    color: #4a5568;
    font-size: 15px;
    font-style: italic;
    margin-bottom: 12px;
    display: block;
    line-height: 1.5;
}

.err-label-user {
    color: #c53030;
    font-weight: 700;
    margin-right: 5px;
}

.err-user-answer {
    color: #e53e3e;
    font-weight: 800;
}

.err-label-correct {
    color: #2f855a;
    font-weight: 700;
    margin-right: 5px;
}

.err-correct-answer {
    color: #38a169;
    font-weight: 800;
}

.err-answer-text {
    font-size: 15px;
    font-weight: 700;
    font-family: 'Courier New', Courier, monospace;
    padding: 3px 8px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 6px;
}

.results-screen {
    min-height: 400px;
}

#question-box {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

/* ============================================ */
/* ФУТЕР                                        */
/* ============================================ */
.site-footer {
    width: 100%;
    background: #718096;
    color: #ffffff;
    text-align: center;
    padding: 12px 15px;
    font-size: 15px;
    position: fixed;
    bottom: 0;
    left: 0;
    z-index: 3;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.15);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.4);
    transition: background 0.4s ease;
}

.site-footer p {
    margin: 0;
    font-weight: 400;
}

/* ============================================ */
/* ФЕЙЕРВЕРКИ                                   */
/* ============================================ */
#fireworks-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    pointer-events: none;
    display: none;
}

#fireworks-canvas.active {
    display: block;
    pointer-events: auto;
}

.congratulations-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1001;
    pointer-events: none;
    text-align: center;
    width: 90%;
    max-width: 90vw;
}

.congratulations-text {
    font-size: 72px;
    font-weight: 900;
    background: linear-gradient(45deg, #ff6b6b, #feca57, #48dbfb, #ff9ff3, #54a0ff, #5f27cd);
    background-size: 400% 400%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 2s ease infinite, scaleIn 0.5s ease-out, float 3s ease-in-out infinite;
    filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.4));
    line-height: 1.2;
    padding: 20px;
    word-wrap: break-word;
}

.congratulations-subtext {
    font-size: 48px;
    font-weight: 800;
    background: linear-gradient(45deg, #ff6b6b, #feca57, #48dbfb, #ff9ff3);
    background-size: 400% 400%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 2s ease infinite, scaleIn 0.7s ease-out;
    margin-top: 10px;
    filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.3));
    word-wrap: break-word;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes scaleIn {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-20px); }
}

/* ============================================ */
/* ДОСТУПНОСТЬ                                  */
/* ============================================ */
.answer-btn:focus-visible,
.action-btn:focus-visible,
.primary-btn:focus-visible,
.control-btn:focus-visible,
.name-input:focus-visible,
.difficulty-btn:focus-visible {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

/* ============================================ */
/* АДАПТИВ: ПЛАНШЕТЫ (до 768px)                 */
/* ============================================ */
@media screen and (max-width: 768px) {
    body {
        background-attachment: scroll;
    }

    .start-screen {
        padding: 20px 15px;
    }

    .card {
        padding: 50px 40px;
        border-radius: 20px;
    }

    .doc-title { font-size: 20px; }

    .test-title {
        font-size: 32px;
        margin-bottom: 35px;
    }

    .primary-btn {
        padding: 20px 50px;
        font-size: 20px;
    }

    .container {
        padding: 35px 30px;
        max-width: 90%;
        max-height: calc(100vh - 80px);
    }

    .question-text {
        font-size: 20px;
        min-height: 70px;
    }

    .congratulations-text { font-size: 52px; }
    .congratulations-subtext { font-size: 36px; }

    .difficulty-btn {
        font-size: 16px;
        padding: 18px 24px;
    }

    .controls-row {
        flex-wrap: wrap;
        justify-content: center;
    }

    .controls-row .action-btn,
    .controls-row .leaderboard-result-btn {
        flex: 1 1 calc(50% - 10px);
        min-width: 140px;
    }

    /* Адаптив QR на старте */
    .start-qr-section { margin-top: 30px; padding-top: 20px; }
    .start-leaderboard-link { font-size: 14px; padding: 10px 20px; }
    #qrcode-start { padding: 10px; }
}

/* ============================================ */
/* АДАПТИВ: СМАРТФОНЫ (до 480px)                */
/* ============================================ */
@media screen and (max-width: 480px) {
    body {
        justify-content: flex-start;
        padding-top: 20px;
        padding-bottom: 60px;
    }

    .start-screen { padding: 15px 10px; }

    .card {
        padding: 40px 25px;
        border-radius: 16px;
        border-top-width: 6px;
    }

    .doc-title {
        font-size: 16px;
        letter-spacing: 0.5px;
        margin-bottom: 15px;
    }

    .doc-meta {
        font-size: 13px;
        margin-bottom: 20px;
    }

    .test-title {
        font-size: 26px;
        margin-bottom: 30px;
    }

    .primary-btn {
        padding: 18px 40px;
        font-size: 18px;
        box-shadow: 0 6px 0 #4c51bf, 0 8px 15px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    }

    .primary-btn:active {
        transform: translateY(6px);
        box-shadow: 0 0 0 #4c51bf, 0 3px 8px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    }

    .container {
        position: relative;
        top: auto;
        left: auto;
        transform: none;
        max-width: 95%;
        width: 95%;
        margin: 10px auto;
        min-height: auto;
        max-height: none;
        padding: 25px 20px;
        border-radius: 16px;
    }

    .container h1 { font-size: 20px !important; }

    .question-text {
        font-size: 18px;
        min-height: 60px;
        margin-bottom: 25px;
    }

    .answer-btn {
        padding: 16px 18px;
        font-size: 16px;
        box-shadow: 0 3px 0 #cbd5e0, 0 4px 8px rgba(0, 0, 0, 0.05);
    }

    .answer-btn:active,
    .answer-btn.selected:active {
        transform: translateY(3px);
    }

    .option-main-text { white-space: normal; }

    .option-hint {
        display: block;
        margin-left: 0;
        margin-top: 4px;
        font-size: 0.85em;
    }

    .timer-box {
        padding: 12px 24px;
        font-size: 15px;
        margin-bottom: 25px;
    }

    .question-counter {
        font-size: 17px;
        margin-bottom: 15px;
    }

    .quiz-actions {
        flex-direction: column-reverse;
        gap: 10px;
    }

    .quiz-actions .action-btn {
        width: 100%;
    }

    .controls-row {
        flex-direction: column;
        gap: 12px;
        padding-top: 15px;
    }

    .controls-row .action-btn,
    .controls-row .leaderboard-result-btn {
        width: 100%;
        flex: none;
        padding: 14px 20px;
        font-size: 16px;
        white-space: normal;
    }

    .action-btn:active,
    .action-btn-skip:active,
    .action-btn-pdf:active,
    .action-btn-restart:active,
    .action-btn-finish:active,
    .leaderboard-result-btn:active {
        transform: translateY(4px);
    }

    .stats {
        padding: 20px;
        font-size: 15px;
        margin: 25px 0;
    }

    .result-title { font-size: 28px; }
    .errors-block { padding: 20px; }
    .errors-block h3 { font-size: 17px; }

    .congratulations-text { font-size: 36px; padding: 10px; }
    .congratulations-subtext { font-size: 24px; }

    .time-stats-block { padding: 15px; }
    .time-stats-block li { font-size: 13px; }

    .modal-card { padding: 35px 25px; }

    .difficulty-btn {
        font-size: 16px;
        padding: 16px 20px;
    }

    #qrcode img {
        max-width: 180px !important;
        height: auto !important;
    }

    .qr-section {
        padding: 15px;
    }

    .leaderboard-link {
        font-size: 14px;
        padding: 12px 20px;
    }

    .site-footer {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
    }

    .top-controls {
        top: 10px;
        right: 10px;
    }

    .control-btn {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }
}

/* ============================================ */
/* ОЧЕНЬ МАЛЕНЬКИЕ ЭКРАНЫ (до 360px)            */
/* ============================================ */
@media screen and (max-width: 360px) {
    .card { padding: 30px 18px; }
    .doc-title { font-size: 14px; }
    .test-title { font-size: 22px; }
    .primary-btn { padding: 16px 30px; font-size: 16px; }
    .congratulations-text { font-size: 28px; }
    .congratulations-subtext { font-size: 20px; }
    .question-text { font-size: 16px; }
    .answer-btn { font-size: 15px; padding: 14px 16px; }
    .modal-card { padding: 28px 20px; }
    .modal-title { font-size: 22px; }
    .difficulty-btn { font-size: 15px; padding: 14px 18px; }
    #qrcode img { max-width: 150px !important; }
}

/* ============================================ */
/* АЛЬБОМНАЯ ОРИЕНТАЦИЯ                         */
/* ============================================ */
@media screen and (max-height: 500px) and (orientation: landscape) {
    body {
        justify-content: flex-start;
        padding: 10px;
    }

    .container {
        position: relative;
        top: auto;
        left: auto;
        transform: none;
        min-height: auto;
        max-height: none;
        margin: 10px auto;
    }

    .question-text {
        min-height: 50px;
        margin-bottom: 15px;
    }

    .options-grid {
        gap: 10px;
        margin-bottom: 15px;
    }

    .answer-btn { padding: 12px 16px; }

    .difficulty-buttons {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .difficulty-btn {
        flex: 1;
        min-width: 120px;
        padding: 12px 16px;
        font-size: 14px;
    }
}

/* ============================================ */
/* SAFE-AREA (iPhone)                           */
/* ============================================ */
@supports (padding: max(0px)) {
    .site-footer {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

/* ============================================ */
/* ПЕЧАТЬ                                       */
/* ============================================ */
@media print {
    body { background: white; }
    .start-screen, .site-footer, .top-controls,
    #fireworks-canvas, .timer-box, .action-btn,
    .primary-btn, .quiz-actions, .difficulty-buttons,
    .qr-section, .leaderboard-link, .leaderboard-result-btn, .toast-container { display: none !important; }
    .container {
        position: relative;
        transform: none;
        box-shadow: none;
        max-width: 100%;
        top: auto;
        left: auto;
    }
}

/* ============================================ */
/* УМЕНЬШЕННАЯ АНИМАЦИЯ                         */
/* ============================================ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    #fireworks-canvas { display: none !important; }
}

/* ============================================ */
/* ТЁМНАЯ ТЕМА (через класс)                    */
/* ============================================ */
body.dark-theme {
    background-color: #0f1724;
    color: #e2e8f0;
}

body.dark-theme::before {
    background: rgba(15, 23, 36, 0.7);
}

body.dark-theme .card,
body.dark-theme .container,
body.dark-theme .modal-card {
    background: linear-gradient(145deg, #1e293b 0%, #1a202c 100%);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

body.dark-theme .doc-title,
body.dark-theme .quiz-header,
body.dark-theme .question-text {
    color: #e2e8f0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

body.dark-theme .doc-meta { color: #94a3b8; }

body.dark-theme .answer-btn {
    background: linear-gradient(135deg, #2d3748 0%, #374151 100%);
    color: #e2e8f0;
    border-color: #4a5568;
    text-shadow: 2px 2px 3px rgba(0, 0, 0, 0.6);
    box-shadow: 0 4px 0 #1a202c, 0 6px 10px rgba(0, 0, 0, 0.3);
}

body.dark-theme .answer-btn:hover {
    border-color: #667eea;
}

body.dark-theme .answer-btn.selected {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
}

body.dark-theme .stats {
    background: linear-gradient(135deg, #2d3748 0%, #374151 100%);
    color: #e2e8f0;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

body.dark-theme .time-stats-block {
    background: linear-gradient(135deg, #1e293b 0%, #2d3748 100%);
    border-color: #4c51bf;
}

body.dark-theme .time-stats-block h3 { color: #a3bffa; }
body.dark-theme .time-stats-block li { color: #e2e8f0; border-color: rgba(76, 81, 191, 0.3); }

body.dark-theme .errors-block {
    background: linear-gradient(135deg, #3b1a1a 0%, #4a2020 100%);
    border-color: #c53030;
}

body.dark-theme .errors-block li { color: #fed7d7; border-color: rgba(197, 48, 48, 0.3); }
body.dark-theme .err-question-context { color: #cbd5e0; }
body.dark-theme .err-answer-text { background: rgba(0, 0, 0, 0.3); color: #feb2b2; }
body.dark-theme .err-correct-answer { color: #68d391; }

body.dark-theme .name-input {
    background: #2d3748;
    border-color: #4a5568;
    color: #e2e8f0;
}

body.dark-theme .name-input:focus { border-color: #667eea; }

body.dark-theme .restore-info {
    background: #2d3748;
    color: #cbd5e0;
}

body.dark-theme .site-footer { background: #1a202c; }

body.dark-theme .progress-bar-container { background: #2d3748; }

body.dark-theme .container::-webkit-scrollbar-track { background: #1a202c; }

body.dark-theme .modal-subtitle { color: #94a3b8; text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.4); }
body.dark-theme .player-name-display { color: #94a3b8; text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.4); }

/* Тёмная тема для кнопок сложности */
body.dark-theme .difficulty-btn {
    background: #2d3748;
    color: #e2e8f0;
    border-color: #4a5568;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    box-shadow: 0 4px 0 #1a202c, 0 6px 10px rgba(0, 0, 0, 0.3);
}

body.dark-theme .difficulty-btn.easy { border-color: #48bb78; color: #68d391; }
body.dark-theme .difficulty-btn.medium { border-color: #ed8936; color: #f6ad55; }
body.dark-theme .difficulty-btn.hard { border-color: #fc8181; color: #feb2b2; }

body.dark-theme .difficulty-btn.easy:hover { background: #276749; }
body.dark-theme .difficulty-btn.medium:hover { background: #c05621; }
body.dark-theme .difficulty-btn.hard:hover { background: #c53030; }

/* Тёмная тема для QR-секции */
body.dark-theme .qr-section {
    background: linear-gradient(135deg, #1e293b 0%, #2d3748 100%);
    border-color: #4a5568;
}

body.dark-theme .qr-section h3 {
    color: #e2e8f0;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

body.dark-theme .qr-hint {
    color: #94a3b8;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.4);
}

/* Тёмная тема для ссылки на лидерборд */
body.dark-theme .leaderboard-link {
    background: linear-gradient(135deg, #1e293b 0%, #2d3748 100%);
    border-color: #667eea;
    color: #a3bffa;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

body.dark-theme .leaderboard-link:hover {
    background: #667eea;
    color: white;
}

/* Тёмная тема для кнопки лидерборда в результатах */
body.dark-theme .leaderboard-result-btn {
    background: linear-gradient(135deg, #c05621 0%, #9c4221 100%);
    box-shadow: 0 5px 0 #7b341e, 0 8px 15px rgba(192, 86, 33, 0.3);
}

body.dark-theme .leaderboard-result-btn:hover {
    filter: brightness(1.1);
}

/* ============================================ */
/* СТИЛИ ДЛЯ PDF (скрытый блок)                 */
/* ============================================ */
#pdf-export-area {
    position: absolute;
    left: -9999px;
    top: 0;
    width: 700px;
    background: #ffffff;
    color: #1a202c;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    padding: 40px;
}

#pdf-export-area h2 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 22px;
}

#pdf-export-area p {
    margin-bottom: 8px;
    font-size: 14px;
    line-height: 1.6;
}

#pdf-export-area .pdf-error {
    background: #fff5f5;
    border: 1px solid #fc8181;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 6px;
    font-size: 13px;
}