/* ===== CSS RESET & BASE STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ===== BODY & LAYOUT ===== */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 20px;
    line-height: 1.6;
    background: linear-gradient(45deg, #1a1a1a, #2d2d2d);
    color: #e0e0e0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
    /* Subtler rainbow background animation */
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4, #feca57, #ff9ff3, #54a0ff);
    background-size: 400% 400%; 
    animation: rainbow 15s ease infinite;
    color: #333;

}

/* ===== TITLE & HEADER STYLES ===== */
.title-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    text-align: center;
    margin-bottom: 30px;
    width: 100%;
    position: relative;
    border: 1px solid rgba(255,255,255,0.1);
}

.title-content {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 20px;
}

h1 {
    color: #2c3e50;
    margin: 0;
    font-size: 2.8em;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    background: linear-gradient(45deg, #2c3e50, #3498db);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

#total-active {
    color: #27ae60;
    font-weight: bold;
    font-size: 1.3em;
  /*  background: rgba(39, 174, 96, 0.1);
    padding: 8px 16px;
    border-radius: 25px;
    border: 2px solid #27ae60;*/
}

/* ===== BUTTON STYLES ===== */
#clear-cache-btn, #dice-btn {
    background: linear-gradient(45deg, #e74c3c, #c0392b);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1em;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
    position: absolute;
    top: 20px;
    border: 2px solid rgba(255,255,255,0.2);
}

#clear-cache-btn {
    right: 20px;
}

#dice-btn {
    background: linear-gradient(45deg, #3498db, #2980b9);
    right: 160px;
}

#clear-cache-btn:hover {
    background: linear-gradient(45deg, #c0392b, #a93226);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.4);
}

