/* --- ГЛОБАЛЬНЫЕ СТИЛИ С ЗАПРЕТОМ ВЫДЕЛЕНИЯ --- */
* {
    box-sizing: border-box;
    user-select: none; -webkit-user-select: none; -moz-user-select: none;
    -ms-user-select: none; -webkit-touch-callout: none;
}

body {
    margin: 0; padding: 0;
    background: linear-gradient(135deg, #74ebd5 0%, #ACB6E5 100%);
    font-family: Arial, sans-serif;
    overflow: hidden; 
}

/* --- СТИЛИ ДЛЯ БОЛЬШИХ ЭКРАНОВ (ДЕСКТОП) --- */
.main-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    padding: 20px;
}

#gameCanvas {
    /* Размеры для десктопа теперь полностью управляются из JS */
    border: 2px solid #333;
    background-color: #fff;
}

#info-panel {
    /* Высота для десктопа управляется из JS */
    width: 200px;
    margin-left: 20px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background-color: #f0f0f0;
    border-radius: 8px;
    text-align: center;
}

/* --- Стили для счета и кнопок (без изменений) --- */
.next-balls-container h3 {
    margin: 0 0 5px 0;
    font-size: 1rem;
    color: #555;
    font-weight: normal;
}
#next-balls-preview {
    display: flex;
    justify-content: center;
    gap: 10px;
    height: 30px;
}

.preview-ball {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, 0.2);
}
.score-container h2 {
    margin: 0;
    font-size: 1.2rem; /* Используем rem для масштабируемости */
    color: #555;
}
.score-container #score-display {
    margin: 5px 0 0 0;
    font-size: 2.5rem; /* rem'ы лучше px для доступности */
    font-weight: bold;
    color: #0074D9;
}

.controls-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.game-button {
    padding: 12px;
    font-size: 1rem; /* 1rem - базовый размер шрифта */
    font-weight: bold;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}
#undo-button { background-color: #FF851B; }
#restart-button { background-color: #FF4136; }
.game-button:hover { background-color: #333; }
.game-button:active { transform: scale(0.98); }
.game-button:disabled { background-color: #ccc; cursor: not-allowed; transform: none; }

/* ===== ФИНАЛЬНЫЙ БЛОК: АДАПТАЦИЯ ДЛЯ УЗКИХ ДЕСКТОПНЫХ ОКОН ===== */
@media (max-width: 900px) and (min-width: 769px) {
    
    #info-panel {
        width: 150px; /* Панель становится уже */
        padding: 10px;
        justify-content: center;
        gap: 15px;
    }

    /* Уменьшаем шрифты */
    .score-container h2 { font-size: 1rem; }
    .score-container #score-display { font-size: 2rem; }
    .next-balls-container h3 { font-size: 0.9rem; }
    
    /* Уменьшаем шарики предпросмотра */
    #next-balls-preview { height: 25px; gap: 8px; }
    .preview-ball { width: 20px; height: 20px; }

    /* Делаем кнопки компактнее */
    .controls-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
        gap: 8px;
    }
    .game-button {
        width: 100%;
        padding: 8px;
        font-size: 0.9rem;
    }
}


/* --- АДАПТАЦИЯ ДЛЯ МОБИЛЬНЫХ УСТРОЙСТВ --- */
/* Эти стили применятся только если ширина экрана 768px или меньше */
@media (max-width: 768px) {
    .main-wrapper {
        flex-direction: column;
        justify-content: center;
    }

    #info-panel {
        order: -1;
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        align-items: center;
        width: 100%;
        height: auto;
        min-height: 80px;
        margin-left: 0;
        margin-bottom: 15px;
        padding: 5px 10px;
        gap: 5px;
    }
    
    .next-balls-container { grid-column: 1 / 2; text-align: left; }
    .next-balls-container h3 {
        margin: 0 0 5px 0;
         /* Шрифт будет 2.5% от высоты окна, но не меньше 14px и не больше 18px */
        font-size: clamp(14px, 2.5vh, 18px);
        color: #555;
        font-weight: normal;
    }
    .score-container { grid-column: 2 / 3; text-align: center; }
    .score-container h2 { font-size: 18px; }
    .score-container #score-display { font-size: 32px; margin-top: 0; }
    .controls-container { grid-column: 3 / 4; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
    .game-button { width: 100%; max-width: 120px; padding: 8px; font-size: 14px; }
    
    .game-container {
        width: 100%; 
        display: flex;
        justify-content: center;
    }
    
    #gameCanvas {
        /* ===== ВОЗВРАЩАЕМ РЕЗИНОВЫЕ СТИЛИ ДЛЯ МОБИЛЬНЫХ ===== */
        width: 100%; /* Занимает всю ширину родителя */
        height: auto; 
        aspect-ratio: 1 / 1;
        max-width: 500px;
    }
}
