/* Dice shapes and styling */

.die {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1rem;
    color: #fff;
    text-shadow:
        1px 1px 2px rgba(0,0,0,0.8),
        -1px -1px 2px rgba(0,0,0,0.8);
    cursor: default;
    user-select: none;
    opacity: 0;
    transform-origin: center center;
}

/* Die sizes */
.die-d4 { width: 40px; height: 40px; font-size: 0.85rem; }
.die-d6 { width: 44px; height: 44px; font-size: 1rem; }
.die-d8 { width: 46px; height: 46px; font-size: 1rem; }
.die-d10 { width: 48px; height: 48px; font-size: 1rem; }
.die-d12 { width: 52px; height: 52px; font-size: 1.1rem; }
.die-d20 { width: 56px; height: 56px; font-size: 1.2rem; }

/* Die shapes using clip-path */
.die-d4 {
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    background: linear-gradient(135deg, #ff4444 0%, #cc0000 100%);
    padding-top: 12px;
}

.die-d6 {
    clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%);
    border-radius: 6px;
    background: linear-gradient(135deg, #44ff44 0%, #00aa00 100%);
}

.die-d8 {
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    background: linear-gradient(135deg, #4488ff 0%, #0044cc 100%);
}

.die-d10 {
    clip-path: polygon(50% 0%, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
    background: linear-gradient(135deg, #ffdd00 0%, #cc9900 100%);
}

.die-d12 {
    clip-path: polygon(50% 0%, 85% 15%, 100% 50%, 85% 85%, 50% 100%, 15% 85%, 0% 50%, 15% 15%);
    background: linear-gradient(135deg, #aa44ff 0%, #6600cc 100%);
}

.die-d20 {
    clip-path: polygon(50% 0%, 79% 10%, 98% 35%, 98% 65%, 79% 90%, 50% 100%, 21% 90%, 2% 65%, 2% 35%, 21% 10%);
    background: linear-gradient(135deg, #ff44aa 0%, #cc0066 100%);
}

/* Die value label */
.die-value {
    z-index: 1;
}

/* Drop animation */
@keyframes dieDrop {
    0% {
        opacity: 0;
        transform: translateY(-150px) scale(0.4) rotate(0deg);
        filter: blur(1px);
        box-shadow: 0 0 0 rgba(0,0,0,0);
    }
    30% {
        opacity: 1;
        transform: translateY(-50px) scale(0.7) rotate(270deg);
        filter: blur(0);
        box-shadow: 0 5px 8px rgba(0,0,0,0.15);
    }
    50% {
        transform: translateY(8px) scale(1.08) rotate(calc(360deg + var(--rotation, 15deg)));
        box-shadow: 0 12px 20px rgba(0,0,0,0.35);
    }
    65% {
        transform: translateY(-4px) scale(0.96) rotate(calc(var(--rotation, 15deg) + 8deg));
        box-shadow: 0 8px 12px rgba(0,0,0,0.25);
    }
    78% {
        transform: translateY(2px) scale(1.02) rotate(calc(var(--rotation, 15deg) - 5deg));
        box-shadow: 0 10px 16px rgba(0,0,0,0.3);
    }
    88% {
        transform: translateY(0) scale(0.99) rotate(calc(var(--rotation, 15deg) + 2deg));
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1) rotate(var(--rotation, 15deg));
        box-shadow: 0 8px 14px rgba(0,0,0,0.3);
    }
}

.die.dropping {
    animation: dieDrop 3s cubic-bezier(0.22, 1, 0.36, 1) forwards,
               dieWireframe 3s ease forwards;
}

/* Wireframe glow during fall, solid on landing */
@keyframes dieWireframe {
    0%, 40% {
        filter: brightness(2) saturate(0.5) drop-shadow(0 0 3px var(--die-color)) drop-shadow(0 0 6px var(--die-color));
    }
    70% {
        filter: brightness(1) saturate(1) drop-shadow(0 4px 6px rgba(0,0,0,0.3));
    }
    100% {
        filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
    }
}

.die-d4 { --die-color: #ff4444; }
.die-d6 { --die-color: #44ff44; }
.die-d8 { --die-color: #4488ff; }
.die-d10 { --die-color: #ffdd00; }
.die-d12 { --die-color: #aa44ff; }
.die-d20 { --die-color: #ff44aa; }

/* Hover effect */
.die:hover {
    filter: brightness(1.2);
    z-index: 100;
}

/* Dice legend */
.dice-legend {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    color: #fff;
    z-index: 50;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 2px;
}

.swatch-d4 { background: linear-gradient(135deg, #ff4444 0%, #cc0000 100%); }
.swatch-d6 { background: linear-gradient(135deg, #44ff44 0%, #00aa00 100%); }
.swatch-d8 { background: linear-gradient(135deg, #4488ff 0%, #0044cc 100%); }
.swatch-d10 { background: linear-gradient(135deg, #ffdd00 0%, #cc9900 100%); }
.swatch-d12 { background: linear-gradient(135deg, #aa44ff 0%, #6600cc 100%); }
.swatch-d20 { background: linear-gradient(135deg, #ff44aa 0%, #cc0066 100%); }
