:root {
    --backdrop-blur: blur(3px);
    --backdrop-filter: blur(3px);
    --blur-10: blur(10px);
    --shadow-base: 0 4px 15px rgba(0,0,0,0.2);
    --shadow-backdrop: 0 10px 15px var(--swal2-backdrop);
    --glass-shadow: 0 4px 15px rgba(0,0,0,0.2);
    --border-radius-sm: 5px;
    --border-radius-md: 8px;
    --border-radius-lg: 12px;
    --border-radius-xl: 16px;
    --transition-base: all 0.3s cubic-bezier(0.25,0.46,0.45,0.94);
    --backdrop-bg: rgba(255,255,255,0.05);
    --glass-bg: rgba(255,255,255,0.05);
    --glass-border: 1px solid rgba(255,255,255,0.6);
    --glass-outline: 1px solid rgba(255,255,255,0.8);
    --glass-inset: inset 0 0 10px rgba(255,255,255,0.5);
    --overlay-bg: rgba(0,0,0,0.5);
    --text-shadow: 2px 2px 4px #000;
    --text-color: #fff;
    --text-color-light: #e5d7ff;
    --glow-orange: 0 0 20px var(--swal2-footer-border-color);
}

/* ==========================================================================
   LAYOUT & STRUCTURE
   ========================================================================== */

.h-vh-100 {
    height: var(--real-vh, 100dvh);
    overflow: hidden;
    box-sizing: border-box;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.gap-1 { gap: 10px; }

#waiting-room {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 5px;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
}

.waiting-info-mobile,
.waiting-info-desktop {
    width: 100%;
    z-index: 1;
}

.waiting-center {
    display: flex;
    justify-content: space-between;
    width: 100%;
}

.waiting-center-opponent,
.waiting-center-user {
    width: 100% !important;
}

.waiting-center-opponent-info,
.waiting-center-user-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
}

.user-active {
    position: relative;
    display: grid;
    grid-template-columns: 2fr 1fr;
    width: 100%;
    flex: 1;
    min-height: 0;
    gap: 5px;
    background: var(--swal2-backdrop);
    box-shadow: var(--shadow-backdrop);
    backdrop-filter: var(--backdrop-blur);
    -webkit-backdrop-filter: var(--backdrop-filter);
    border-bottom: 1px solid var(--swal2-backdrop);
    outline: 1px solid var(--swal2-backdrop);
    box-sizing: border-box;
}

.vs-center {
    position: relative;
}

.vs-center .thunder {
    height: 100%;
    width: auto;
    object-fit: contain;
    position: relative;
    z-index: 1;
}

.vs-center .vs {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    width: 100%;
    object-fit: contain;
}

.vs-center-opponent,
.vs-center-user {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    width: 100%;
}

.vs-center-opponent img,
.vs-center-user img {
    width: 90px;
    padding: 10px;
}

.vs-center-user-frame {
    position: relative;
}

.vs-center-user-avatar {
    position: absolute;
    border-radius: 50%;
    background: var(--swal2-backdrop);
    width: 60px !important;
    padding: 0 !important;
    z-index: -1;
    object-fit: cover;
    aspect-ratio: 1 / 1;
}

.text-ellipsis {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
    font-size: 14px;
    text-align: center;
}

.user-choose-ready,
.user-choose-card-list {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    padding: 5px;
    width: 100%;
    box-sizing: border-box;
    justify-content: start;
    position: relative;
}

.user-choose-card-list {
    position: relative;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    align-content: start;
}

.user-choose-card-list .slot{
    aspect-ratio: 3/4;
    border-radius: var(--border-radius-md);
    background: rgba(255, 255, 255, 0.1);
    border: 2px dashed rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: start;
    z-index: 2;
    position: relative;
}
.user-choose-ready .slot {
    background: url(/images/video/card-flip/fantasy_card_back.webp) center / 100% auto no-repeat, url(/images/arena/battle/arena-choose.webp) center / 100% auto no-repeat, rgba(0, 0, 0, 0.7);
    background-blend-mode: overlay;
    border: 2px dashed rgba(255, 255, 255, 0.3);
}
.card-frame {
    position: absolute;
    width: 105%;
}
.card-frame-battle {
    position: absolute;
    width: 90%;
    z-index: 1;
}
.user-choose-card-list .slot.empty::before,
.user-choose-ready .slot.empty::before {
    content: '';
    width: 60%;
    height: 80%;
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
}

