/* styles.css - Основные стили для игры TECNO AI EXPERT */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: linear-gradient(135deg, rgba(106, 17, 203, 0.8) 0%, rgba(37, 117, 252, 0.8) 100%), url('background.png') no-repeat center center;
    background-size: cover;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    color: white;
    transition: all 0.3s ease;
}

/* Стиль для скрытия основного контента при открытом модального окна */
body.modal-open {
    overflow: hidden;
}

body.modal-open .main-content {
    display: none;
}

.main-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* Header стили */
header {
    text-align: center;
    margin-bottom: 30px;
    width: 100%;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.instructions {
    max-width: 600px;
    background-color: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    text-align: center;
    margin: 0 auto 20px;
}

/* Стили для кнопки таблицы лидеров */
.leaderboard-section {
    margin: 20px 0;
}

.leaderboard-btn {
    background: linear-gradient(45deg, #FFD700 0%, #FFA500 100%);
    border: none;
    padding: 12px 25px;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    color: #333;
}

.leaderboard-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

/* Контейнер игры */
.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 800px;
}

/* Сетка карточек */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 30px;
    width: 100%;
}

.card {
    aspect-ratio: 1 / 1;
    perspective: 1000px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.card.disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

/* Стили для заблокированных карточек после завершения игры */
.card.game-ended {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

.card.game-ended .card-front,
.card.game-ended .card-back {
    filter: grayscale(0.5);
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

.card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-weight: bold;
    padding: 10px;
}

.card-front {
    background: linear-gradient(45deg, #5959DC 0%, #020227 100%);
    color: #333;
    font-size: 3rem;
}

.card-front img {
    width: 70%;
    height: auto;
    object-fit: contain;
}

.card-back {
    background: linear-gradient(45deg, #a1c4fd 0%, #c2e9fb 100%);
    color: #333;
    transform: rotateY(180deg);
    font-size: 1.2rem;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
}

/* Таймер */
.timer-container {
    background-color: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    width: 100%;
    max-width: 300px;
    margin-bottom: 15px;
}

.timer {
    font-size: 2rem;
    margin: 10px 0;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.controls {
    display: flex;
    gap: 15px;
    margin-top: 10px;
    justify-content: center;
}

/* Кнопки */
button {
    background: linear-gradient(45deg, #ff9a9e 0%, #fad0c4 100%);
    border: none;
    padding: 10px 20px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    color: #333;
}

button:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

button:active {
    transform: translateY(1px);
}

button:disabled {
    background: #cccccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Информация о раунде */
.round-info {
    background-color: rgba(255, 255, 255, 0.1);
    padding: 10px;
    border-radius: 10px;
    text-align: center;
    margin-bottom: 15px;
    width: 100%;
    max-width: 300px;
}

/* Таблица результатов */
.results-table {
    background-color: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 10px;
    width: 100%;
    max-width: 600px;
    margin-top: 20px;
    display: none;
    overflow-x: auto; /* Добавляем горизонтальную прокрутку */
}

.results-table table {
    width: 100%;
    border-collapse: collapse;
    min-width: 500px; /* Минимальная ширина таблицы */
}

th, td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

th {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Футер */
footer {
    margin-top: 30px;
    text-align: center;
    font-size: 0.9rem;
    opacity: 0.8;
}

/* Модальные окна */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow-y: auto;
}

.modal-content {
    background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    padding: 20px;
    border-radius: 15px;
    width: 90%;
    max-width: 450px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    max-height: 90vh;
    overflow-y: auto;
    text-align: center;
}

.modal h2 {
    margin-bottom: 15px;
    text-align: center;
    font-size: 1.5rem;
}

.form-group {
    margin-bottom: 15px;
    text-align: left;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    font-size: 0.9rem;
}

input, textarea {
    width: 100%;
    padding: 8px;
    border-radius: 5px;
    border: none;
    background-color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
}

textarea {
    height: 80px;
    resize: vertical;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 15px;
}

.modal-buttons.two-column {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* Индикаторы загрузки и сообщения */
.loading {
    display: none;
    text-align: center;
    margin: 10px 0;
}

.loading-spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top: 4px solid white;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

.success-message {
    display: none;
    text-align: center;
    margin: 10px 0;
    color: #90EE90;
    font-weight: bold;
}

#explanationText {
    text-align: center;
    line-height: 1.6;
    font-size: 1.1rem;
}

/* Анимации */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Анимация для появления основного контента */
.main-content {
    animation: fadeIn 0.5s ease-in-out;
}

.modal-content {
    animation: slideIn 0.3s ease-out;
}

/* Адаптивный дизайн */
@media (max-width: 768px) {
    .cards-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }
    .card-front, .card-back { padding: 6px; border-radius: 8px; }
    .card-inner { border-radius: 8px; }
    .card-back { font-size: 0.85rem; padding: 8px; }
    
    h1 {
        font-size: 2rem;
    }
    
    .timer {
        font-size: 1.8rem;
    }
    
    body {
        background: linear-gradient(135deg, rgba(106, 17, 203, 0.8) 0%, rgba(37, 117, 252, 0.8) 100%), url('background-mobile.jpg') no-repeat center center;
        background-size: cover;
    }
    
    .modal {
        align-items: flex-start;
        padding-top: 40px;
        padding-bottom: 40px;
    }
    
    .modal-content {
        max-height: 85vh;
    }
}

@media (max-width: 480px) {
    .cards-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
    }
    .card-back { font-size: 0.7rem; padding: 6px; }
    .card-front img { width: 80%; }
    
    h1 {
        font-size: 1.8rem;
    }
    
    .timer {
        font-size: 1.5rem;
    }
    
    .controls {
        flex-direction: column;
        align-items: center;
    }
    
    button {
        width: 100%;
        max-width: 200px;
    }
    
    body {
        background: linear-gradient(135deg, rgba(106, 17, 203, 0.8) 0%, rgba(37, 117, 252, 0.8) 100%), url('background-mobile.jpg') no-repeat center center fixed;
        background-size: cover;
    }
    
    .modal {
        align-items: flex-start;
        padding-top: 20px;
        padding-bottom: 20px;
    }
    
    .modal-content {
        max-height: 80vh;
    }
    
    .modal-buttons.two-column {
        grid-template-columns: 1fr;
    }
}

/* Дополнительные стили для модального окна ввода данных */
.game-title-modal {
    text-align: center;
    margin-bottom: 15px;
    font-size: 2rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.leaderboard-modal-section {
    text-align: center;
    margin-bottom: 20px;
}

.modal-subtitle {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.3rem;
    opacity: 0.9;
}

/* Стили для кнопки лидерборда в модальном окне */
#leaderboardBtnFromModal {
    background: linear-gradient(45deg, #FFD700 0%, #FFA500 100%);
    border: none;
    padding: 12px 25px;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    color: #333;
    width: 100%;
    max-width: 250px;
}

#leaderboardBtnFromModal:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

/* Исправления для модального окна пояснения */
#explanationModal .modal-buttons.two-column {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
}

#explanationModal .modal-buttons.two-column button {
    flex: 1;
    max-width: 140px;
}

/* Исправления для таблицы результатов на мобильных */
.results-table {
    background-color: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 10px;
    width: 100%;
    max-width: 600px;
    margin-top: 20px;
    display: none;
    overflow-x: auto; /* Добавляем горизонтальную прокрутку */
}

.results-table table {
    width: 100%;
    border-collapse: collapse;
    min-width: 500px; /* Минимальная ширина таблицы */
}

/* Стили для чекбокса подтверждения */
.confirmation-checkbox {
    margin: 20px 0;
    text-align: left;
    display: flex;
    align-items: center; /* Выравнивание по центру */
    gap: 10px;
    flex-wrap: nowrap; /* Запрещаем перенос на новую строку */
}

.confirmation-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin: 0; /* Убираем верхний отступ */
    flex-shrink: 0;
}

.confirmation-checkbox label {
    font-size: 0.9rem;
    line-height: 1.4;
    cursor: pointer;
    user-select: none;
    margin: 0; /* Убираем отступы */
    white-space: normal; /* Разрешаем перенос текста */
}

/* Стили для обязательных полей */
input:required, textarea:required {
    border-left: 3px solid #ff6b6b;
}

input:valid, textarea:valid {
    border-left: 3px solid #51cf66;
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    .results-table {
        margin-left: -10px;
        margin-right: -10px;
        width: calc(100% + 20px);
        border-radius: 0;
        padding: 10px;
    }
    
    .results-table table {
        min-width: 400px;
        font-size: 0.9rem;
    }
    
    .results-table th,
    .results-table td {
        padding: 8px 6px;
        font-size: 0.85rem;
    }
    
    /* Адаптивность для чекбокса на мобильных */
    .confirmation-checkbox {
        align-items: flex-start; /* На маленьких экранах выравниваем по верху */
    }
    
    .confirmation-checkbox label {
        font-size: 0.85rem;
        line-height: 1.3;
    }
    
    /* Улучшение отображения на очень маленьких экранах */
    @media (max-width: 480px) {
        .results-table table {
            min-width: 350px;
        }
        
        .results-table th,
        .results-table td {
            padding: 6px 4px;
            font-size: 0.8rem;
        }
        
        .confirmation-checkbox label {
            font-size: 0.8rem;
        }
    }
}


/* --- Auth modal --- */
.auth-tabs{
    display:flex;
    gap:10px;
    margin:10px 0 18px;
}
.auth-tab{
    flex:1;
    padding:10px 12px;
    border-radius:10px;
    border:1px solid rgba(255,255,255,0.25);
    background: rgba(255,255,255,0.08);
    color:#fff;
    cursor:pointer;
    font-weight:600;
}
.auth-tab.active{
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.4);
}
.auth-error{
    margin-top:12px;
    background: rgba(255, 59, 48, 0.12);
    border: 1px solid rgba(255, 59, 48, 0.35);
    color: #fff;
    padding:10px 12px;
    border-radius:12px;
    font-size: 0.95rem;
}
.auth-hint{
    margin-top: 12px;
    font-size: 0.9rem;
    opacity: 0.9;
}
.secondary-btn{
    width:100%;
    border:1px solid rgba(255,255,255,0.25);
    background: rgba(255,255,255,0.08);
    color:#fff;
    padding:12px 14px;
    border-radius:12px;
    cursor:pointer;
    display:flex;
    align-items:center;
    justify-content:center;
    gap:8px;
}
.small-hint{
    margin-top:8px;
    font-size:0.85rem;
    opacity:0.85;
}


/* --- User bar (logged in) --- */
.userbar{
    margin-top: 10px;
    display:flex;
    gap:10px;
    align-items:center;
    justify-content:center;
    flex-wrap:wrap;
}
.userbar-label{
    font-size:0.95rem;
    opacity:0.9;
}
.userbar-link{
    color:#fff;
    text-decoration:none;
    padding:6px 10px;
    border-radius:10px;
    border:1px solid rgba(255,255,255,0.22);
    background: rgba(255,255,255,0.06);
}
.userbar-link:hover{ background: rgba(255,255,255,0.12); }
.userbar-logout{
    padding:6px 10px;
    border-radius:10px;
    border:1px solid rgba(255,255,255,0.22);
    background: rgba(255,255,255,0.06);
    color:#fff;
    cursor:pointer;
    font-weight:600;
}
.userbar-logout:hover{ background: rgba(255,255,255,0.12); }

/* Make selects match inputs */
select{
    width:100%;
    padding:12px 14px;
    border-radius:12px;
    border:1px solid rgba(255,255,255,0.22);
    background: rgba(0,0,0,0.18);
    color:#fff;
    outline:none;
}
select option{ color:#000; }