#dice-btn:hover {
    background: linear-gradient(45deg, #2980b9, #21618c);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

/* ===== LEVEL SELECTOR ===== */
.level-selector {
    display: flex;
    justify-content: center;
    overflow-x: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
    padding: 15px 20px;
    gap: 12px;
    flex-wrap: nowrap;
    touch-action: pan-x;
    background: rgba(0,0,0,0.1);
    border-radius: 12px;
    margin: 10px 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    /* Visual cues for draggable area */
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

    .level-selector:active {
        cursor: grabbing;
    }

    /* Hide scrollbar for Chrome, Safari and Opera */
    .level-selector::-webkit-scrollbar {
        display: none;
    }

/* Ensure level buttons don't shrink */
.level-btn {
    flex-shrink: 0;
    white-space: nowrap;
    background: linear-gradient(45deg, #9b59b6, #8e44ad);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1em;
    box-shadow: 0 4px 15px rgba(155, 89, 182, 0.3);
    border: 2px solid rgba(255,255,255,0.2);
    /* Prevent button text selection during drag */
    user-select: none;
    -webkit-user-select: none;
}

    .level-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(155, 89, 182, 0.4);
    }

    .level-btn.active {
        background: linear-gradient(45deg, #27ae60, #2ecc71);
        box-shadow: 0 0 20px rgba(46, 204, 113, 0.6);
        transform: translateY(-2px);
    }

/* Specific button colors */
#btn-cantrip {
    background: linear-gradient(45deg, #f1c40f, #f39c12);
}

    #btn-cantrip.active {
        background: linear-gradient(45deg, #d4ac0d, #e67e22);
    }

#btn-staff {
    background: linear-gradient(45deg, #34495e, #2c3e50);
}

    #btn-staff.active {
        background: linear-gradient(45deg, #2c3e50, #1c2833);
    }

.level-selector {
    display: flex;
    justify-content: flex-start; /* Start from left */
    overflow-x: auto;
    scrollbar-width: thin;
    -ms-overflow-style: none;
    padding: 15px calc(50% - 600px); /* Center the entire container with padding */
    gap: 12px;
    flex-wrap: nowrap;
    touch-action: pan-x;
    background: rgba(0,0,0,0.1);
    border-radius: 12px;
    margin: 10px auto; /* Center the container */
    width: 100%;
    /*max-width: 1200px;*/ /* Match your content width */
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

    .level-selector:active {
        cursor: grabbing;
    }

    /* Show scrollbar for Chrome, Safari and Opera */
    .level-selector::-webkit-scrollbar {
        display: block;
        height: 8px;
    }

    .level-selector::-webkit-scrollbar-track {
        background: rgba(0,0,0,0.2);
        border-radius: 4px;
    }

    .level-selector::-webkit-scrollbar-thumb {
        background: linear-gradient(45deg, #9b59b6, #8e44ad);
        border-radius: 4px;
    }

        .level-selector::-webkit-scrollbar-thumb:hover {
            background: linear-gradient(45deg, #8e44ad, #7d3c98);
        }

/* Ensure level buttons don't shrink */
.level-btn {
    flex-shrink: 0;
    white-space: nowrap;
    background: linear-gradient(45deg, #9b59b6, #8e44ad);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1em;
    box-shadow: 0 4px 15px rgba(155, 89, 182, 0.3);
    border: 2px solid rgba(255,255,255,0.2);
    user-select: none;
    -webkit-user-select: none;
}

    .level-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(155, 89, 182, 0.4);
    }

    .level-btn.active {
        background: linear-gradient(45deg, #27ae60, #2ecc71);
        box-shadow: 0 0 20px rgba(46, 204, 113, 0.6);
        transform: translateY(-2px);
    }


/* ===== LEVEL SELECTOR ===== */
    /*.level-selector {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    justify-content: center;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 15px 20px;
    gap: 12px;
    touch-action: pan-x;
    background: rgba(0,0,0,0.1);
    border-radius: 12px;
    margin: 10px 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
}

    .level-selector::-webkit-scrollbar {
        display: none;
    }*/
    /*.level-selector {
    display: flex;
    justify-content: center;
    overflow-x: auto;
    scrollbar-width: none;  Firefox 
    -ms-overflow-style: none;  IE/Edge 
    padding: 15px 20px;
    gap: 12px;
    flex-wrap: nowrap;
    touch-action: pan-x;
    background: rgba(0,0,0,0.1);
    border-radius: 12px;
    margin: 10px 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;  Smooth scrolling on iOS 
     Center the content visually when not overflowing 
    position: relative;
}

     Hide scrollbar for Chrome, Safari and Opera 
    .level-selector::-webkit-scrollbar {
        display: none;
    }

 Ensure level buttons don't shrink and allow centering 
.level-btn {
    flex-shrink: 0;
    white-space: nowrap;
     ... your other level-btn styles ... 
}

 This creates a pseudo-element that helps with centering 
.level-selector::before,
.level-selector::after {
    content: '';
    flex: 1 0 auto;
    min-width: 0;
    visibility: hidden;
}

 Alternative method using auto margins - often more reliable 
.level-selector {
    display: flex;
    justify-content: center;
    overflow-x: auto;
     ... other styles ... 
}

.level-btn:first-child {
    margin-left: auto;  Push first button to center 
}

.level-btn:last-child {
    margin-right: auto;  Push last button to center 
}


*/
    /* Specific button colors */
    #btn-cantrip {
    background: linear-gradient(45deg, #f1c40f, #f39c12);
}

    #btn-cantrip.active {
        background: linear-gradient(45deg, #d4ac0d, #e67e22);
    }

#btn-staff {
    background: linear-gradient(45deg, #34495e, #2c3e50);
}

    #btn-staff.active {
        background: linear-gradient(45deg, #2c3e50, #1c2833);
    }

/* ===== SPELL SECTIONS ===== */
.spell-container {
    width: 100%;
    max-width: 1200px;
}

.section {
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
    border: 1px solid #444;
    overflow: hidden;
}

    .section:hover {
        transform: translateY(-5px);
        box-shadow: 0 12px 40px rgba(0,0,0,0.4);
    }

    .section.hidden-by-selector {
        opacity: 0;
        max-height: 0;
        padding-top: 0;
        padding-bottom: 0;
        margin-bottom: 0;
        border: none;
        cursor: default;
        transform: scale(0.95);
    }

    .section h2 {
        font-size: 1.8em;
        font-weight: 700;
        color: #3498db;
        border-bottom: 3px solid #3498db;
        padding-bottom: 15px;
        margin-bottom: 20px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-wrap: wrap;
        gap: 15px;
    }

/* ===== SLOT CONTROLS ===== */
.slot-controls {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.slot-btn {
    font-size: 1.1em;
    font-weight: bold;
    color: white;
    background: linear-gradient(45deg, #3498db, #2980b9);
    padding: 8px 16px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid rgba(255,255,255,0.2);
    min-width: 50px;
}

    .slot-btn:hover:not(.max) {
        background: linear-gradient(45deg, #2980b9, #21618c);
        transform: translateY(-2px);
    }

    .slot-btn.max {
        background: linear-gradient(45deg, #e74c3c, #c0392b);
        animation: pulse-red 0.6s infinite alternate;
    }

@keyframes pulse-red {
    from {
        box-shadow: 0 0 10px rgba(231, 76, 60, 0.6);
    }

    to {
        box-shadow: 0 0 20px rgba(231, 76, 60, 0.8), 0 0 30px rgba(231, 76, 60, 0.4);
    }
}

.reset-btn {
    font-size: 1em;
    color: white;
    background: linear-gradient(45deg, #95a5a6, #7f8c8d);
    padding: 8px 16px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid rgba(255,255,255,0.2);
}

    .reset-btn:hover {
        background: linear-gradient(45deg, #7f8c8d, #616a6b);
        transform: translateY(-2px);
    }

/* ===== TABLE STYLES ===== */
table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    margin-top: 20px;
 /*   background: rgba(0,0,0,0.2);*/
    border-radius: 10px;
    overflow: hidden;
}

    table th,
    table td {
        padding: 12px;
        text-align: left;
        border-bottom: 1px solid #444;
        vertical-align: top;
        font-size: 1.1em;
    }

        /* Column 1: Active (5%) */
        table th:nth-child(1),
        table td:nth-child(1) {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            width: 5%;
            text-align: center;
        }

        /* Column 2: Spell (18%) */
        table th:nth-child(2),
        table td:nth-child(2) {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            width: 18%;
        }

        /* Column 3: Used (8%) */
        table th:nth-child(3),
        table td:nth-child(3) {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            width: 8%;
            text-align: center;
        }

        /* Column 4: Description (53%) */
        table th:nth-child(4),
        table td:nth-child(4) {
            width: 53%;
            white-space: normal;
            word-wrap: break-word;
            overflow: visible;
            line-height: 1.5;
        }

        /* Column 5: Dice Needed (16%) */
        table th:nth-child(5),
        table td:nth-child(5) {
            width: 16%;
            white-space: normal;
            word-wrap: break-word;
            overflow: visible;
        }

/* Header styles */
th {
    background: linear-gradient(45deg, #3498db, #2980b9);
    color: white;
    font-weight: bold;
    font-size: 1.1em;
    padding: 15px 12px;
}

/* Row styles */
tr {
    transition: background-color 0.3s ease;
}

    tr:nth-child(even) {
        background-color: rgba(255,255,255,0.05);
    }

    tr:hover {
        background-color: rgba(52, 152, 219, 0.1);
    }

/* Row type colors */
.cantrip {
    background-color: rgba(241, 196, 15, 0.1);
    border-left: 4px solid #f1c40f;
}

.level1 {
    background-color: rgba(52, 152, 219, 0.1);
    border-left: 4px solid #3498db;
}

.level2 {
    background-color: rgba(46, 204, 113, 0.1);
    border-left: 4px solid #2ecc71;
}

.level3 {
    background-color: rgba(231, 76, 60, 0.1);
    border-left: 4px solid #e74c3c;
}

.staff {
    background-color: rgba(149, 165, 166, 0.1);
    border-left: 4px solid #95a5a6;
}

/* ===== TOGGLE BUTTONS ===== */
.toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.6em;
    color: #27ae60;
    transition: all 0.3s ease;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

    .toggle-btn.used {
        color: #e74c3c;
        transform: scale(1.1);
    }

    .toggle-btn:hover {
        background: rgba(255,255,255,0.1);
        transform: scale(1.2);
    }

/* ===== USES CONTROLS ===== */
.uses-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 0;
    width: 100%;
}

    .uses-controls span {
        font-weight: bold;
        font-size: 1.1em;
        min-width: 30px;
        text-align: center;
        padding: 6px 8px;
        background: rgba(0,0,0,0.4);
        border-radius: 8px;
        color: #fff;
        border: 1px solid #444;
    }

.uses-btn {
    padding: 6px 10px;
    font-size: 0.9em;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    min-width: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    box-sizing: border-box;
    border: 1px solid rgba(255,255,255,0.2);
}

.uses-btn-plus {
    background: linear-gradient(45deg, #27ae60, #2ecc71);
    color: white;
}

    .uses-btn-plus:hover {
        background: linear-gradient(45deg, #219a52, #27ae60);
        transform: scale(1.1);
    }

.uses-btn-reset {
    background: linear-gradient(45deg, #e74c3c, #c0392b);
    color: white;
}

    .uses-btn-reset:hover {
        background: linear-gradient(45deg, #c0392b, #a93226);
        transform: scale(1.1);
    }

.uses-btn-small {
    min-width: 25px;
    padding: 4px 6px;
    font-size: 0.8em;
}

/* ===== SHOW USED BUTTON ===== */
.show-used-btn {
    background: linear-gradient(45deg, #3498db, #2980b9);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1em;
    margin-left: 15px;
    border: 2px solid rgba(255,255,255,0.2);
}

    .show-used-btn:hover {
        background: linear-gradient(45deg, #2980b9, #21618c);
        transform: translateY(-2px);
    }

    .show-used-btn.active {
        background: linear-gradient(45deg, #27ae60, #2ecc71);
    }

/* ===== MODAL STYLES ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.8);
    animation: fadeIn 0.3s ease;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(8px);
}

.modal-content {
    background: linear-gradient(145deg, #2b2b2b, #1f1f1f);
    margin: 0;
    padding: 40px 30px 30px;
    border: none;
    border-radius: 20px;
    width: 95%;
    max-width: 950px;
    max-height: 95vh;
    overflow-y: auto;
    position: relative;
    animation: rainbowGlow 15s ease infinite;
    box-shadow: 0 25px 50px rgba(0,0,0,0.5);
    border: 2px solid rgba(255,255,255,0.1);
    color: #e0e0e0;
}

@keyframes rainbowGlow {
    0% {
        box-shadow: 0 0 40px rgba(255, 107, 107, 0.7), 0 0 80px rgba(255, 107, 107, 0.4);
    }

    14% {
        box-shadow: 0 0 40px rgba(78, 205, 196, 0.7), 0 0 80px rgba(78, 205, 196, 0.4);
    }

    28% {
        box-shadow: 0 0 40px rgba(69, 183, 209, 0.7), 0 0 80px rgba(69, 183, 209, 0.4);
    }

    42% {
        box-shadow: 0 0 40px rgba(150, 206, 180, 0.7), 0 0 80px rgba(150, 206, 180, 0.4);
    }

    57% {
        box-shadow: 0 0 40px rgba(254, 202, 87, 0.7), 0 0 80px rgba(254, 202, 87, 0.4);
    }

    71% {
        box-shadow: 0 0 40px rgba(255, 159, 243, 0.7), 0 0 80px rgba(255, 159, 243, 0.4);
    }

    85% {
        box-shadow: 0 0 40px rgba(84, 160, 255, 0.7), 0 0 80px rgba(84, 160, 255, 0.4);
    }

    100% {
        box-shadow: 0 0 40px rgba(255, 107, 107, 0.7), 0 0 80px rgba(255, 107, 107, 0.4);
    }
}

.close {
    color: white;
    float: right;
    font-size: 32px;
    font-weight: bold;
    position: absolute;
    right: 25px;
    top: 20px;
    z-index: 1001;
    cursor: pointer;
    background: rgba(0,0,0,0.7);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    border: 2px solid rgba(255,255,255,0.3);
}

    .close:hover {
        background: rgba(255, 107, 107, 0.9);
        transform: rotate(90deg) scale(1.1);
        border-color: rgba(255, 107, 107, 0.8);
    }

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ===== DICE ROLLER STYLES ===== */
#dice-title {
    text-align: center;
    margin: 0 0 30px 0;
    font-size: 2.5em;
    font-weight: 700;
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

#top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 90%;
    max-width: 800px;
    margin: 0 auto 30px auto;
    padding: 20px;
   /* background: rgba(0,0,0,0.4);
    border-radius: 15px;
    border: 2px solid #444;*/
}

#total {
    font-size: 2em;
    font-weight: bold;
    background: linear-gradient(45deg, #27ae60, #2ecc71);
    color: white;
    padding: 15px 30px;
   /* border-radius: 12px;
    border: 3px solid rgba(255,255,255,0.2);
    text-shadow: 0 2px 8px rgba(0,0,0,0.3);
    box-shadow: 0 6px 20px rgba(39, 174, 96, 0.4);*/
}

#clear-btn {
    background: linear-gradient(45deg, #e74c3c, #c0392b);
    border: none;
    color: white;
    font-weight: bold;
    padding: 15px 30px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.1em;
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.4);
    border: 3px solid rgba(255,255,255,0.2);
}

    #clear-btn:hover {
        transform: translateY(-3px);
        box-shadow: 0 8px 25px rgba(231, 76, 60, 0.6);
    }

#rolled-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    min-height: 150px;
    width: 95%;
    margin: 0 auto 30px auto;
    border-bottom: 3px solid #444;
    padding: 25px;
   /* background: rgba(0,0,0,0.3);
    border-radius: 15px;
    border: 2px solid #444;*/
}

#dice-container {
    display: flex;
    gap: 25px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 25px;
    padding: 30px;
   /* background: rgba(0,0,0,0.3);
    border-radius: 15px;
    border: 2px solid #444;*/
}

/* ===== DIE STYLES ===== */
.die {
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: bold;
    cursor: pointer;
    color: #ffffff;
    position: relative;
    transition: all 0.4s ease;
    perspective: 400px;
    text-shadow: 2px 2px 6px rgba(0,0,0,0.5);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

    .die:hover {
        transform: translateY(-8px) scale(1.1);
        box-shadow: 0 15px 40px rgba(0,0,0,0.6);
    }

    .die::before {
        content: '';
        position: absolute;
        inset: 0;
        border-radius: inherit;
        background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.4), transparent 70%);
        mix-blend-mode: overlay;
    }

    /* Specific die styles */
    .die.d4 {
        background: linear-gradient(145deg, #e74c3c, #c0392b);
        clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    }

    .die.d6 {
        background: linear-gradient(145deg, #3498db, #2980b9);
    }

    .die.d8 {
        background: linear-gradient(145deg, #27ae60, #219a52);
        clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    }

    .die.d10 {
        background: linear-gradient(145deg, #9b59b6, #8e44ad);
        clip-path: polygon(50% 0%, 100% 35%, 80% 100%, 20% 100%, 0% 35%);
    }

    .die.d12 {
        background: linear-gradient(145deg, #f39c12, #e67e22);
        clip-path: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%);
    }

    .die.d20 {
        background: linear-gradient(145deg, #1abc9c, #16a085);
        clip-path: polygon(50% 0%, 90% 20%, 100% 60%, 75% 100%, 25% 100%, 0% 60%, 10% 20%);
    }

/* Rolling animation */
@keyframes spin {
    0% {
        transform: rotateY(0deg) rotateX(0deg) scale(1);
    }

    50% {
        transform: rotateY(720deg) rotateX(360deg) scale(1.2);
    }

    100% {
        transform: rotateY(1440deg) rotateX(720deg) scale(1);
    }
}

.rolling {
    animation: spin var(--duration) ease-in-out;
}

/* ===== READY ROLL BUTTON ===== */
.ready-roll-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1002;
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4, #feca57, #ff9ff3, #54a0ff);
    background-size: 400% 400%;
    animation: rainbow 15s ease infinite, pulse 1.5s ease-in-out infinite alternate, glow 2s ease-in-out infinite alternate;
    border: none;
    color: white;
    font-weight: bold;
    padding: 25px 50px;
    border-radius: 50px;
    font-size: 1.8em;
    cursor: pointer;
    box-shadow: 0 15px 40px rgba(0,0,0,0.5);
    transition: all 0.3s ease;
    border: 4px solid rgba(255,255,255,0.3);
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

    .ready-roll-btn:hover {
        transform: translate(-50%, -50%) scale(1.15);
        box-shadow: 0 20px 50px rgba(0,0,0,0.7);
    }

@keyframes pulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
    }

    100% {
        transform: translate(-50%, -50%) scale(1.2);
    }
}

@keyframes glow {
    0% {
        box-shadow: 0 0 40px rgba(255,255,255,0.6), 0 0 80px rgba(255,107,107,0.4);
    }

    100% {
        box-shadow: 0 0 60px rgba(255,255,255,0.9), 0 0 100px rgba(255,107,107,0.6), 0 0 150px rgba(78,205,196,0.4);
    }
}

/* ===== ROLL BUTTON IN SPELL TABLE ===== */
.roll-btn {
    font-size: 0.9em;
    padding: 6px 12px;
    background: linear-gradient(45deg, #27ae60, #2ecc71);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    margin-right: 8px;
    transition: all 0.3s ease;
    border: 1px solid rgba(255,255,255,0.2);
}

    .roll-btn:hover {
        background: linear-gradient(45deg, #219a52, #27ae60);
        transform: translateY(-2px);
    }

/* ===== HIDE ACTIVE COLUMN ===== */
.hide-active-col th:first-child,
.hide-active-col td:first-child {
    display: none;
}

/* ===== SCROLLBAR STYLING ===== */
.modal-content::-webkit-scrollbar {
    width: 12px;
}

.modal-content::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.3);
    border-radius: 6px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
    border-radius: 6px;
    border: 2px solid rgba(0,0,0,0.2);
}

    .modal-content::-webkit-scrollbar-thumb:hover {
        background: linear-gradient(45deg, #e74c3c, #3498db);
    }

.level-selector::-webkit-scrollbar {
    height: 8px;
    display: block;
}

.level-selector::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.2);
    border-radius: 4px;
}

.level-selector::-webkit-scrollbar-thumb {
    background: linear-gradient(45deg, #9b59b6, #8e44ad);
    border-radius: 4px;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .title-container {
        padding: 15px;
    }

    h1 {
        font-size: 2em;
    }

    .title-content {
        flex-direction: column;
        gap: 10px;
    }

    #clear-cache-btn, #dice-btn {
        position: relative;
        top: auto;
        right: auto;
        margin: 5px;
    }

    .level-selector {
        padding: 10px 20px;
        gap: 8px;
    }

    .level-btn {
        padding: 8px 15px;
        font-size: 0.9em;
    }

    .section {
        padding: 15px;
        margin-bottom: 20px;
    }

        .section h2 {
            flex-direction: column;
            align-items: flex-start;
            gap: 10px;
        }

    table {
        font-size: 0.9em;
        display: block;
        overflow-x: auto;
    }

        table th,
        table td {
            padding: 8px 6px;
        }

    .modal-content {
        padding: 30px 20px 20px;
        margin: 10px;
        width: calc(100% - 20px);
    }

    #dice-title {
        font-size: 1.8em;
        margin-bottom: 20px;
    }

    #top-bar {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }

    .die {
        width: 80px;
        height: 80px;
        font-size: 2rem;
    }

    .ready-roll-btn {
        padding: 20px 35px;
        font-size: 1.4em;
    }

    #rolled-container,
    #dice-container {
        padding: 15px;
        gap: 15px;
    }

    .uses-controls {
        flex-wrap: wrap;
    }

    .slot-controls {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.6em;
    }

    .section h2 {
        font-size: 1.4em;
    }

    .die {
        width: 70px;
        height: 70px;
        font-size: 1.8rem;
    }

    #total {
        font-size: 1.6em;
        padding: 12px 20px;
    }

    .modal-content {
        padding: 25px 15px 15px;
    }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
button:focus,
.die:focus {
    outline: 3px solid #3498db;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .section {
        border: 2px solid #fff;
    }

    button {
        border: 2px solid #fff;
    }
}
