.carousel-container {
    position: relative;
    width: 100%;
    max-width: 1400px; /* Wider container to fit all items */
    height: 450px;
    perspective: 2000px;
    overflow: visible;
    margin: 0 auto 20px;
}

/* Core carousel with row display */
.carousel {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    transform-style: preserve-3d;
    gap: 30px; /* Adds space between items */
    justify-content: center; /* Centers all items */
    padding: 20px; /* Adds padding around the carousel */
}

/* Premium card styling for character display */
.carousel-item {
    filter: brightness(1.1) contrast(1.05) saturate(1.1) !important;

    position: relative;
    width: 280px;
    height: 380px;
    margin: 0 5px; /* Replace negative margins with positive spacing */
    border-radius: 20px;
    overflow: hidden;
    box-shadow:
        0 20px 40px rgba(0,0,0,0.4),
        0 5px 15px rgba(0,0,0,0.2),
        0 0 0 1px rgba(255,255,255,0.05);
    transform-origin: center center;
    transition: all 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
    cursor: pointer;
    background: linear-gradient(145deg,
                rgba(45,45,65,0.85),
                rgba(15,15,25,0.95));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transform-style: preserve-3d;
    border: 1px solid rgba(255,255,255,0.08);
    z-index: 5; /* Increase default z-index */

    z-index: 10;
    border: 1px solid rgba(230, 185, 30, 0.5);
    background: linear-gradient(145deg,
                rgba(60,60,80,0.8),
                rgba(35,35,45,0.95));
    filter: brightness(1.1) contrast(1.05);
}

/* Optimized image handling for transparent character art */
.carousel-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1), filter 0.5s ease;
    filter: drop-shadow(0 15px 25px rgba(0,0,0,0.25));
    transform-style: preserve-3d;
    transform: translateZ(20px);
    z-index: 3;
    position: relative;
}

/* Dynamic character lighting effect */
.carousel-item::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(
        circle at 70% 30%,
        rgba(100, 100, 130, 0.08) 0%,
        rgba(10, 10, 20, 0.6) 100%
    );
    z-index: 2;
    opacity: 0.8;
    transition: opacity 0.6s ease, background 0.7s ease;
    mix-blend-mode: soft-light;
}

/* Dramatic spotlight for active character */
.carousel-item.active::after {
    background: radial-gradient(
        circle at 70% 30%,
        rgba(255, 215, 80, 0.2) 0%,
        rgba(35, 35, 45, 0.6) 100%
    );
    opacity: 0.85;
}

/* Premium active state with character highlight */
.carousel-item.active {
    /* box-shadow:
        0 25px 50px rgba(0,0,0,0.4),
        0 15px 35px rgba(230, 185, 30, 0.25),
        0 0 0 1px rgba(230, 185, 30, 0.4); */
    /* border: 1px solid rgba(230, 185, 30, 0.5); */
    background: linear-gradient(145deg,
                rgba(60,60,80,0.8),
                rgba(35,35,45,0.95));
}

.carousel-item.active .carousel-image {
    transform: translateZ(40px) scale(1.05);
    filter: drop-shadow(0 20px 30px rgba(0,0,0,0.3)) brightness(1.12) contrast(1.05);
}

/* Enhanced interaction feedback with character animations */
.carousel-item:hover {
}

.carousel-item .carousel-image {
    transform: translateZ(30px) scale(1.03);
    filter: drop-shadow(0 15px 25px rgba(0,0,0,0.25));
}

/* Premium border glow effect */
.carousel-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 2px solid transparent;
    border-radius: 20px;
    box-sizing: border-box;
    transition: all 0.8s ease;
    z-index: 3;
    pointer-events: none;
    opacity: 0;
}

.carousel-item.active::before {
    box-shadow:
        inset 0 0 25px rgba(230, 185, 30, 0.15),
        0 0 20px rgba(230, 185, 30, 0.2);
    opacity: 1;
    animation: dragonica-glow 3s infinite ease-in-out;
}

/* Magical glow animation */
@keyframes dragonica-glow {
    0% { box-shadow: inset 0 0 20px rgba(230, 185, 30, 0.15), 0 0 15px rgba(230, 185, 30, 0.2); }
    50% { box-shadow: inset 0 0 30px rgba(230, 185, 30, 0.25), 0 0 25px rgba(230, 185, 30, 0.3); }
    100% { box-shadow: inset 0 0 20px rgba(230, 185, 30, 0.15), 0 0 15px rgba(230, 185, 30, 0.2); }
}

