* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f0f2f5;
    color: #333;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.game-container {
    max-width: 1200px; /* Increased width */
    width: 100%;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.header {
    text-align: center;
    padding-bottom: 10px;
    border-bottom: 2px solid #eee;
}

.setup-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 40px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 300px;
}

.input-group label {
    font-weight: bold;
}

.input-group input, .input-group select {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 1rem;
    background-color: white;
}

.main-area {
    display: flex;
    gap: 30px;
    flex-wrap: nowrap; /* Prevent wrapping */
    justify-content: flex-start; /* Align left */
    align-items: flex-start;
}

/* Board Styles */
.board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: 5px;
    width: 700px;
    height: 700px;
    background-color: #dbe4eb;
    padding: 10px;
    border-radius: 8px;
}

.cell {
    background-color: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    position: relative;
    text-align: center;
    padding: 2px;
}

.cell-name {
    font-weight: bold;
    margin-bottom: 2px;
    z-index: 2; /* Ensure text is above tokens */
    position: relative;
}

.cell-color-bar {
    width: 100%;
    height: 15px;
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 3px 3px 0 0;
}

:root {
    --group-brown: #8d6e63;
    --group-lightblue: #81d4fa;
    --group-pink: #f48fb1;
    --group-orange: #ffcc80;
    --group-red: #ef5350;
    --group-yellow: #fff59d;
    --group-green: #a5d6a7;
    --group-blue: #90caf9;
}

.group-brown { background-color: var(--group-brown); }
.group-lightblue { background-color: var(--group-lightblue); }
.group-pink { background-color: var(--group-pink); }
.group-orange { background-color: var(--group-orange); }
.group-red { background-color: var(--group-red); }
.group-yellow { background-color: var(--group-yellow); }
.group-green { background-color: var(--group-green); }
.group-blue { background-color: var(--group-blue); }

.cell-price {
    font-size: 0.7rem;
    color: #666;
    z-index: 2; /* Ensure price is above tokens */
    position: relative;
}

.chance-mark {
    font-size: 1.5rem;
    font-weight: bold;
    color: #e67e22;
}

.center-deck {
    grid-column: 2 / 8;
    grid-row: 2 / 8;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #dbe4eb; /* Match board bg */
}

.deck-card {
    width: 100px;
    height: 140px;
    background: linear-gradient(135deg, #e67e22 0%, #d35400 100%);
    border: 2px solid white;
    border-radius: 8px;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 3rem;
    font-weight: bold;
    transform: rotate(-5deg);
}

.cell-owner {
    width: 100%;
    height: 5px;
    margin-top: auto;
}

.owner-p1 { background-color: #e74c3c; } /* Red */
.owner-p2 { background-color: #3498db; } /* Blue */
.owner-p3 { background-color: #2ecc71; } /* Green */
.owner-p4 { background-color: #8d6e63; } /* Brown */

/* Player Tokens on Board */
.tokens-container {
    position: absolute;
    bottom: 5px; /* Move to bottom */
    left: 0;
    right: 0;
    display: flex;
    justify-content: center; /* Center horizontally */
    gap: 2px;
    z-index: 1; /* Behind text */
    opacity: 0.7; /* Slight transparency to see background if needed */
}

.token {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    line-height: 1;
}

.p1-token { text-shadow: 0 0 2px #fff; }
.p2-token { text-shadow: 0 0 2px #fff; }
.p3-token { text-shadow: 0 0 2px #fff; }
.p4-token { text-shadow: 0 0 2px #fff; }

/* Controls Styles */
.controls {
    flex: 1;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.players-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
}

.player-info {
    padding: 10px;
    border-radius: 8px;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    transition: all 0.3s ease;
}

.player-info.active-p1 { border: 2px solid #e74c3c; background-color: #fdedeb; transform: scale(1.02); box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
.player-info.active-p2 { border: 2px solid #3498db; background-color: #ebf5fb; transform: scale(1.02); box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
.player-info.active-p3 { border: 2px solid #2ecc71; background-color: #eafaf1; transform: scale(1.02); box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
.player-info.active-p4 { border: 2px solid #8d6e63; background-color: #efebe9; transform: scale(1.02); box-shadow: 0 2px 5px rgba(0,0,0,0.1); }

.owned-properties {
    margin-top: 10px;
    border-top: 1px solid #ddd;
    padding-top: 5px;
}

.owned-properties h4 {
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.owned-properties ul {
    list-style: none;
    padding: 0;
    font-size: 0.8rem;
    max-height: 100px;
    overflow-y: auto;
}

.owned-properties li {
    margin-bottom: 2px;
}

.game-actions {
    text-align: center;
    padding: 20px;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.message-box {
    margin-bottom: 15px;
    min-height: 40px;
    font-weight: 500;
}

button {
    padding: 10px 20px;
    font-size: 1rem;
    cursor: pointer;
    background-color: #2ecc71;
    color: white;
    border: none;
    border-radius: 5px;
    transition: background-color 0.2s;
    margin: 5px;
}

button:hover { background-color: #27ae60; }
button:disabled { background-color: #95a5a6; cursor: not-allowed; }

#end-turn-btn { background-color: #e67e22; }
#end-turn-btn:hover { background-color: #d35400; }

#buy-btn { background-color: #9b59b6; }
#buy-btn:hover { background-color: #8e44ad; }

#pass-btn { background-color: #7f8c8d; }
#pass-btn:hover { background-color: #95a5a6; }

.hidden { display: none; }

#dice-result {
    font-size: 4rem; /* Large dice */
    font-weight: bold;
    margin: 10px 0;
    height: 80px;
    line-height: 80px;
    transition: transform 0.2s;
    color: #333;
}

.rolling {
    animation: shake 0.5s infinite;
}

@keyframes shake {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(10deg); }
    50% { transform: rotate(0deg); }
    75% { transform: rotate(-10deg); }
    100% { transform: rotate(0deg); }
}

/* Mobile Responsiveness */
@media (max-width: 1050px) {
    .main-area {
        flex-wrap: wrap;
        justify-content: center;
    }

    .controls {
        width: 100%;
        min-width: auto;
    }
}

@media (max-width: 750px) {
    .board {
        width: 100%;
        height: auto;
        aspect-ratio: 1 / 1;
        gap: 2px;
        padding: 5px;
    }

    .cell {
        font-size: 0.6rem;
        padding: 1px;
    }

    .cell-name {
        font-size: 0.6rem;
        margin-bottom: 0;
    }

    .cell-price {
        font-size: 0.5rem;
    }

    .token {
        width: 20px;
        height: 20px;
        font-size: 16px;
    }

    .deck-card {
        width: 60px;
        height: 90px;
        font-size: 2rem;
    }
    
    .game-container {
        padding: 10px;
    }
}