/* Import Fonts */
/* Gabriela is imported in HTML via Google Fonts link */

/* CSS Variables for Theming */
:root {
    --bg-color: #1A1A2E; /* Dark Imperial Blue */
    --text-color: #F0F8FF; /* AliceBlue */
    --title-font: 'Gabriela', serif;
    --body-font: 'Aptos', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    
    --button-bg-color: #6A0DAD; /* MediumPurple */
    --button-border-color: #480082; /* Indigo */
    --button-hover-bg-color: #7B1FA2; /* Slightly lighter purple for hover */
    
    --dice-face-bg: #FFFFFF; /* White */
    --dice-dot-color: #1A1A2E; /* Dark Imperial Blue, same as page background */
    
    --input-bg-color: #2c2c44;
    --input-border-color: var(--button-border-color);

    --shadow-color-strong: rgba(0, 0, 0, 0.8);
    --shadow-color-medium: rgba(0, 0, 0, 0.5);
    --shadow-color-soft: rgba(0, 0, 0, 0.2);

    --dice-size: 70px;
    --dot-size-ratio: 0.20; /* Dot size as a percentage of dice size */
}

/* Global Styles */
body, html {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--body-font);
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100%;
}

*, *:before, *:after {
    box-sizing: inherit;
}

.main-container {
    min-height: 100vh;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Text Shadow Utility */
.text-with-shadow {
    text-shadow: 2px 2px 6px var(--shadow-color-strong), 
                 -2px -2px 8px var(--shadow-color-soft), 
                 2px -2px 8px var(--shadow-color-medium);
}

/* Header and Title */
header {
    margin-bottom: 30px;
    text-align: center;
}

.title {
    font-family: var(--title-font);
    font-size: 3em; /* Responsive font size can be used: clamp(2em, 5vw, 3.5em) */
    color: var(--text-color);
    margin: 0;
    /* Applying text shadow directly as it's a key feature */
    text-shadow: 2px 2px 6px var(--shadow-color-strong), 
                 -2px -2px 8px var(--shadow-color-soft), 
                 2px -2px 8px var(--shadow-color-medium);
}

/* Controls Area */
.controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
    padding: 15px;
    background-color: rgba(0,0,0,0.1);
    border-radius: 12px;
    flex-wrap: wrap; /* Allow controls to wrap on smaller screens */
}

.controls label {
    font-size: 1.1em;
    text-shadow: 1px 1px 3px var(--shadow-color-medium);
}

.controls input[type="number"] {
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--input-border-color);
    background-color: var(--input-bg-color);
    color: var(--text-color);
    font-family: var(--body-font);
    font-size: 1em;
    width: 80px; /* Adjust as needed */
    text-align: center;
    box-shadow: inset 1px 1px 3px rgba(0,0,0,0.3);
}
/* Hide spinner buttons for number input for a cleaner look */
.controls input[type="number"]::-webkit-outer-spin-button,
.controls input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.controls input[type="number"] {
    -moz-appearance: textfield; /* Firefox */
}


.action-button {
    padding: 10px 20px;
    font-family: var(--body-font);
    font-size: 1.1em;
    font-weight: bold;
    color: var(--text-color);
    background-color: var(--button-bg-color);
    border: 2px solid var(--button-border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    text-shadow: 1px 1px 3px var(--shadow-color-medium);
    box-shadow: 0px 3px 6px rgba(0,0,0,0.2);
}

.action-button:hover {
    background-color: var(--button-hover-bg-color);
    transform: translateY(-1px);
}

.action-button:active {
    transform: translateY(1px);
    box-shadow: 0px 1px 3px rgba(0,0,0,0.2);
}

/* Dice Results Area */
.dice-results-area {
    display: flex;
    flex-wrap: wrap; /* Allow dice to wrap to next line */
    justify-content: center;
    gap: 20px; /* Spacing between dice */
    padding: 20px;
    width: 100%;
    max-width: 900px; /* Max width for dice container on large screens */
}

.dice-results-area.rolling .die-item {
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

/* Individual Die Styling */
.die-item {
    width: var(--dice-size);
    height: var(--dice-size);
    background-color: var(--dice-face-bg);
    border-radius: calc(var(--dice-size) * 0.15); /* Rounded corners relative to size */
    box-shadow: 3px 3px 8px rgba(0,0,0,0.3), 
                inset -2px -2px 5px rgba(0,0,0,0.1);
    display: grid; /* Using grid to position dots */
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    padding: calc(var(--dice-size) * 0.1); /* Padding inside the die */
    opacity: 0; /* For fade-in animation */
    transform: scale(0.8); /* For pop-in animation */
    animation: fadeInDie 0.3s ease-out forwards;
}

.die-item.visible { /* Class added by JS after initial setup if needed */
    opacity: 1;
    transform: scale(1);
}


.dot {
    width: calc(var(--dice-size) * var(--dot-size-ratio));
    height: calc(var(--dice-size) * var(--dot-size-ratio));
    background-color: var(--dice-dot-color);
    border-radius: 50%;
    align-self: center; /* Center dot in grid cell */
    justify-self: center; /* Center dot in grid cell */
}

/* Animations */
@keyframes fadeInDie {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes shake {
  10%, 90% { transform: translate3d(-1px, 0, 0) rotate(1deg); }
  20%, 80% { transform: translate3d(2px, 0, 0) rotate(-1deg); }
  30%, 50%, 70% { transform: translate3d(-3px, 0, 0) rotate(1deg); }
  40%, 60% { transform: translate3d(3px, 0, 0) rotate(-1deg); }
}


/* Responsive adjustments */
@media (max-width: 768px) {
    .title {
        font-size: 2.5em;
    }
    .main-container {
        padding: 15px;
    }
    .controls {
        flex-direction: column;
        gap: 12px;
    }
    .controls input[type="number"] {
        width: 100px;
    }
    .action-button {
        width: 100%;
        max-width: 250px; /* Max button width on mobile */
    }
    :root {
        --dice-size: 60px; /* Smaller dice on smaller screens */
    }
    .dice-results-area {
        gap: 15px;
    }
}

@media (max-width: 480px) {
    .title {
        font-size: 2em;
    }
    :root {
        --dice-size: 50px; /* Even smaller dice on very small screens */
    }
     .main-container {
        padding: 10px; /* Use most of the available space, small border */
    }
    .controls label {
        font-size: 1em;
    }
    .controls input[type="number"] {
        padding: 8px 10px;
        font-size: 0.9em;
    }
    .action-button {
        font-size: 1em;
        padding: 8px 15px;
    }
}