body {
    background-color: #bcd2ee;
    color: #333333;
    margin: 0;
    font-family: sans-serif;
}

.player-block.active-turn {
    border: 2px solid #007bff;
    border-radius: 5px;
    background-color: #f0f8ff;
}

.player-block {
    padding: 5px;
    margin: 5px;
    border: 2px solid #ccc;
    display: inline-block;
    min-width: 100px;
    text-align: center;
}

.score-option {
    display: block;
    width: 100%;
    padding: 8px;
    margin: 4px 0;
    background-color: #e9e9e9;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    text-align: left;
}

.score-option:hover {
    background-color: #d8d8d8;
}

.scene.used {
    opacity: 0.5;
    border: 2px solid #888;
    box-shadow: none;
    pointer-events: none;
}

#chat-container {
    margin-top: 20px;
    width: 100%;
}

#join-view {
    background: #fff;
    padding: 32px 24px;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    max-width: 350px;
    margin: 60px auto 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#game-view {
    background: #fff;
    padding: 32px 24px;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    max-width: 800px;
    margin: 40px auto 0 auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 16px;
    min-height: 90vh;
}

/* Section wrappers for layout stability */
#activePlayer-section {
    min-height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#scoring-section {
    min-height: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
}

#actionItems-section {
    min-height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

#players-section {
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#chat-section {
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-sender {
    font-weight: bold;
    padding-right: 3px;
}

#join-view h1,
#join-view p,
#join-view label,
#join-view input,
#join-view button {
    color: #333333;
}

#join-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

#join-form input[type="text"] {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
    color: #333333;
    background: #f8f8f8;
    margin-bottom: 8px;
    margin-top: 16px;
}

#join-form button {
    padding: 10px 20px;
    background: #52aa52;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

#join-form button:disabled {
    background: #ccc;
    color: #888;
    cursor: not-allowed;
}

#join-form button:not(:disabled):hover {
    background: #ff7700;
    padding: 10px;
}

#chat-messages {
    height: 150px;
    overflow-y: scroll;
    /* border: 1px solid #eee; */
    padding: 5px;
    margin-bottom: 10px;
    background-color: #f8f8f8;
}

.chat-message {
    padding: 2px;
    border-radius: 4px;
    border: 1px solid #333;
    margin-bottom: 5px;
}

/* Your custom colors */
.player-message-a {
    background-color: #73ee73;
}
.player-message-b {
    background-color: #ffd6b2;
}
.server {
    background-color: #ffff00;
    font-style: italic;
}
/* For a potential winner message */
.chat-message:has(.chat-sender.winner) {
    background: #d32f2f;
    color: #ffe600;
    font-weight: bold;
    padding: 18px 24px;
    border-radius: 8px;
    text-align: center;
    font-size: 1.4rem;
    margin: 18px 0;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.winner-message {
    background: #d32f2f;
    color: #ffe600;
    font-weight: bold;
    padding: 18px 24px;
    border-radius: 8px;
    text-align: center;
    font-size: 1.4rem;
    margin: 18px 0;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

#chat-input-container {
    display: flex;
}

#chat-input {
    flex-grow: 1;
}

/* adding dice css */
#dice-section {
    display: flex;
}

#dice-container {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-evenly;
    gap: 10px;
    width: 100%;
}

/* Scene container to establish 3D perspective */
.scene {
    width: 100px;
    height: 100px;
    perspective: 400px;
    margin-bottom: 40px;
    border: 2px solid transparent;
    box-sizing: border-box;
}

/* The cube element that will be transformed */
.cube {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transform: translateZ(-50px);
    transition: transform 1s;
}

/* Base styling for each face of the cube */
.face {
    position: absolute;
    width: 100px;
    height: 100px;
    background-color: #52aa52;
    border: 2px solid #333;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.2);
}

/* Positioning each face in 3D space to form a cube */
.front {
    transform: rotateY(0deg) translateZ(50px);
}
.back {
    transform: rotateY(180deg) translateZ(50px);
}
.right {
    transform: rotateY(90deg) translateZ(50px);
}
.left {
    transform: rotateY(-90deg) translateZ(50px);
}
.top {
    transform: rotateX(90deg) translateZ(50px);
}
.bottom {
    transform: rotateX(-90deg) translateZ(50px);
}

/* Styling for the dots on each face */
.dot-container {
    width: 75%;
    height: 75%;
    display: grid;
    gap: 5%; /* Adjusted gap for consistent sizing */
}
.dot {
    background-color: #ff7700;
    border: 2px solid #333;
    border-radius: 50%;
    box-sizing: border-box;
    /* Set a fixed size for all pips */
    width: 22px;
    height: 22px;
    /* Center the pip within its grid cell */
    align-self: center;
    justify-self: center;
}

