/* Основные стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: #f0f0f0;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

h1 {
    text-align: center;
    margin-bottom: 20px;
    color: #2c3e50;
}

/* Заголовок с кнопкой правил */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.rules-btn {
    background-color: #3498db;
    padding: 8px 15px;
    font-size: 14px;
}

/* Игровое поле */
.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: 2px;
    width: 100%;
    max-width: 500px;
    aspect-ratio: 1/1;
    background-color: #34495e;
    padding: 5px;
    border-radius: 5px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
}

.cell {
    background-color: #ecf0f1;
    border-radius: 3px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    opacity: 0.4;
}

#start-pos
{
    position:absolute;
    opacity:0.5;
}

#end-pos 
{
    position:absolute;
    opacity:0.8;
}

.cell img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

/* Элементы управления */
.controls {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.commands {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.command-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
    height: 80px;
}

.command-btn:hover {
    background-color: #2980b9;
}

.command-btn:disabled {
    background-color: #95a5a6;
    cursor: not-allowed;
}

.command-btn img {
    width: 30px;
    height: 30px;
    margin-bottom: 5px;
}

.command-count {
    font-size: 12px;
    font-weight: bold;
}

/* Область кода */
.code-area {
    display: none; /* По умолчанию скрыта, будет показана в зависимости от режима */
}

.code-textarea {
    width: 100%;
    min-height: 150px;
    padding: 10px;
    font-family: monospace;
    border: 1px solid #bdc3c7;
    border-radius: 5px;
    resize: vertical;
}

.code-display {
    width: 100%;
    min-height: 150px;
    padding: 10px;
    font-family: monospace;
    background-color: #f9f9f9;
    border: 1px solid #bdc3c7;
    border-radius: 5px;
    white-space: pre-wrap;
    overflow-y: auto;
}

/* Кнопки действий */
.actions {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.btn {
    padding: 10px 20px;
    background-color: #2ecc71;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
    font-size: 16px;
}

.btn:hover {
    background-color: #27ae60;
}

#reset-btn {
    background-color: #e74c3c;
}

#reset-btn:hover {
    background-color: #c0392b;
}

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

.modal-content {
    background-color: white;
    padding: 30px;
    border-radius: 10px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

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

/* Стили для модального окна с правилами */
.rules-content {
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

.rules-text {
    text-align: left;
    margin: 15px 0;
}

.rules-text h3 {
    margin-top: 15px;
    color: #2c3e50;
}

.rules-text ul {
    padding-left: 20px;
    margin: 10px 0;
}

.rules-text li {
    margin-bottom: 5px;
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    .game-container {
        flex-direction: column;
    }
    
    .game-board {
        max-width: 100%;
    }
    
    .controls {
        max-width: 100%;
    }
    
    .commands {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .header {
        flex-direction: column;
        gap: 10px;
    }
    
    .rules-btn {
        margin-bottom: 10px;
    }
    
    .rules-content {
        width: 90%;
        max-height: 70vh;
    }
}

@media (max-width: 480px) {
    .commands {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .command-btn {
        height: 70px;
        padding: 8px;
    }
    
    .command-btn img {
        width: 25px;
        height: 25px;
    }
}