/* ==========================================================================
   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; }
#index-section {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.header-wrapper {
    flex: 1;
    overflow: hidden;
}
.arena_container {
    background: url(/images/giftcode/giftcode.jpg) center / cover no-repeat fixed;
    color: #fff;
    display: flex !important;
    flex-direction: column;
    height: 100%;
    width: 100%;
    box-sizing: border-box;
}
.text-ellipsis {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
    font-size: 14px;
    text-align: center;
}
.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 {
    border-radius: 5px;
    background: rgb(0 0 0 / 70%);
    box-shadow: 0 10px 15px var(--swal2-backdrop);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    border: 1px solid var(--swal2-backdrop);
    outline: 1px solid var(--swal2-backdrop);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    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;
    padding: 10px;
}
.no-cards-placeholder,
.unlock-location-login {
    grid-column: 1 / -1;
    text-align: center;
}
.unlock-location span.upgradable {
    color: #ffaa00;
    font-weight: bold;
    text-shadow: 0 0 8px #ff8800;
    animation: pulse-orange 2s ease-in-out infinite;
}

@keyframes pulse-orange {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.75; }
}
.card-room {
    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: 10px;
    overflow-y: auto;
    height: 100%;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 10px 10px 100px 10px;
    align-content: start;
    border-top: 1px solid #ccc;
}
.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;
}
.my-card-slot {
    position: relative;
    width: 100%;
    border-radius: 5px;
    background: blur(3px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2), inset 0 0 10px rgba(255,255,255,0.5);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    border: 1px solid rgba(255,255,255,0.6);
    cursor: pointer;
    will-change: transform, opacity;
    transition: opacity 0.6s ease;
}
.my-card-slot:hover {
    transform: scale(1.04);
    box-shadow: 0 8px 25px rgba(255, 215, 0, 0.45);
    transition: all 0.25s ease;
}
.my-card-slot img {
    aspect-ratio: 3 / 4;
    width: 100%;
    object-fit: cover;
}
.card-type-indicator {
    position: absolute;
    top: 0;
    right: 0;
    font-size: 20px;
    line-height: 1;
    text-shadow: 0 0 6px rgba(0,0,0,0.7);
    pointer-events: none;
}
.has-free-points .card-type-indicator.sparkle {
    animation: sparkle-glow 1.8s ease-in-out infinite;
}
.my-card-slot.has-free-points {
    border: 2px solid #ffaa00; /* viền cam nhẹ */
    box-shadow: 0 0 15px rgba(255, 170, 0, 0.5), 
                inset 0 0 12px rgba(255, 170, 0, 0.3);
    background: linear-gradient(135deg, rgba(255,170,0,0.08), transparent 70%);
    transition: all 0.4s ease;
}