.user-choose-card-list img.slot-card,
.user-choose-ready img.slot-card {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}
.user-ready-button {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    height: 100%;
    font-size: 12px;
    min-height: 0;
    position: relative;
}
.map-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.arena-map {
    width: 100%;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.user-choose-card-list-center::-webkit-scrollbar,
.arena-map::-webkit-scrollbar,
.user-choose-card-list::-webkit-scrollbar,
.card-room-content::-webkit-scrollbar {
    display: none;
}
.arena-guide-image {
    width: 100%;
    grid-column: span 2;
    border-radius: var(--border-radius-sm);
}

.arena-guide-elements {
    display: flex;
    flex-direction: column;
    grid-column: span 3;
}
.room-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    z-index: 2;
    width: 100%;
    box-sizing: border-box;
    height: 100%;
    position: relative;
}

.card-room,
.card-room-avatar {
    padding: 10px;
    border-radius: var(--border-radius-sm);
    background: rgb(0 0 0 / 70%);
    box-shadow: var(--shadow-backdrop);
    backdrop-filter: var(--backdrop-blur);
    -webkit-backdrop-filter: var(--backdrop-filter);
    border-bottom: 1px solid var(--swal2-backdrop);
    outline: 1px solid var(--swal2-backdrop);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    overflow: hidden;
    height: 100%;
}
.unlock-location {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    text-align: center;
    font-size: 14px;
    font-family: monospace;
}
.card-room {
    grid-column: span 2;
    position: relative;
}

.card-room-avatar {
    position: relative;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    background: url(/images/video/card-flip/fantasy_card_back.webp) center / auto auto no-repeat,
                url(/images/arena/battle/arena-choose.webp) center / 100% auto no-repeat,
                rgba(0,0,0,0.7);
    background-blend-mode: overlay;
    color: #fff;
}

.card-room-content {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 15px;
    overflow-y: auto;
    height: 100%;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 10px 0 100px 0;
    align-content: start;
    border-top: 1px solid #ccc;
}
/* ==================== AI BADGE ==================== */
.ai-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
    aspect-ratio: 1 / 1;
}

.ai-level-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.75);
    color: var(--orange);
    font-size: 12px;
    font-weight: 700;
    font-family: monospace;
    padding: 2px 5px;
    line-height: 1;
    pointer-events: none;
}

.ai-difficulty-badge {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0.4));
    font-family: monospace;
    text-align: center;
    font-size: 12px;
    pointer-events: none;
}
.floating-toggle {
    position: absolute;
    bottom: 15px;
    right: 15px;
    z-index: 1;
    width: 120px;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    filter: drop-shadow(0 0 10px var(--orange));
    cursor: pointer;
    transition: all 0.35s ease;
}

