* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
    padding: 20px;
    max-width: 800px;
    margin: 0 auto;
}

.container {
    background: white;
    border-radius: 20px;
    padding: 5px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    min-height: 90vh;
}

.header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
}

.header h1 {
    font-size: 16px;
    color: #2c3e50;
}


.buttons-container {
    /* display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px; */
    overflow-x: auto;
} 
 /*
 .subject-btn {
    padding: 15px 20px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
}

.subject-btn:hover {
    background-color: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
} 

.subject-btn:active {
    transform: translateY(0);
}*/

.selected-info {
    background-color: #f0f9ff;
    border-left: 4px solid #2196F3;
    padding: 5px;
    border-radius: 0 5px 5px 0;
    margin-top: 5px;
    margin-bottom: 5px;
    display: grid;
    /* grid-template-columns: repeat(2, 1fr); */
    grid-template-columns: 0.1fr 0.9fr;
    align-items: center;
    gap: 8px;
}

.selected-info h2 {
    color: #2481cc;
    /* margin-bottom: 5px; */
    font-size: 14px;
}

#selectedSubject, #selectedSection, #selectedTopic {
    font-weight: bold;
    color: #2c3e50;
    font-size: 14px;
}

.no-selection {
    color: #888;
    font-style: italic;
}

/* Сетка предметов и кнопки выбора  ----->   */
.subjects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.subject-card {
    background: #fff;
    border-radius: 15px;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.3s ease;
    border: 2px solid #e0e0e0;
    display: flex;
    /* justify-content: center; */
    justify-content: space-between;
}

.subject-card:hover {
    /* transform: translateY(-5px); */
    border-color: #3498db;
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.2);
    background-color:  #3498db;
}

.subject-card:active {

    background-color: #3498db; /* Зеленый */
    color: white;
}

.subject-icon {
    font-size: 14px;
    margin-bottom: 10px;
    margin-right: 10px;
    color: #3498db;
}

.subject-card h3 {
    font-size: 16px;
    color: #2c3e50;
    text-align: left;
}

.task_count {
    font-size: 14px;
    color: #2c3e50;
}
/*  <-----  Сетка предметов и кнопки выбора  */

.hidden {
    display: none !important;
}



/* Контейнер с вопросами   ----->   */
.score {
    font-size: 14px;
    font-weight: bold;
    /* color: var(--tg-theme-link-color, #2481cc); */
    color:  #2481cc;
}

.question-container {
    /* background: var(--tg-theme-secondary-bg-color, #f0f9ff); */
    background:  #f0f9ff;
    border-radius: 15px;
    padding: 10px;
    margin-bottom: 10px;
}

.question {
    font-size: 12px;
    margin-bottom: 10px;
    text-align: justify;
}

.question img{
    max-width: 100%;
    height: auto;
}

.question table, th, td{
    /* width: 100%; */
    /* border: 1px solid #2196F3; */
    /* border-collapse: collapse; */
    /* border-radius: 10px; */
   border: 3px solid #f0f9ff;
   border-collapse: collapse;
   word-wrap: break-word;
   font-size: 10px;
 
}

.question th, td{
    background-color: white;
}

.question table{
    table-layout: fixed;
    width: 100%;
}

.answer_options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.option-btn {
    padding: 10px;
    border: none;
    border-radius: 10px;
    /* background: var(--tg-theme-bg-color, #ffffff);
    color: var(--tg-theme-text-color, #000000); */
    background: #ffffff;
    color: #000000;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.question_btn_line {
    padding: 15px;
    border: none; 
    border-radius: 10px;
    /* background: var(--tg-theme-bg-color, #ffffff);
    color: var(--tg-theme-text-color, #000000); */
    background:  #ffffff;
    color:  #000000;
    font-size: 14px;
    cursor: pointer;
    /* transition: all 0.3s ease; */
    /* overflow-x: auto;
    white-space: nowrap; */
}

.question_btn_select {    
    border-bottom: 4px solid #2196F3;
    border-top: 4px solid #2196F3;
}


/* , .question_btn_line:hover */
.option-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.option-btn.correct, .question_btn_line.correct, .menu-item.correct {
    background: #4CAF50;
    color: white;
}

.option-btn.incorrect, .question_btn_line.incorrect, .menu-item.incorrect {
    background: #f44336;
    color: white;
}