.my-card-slot.has-free-points:hover {
    border-color: #ffcc00;
    box-shadow: 0 0 25px rgba(255, 170, 0, 0.7), 
                inset 0 0 18px rgba(255, 170, 0, 0.5);
    transform: scale(1.06);
}
@keyframes sparkle-glow {
    0%, 100% {
        transform: scale(1) rotate(0deg);
        text-shadow: 0 0 8px #fff, 0 0 16px #ffd700, 0 0 24px #ffaa00;
        color: #fff;
    }
    50% {
        transform: scale(1.25) rotate(8deg);
        text-shadow: 0 0 14px #fff, 0 0 28px #ffea00, 0 0 40px #ff8800;
        color: #ffea00;
    }
}
.card-inner {
    height: 100%;
    display: flex;
    flex-direction: column;
}
.card-stats {
    position: absolute;
    width: 30%;
    display: flex;
    flex-direction: column;
    align-items: center;
    top: 0;
    contain: paint;
    pointer-events: none;
}
.card-stats span {
    text-shadow: 3px 2px 2px #000;
    font-weight: 700;
    font-family: monospace;
    font-size: 30px;
}
.card-stats span::after {
    content: attr(data-val);
}
.card-stats .atk,
.card-stats .spd {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}
.card-stats .atk { right: 0; }
.card-stats .def { bottom: 0; }
.card-stats .spd { left: 0; }
.my-card-slot .personal-card-frame-wrapper.small-frame .personal-card-frame {
    position: absolute;
    inset: -4px;
    width: 107%;
    object-fit: contain;
    pointer-events: none;
}
.personal-card-detail .personal-card-frame-wrapper {
    position: relative;
    width: 150px;
    aspect-ratio: 3 / 4;
    perspective: 1000px;
}
.personal-card-detail .personal-card-frame {
    position: absolute;
    inset: -8px;
    width: calc(100% + 16px);
    height: calc(100% + 16px);
    object-fit: contain;
    z-index: 2;
    pointer-events: none;
    border-radius: 24px;
    transform: rotateY(0deg) rotateX(0deg) scale(1.02);
    transition: transform 0.6s cubic-bezier(0.34,1.56,0.64,1);
    box-shadow: 0 15px 35px rgba(0,0,0,0.6);
    will-change: transform;
}
.personal-card-detail .card-detail-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 5px;
    z-index: 1;
    transform: rotateY(0deg) rotateX(0deg) scale(1);
    transition: transform 0.6s cubic-bezier(0.34,1.56,0.64,1);
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    will-change: transform, opacity;
}
.tattoo-frames {
    position: absolute;
    inset: 0;               /* full panel */
    pointer-events: none;
    z-index: 1;
    overflow: hidden;       /* tránh tràn nếu cần */
}

