/* ===== Базовые стили ===== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    touch-action: manipulation; /* Отключает задержки тапов и двойной зум */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 18px;
    line-height: 1.5;
    color: #333;
    background-color: #fff9f9;
    text-align: center;
    overflow-x: hidden; /* Запрет горизонтального скролла */
    -webkit-text-size-adjust: 100%; /* Фикс для iOS */
}

/* ===== Контейнеры ===== */
.container {
    width: 95%;
    max-width: 500px;
    margin: 10px auto;
    padding: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    animation: fadeIn 0.5s ease-out;
}

#start-screen, #game-screen, #result-screen {
    transition: opacity 0.3s;
}

/* ===== Кнопки ===== */
button {
    display: inline-block;
    background: #ff6b6b;
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 8px;
    font-size: 18px;
    cursor: pointer;
    margin-top: 20px;
    width: 100%;
    max-width: 300px;
    user-select: none;
    -webkit-tap-highlight-color: transparent; /* Убирает синий highlight при тапе */
}

button:disabled {
    background: #ddd;
    cursor: not-allowed;
}

/* ===== Вопросы и ответы ===== */
#question-text {
    font-size: 22px;
    margin-bottom: 25px;
    font-weight: 500;
    color: #444;
}

#answers {
    margin: 20px 0;
}

.answer-option {
    display: block;
    padding: 16px;
    margin: 10px 0;
    background: #f8f8f8;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.answer-option:active {
    background: #eee;
}

input[type="text"] {
    width: 100%;
    padding: 15px;
    border: 2px solid #eee;
    border-radius: 8px;
    font-size: 16px;
    margin: 10px 0;
}

/* ===== Прогресс-бар ===== */
.progress-bar {
    height: 6px;
    background: #f0f0f0;
    margin: 20px 0;
    border-radius: 3px;
    overflow: hidden;
}

#progress {
    height: 100%;
    background: #ff6b6b;
    border-radius: 3px;
    width: 0%;
    transition: width 0.4s ease-out;
}

/* ===== Результат ===== */
#code {
    font-size: 28px;
    font-weight: bold;
    color: #ff6b6b;
    margin: 20px 0;
    letter-spacing: 2px;
}

/* ===== Попап ===== */
.popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.popup.active {
    opacity: 1;
    pointer-events: all;
}

.popup-content {
    background: white;
    padding: 25px;
    border-radius: 12px;
    width: 85%;
    max-width: 300px;
    transform: scale(0.9);
    transition: transform 0.3s;
}

.popup.active .popup-content {
    transform: scale(1);
}

#popup-ok {
    margin-top: 15px;
    background: #ff6b6b;
}

/* ===== Анимации ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

.shake {
    animation: shake 0.5s;
}

/* ===== Адаптация для маленьких экранов ===== */
@media (max-width: 400px) {
    body {
        font-size: 16px;
    }

    #question-text {
        font-size: 20px;
    }

    button, .answer-option {
        padding: 12px 20px;
    }
}