/* Ludo King Style Master CSS - Universal Mobile Layout & 3D Physics Dice */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600;700;800;900&family=Poppins:wght@500;600;700;800;900&display=swap');

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    padding: 0;
    overflow: hidden !important;
    user-select: none;
    -webkit-user-select: none;
    background-color: #070d1e;
    touch-action: manipulation;
}

/* Safe areas for iOS and Android notches */
.safe-area-top {
    padding-top: max(8px, env(safe-area-inset-top));
}
.safe-area-bottom {
    padding-bottom: max(8px, env(safe-area-inset-bottom));
}

@keyframes turnRingPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.8);
    }
    70% {
        box-shadow: 0 0 0 7px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

.turn-active-ring {
    animation: turnRingPulse 1.2s infinite cubic-bezier(0.66, 0, 0, 1);
    border-color: #10b981 !important;
}

@keyframes botTurnRingPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.8);
    }
    70% {
        box-shadow: 0 0 0 7px rgba(239, 68, 68, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.bot-turn-active-ring {
    animation: botTurnRingPulse 1.2s infinite cubic-bezier(0.66, 0, 0, 1);
    border-color: #ef4444 !important;
}

/* ========================================================
   REALISTIC 3D DICE SYSTEM (Pure CSS 3D Cube with Pips)
   ======================================================== */
.dice-scene {
    width: 46px;
    height: 46px;
    perspective: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cube-3d {
    width: 44px;
    height: 44px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.cube-face {
    position: absolute;
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #ffffff 0%, #f1f5f9 60%, #cbd5e1 100%);
    border: 2px solid #94a3b8;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.15), 0 3px 6px rgba(0,0,0,0.3);
    padding: 4px;
}

/* Face positions in 3D Space (half of 44px = 22px) */
.face-1 { transform: rotateY(0deg) translateZ(22px); }
.face-2 { transform: rotateY(90deg) translateZ(22px); }
.face-3 { transform: rotateY(180deg) translateZ(22px); }
.face-4 { transform: rotateY(-90deg) translateZ(22px); }
.face-5 { transform: rotateX(90deg) translateZ(22px); }
.face-6 { transform: rotateX(-90deg) translateZ(22px); }

/* Rotations showing each number */
.show-face-1 { transform: rotateX(0deg) rotateY(0deg); }
.show-face-2 { transform: rotateX(0deg) rotateY(-90deg); }
.show-face-3 { transform: rotateX(0deg) rotateY(-180deg); }
.show-face-4 { transform: rotateX(0deg) rotateY(90deg); }
.show-face-5 { transform: rotateX(-90deg) rotateY(0deg); }
.show-face-6 { transform: rotateX(90deg) rotateY(0deg); }

/* Rolling Tumble Animation */
@keyframes diceTumble {
    0% { transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg) scale(1) translateY(0); }
    25% { transform: rotateX(180deg) rotateY(90deg) rotateZ(45deg) scale(1.15) translateY(-8px); }
    50% { transform: rotateX(360deg) rotateY(270deg) rotateZ(180deg) scale(1.2) translateY(-14px); }
    75% { transform: rotateX(540deg) rotateY(360deg) rotateZ(270deg) scale(1.1) translateY(-6px); }
    100% { transform: rotateX(720deg) rotateY(540deg) rotateZ(360deg) scale(1) translateY(0); }
}

.rolling-3d {
    animation: diceTumble 0.5s ease-in-out infinite;
}

/* Dice Pip Dots */
.pip {
    width: 7.5px;
    height: 7.5px;
    background: radial-gradient(circle at 2px 2px, #475569, #0f172a);
    border-radius: 50%;
    box-shadow: inset 0 1px 1px rgba(0,0,0,0.5), 0 0.5px 0.5px rgba(255,255,255,0.7);
}
.pip-red {
    background: radial-gradient(circle at 2px 2px, #f87171, #dc2626);
}

/* Face Pip Layouts */
.pip-grid-1 {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}
.pip-grid-2 {
    display: flex;
    justify-content: space-between;
    width: 100%;
    height: 100%;
    padding: 2px;
}
.pip-grid-2 .pip:last-child {
    align-self: flex-end;
}
.pip-grid-3 {
    display: flex;
    justify-content: space-between;
    width: 100%;
    height: 100%;
    padding: 2px;
}
.pip-grid-3 .pip:nth-child(2) {
    align-self: center;
}
.pip-grid-3 .pip:last-child {
    align-self: flex-end;
}
.pip-grid-4 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    width: 100%;
    height: 100%;
    padding: 2px;
    place-items: center;
}
.pip-grid-5 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    width: 100%;
    height: 100%;
    padding: 2px;
    place-items: center;
}
.pip-grid-5 .pip:nth-child(1) { grid-area: 1 / 1; }
.pip-grid-5 .pip:nth-child(2) { grid-area: 1 / 3; }
.pip-grid-5 .pip:nth-child(3) { grid-area: 2 / 2; }
.pip-grid-5 .pip:nth-child(4) { grid-area: 3 / 1; }
.pip-grid-5 .pip:nth-child(5) { grid-area: 3 / 3; }

.pip-grid-6 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    width: 100%;
    height: 100%;
    padding: 2px;
    place-items: center;
}

/* Canvas crisp rendering */
canvas {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    touch-action: manipulation;
}
