:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-color: #f8fafc;
    --text-secondary: #94a3b8;
    --die-bg: #ffffff;
    --die-dot: #1e293b;
    --shadow-color: rgba(0, 0, 0, 0.25);
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    background-image:
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(168, 85, 247, 0.15) 0px, transparent 50%);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
}

.container {
    width: 100%;
    max-width: 1000px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

/* Header & Controls */
header {
    text-align: center;
    margin-bottom: 2rem;
}

h1 {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.05em;
    filter: drop-shadow(0 0 2em rgba(99, 102, 241, 0.3));
}

.controls-panel {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: var(--glass-border);
    padding: 1.5rem 2rem;
    border-radius: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 800px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

input[type="number"] {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    font-size: 1rem;
    width: 100px;
    transition: all 0.2s;
}

input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.btn-primary {
    background: var(--accent-gradient);
    border: none;
    color: white;
    padding: 0.75rem 2rem;
    border-radius: 0.75rem;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    background-size: 200% auto;
}

.btn-primary:hover {
    background-position: right center;
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

input[type="color"] {
    -webkit-appearance: none;
    appearance: none;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    background: none;
    padding: 0;
    overflow: hidden;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 50%;
}

select {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    font-size: 1rem;
    cursor: pointer;
}

/* Dice Area */
.dice-container {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    justify-content: center;
    padding: 2rem;
    min-height: 200px;
    perspective: 1000px;
}

.die {
    width: 100px;
    height: 100px;
    background-color: var(--die-bg);
    border-radius: 16px;
    box-shadow:
        inset 0 0 10px rgba(0, 0, 0, 0.1),
        0 10px 20px rgba(0, 0, 0, 0.2),
        0 0 0 2px rgba(255, 255, 255, 0.05);
    /* Subtle rim */
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
}

.die.is-rolling {
    animation: roll 0.6s ease-in-out;
}

@keyframes roll {
    0% {
        transform: rotateX(0) rotateY(0) rotateZ(0);
    }

    100% {
        transform: rotateX(720deg) rotateY(720deg) rotateZ(720deg);
    }
}

.dot {
    width: 18px;
    height: 18px;
    background-color: var(--die-dot);
    border-radius: 50%;
    position: absolute;
    box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.3);
    opacity: 0;
    /* Hide by default */
}

/* Dot Positions */
/* Face 1 */
.die[data-face="1"] .dot:nth-child(1) {
    opacity: 1;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Face 2 */
.die[data-face="2"] .dot:nth-child(1) {
    opacity: 1;
    top: 20%;
    left: 20%;
}

.die[data-face="2"] .dot:nth-child(2) {
    opacity: 1;
    bottom: 20%;
    right: 20%;
}

/* Face 3 */
.die[data-face="3"] .dot:nth-child(1) {
    opacity: 1;
    top: 20%;
    left: 20%;
}

.die[data-face="3"] .dot:nth-child(2) {
    opacity: 1;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.die[data-face="3"] .dot:nth-child(3) {
    opacity: 1;
    bottom: 20%;
    right: 20%;
}

/* Face 4 */
.die[data-face="4"] .dot:nth-child(1) {
    opacity: 1;
    top: 20%;
    left: 20%;
}

.die[data-face="4"] .dot:nth-child(2) {
    opacity: 1;
    top: 20%;
    right: 20%;
}

.die[data-face="4"] .dot:nth-child(3) {
    opacity: 1;
    bottom: 20%;
    left: 20%;
}

.die[data-face="4"] .dot:nth-child(4) {
    opacity: 1;
    bottom: 20%;
    right: 20%;
}

/* Face 5 */
.die[data-face="5"] .dot:nth-child(1) {
    opacity: 1;
    top: 20%;
    left: 20%;
}

.die[data-face="5"] .dot:nth-child(2) {
    opacity: 1;
    top: 20%;
    right: 20%;
}

.die[data-face="5"] .dot:nth-child(3) {
    opacity: 1;
    bottom: 20%;
    left: 20%;
}

.die[data-face="5"] .dot:nth-child(4) {
    opacity: 1;
    bottom: 20%;
    right: 20%;
}

.die[data-face="5"] .dot:nth-child(5) {
    opacity: 1;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Face 6 */
.die[data-face="6"] .dot:nth-child(1) {
    opacity: 1;
    top: 20%;
    left: 20%;
}

.die[data-face="6"] .dot:nth-child(2) {
    opacity: 1;
    top: 20%;
    right: 20%;
}

.die[data-face="6"] .dot:nth-child(3) {
    opacity: 1;
    top: 50%;
    left: 20%;
    transform: translateY(-50%);
}

.die[data-face="6"] .dot:nth-child(4) {
    opacity: 1;
    top: 50%;
    right: 20%;
    transform: translateY(-50%);
}

.die[data-face="6"] .dot:nth-child(5) {
    opacity: 1;
    bottom: 20%;
    left: 20%;
}

.die[data-face="6"] .dot:nth-child(6) {
    opacity: 1;
    bottom: 20%;
    right: 20%;
}


/* Results Overlay */
.total-display {
    margin-top: 2rem;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.2);
    padding: 1rem 2rem;
    border-radius: 1rem;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s ease;
}

.total-display.visible {
    opacity: 1;
    transform: translateY(0);
}

.total-value {
    color: #a855f7;
    font-size: 2rem;
    font-weight: 800;
}

/* Shape Variation */
.die.circle {
    border-radius: 50%;
}