/* Grid layouts for each number of dots */
.face-1 .dot-container {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
}
.face-2 .dot-container {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}
.face-2 .dot:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
}
.face-2 .dot:nth-child(2) {
    grid-column: 2;
    grid-row: 2;
}

.face-3 .dot-container {
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
}
.face-3 .dot:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
}
.face-3 .dot:nth-child(2) {
    grid-column: 2;
    grid-row: 2;
}
.face-3 .dot:nth-child(3) {
    grid-column: 3;
    grid-row: 3;
}

.face-4 .dot-container {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}
/* Explicitly place dots for face 4 */
.face-4 .dot:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
}
.face-4 .dot:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
}
.face-4 .dot:nth-child(3) {
    grid-column: 1;
    grid-row: 2;
}
.face-4 .dot:nth-child(4) {
    grid-column: 2;
    grid-row: 2;
}

.face-5 .dot-container {
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
}
.face-5 .dot:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
}
.face-5 .dot:nth-child(2) {
    grid-column: 3;
    grid-row: 1;
}
.face-5 .dot:nth-child(3) {
    grid-column: 2;
    grid-row: 2;
}
.face-5 .dot:nth-child(4) {
    grid-column: 1;
    grid-row: 3;
}
.face-5 .dot:nth-child(5) {
    grid-column: 3;
    grid-row: 3;
}

.face-6 .dot-container {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
}
/* Explicitly place dots for face 6 */
.face-6 .dot:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
}
.face-6 .dot:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
}
.face-6 .dot:nth-child(3) {
    grid-column: 1;
    grid-row: 2;
}
.face-6 .dot:nth-child(4) {
    grid-column: 2;
    grid-row: 2;
}
.face-6 .dot:nth-child(5) {
    grid-column: 1;
    grid-row: 3;
}
.face-6 .dot:nth-child(6) {
    grid-column: 2;
    grid-row: 3;
}

/* Keyframe animation for the rolling effect */
@keyframes roll {
    0% {
        transform: translateZ(-50px) rotateX(0deg) rotateY(0deg);
    }
    100% {
        transform: translateZ(-50px) rotateX(1080deg) rotateY(1080deg);
    }
}

/* Class to apply the animation */
.rolling {
    animation: roll 2s ease-out;
}

/* Transform classes to show a specific face */
.show-1 {
    transform: translateZ(-50px) rotateY(0deg);
}
.show-2 {
    transform: translateZ(-50px) rotateY(-90deg);
}
.show-3 {
    transform: translateZ(-50px) rotateX(90deg);
} /* Flipped 3 and 4 for standard die layout */
.show-4 {
    transform: translateZ(-50px) rotateX(-90deg);
} /* Flipped 3 and 4 for standard die layout */
.show-5 {
    transform: translateZ(-50px) rotateY(90deg);
}
.show-6 {
    transform: translateZ(-50px) rotateY(180deg);
}

/* Responsive styles for smaller screens */
@media (max-width: 600px) {
    #game-view {
        padding-top: 0;
    }
    /* 1. Reduce the size of the container and its 3D perspective */
    .scene {
        width: 60px;
        height: 60px;
        perspective: 240px; /* Scaled down from 400px */
        border: 2px solid transparent;
        box-sizing: border-box;
    }

    /* 2. Reduce the size of each face to match the new scene size */
    .face {
        width: 60px;
        height: 60px;
    }

    /* 3. Adjust the 'translateZ' to half the new width to maintain the cube shape */
    .front {
        transform: rotateY(0deg) translateZ(30px);
    }
    .back {
        transform: rotateY(180deg) translateZ(30px);
    }
    .right {
        transform: rotateY(90deg) translateZ(30px);
    }
    .left {
        transform: rotateY(-90deg) translateZ(30px);
    }
    .top {
        transform: rotateX(90deg) translateZ(30px);
    }
    .bottom {
        transform: rotateX(-90deg) translateZ(30px);
    }

    /* 4. Make the pips on the dice smaller to fit the new face size */
    .dot {
        width: 14px;
        height: 14px;
    }

    /* 5. Adjust the final 'show' transforms to the new Z-axis translation */
    .show-1,
    .show-2,
    .show-3,
    .show-4,
    .show-5,
    .show-6 {
        transform: translateZ(-30px);
    }

    /* Overwrite the individual show classes with the correct rotations and new translation */
    .show-1 {
        transform: translateZ(-30px) rotateY(0deg);
    }
    .show-2 {
        transform: translateZ(-30px) rotateY(-90deg);
    }
    .show-3 {
        transform: translateZ(-30px) rotateX(90deg);
    }
    .show-4 {
        transform: translateZ(-30px) rotateX(-90deg);
    }
    .show-5 {
        transform: translateZ(-30px) rotateY(90deg);
    }
    .show-6 {
        transform: translateZ(-30px) rotateY(180deg);
    }
}
