* { box-sizing: border-box; margin: 0; padding: 0; font-family: sans-serif; }

body { background-color: #f4f4f9; color: #333; height: 100vh; }

.app-container { display: flex; height: 100%; }

.sidebar {
    width: 250px;
    background: #fff;
    padding: 20px;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.dice-control {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 18px;
    font-weight: bold;
    user-select: none;
    padding: 5px 0;
    transition: color 0.2s;
}

.dice-control.grayed-out {
    color: #b0b0b0; /* Grayed out appearance */
}

.arrow {
    cursor: pointer;
    padding: 5px 15px;
    color: #007bff;
    font-size: 20px;
}

.dice-control.grayed-out .arrow {
    color: #b0b0b0;
}

.arrow:hover {
    color: #0056b3;
}

.dice-control.grayed-out .picker-die {
    opacity: 0.5;
    filter: grayscale(100%);
}

.picker-die {
    width: 60px;
    height: 60px;
    background-color: transparent;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.2s;
}

.picker-die-name {
    font-size: 16px;
    font-weight: bold;
    color: #333;
    white-space: nowrap; /* Added to keep text on a single line */
    text-shadow: 
        -1px -1px 0 #fff,  
         1px -1px 0 #fff,
        -1px  1px 0 #fff,
         1px  1px 0 #fff;
}

.picker-die-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: #444;
    color: #fff;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.difficulty-control {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: auto;
    margin-bottom: 10px;
}

.diff-buttons {
    display: flex;
    gap: 5px;
}

.diff-btn {
    flex: 1;
    padding: 8px 0;
    border: 1px solid #ccc;
    background: #f9f9f9;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
}

.diff-btn.active {
    background: #007bff;
    color: #fff;
    border-color: #0056b3;
    font-weight: bold;
}

.diff-slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

#diff-val-display {
    font-size: 18px;
    font-weight: bold;
    min-width: 30px;
    text-align: center;
}

#diff-target {
    flex: 1;
    cursor: pointer;
}

.die.failed {
    opacity: 0.3;
    filter: grayscale(100%) !important; /* overrides any aura colors */
}

#roll-btn {
    padding: 10px;
    background: #007bff;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
}

#roll-btn:hover { background: #0056b3; }

.main-content {
    flex: 1;
    padding: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
}

#dice-board {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
}

.die {
    width: 80px;
    height: 80px;
    background-color: transparent;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    flex-direction: column; /* Stack name and value */
    align-items: center;
    justify-content: center;
    position: relative;
    user-select: none;
    cursor: pointer;
}

.die-name {
    font-size: 10px;
    color: #555;
    font-weight: bold;
    margin-bottom: 2px;
    /* Create a 1px solid white border around the text */
    text-shadow: 
        -1px -1px 0 #fff,  
         1px -1px 0 #fff,
        -1px  1px 0 #fff,
         1px  1px 0 #fff;
}

.die-value {
    font-size: 24px;
    font-weight: bold;
    color: #000;
    /* Create a 1px (or slightly thicker) solid white border around the text */
    text-shadow: 
        -1px -1px 0 #fff,  
         1px -1px 0 #fff,
        -1px  1px 0 #fff,
         1px  1px 0 #fff,
         0px  2px 0 #fff; /* Optional bottom drop for extra pop */
}

/* Optional subtle shake animation to simulate rolling in place */
@keyframes shake {
    0% { transform: rotate(-3deg); }
    50% { transform: rotate(3deg); }
    100% { transform: rotate(-3deg); }
}

.die.rolling {
    animation: shake 0.1s infinite;
    color: #888;
}

#mobile-toggle-btn {
    display: none;
    padding: 5px 10px;
    background: transparent;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    font-size: 24px;
    width: max-content;
    align-self: flex-start; /* Aligns the button to the left */
    color: #333;
}

/* Responsive layout: when 250px is more than 1/3 of the screen (< 750px) */
@media (max-width: 750px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        padding: 10px 20px;
        position: fixed;
        top: 0;
        left: 0;
        z-index: 100;
        gap: 0;
    }
    
    #mobile-toggle-btn {
        display: block;
    }
    
    #controls-container {
        display: none; /* Hidden by default on small screens */
        max-height: 50vh;
        overflow-y: auto;
        margin-top: 10px;
    }
    
    .sidebar.expanded #controls-container {
        display: block; /* Show when expanded */
    }
    
    #roll-btn {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        margin: 0;
        border-radius: 0;
        padding: 15px;
        font-size: 20px;
        z-index: 100;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
    }

    .difficulty-control {
        position: fixed;
        bottom: 54px; /* Sits right above the ~54px tall Roll button */
        left: 0;
        width: 100%;
        background: #fff;
        padding: 10px 20px;
        margin: 0;
        z-index: 100;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    }
    
    .main-content {
        margin-top: 60px; /* Leave space for top bar */
        padding-bottom: 150px; /* Leave enough room for both fixed elements */
        align-items: flex-start; /* Prevent dice from hiding behind top bar */
    }
}