/* Enhanced character info display */
.carousel-content {
    position: absolute;
    bottom: 30px;
    left: 0;
    width: 100%;
    padding: 0 15px;
    text-align: center;
    z-index: 4;
    transform: translateZ(30px);
    transition: all 0.6s cubic-bezier(0.19, 1, 0.22, 1);
    background: linear-gradient(to top,
        rgba(20,20,30,0.9) 0%,
        rgba(20,20,30,0.7) 60%,
        rgba(20,20,30,0) 100%);
    padding-top: 40px;
}

.carousel-content h2 {
    margin-bottom: 8px;
    font-weight: 700;
    font-size: 1.2em;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 5px rgba(0,0,0,0.4);
    transition: all 0.6s ease;
    color: rgba(255,255,255,0.95);
    transform: translateY(5px);
    font-family: 'Cinzel', serif;
    opacity: 0.9;
}

.carousel-content p {
    max-width: 250px;
    margin: 0 auto;
    font-size: 0.85em;
    transform: translateY(5px);
    transition: all 0.6s ease 0.1s;
    opacity: 0.7;
}

.carousel-item.active .carousel-content {
    opacity: 1;
    transform: translateY(-5px) translateZ(45px);
}

.carousel-item.active .carousel-content h2 {
    color: #E6B91E;
    text-shadow:
        0 0 10px rgba(230, 185, 30, 0.4),
        0 2px 5px rgba(0,0,0,0.6);
    transform: translateY(0);
    opacity: 1;
}

.carousel-item.active .carousel-content p {
    transform: translateY(0);
    opacity: 0.9;
}

/* Premium visual enhancements */
.card-reflection {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 40%;
    background: linear-gradient(to bottom,
                 rgba(255,255,255,0.15),
                 rgba(255,255,255,0));
    z-index: 2;
    opacity: 0.7;
    transform: translateZ(2px);
    pointer-events: none;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
}

/* Edge highlight */
.card-edge-highlight {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 20px;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.15);
    z-index: 4;
    pointer-events: none;
}