.tattoo-left,
.tattoo-right {
    width: 80px;
    height: auto;
    object-fit: contain;
    opacity: 0.4;
    filter: brightness(0.5);
}
.tattoo-left {
    position: absolute;
    top: 0;
    left: 0;
}
.tattoo-right {
    position: absolute;
    bottom: 0;
    right: 0;
    transform: rotate(180deg);
}
.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;
}
#card-detail-content {
    width: 100%;
}
.card-detail-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    perspective: 1200px;
    padding: 10px;
    width: 100%;
    height: 100%;
}
.detail-info-btn {
    cursor: pointer;
    font-size: 1.5rem;
    position: absolute;
    top: 10px;
    right: 10px;
}
.no-cards-message { grid-column: 1 / -1; }
.pet-stats {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    width: 100%;
}
.pet-star {
    display: flex;
    align-items: center;
    font-size: 10px;
    gap: 2px;
}
.upgraded-star{font-size:1.3em!important;background:linear-gradient(45deg,#ffd700,#ffed4e,#ffd700);-webkit-background-clip:text;-webkit-text-fill-color:transparent;text-shadow:0 0 8px rgba(255,215,0,0.8);animation:glow 2s ease-in-out infinite alternate;transform:scale(1.2);display:inline-block;box-shadow:none!important}
.progress {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(255,255,255,0.2);
    width: 100%;
    height: 10px;
}
.progress-bar {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    transition: width .3s ease;
    font-size: 12px;
    line-height: 20px;
    text-align: center;
    border-radius: 10px;
    background: linear-gradient(90deg,#ffd700,#ff4500);
}
.pet-stats-info {
    display: grid;
    grid-template-columns: 1fr;
    gap: 5px;
    width: 100%;
    border-top: 1px solid #ccc;
    margin-top: 5px;
}
.free-points {
    font-size: 15px;
    font-weight: 900;
    color: var(--orange);
    transition: color 0.4s ease;
}
.free-points-active {
    color: var(--orange) !important;
    text-shadow: 0 0 8px var(--orange);
    animation: pulse-free 1.5s infinite;
}
@keyframes pulse-free {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}
.pet-stats-info-progress-bar {
    display: grid;
    grid-template-columns: 5fr 6fr 2fr 1fr;
    align-items: center;
    gap: 5px;
    width: 100%;
    font-size: 12px;
}

.pet-level { width: 70%; font-size: 12px; }
.up-stat {
    width: 60% !important;
    height: 100% !important;
    background: none !important;
    border: 0;
    outline: 0 !important;
    box-shadow: none !important;
}
.pet-index {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    width: 100%;
}
.list-item {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.items-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;justify-items:center;}

.item-name{
    position: absolute;
    font-size: 10px;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    padding: 2px;
    border-radius: 5px 5px 0 0;
    background: var(--swal2-backdrop);
}
.item-upgrade{
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}
.item-upgrade img{
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.8);
}
.item-upgrade-qt{
    position: absolute;
    bottom: 0;
    width: 100%;
    border-radius: 0 0 5px 5px;
    font-size: 10px;
}
.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: 5px;
}

/* ==========================================================================
   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: 5px;
    border: 1px solid #ccc;
}
.swal2-popup .swal2-input:not(:last-child) {
    margin-bottom: 0.5em !important;
}
.swal2-popup {
    border-radius: 5px !important;
    background: radial-gradient(circle at center, #7800ffa3, #000) !important;
    backdrop-filter: blur(3px) !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: 2px 2px 4px #000 !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;
}
.swal2-html-container {
    padding: 0;
}
.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: blur(3px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2), inset 0 0 10px rgba(255,255,255,0.5);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}
#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;
}

/* ==========================================================================
   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) {
    /* Tắt animation sparkle + viền glow trên mobile để tránh lag */
    .has-free-points .card-type-indicator.sparkle {
        animation: none !important;
        transform: none !important;
        text-shadow: 0 0 8px #ffaa00 !important; /* giữ glow nhẹ tĩnh */
        color: #ffea00 !important;
    }

    .my-card-slot.has-free-points {
        border: 1.5px solid #ffaa00;
        box-shadow: 0 0 8px rgba(255,170,0,0.4) !important; /* giảm mạnh glow */
        background: none !important; /* bỏ gradient */
        transition: none !important; /* tắt transition scale */
    }

    .my-card-slot.has-free-points:hover {
        transform: none !important;
        box-shadow: 0 0 12px rgba(255,170,0,0.6) !important;
    }

    /* Giảm blur overlay mobile */
    .mobile-detail-overlay.show .overlay-content {
        backdrop-filter: blur(4px) !important; /* giảm từ 8px xuống */
    }

    [class*="backdrop-filter"],
    .card-room,
    .card-room-avatar,
    .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%;
    }
    .waiting-info-mobile {
        background: var(--swal2-backdrop);
        box-shadow: 0 10px 15px var(--swal2-backdrop);
        border-bottom: 1px solid var(--swal2-backdrop);
        outline: 1px solid var(--swal2-backdrop);
        box-sizing: border-box;
    }
    #card-detail-panel { display: none !important; }
    .card-room-content { grid-template-columns: repeat(3, 1fr); }
    .personal-card-detail .personal-card-frame-wrapper { width: 130px; }
}
@media (min-width: 768px) {
    .body-room {
        width: 100%;
        height: 100%;
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        padding: 10px;
    }
    .card-room {
        grid-column: span 2;
    }
    .card-room-content {
        grid-template-columns: repeat(4, 1fr);
    }
    .waiting-info-mobile { display: none; }
    .mobile-detail-overlay { display: none !important; }
}
@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 (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); }
}
@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi),(min-resolution:2dppx) {
    .my-card-slot img,
    .card-detail-img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
    .my-card-slot,
    .card-stats span,
    .pet-stats-info-progress-bar .progress {
        border-width: 2px;
    }
    .card-stats span { font-size: xx-large}
    [class*="backdrop-filter"] { --backdrop-blur: blur(4px); }
}
@media (-webkit-min-device-pixel-ratio:3),(min-resolution:288dpi),(min-resolution:3dppx) {
    .my-card-slot img,
    .card-detail-img {
        image-rendering: crisp-edges;
    }
    .my-card-slot { border-width: 2.5px; }
    .card-stats span { font-size: 30px }
    [class*="backdrop-filter"] { --backdrop-blur: blur(5px); }
}