body {
    margin: 0;
    font-family: Arial, sans-serif;
    background-color: #2f3542;
    display: flex;
    justify-content: center;
	align-items: flex-start; /* ИСПРАВЛЕНО: предотвращает обрезание верха */
    min-height: 100vh; /* ИСПРАВЛЕНО: позволяет контенту растягивать страницу */
    padding: 20px;
    box-sizing: border-box;
	
}

.game-container {
	display: flex;
    flex-direction: row; 
    gap: 20px;
    align-items: flex-start;
    justify-content: center;
    flex-wrap: wrap; /* Позволяет блокам переноситься, если не хватает ширины */
    max-width: 100%;
	
    text-align: center;
	
}

/* Правая или нижняя панель управления (в зависимости от экрана) */
.side-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 320px;
}

/* Панель баланса и кубика */
.player-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #1e272e;
    padding: 15px;
    border-radius: 8px;
    color: #fff;
    font-weight: bold;
    font-size: 14px;
    box-sizing: border-box;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.player-info {
    padding: 8px;
    border-radius: 4px;
    transition: all 0.3s;
    opacity: 0.5;
}

/* Подсветка того, чей сейчас ход */
.active-p1 { opacity: 1; background-color: #ff4757; color: white; }
.active-p2 { opacity: 1; background-color: #2e86de; color: white; }

#dice-btn {
    background-color: #ffa502;
    border: none;
    color: white;
    padding: 12px;
    font-size: 14px;
    font-weight: bold;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 4px #ff7f50;
    transition: all 0.1s;
}


#dice-btn:active { box-shadow: 0 0 #ff7f50; transform: translateY(4px); }
#dice-btn:disabled { background-color: #747d8c; box-shadow: none; cursor: not-allowed; transform: none; }


/* Игровое поле строго 720x480 */
#game-field {
    /* width: 720px; */
	width: 624px;
    height: 624px;
    background-color: #dee2e6;
    border: 4px solid #1e272e;
    position: relative;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.4);
    
    /* Сетка 12х12 края по 72px, внутри 10 колонок/рядов по 48px */
    display: grid;
    grid-template-columns: 72px repeat(10, 48px) 72px;
    grid-template-rows: 72px repeat(10, 48px) 72px;
    
    background-image:url('images/city_monopoly.png'); 
	background-position:center; 
	background-repeat:no-repeat;
	background-size: contain;
}

/* Стили для каждой карточки Монополии */
.cell {
    border: 1px solid #1e272e;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    background-color: #f8f9fa;
    position: relative;
    overflow: hidden;
    transition: background-color 0.3s;
}

/* Карточки верхней и нижней строки (72 в ширину, 48 в высоту) */
.cell-horizontal {
    flex-direction: column;
    justify-content: space-between;
    padding: 2px 0;
}
.cell-horizontal .cell-header {
    width: 100%;
    height: 8px;
    border-bottom: 1px solid #1e272e;
}