/* Dragon-themed corner accents */
.card-corner {
    position: absolute;
    width: 12px;
    height: 12px;
    border: 1.5px solid rgba(230, 185, 30, 0.4);
    z-index: 5;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.corner-top-left {
    top: 8px;
    left: 8px;
    border-right: none;
    border-bottom: none;
    border-top-left-radius: 4px;
}

.corner-top-right {
    top: 8px;
    right: 8px;
    border-left: none;
    border-bottom: none;
    border-top-right-radius: 4px;
}

.corner-bottom-left {
    bottom: 8px;
    left: 8px;
    border-right: none;
    border-top: none;
    border-bottom-left-radius: 4px;
}

.corner-bottom-right {
    bottom: 8px;
    right: 8px;
    border-left: none;
    border-top: none;
    border-bottom-right-radius: 4px;
}

.carousel-item .card-corner {
    opacity: 0.5; /* Show corner accents on all cards */
}

/* Class-specific color effects */
.carousel-item[data-class="warrior"] .carousel-image {
    filter: drop-shadow(0 15px 25px rgba(255,50,50,0.15));
}

.carousel-item[data-class="magician"] .carousel-image {
    filter: drop-shadow(0 15px 25px rgba(80,120,255,0.15));
}

.carousel-item[data-class="archer"] .carousel-image {
    filter: drop-shadow(0 15px 25px rgba(100,220,100,0.15));
}

.carousel-item[data-class="thief"] .carousel-image {
    filter: drop-shadow(0 15px 25px rgba(200,100,255,0.15));
}

/* Character silhouette behind image */
.character-silhouette {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 80%;
    height: 80%;
    border-radius: 50%;
    transform: translate(-50%, -55%);
    background: radial-gradient(
        circle at center,
        rgba(230, 185, 30, 0.2) 0%,
        rgba(230, 185, 30, 0) 60%
    );
    z-index: 1;
    filter: blur(15px);
    opacity: 0;
    transition: opacity 0.5s ease;
}

.carousel-item.active .character-silhouette {
    opacity: 0.4;
}

/* Additional decorative effects */
.dragon-scales {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='10' viewBox='0 0 20 10'%3E%3Cpath fill='%23E6B91E' fill-opacity='0.05' d='M0 5 C 2.5 0, 7.5 0, 10 5 C 12.5 10, 17.5 10, 20 5 L 20 10 L 0 10 Z'%3E%3C/path%3E%3C/svg%3E");
    background-size: 20px 10px;
    z-index: 2;
    opacity: 0.3;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
    pointer-events: none;
}

/* Character-specific accent colors */
.color-accent {
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 100%;
    height: 5px;
    background: linear-gradient(90deg,
        rgba(230, 185, 30, 0) 0%,
        rgba(230, 185, 30, 1) 50%,
        rgba(230, 185, 30, 0) 100%);
    box-shadow: 0 0 15px rgba(230, 185, 30, 0.6);
    z-index: 7;
    opacity: 0;
    transition: opacity 0.5s ease, transform 0.5s ease;
    transform: translateY(5px);
}

.carousel-item .color-accent {
    opacity: 0.4; /* Show color accent on all cards */
    transform: translateY(0);
}

/* Class-specific elements */
.carousel-item[data-class="warrior"] .color-accent {
    background: linear-gradient(90deg,
        rgba(220, 50, 50, 0) 0%,
        rgba(220, 50, 50, 1) 50%,
        rgba(220, 50, 50, 0) 100%);
    box-shadow: 0 0 15px rgba(220, 50, 50, 0.6);
}

/* Class-specific elements */
.carousel-item[data-class="warrior"] .color-accent {
    background: linear-gradient(90deg,
        rgba(220, 50, 50, 0) 0%,
        rgba(220, 50, 50, 1) 50%,
        rgba(220, 50, 50, 0) 100%);
    box-shadow: 0 0 15px rgba(220, 50, 50, 0.6);
}

.carousel-item[data-class="magician"] .color-accent {
    background: linear-gradient(90deg,
        rgba(80, 120, 255, 0) 0%,
        rgba(80, 120, 255, 1) 50%,
        rgba(80, 120, 255, 0) 100%);
    box-shadow: 0 0 15px rgba(80, 120, 255, 0.6);
}

.carousel-item[data-class="archer"] .color-accent {
    background: linear-gradient(90deg,
        rgba(100, 220, 100, 0) 0%,
        rgba(100, 220, 100, 1) 50%,
        rgba(100, 220, 100, 0) 100%);
    box-shadow: 0 0 15px rgba(100, 220, 100, 0.6);
}

.carousel-item[data-class="thief"] .color-accent {
    background: linear-gradient(90deg,
        rgba(200, 100, 255, 0) 0%,
        rgba(200, 100, 255, 1) 50%,
        rgba(200, 100, 255, 0) 100%);
    box-shadow: 0 0 15px rgba(200, 100, 255, 0.6);
}

/* Character level indicator */
.character-level {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(35, 35, 45, 0.8);
    border: 1px solid rgba(230, 185, 30, 0.3);
    color: #E6B91E;
    font-size: 0.8em;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 12px;
    z-index: 6;
    transform: translateZ(25px);
    box-shadow: 0 5px 10px rgba(0,0,0,0.2);
    opacity: 0.8;
    transition: all 0.4s ease;
}

/* Apply emblem & level badges styling consistently */
.carousel-item .character-level,
.carousel-item .class-emblem {
    opacity: 0.9;
    transform: translateZ(30px);
}


/* Class emblem */
.class-emblem {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(35, 35, 45, 0.8);
    border: 1px solid rgba(230, 185, 30, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 6;
    transform: translateZ(25px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    opacity: 0.8;
    transition: all 0.4s ease;
    color: #E6B91E;
    font-weight: bold;
    font-size: 14px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.carousel-item.active .class-emblem {
    opacity: 1;
    transform: translateZ(45px);
    border: 1px solid rgba(230, 185, 30, 0.6);
    background: rgba(45, 45, 55, 0.9);
    box-shadow: 0 8px 20px rgba(0,0,0,0.4), 0 0 10px rgba(230, 185, 30, 0.3);
}

/* Magic rune element */
.magical-runes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 20px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Cpath fill='%23E6B91E' fill-opacity='0.06' d='M20 0L0 20h10l10-10 10 10h10L20 0zm0 40l20-20H30l-10 10-10-10H0l20 20z'%3E%3C/path%3E%3C/svg%3E");
    z-index: 1;
    opacity: 0.2;
    transition: opacity 0.5s ease;
}

.carousel-item.active .magical-runes {
    opacity: 0.35;
    animation: rune-glow 8s infinite linear;
}

@keyframes rune-glow {
    0% { opacity: 0.2; }
    50% { opacity: 0.4; }
    100% { opacity: 0.2; }
}

/* Responsive design with all items visible */
@media (max-width: 1400px) {
    .carousel-container {
        max-width: 90%;
    }

    .carousel-item {
        width: 240px;
        height: 340px;
        margin: 0 -40px; /* More overlap on smaller screens */
    }

    .carousel-item.active {
        margin: 0 -25px;
    }
}

@media (max-width: 1100px) {
    .carousel {
        justify-content: flex-start; /* Left align when items can't fit */
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        gap: 15px;
        padding: 0 30px;
    }

    .carousel-item {
        min-width: 240px; /* Ensure minimum width */
        margin: 0;
        scroll-snap-align: center;
    }
}

@media (max-width: 768px) {
    .carousel {
        gap: 10px;
    }

    .carousel-item {
        min-width: 200px;
    }
}

@media (max-width: 900px) {
    .carousel-container {
        height: 380px;
    }

    .carousel-item {
        width: 200px;
        height: 300px;
        margin: 0 -60px;
    }

    .carousel-item.active {
        margin: 0 -45px;
    }

    .carousel-content h2 {
        font-size: 1.1em;
    }

    .carousel-content p {
        font-size: 0.8em;
    }
}

@media (max-width: 768px) {
    .carousel {
        overflow-x: auto;
        padding: 20px 50px;
        justify-content: flex-start;
    }

    .carousel-item {
        min-width: 180px;
        height: 280px;
        margin: 0 -20px;
        flex-shrink: 0;
    }

    .carousel-item.active {
        margin: 0 -15px;
    }

    .carousel::-webkit-scrollbar {
        height: 6px;
    }

    .carousel::-webkit-scrollbar-track {
        background: rgba(30, 30, 40, 0.3);
        border-radius: 10px;
    }

    .carousel::-webkit-scrollbar-thumb {
        background: rgba(230, 185, 30, 0.5);
        border-radius: 10px;
    }

    .class-emblem, .character-level {
        transform: translateZ(20px);
    }

    .carousel-item.active .class-emblem,
    .carousel-item.active .character-level {
        transform: translateZ(35px);
    }
}

@media (max-width: 576px) {
    .carousel-item {
        min-width: 160px;
        height: 250px;
        margin: 0 -15px;
    }

    .carousel-content h2 {
        font-size: 1em;
    }

    .carousel-content p {
        font-size: 0.75em;
        max-width: 90%;
    }
}

/* Preserve existing control styles */
.carousel-control {
    width: 100px;
    height: 36px;
    margin: 0;
    opacity: 0.9;
    transform: scale(0.85);
}

.carousel-control .button-yellow-border {
    background: linear-gradient(to bottom, #ffffff, #e6e6e6);
    filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.5));
}

.carousel-control .button-outer-frame {
    background: linear-gradient(to bottom, #f2f2f2, #e6e6e6);
}

.carousel-control .button-frame {
    background: linear-gradient(to bottom, #f5f5f5, #ececec);
}

.carousel-control .button-metal {
    background: linear-gradient(to bottom,
        rgba(255, 255, 255, 1) 0%,
        rgba(245, 245, 245, 1) 50%,
        rgba(235, 235, 235, 1) 100%);
    box-shadow:
        inset 0 1px 1px rgba(255, 255, 255, 0.8),
        inset 0 -1px 1px rgba(200, 200, 200, 0.3);
}

.carousel-control .button-face {
    background: linear-gradient(to bottom,
        rgba(255, 255, 255, 1) 0%,
        rgba(248, 248, 248, 1) 50%,
        rgba(240, 240, 240, 1) 100%);
}

.carousel-control .button-content {
    padding: 0 5px;
}

.carousel-control .button-text {
    font-size: 12px;
    font-weight: normal;
    color: #505050;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);
    letter-spacing: 0;
}

.carousel-control .button-icon {
    font-size: 14px;
    color: #505050;
    filter: drop-shadow(0 1px 1px rgba(255, 255, 255, 0.8));
}

.carousel-control .corner-accent {
    width: 6px;
    height: 6px;
    background: #e0e0e0;
}

.carousel-control .dragon-emblem,
.carousel-control .fire-particles,
.carousel-control .pulse-highlight {
    display: none;
}

.carousel-control .button-glow {
    opacity: 0.03;
    box-shadow: inset 0 0 3px rgba(255, 255, 255, 0.6), 0 0 3px rgba(255, 255, 255, 0.3);
}

#prevBtn .button-content {
    flex-direction: row;
    justify-content: center;
}

#nextBtn .button-content {
    flex-direction: row-reverse;
    justify-content: center;
}

#prevBtn .button-icon {
    margin-right: 3px;
}

#nextBtn .button-icon {
    margin-left: 3px;
}

.carousel-control.icon-only .button-text {
    display: none;
}

.carousel-control.icon-only {
    width: 36px;
}

@media (max-width: 768px) {
    .carousel-control {
        transform: scale(0.75);
    }
}

.carousel-control:hover {
    transform: scale(0.87);
    filter: brightness(1.03);
}

.carousel-control:hover .button-glow {
    opacity: 0.15;
}

.carousel-control:active {
    transform: scale(0.8);
}
