body { display: flex; justify-content: center; align-items: center; min-height: 100vh; margin: 0; padding: 15px 0; background-color: #3a7bd5; background-image: linear-gradient(90deg, rgba(0,0,0,0.03) 1px, transparent 1px), linear-gradient(rgba(0,0,0,0.03) 1px, transparent 1px); background-size: 48px 48px; padding: 0px; font-family: 'Arial Rounded MT Bold', Arial, sans-serif; box-sizing: border-box; overflow-y: auto; }

#startScreen { display: flex; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0, 0, 0, 0.75); z-index: 200; justify-content: center; align-items: center; color: white; }
#startBox { background-color: #3a7bd5; background-image: linear-gradient(to top, #004e92, #3a7bd5); padding: 25px 20px; border-radius: 20px; border: 3px solid #fff; box-shadow: 0 0 20px rgba(0,0,0,0.5); text-align: center; }
#startBox h2 { font-size: 28px; margin-top:0; text-shadow: 2px 2px 4px #000; }
#startBox h3 { font-size: 18px; margin-bottom: 10px; color: #ffcc00; }
.setup-section { margin-bottom: 25px; }
#playerCountSelector button, #startGameButton { padding: 8px 10px; font-size: 16px; margin: 0 5px; cursor: pointer; border: 2px solid #ddd; border-radius: 8px; background-color: #f0f0f0; color: #333; font-weight: bold; transition: all 0.2s ease; }
#playerCountSelector button.selected { background-color: #ffcc00; border-color: #fff; transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.3); }
#startGameButton { margin-top: 10px; width: 80%; padding: 12px; font-size: 18px; background-color: #ffcc00; }
#startGameButton:hover { background-color: #e6b800; transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.3); }
#colorSelector { display: flex; justify-content: center; gap: 15px; }
.color-btn { width: 45px; height: 45px; border-radius: 50%; border: 3px solid #fff; cursor: pointer; transition: all 0.2s ease; box-shadow: 0 2px 5px rgba(0,0,0,0.2); }
.color-btn:hover { transform: scale(1.1); }
.color-btn.selected { transform: scale(1.15); box-shadow: 0 0 15px 3px #fff; }
.color-btn.blue { background-color: #0077C8; }
.color-btn.red { background-color: #D82028; }
.color-btn.green { background-color: #00A859; }
.color-btn.yellow { background-color: #FDD900; }
.color-btn[disabled] { opacity: 0.3; cursor: not-allowed; transform: none; box-shadow: none; }

#gameContainer { display: none; flex-direction: column; align-items: center; padding:10px; border-radius: 20px; width: 100%; max-width: 450px; box-sizing: border-box; position: relative; }
#playerInfoContainerTop, #playerInfoContainerBottom { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; margin-bottom: 10px; box-sizing: border-box; }
#playerInfoContainerBottom { margin-top: 10px; margin-bottom: 0; }
.player-info-box { display: flex; align-items: center; background-color: #f0f0f0; border: 3px solid #a0a0a0; border-radius: 15px; padding: 5px 8px; width: 48%; box-shadow: inset 0 0 5px rgba(0,0,0,0.2); position: relative; min-height: 55px; box-sizing: border-box; }
#playerInfo0 { border-color: #005090; background-color: #e0f0ff;}
#playerInfo1 { border-color: #A01018; background-color: #ffe0e0;}
#playerInfo2 { border-color: #007030; background-color: #e0ffe0;}
#playerInfo3 { border-color: #C0A000; background-color: #ffffe0;}
.player-pin-icon { width: 35px; height: 35px; border-radius: 50%; margin-right: 8px; border: 2px solid #555; display: flex; justify-content: center; align-items: center; font-size: 20px; color: white; position: relative; clip-path: polygon(50% 100%, 100% 45%, 100% 0, 0 0, 0 45%); transform: scale(0.8); flex-shrink: 0; }
#playerInfo0 .player-pin-icon { background-color: #0077C8; }
#playerInfo1 .player-pin-icon { background-color: #D82028; }
#playerInfo2 .player-pin-icon { background-color: #00A859; }
#playerInfo3 .player-pin-icon { background-color: #FDD900; }
.player-name { font-size: clamp(13px, 3vw, 16px); font-weight: bold; color: #333; flex-grow: 1; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0 5px; }
.player-info-box.active { border-width: 4px; border-color: #fff; box-shadow: 0 0 10px 3px var(--player-active-glow, #FFFF00); }
#playerInfo0.active { --player-active-glow: #60b0ff; }
#playerInfo1.active { --player-active-glow: #ff6060; }
#playerInfo2.active { --player-active-glow: #60ff90; }
#playerInfo3.active { --player-active-glow: #ffff60; }
#gameArea { position: relative; width: fit-content; max-width: 100%; margin: 0; box-shadow: 0px 10px 25px rgba(0, 0, 0, 0.4); border-radius: 15px; overflow: hidden; border: 5px solid #fff; box-sizing: border-box; }
canvas { display: block; background-color: #fff; max-width: 100%; height: auto; }
.timer-display { position: absolute; top: 19px; left: 47px; font-size: 14px; font-weight: bold; color: #fff; background-color: rgba(0,0,0,0.6); padding: 1px 6px; border-radius: 10px; display: none; }
.player-info-box.active .timer-display { display: block; }
#gameOverScreen { display: none; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0, 0, 0, 0.75); z-index: 100; flex-direction: column; justify-content: center; align-items: center; color: white; text-align: center; }
#gameOverBox { background-color: #3a7bd5; background-image: linear-gradient(to top, #004e92, #3a7bd5); padding: 25px; border-radius: 20px; border: 3px solid #fff; box-shadow: 0 0 20px rgba(0,0,0,0.5); }
#gameOverTitle { font-size: 28px; margin-bottom: 10px; text-shadow: 2px 2px 4px #000; }
#rankList { list-style: none; padding: 0; margin: 15px 0; font-size: 18px; }
#rankList li { background: rgba(0,0,0,0.2); padding: 8px 15px; margin-bottom: 8px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
#rankList li:first-child { background: #ffcc00; color: #333; font-weight: bold; font-size: 22px; }

.dice-display {
    width: 45px;
    height: 45px;
    margin-left: 8px;
    cursor: pointer;
    flex-shrink: 0;
    perspective: 300px;
    background-color: rgba(0, 0, 0, 0.05);
    border: 2px solid transparent;
    border-radius: 8px;
    transition: border-color 0.3s ease;
}
.player-info-box.active .dice-display {
    border-color: #888;
}
.dice-cube {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.5s ease-out, opacity 0.4s ease-in-out;
    opacity: 0;
}
.player-info-box.active .dice-cube {
    opacity: 1;
}
.dice-cube.rolling {
    animation: spin 1.2s ease-out forwards;
}
@keyframes spin { 100% { transform: rotateX(1080deg) rotateY(1440deg) rotateZ(720deg); } }
.dice-cube .face {
    position: absolute;
    width: 45px;
    height: 45px;
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    border: 1px solid #bbb;
    border-radius: 6px;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    backface-visibility: hidden;
}
.dice-cube .dot {
    width: 8px;
    height: 8px;
    background-color: #333;
    border-radius: 50%;
    position: absolute;
}
.face-1 { transform: rotateY(0deg) translateZ(22.5px); }
.face-2 { transform: rotateY(90deg) translateZ(22.5px); }
.face-3 { transform: rotateX(90deg) translateZ(22.5px); }
.face-4 { transform: rotateX(-90deg) translateZ(22.5px); }
.face-5 { transform: rotateY(-90deg) translateZ(22.5px); }
.face-6 { transform: rotateY(180deg) translateZ(22.5px); }

.show-1 { transform: rotateY(0deg); }
.show-2 { transform: rotateY(-90deg); }
.show-3 { transform: rotateX(-90deg); }
.show-4 { transform: rotateX(90deg); }
.show-5 { transform: rotateY(90deg); }
.show-6 { transform: rotateY(-180deg); }

#controls { text-align: center; margin-top: 15px; width: 100%; box-sizing: border-box; }
#htmlRestartButton { margin: 15px 0 0 0; padding: 12px 25px; font-size: clamp(16px, 3.5vw, 18px); cursor: pointer; border: none; border-radius: 8px; background-color: #ffcc00; color: #333; font-weight: bold; box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2); transition: background-color 0.2s ease; display: inline-block; }
#htmlRestartButton:hover { background-color: #e6b800; }

@media (max-width: 768px) { body { padding-top: 15px; padding-bottom: 15px; } #gameContainer { padding: 0px; width: 95%; max-width: 95%; } startBox{padding: 20px 0px;width:95%;} .player-info-box { padding: 4px 6px; min-height: 50px; } .player-pin-icon { width: 30px; height: 30px; font-size: 18px; margin-right: 5px; } .dice-display { width: 40px; height: 40px; } .dice-cube .face { width: 40px; height: 40px; } .face-1, .face-2, .face-3, .face-4, .face-5, .face-6 { transform-origin: 20px 20px; } .face-1 { transform: rotateY(0deg) translateZ(20px); } .face-2 { transform: rotateY(90deg) translateZ(20px); } .face-3 { transform: rotateX(90deg) translateZ(20px); } .face-4 { transform: rotateX(-90deg) translateZ(20px); } .face-5 { transform: rotateY(-90deg) translateZ(20px); } .face-6 { transform: rotateY(180deg) translateZ(20px); } .dice-cube .dot { width: 6px; height: 6px; } #gameArea { border-width: 3px; } #controls { margin-top: 10px; } }
@media (max-width: 480px) { #playerInfoContainerTop, #playerInfoContainerBottom { gap: 8px; } /*flex-direction: column;*/ .player-info-box { width: 95%; margin-bottom: 5px; min-height: 48px; padding: 3px 5px; } .player-pin-icon { width: 28px; height: 28px; font-size: 16px; } .dice-display { width: 38px; height: 38px; } .dice-cube .face { width: 38px; height: 38px; } .face-1, .face-2, .face-3, .face-4, .face-5, .face-6 { transform-origin: 19px 19px; } .face-1 { transform: rotateY(0deg) translateZ(19px); } .face-2 { transform: rotateY(90deg) translateZ(19px); } .face-3 { transform: rotateX(90deg) translateZ(19px); } .face-4 { transform: rotateX(-90deg) translateZ(19px); } .face-5 { transform: rotateY(-90deg) translateZ(19px); } .face-6 { transform: rotateY(180deg) translateZ(19px); } }