/* Повернутые боковые карточки (48 в ширину, 72 в высоту) */
.cell-vertical {
    flex-direction: row;
    justify-content: space-between;
    padding: 0 2px;
}
/* У вертикальных карточек цветная полоса идет сбоку! */
.cell-vertical .cell-header {
    width: 8px;
    height: 100%;
}
/* Для левой стороны полоса справа, для правой — слева */
.cell-left .cell-header { order: 2; border-left: 1px solid #1e272e; }
.cell-right .cell-header { order: 1; border-right: 1px solid #1e272e; }

/* Угловые карточки (квадраты 72х72) */
.cell-corner {
    background-color: #ffeaa7;
    flex-direction: column;
}

/* Стиль для полей Шанс на карте */
.cell-chance {
    background-color: #ffbe76 !important;
    color: #d35400;
    font-size: 12px;
}

/* Классные маркеры купленных клеток */
.owner-p1 { background-color: #ffb8b8 !important; }
.owner-p2 { background-color: #b3d9ff !important; }


/* Общие стили машинок */
.car {
    width: 22px;
    height: 36px;
    position: absolute;
    border-radius: 4px;
    z-index: 10;
    transition: left 0.4s ease-out, top 0.4s ease-out, transform 0.3s ease-in-out;
    transform-origin: center center;
}
.car::before { content: ''; position: absolute; top: 2px; left: 3px; width: 3px; height: 3px; background-color: #fff200; box-shadow: 13px 0 0 #fff200; border-radius: 50%; }
.car::after { content: ''; position: absolute; top: 6px; left: -2px; width: 2px; height: 6px; background-color: #1e272e; box-shadow: 24px 0 0 #1e272e, 0 18px 0 #1e272e, 24px 18px 0 #1e272e; }

/* Различаем игроков по цветам кузова */
.car-red { background-color: #ff4757; }
.car-blue { background-color: #2e86de; }



/* Всплывающее окно (Модалка) */
.modal {
    display: none; /* Скрыто по умолчанию */
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 100;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: white;
    padding: 25px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    width: 300px;
}

/* Особая рамка для окна Шанса */
.chance-content {
    border: 4px dashed #ff9f43;
}

.modal-buttons {
    display: flex;
    justify-content: space-around;
    margin-top: 20px;
}

.modal-buttons button {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
}

.modal-buttons { display: flex; justify-content: space-around; margin-top: 20px; }
.modal-buttons button, .btn-orange { padding: 10px 20px; border: none; border-radius: 5px; font-weight: bold; cursor: pointer; }
.btn-green { background-color: #2ed573; color: white; }
.btn-red { background-color: #ff4757; color: white; }
.btn-orange { background-color: #ff9f43; color: white; margin-top: 15px; width: 100%; }

.chat-container {
	width: 100%;
    background: #1e272e;
    border-radius: 8px;
    padding: 10px;
    box-sizing: border-box;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

#chat-box {
    height: 340px; /* ИСПРАВЛЕНО: Сделали чат выше, так как сбоку много места */
    overflow-y: auto;
    background: #2f3542;
    border-radius: 4px;
    padding: 8px;
    text-align: left;
    color: #fff;
    font-size: 13px;
    margin-bottom: 8px;
}

.chat-msg { margin-bottom: 5px; line-height: 1.4; word-break: break-all; }
.chat-input-row { display: flex; gap: 8px; }
#chat-input { flex: 1; padding: 8px; border: none; border-radius: 4px; background: #f1f2f6; font-size: 13px; }
#chat-send-btn { background: #2ed573; color: white; border: none; padding: 8px 15px; border-radius: 4px; font-weight: bold; cursor: pointer; }

#chat-send-btn:hover { background: #26af5f; }


/* АДАПТИВНОСТЬ: Если экран вертикальный (например, на телефонах) */
@media (max-width: 980px) {
    body { align-items: flex-start; }
    .game-container { flex-direction: column; align-items: center; width: 100%; }
    .side-panel { width: 624px; }
    #chat-box { height: 120px; } /* Делаем чат пониже на смартфонах */
}

/* Новые стили для правильного масштабирования без обрезания границ */
.game-wrapper {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    /*width: 100%;*/
    overflow: hidden;
    padding: 10px 0;
}


/* АДАПТИВНОСТЬ: Масштабирование через встроенные контейнерные запросы */
/* Если экран смартфона или узкого окна меньше, чем ширина нашей игры (964px + отступы) */
@media (max-width: 700px) {
    .game-container {
        /* CSS автоматически считает коэффициент сжатия. */
        /* Например, если экран 400px, то 400 / 980 = уменьшить игру в ~2.4 раза */
        transform: scale(calc(window.innerWidth / 700)); 
        
        /* Фикс для адапттивных браузеров: подгоняем масштаб под ширину видимой области */
        transform: scale(calc((100vw - 30px) / 644));
    }
}

/* --- СТИЛИ 3D КУБИКА --- */
.dice-scene {
    width: 140px;
    height: 60px;
    margin: 15px auto;
    perspective: 300px; /* Эффект глубины */
    display: flex;
    gap: 20px;
}

.cube {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transform: rotateX(-20deg) rotateY(20deg); /* Начальный наклон */
    transition: transform 1.2s cubic-bezier(0.2, 0.8, 0.3, 1); /* Плавное торможение */
}

.cube-face {
    position: absolute;
    width: 60px;
    height: 60px;
    background: white;
    border: 2px solid #1e272e;
    border-radius: 8px;
    color: #1e272e;
    font-size: 14px;
    line-height: 1.1;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-shadow: inset 0 0 8px rgba(0,0,0,0.2), 0 3px 5px rgba(0,0,0,0.3);
    backface-visibility: hidden; /* Скрывает невидимые грани */
}

/* Разворачиваем грани в 3D пространстве на 30px от центра куба */
.face-1 { transform: rotateY(0deg) translateZ(30px); color: #ff4757; font-size: 24px; } /* Красная центральная точка */
.face-2 { transform: rotateY(90deg) translateZ(30px); }
.face-3 { transform: rotateX(90deg) translateZ(30px); }
.face-4 { transform: rotateX(-90deg) translateZ(30px); }
.face-5 { transform: rotateY(-90deg) translateZ(30px); }
.face-6 { transform: rotateY(180deg) translateZ(30px); }