.toggle-icon {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-choose-card-list-center {
    position: relative;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.center-tattoo {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 250px;
    opacity: 0.4;
    filter: brightness(0.5);
    pointer-events: none;
    z-index: 0;
}
.user-choose-card-list-center.disabled::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 10;
    pointer-events: auto;
}

.user-choose-card-list-center.disabled {
    overflow: hidden !important;
}

.user-choose-card-list-center.disabled .slot {
    pointer-events: none;
    opacity: 0.5;
}

.user-choose-card-list-center.disabled::after {
    content: attr(data-status-text);
    position: absolute;
    top: 30%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 11;
    font-weight: 700;
    font-size: 22px;
    letter-spacing: 2px;
    text-transform: uppercase;
    background: linear-gradient(90deg, #8de3ff, #8ab6ff, #b18cff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 4px rgba(255,255,255,0.8),
                 0 0 8px rgba(150,180,255,0.8),
                 0 0 12px rgba(120,130,255,0.7);
    filter: drop-shadow(0 0 2px #000) drop-shadow(0 0 1px #000);
    text-align: center;
    line-height: 1.2;
    width: 100%;
}

/* ==========================================================================
   COMPONENTS
   ========================================================================== */

.ai-list-item {
    transition: opacity 0.6s ease;
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 5px;
    background: var(--white);
    box-shadow: var(--shadow-base), inset 0 0 10px rgba(255,255,255,0.5);
    backdrop-filter: var(--backdrop-filter);
    -webkit-backdrop-filter: var(--backdrop-filter);
    border: 1px solid rgba(255,255,255,0.8);
    cursor: pointer;
}
.ai-detail {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    height: 100%;
}

.ai-detail img {
    width: 100px;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 5px;
    background: var(--white);
    box-shadow: var(--shadow-base), inset 0 0 10px rgba(255,255,255,0.5);
    backdrop-filter: var(--backdrop-filter);
    -webkit-backdrop-filter: var(--backdrop-filter);
    outline: 1px solid rgba(255,255,255,0.8);
}

.ai-detail-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-detail-difficulty,
.ai-detail-type {
    background: var(--swal2-timer-progress-bar-background);
    padding: 5px;
    border-radius: 5px;
    box-shadow: var(--shadow-base), inset 0 0 10px rgba(255,255,255,0.5);
    backdrop-filter: var(--backdrop-filter);
    -webkit-backdrop-filter: var(--backdrop-filter);
    outline: 1px solid rgba(255,255,255,0.8);
    font-size: 12px;
}
.matchIndex{display:grid;grid-template-columns:repeat(3,1fr);gap:20px;padding:5px}
.match-item{position:relative;text-align:center}
.circle-svg{width:60px;height:60px}
.match-item small{position:absolute;bottom:-5px;left:50%;transform:translateX(-50%);font-size:14px;background:var(--swal2-deny-button-background-color);padding:0 8px;border-radius:var(--border-radius-sm)}
.card-stats span {
    transition: all 0.4s ease;
    display: inline-block;
    line-height: 1;
    vertical-align: middle;
}

.detail-info-btn i {
    cursor: pointer;
    font-size: 1.5rem;
    position: absolute;
    top: 10px;
    right: 10px;
    color: #fff;
    z-index: 10;
    background: rgba(0,0,0,0.5);
    border-radius: 50%;
    padding: 8px;
}
.ai-milestones {
    margin: 12px 0;
    padding: 8px 12px;
    background: rgba(253,126,20,0.1);
    border: 1px solid var(--orange);
    border-radius: 8px;
    font-size: 13px;
    transition: background 0.2s;
}

.ai-milestones:hover {
    background: rgba(253,126,20,0.2);
}

.milestone-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.milestone-item:last-child {
    margin-bottom: 0;
}

.milestone-reward-card {
    width: 24px !important;
    aspect-ratio: 3 / 4 !important;
    outline: 0 !important;
}
.world-ai-reward-item {
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    align-items: center;
}
.world-ai-reward-item img {
    width: 120px;
    object-fit: cover;
    border-radius: 5px;
    transition: transform 0.6s cubic-bezier(0.34,1.56,0.64,1);
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}
.milestone-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: auto;
}

.milestone-item.disabled:hover {
    transform: none;
}

/* ==========================================================================
   BUTTON & GLOWING
   ========================================================================== */

.glowing-gold {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 3px;
    border-radius: var(--border-radius-md);
    overflow: hidden;
    background: rgba(255,255,255,0.07);
    box-shadow: 0 4px 15px rgba(0,0,0,0.35), inset 0 0 12px rgba(255,255,255,0.3);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    cursor: pointer;
    margin: 10px 0;
    animation: pulse-gold 2s infinite ease-in-out;
}

.glowing-gold .button-text {
    position: relative;
    z-index: 1;
    padding: 8px 15px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: linear-gradient(145deg, #fff7d1, #f4cf74, #c9a345);
    border: 5px solid var(--overlay-bg);
    color: #4a2e00;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.5);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.35), inset 0 1px 4px rgba(255, 255, 255, 0.4);
}
@keyframes pulse-gold {
    0%, 100% {
        box-shadow: 0 4px 15px rgba(0,0,0,0.35), inset 0 0 12px rgba(255,215,0,0.3),
                    0 0 10px rgba(255,215,0,0.4);
    }
    50% {
        box-shadow: 0 4px 15px rgba(0,0,0,0.35), inset 0 0 12px rgba(255,215,0,0.3),
                    0 0 25px rgba(255,215,0,0.8);
    }
}

/* ==========================================================================
   SWEETALERT & MODAL OVERRIDE
   ========================================================================== */

.swal2-popup .swal2-input,
.swal2-popup .swal2-content {
    width: 100% !important;
    box-sizing: border-box !important;
    margin: 0.5em 0 !important;
    padding: 0.5em !important;
    max-width: 100% !important;
    border-radius: var(--border-radius-sm);
    border: 1px solid #ccc;
}

.swal2-popup .swal2-input:not(:last-child) {
    margin-bottom: 0.5em !important;
}

.swal2-popup {
    border-radius: var(--border-radius-sm) !important;
    background: radial-gradient(circle at center, #7800ffa3, #000) !important;
    backdrop-filter: var(--backdrop-blur) !important;
    border: 1px solid rgba(255,255,255,0.6) !important;
    color: #e5d7ff !important;
}

.swal2-styled.swal2-confirm,
.swal2-styled.swal2-cancel {
    background: url(/images/arena/battle/vs-button.webp) center / 100% 100% no-repeat !important;
    padding: 10px 24px !important;
    font-weight: 900 !important;
    text-transform: uppercase !important;
    text-shadow: var(--text-shadow) !important;
    color: var(--orange) !important;
    filter: drop-shadow(0 0 12px #ff6b0066) !important;
}

.swal2-styled.swal2-cancel {
    filter: grayscale(0.7) drop-shadow(0 0 8px #666) !important;
}

.swal2-backdrop-show {
    background: rgba(0,0,0,0.82) !important;
    z-index: 1061;
}

.swal2-icon.swal2-error {
    display: none !important;
}

.swal2-popup:has(.swal2-icon) .swal2-title,
.swal2-warning ~ .swal2-title,
.swal2-error ~ .swal2-title {
    display: none !important;
}

.swal2-styled:focus,
.swal2-popup .swal2-styled:focus,
.swal2-container button.swal2-styled:focus {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

.modal-dialog {
    height: 100dvh !important;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px;
    border: 0;
}

.modal-header span {
    font-weight: bold;
    font-size: 18px;
}

/* ==========================================================================
   LOADING & COUNTDOWN
   ========================================================================== */

#loading-overlay {
    position: fixed;
    inset: 0;
    background-color: #000;
    background-image: linear-gradient(rgba(0,0,0,0.7), rgba(0,0,0,0.8)), url(/images/4k.webp);
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    color: white;
    transition: opacity 0.3s;
}

#image-container {
    width: 300px;
    height: 25px;
    position: relative;
    overflow: hidden;
}

#image-container img {
    width: 50px;
    position: absolute;
    left: 0;
    transition: left 0.3s;
}

#loading-progress {
    width: 300px;
    height: 10px;
    border-radius: 10px;
    overflow: hidden;
    background: var(--backdrop-bg);
    box-shadow: var(--shadow-base), inset 0 0 10px rgba(255,255,255,0.5);
    backdrop-filter: var(--backdrop-blur);
    -webkit-backdrop-filter: var(--backdrop-filter);
}

#progress-bar {
    width: 0%;
    height: 100%;
    background: var(--orange);
    transition: width 0.3s;
}

#loading-text {
    max-width: 250px;
    text-align: center;
    white-space: normal;
    word-wrap: break-word;
    font-size: 14px;
}
/* ==========================================================================
   BATTLE ARENA
   ========================================================================== */
.arena_center.show,
.arena_user.show,
.arena_opponent.show {
    display: flex !important;
}

/* ==========================================================================
   MOBILE OVERLAY
   ========================================================================== */

.mobile-detail-overlay {
    position: fixed;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-detail-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.overlay-content {
    position: relative;
    background: url(/images/video/card-flip/fantasy_card_back.webp) center / auto auto no-repeat,
                url(/images/arena/battle/arena-choose.webp) center / 100% auto no-repeat,
                rgba(0,0,0,0.7);
    background-blend-mode: overlay;
    color: #fff;
    overflow: hidden;
    height: 100%;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: transform 0.35s cubic-bezier(0.32,0.72,0,1);
    transform: translateY(100%);
    display: flex;
    flex-direction: column;
    padding: 10px;
}

.mobile-detail-overlay.show .overlay-content {
    transform: translateY(0);
    will-change: transform, opacity;
}

.mobile-detail-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.mobile-detail-body::-webkit-scrollbar {
    display: none;
}
/* ==========================================================================
   MEDIA QUERIES
   ========================================================================== */

@media (max-width: 767px) {
    [class*="backdrop-filter"],
    .card-room,
    .card-room-avatar,
    .ai-list-item,
    .user-choose-card-list .slot,
    .user-choose-ready .slot,
    .waiting-info-mobile {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
    .body-room {
        display: flex;
        flex-direction: column;
        padding: 10px;
        height: 100%;
        width: 100%;
    }

    .user-choose-card-list {
        grid-template-columns: repeat(3, 1fr);
        height: 100%;
        justify-content: start;
    }

    .user-choose-card-list .slot {
        align-self: start;
        justify-self: center;
    }

    .waiting-info-mobile {
        background: var(--swal2-backdrop);
        box-shadow: var(--shadow-backdrop);
        border-bottom: 1px solid var(--swal2-backdrop);
        outline: 1px solid var(--swal2-backdrop);
        box-sizing: border-box;
    }

    .waiting-info-desktop {
        display: none;
    }

    #ai-detail-panel {
        display: none !important;
    }

    .card-room-content {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 768px) {
    .body-room {
        width: 100%;
        height: 100%;
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        padding: 10px;
    }
    .waiting-info-mobile {
        display: none;
    }

    .mobile-detail-overlay {
        display: none !important;
    }

    .vs-center-opponent img,
    .vs-center-user img {
        width: 60px;
        padding: 0;
    }

    .vs-center-user-avatar {
        width: 50px !important;
    }
}
@media (min-width: 1024px) {
    .arena-guide {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        gap: 5px;
        padding: 5px;
        width: 100%;
    }
}
@media (min-width: 1280px) {
    .body-room {
        grid-template-columns: repeat(8, 1fr);
    }

    .card-room-avatar {
        grid-column: span 3;
    }

    .card-room {
        grid-column: span 5;
    }
}

@media screen and (min-width: 1920px) {
    .container-fluid {
        background: linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5)), url(/images/4k.webp) center / cover no-repeat;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .justify-content-center {
        max-width: 100%;
    }
    .card-room-content {
        grid-template-columns: repeat(10, 1fr);
    }
}