#restart-btn {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 10px;
    /* background: var(--tg-theme-button-color, #2481cc);
    color: var(--tg-theme-button-text-color, #ffffff); */
    background: #2481cc;
    color: #ffffff;
    font-size: 14px;
    cursor: pointer;
}

    .scroll-menu-container {
        width: 100%;
        overflow-x: scroll;
        -webkit-overflow-scrolling: touch; /* Плавная прокрутка на iOS */
        padding-bottom: 10px; /* Пространство для скроллбара */
    }

    * Скрываем стандартный скроллбар для красоты */
    .scroll-menu-container::-webkit-scrollbar {
        height: 6px;
    }

    .scroll-menu-container::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 3px;
    }

    .scroll-menu-container::-webkit-scrollbar-thumb {
        background: #c1c1c1;
        border-radius: 3px;
    }

    .scroll-menu-container::-webkit-scrollbar-thumb:hover {
        background: #a1a1a1;
    }


    .scroll-menu {
            display: inline-flex;
            gap: 12px;
            /* padding: 10px 5px; */
            white-space: nowrap; /* Предотвращает перенос элементов */
            min-width: min-content; /* Контейнер растягивается под содержимое */
    }

    .menu-item {
            display: flex;
            align-items: center;
            justify-content: center;
            min-width: 60px;
            height: 60px;
            background: white;
            border-radius: 10px;
            border: none;
            font-size: 14;
            font-weight: 600;
            color: #000000;
            text-decoration: none;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
            transition: all 0.2s ease;
            padding: 0 15px;
            flex-shrink: 0; /* Предотвращает сжатие элементов */
            cursor: pointer;
        }

    /* .menu-item:hover { */
            /* background: #007aff;
            color: white; */
            /* transform: translateY(-2px); */
            /* box-shadow: 0 4px 15px rgba(0, 122, 255, 0.3); */
            /* box-shadow: 0 4px 8px rgba(0,0,0,0.1); */
        /* } */

     /* .menu-item.active {
        /* background: #2196F3;
        color: white; 
         border-bottom: 4px solid #2196F3;
        border-top: 4px solid #2196F3;
    }  */

    .menu-item_select {    
        border-bottom: 4px solid #2196F3;
        border-top: 4px solid #2196F3;
    }


    /* блок ввода ответов на вопрос */
    /* .answer-input-block{
        justify-content: space-between;
        padding: 5px; 
        /* border: none; */
        /* border-radius: 10px; */
    /* background: #ffffff;
    color: #000000;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease; */

   /* } */

    .input-field{
        padding: 5px;
        border: none;
        border-radius: 10px;
        text-align: center;
        /* background: var(--tg-theme-bg-color, #ffffff);
        color: var(--tg-theme-text-color, #000000); */
        background: #ffffff;
        color: #000000;
        font-size: 14px;
        
    }

/*  <-----  Контейнер с вопросами  */

/*  ----->  Контейнер стартовой страницы со статистикой и кнопками */
.start-container{
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 400px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

/* Верхняя строка со статистикой */
.stats-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.stat-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 16px 8px;
    background: #f8f9fa;
    border-radius: 12px;
}

.stat-number {
    font-size: 20px;
    font-weight: 700;
    color: #1d1d1f;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 14px;
    color: #8e8e93;
    font-weight: 500;
}

.statistic-container{    
    width: 100%;
    border-radius: 10px;
}

.statistic-container img{    
    width: 100%;
    border-radius: 10px;
}

/* Меню кнопок (нижние кнопки) */
    .main-buttons-container {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .menu-btn-row {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 16px;
        background: #f8f9fa;
        border: none;
        border-radius: 12px;
        cursor: pointer;
        transition: all 0.2s ease;
        text-align: left;
    }

    .menu-btn-row:hover {
        background: #f0f0f0;
        background-color:  #3498db;
    }

    .menu-btn-row.active {
        background: #3498db;
        color: white;
    }

    .menu-btn-row.active .btn-icon-small {
        background: rgba(255, 255, 255, 0.2);
        color: white; 
    }

    .btn-icon-small {
        width: 36px;
        height: 36px;
        /* background: white; */
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 600;
        font-size: 16px;
        color: #007aff;
        flex-shrink: 0;
        transition: all 0.2s ease;
    }

    .btn-title-small {
        font-size: 15px;
        font-weight: 500;
        color: #1d1d1f;
        flex: 1;
    }

    .menu-btn-row.active .btn-title-small {
        color: white;
    }



/*  <-----  Контейнер стартовой страницы со статистикой и кнопками  */

/* Адаптивность   ----->   */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 5px;
    }
    
    .subjects-grid {
        grid-template-columns: repeat(1, 1fr);
    }
    
    .question-block {
        padding: 15px;
    }
    
    .navigation-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .subjects-grid {
        grid-template-columns: 1fr;
    }
    
    .question-number {
        width: 35px;
        height: 35px;
        font-size: 14px;
    }

    .menu-item {
        min-width: 40px;
        height: 40px;
        font-size: 14px;
        padding: 0 16px;
    }

    .scroll-menu {
        gap: 8px;
    }

    .menu-grid {
                gap: 8px;
    }
    
    .menu-btn {
        padding: 16px 8px;
        min-height: 90px;
    }
    
    .btn-icon {
        width: 40px;
        height: 40px;
        font-size: 16px;
        margin-bottom: 8px;
    }
    
    .btn-title {
        font-size: 14px;
    }
}

/*  <-----  Адаптивность  */