/* ========= CASE MODAL STYLES ========= */

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 4px 15px rgba(245,158,11,0.4); transform: scale(1); }
    50%       { box-shadow: 0 6px 25px rgba(245,158,11,0.7); transform: scale(1.01); }
}

/* ========= STARTER PACK MODAL ========= */
.starter-pack-modal {
    display: none;
    position: fixed;
    z-index: 11000;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    align-items: center;
    justify-content: center;
}
.starter-pack-modal.show { display: flex; }
.starter-pack-content {
    background: linear-gradient(160deg, #12111f 0%, #0e1e38 100%);
    border: 1.5px solid rgba(245,158,11,0.4);
    border-radius: 20px;
    padding: 30px;
    max-width: 460px;
    width: 90%;
    text-align: center;
    box-shadow: 0 0 40px rgba(245,158,11,0.15), 0 20px 50px rgba(0,0,0,0.4);
    animation: caseSlideIn 0.28s cubic-bezier(.34,1.4,.64,1);
}

.case-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: fadeIn 0.22s ease-out;
}

.case-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.case-modal.closing {
    animation: fadeOut 0.3s ease-in;
}

.case-modal-content.closing {
    animation: caseSlideOut 0.3s ease-in;
}

.case-modal-content.closing-smooth {
    animation: slideOutDown 0.4s ease-in;
}

.case-modal-content {
    background: linear-gradient(160deg, #12111f 0%, #161830 60%, #0e1e38 100%);
    border-radius: 20px;
    padding: 22px 26px 24px;
    max-width: 700px;
    width: 95%;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: 0 28px 60px rgba(0,0,0,0.45), 0 0 0 1px rgba(74,158,255,0.12);
    border: 1.5px solid rgba(74,158,255,0.3);
    animation: caseSlideIn 0.28s cubic-bezier(.34,1.4,.64,1);
    scrollbar-width: thin;
    scrollbar-color: rgba(74,158,255,0.25) transparent;
}
.case-modal-content::-webkit-scrollbar { width: 4px; }
.case-modal-content::-webkit-scrollbar-thumb { background: rgba(74,158,255,0.25); border-radius: 4px; }

/* Case modal specific animations */
@keyframes caseSlideIn {
    from { 
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes caseSlideOut {
    from { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to { 
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
}

.case-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(74,158,255,0.2);
}

.case-modal-header h2 {
    color: #f1f5f9;
    font-size: 22px;
    margin: 0;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.close-case-modal {
    background: none;
    border: none;
    color: #fff;
    font-size: 30px;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.close-case-modal:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: rotate(90deg);
}

/* ========= CASE SELECTION ========= */
.case-selection {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 7px;
    margin-bottom: 16px;
}

.case-type-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(74,158,255,0.25);
    color: rgba(255,255,255,0.85);
    padding: 7px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.18s ease;
    min-width: 0;
    white-space: nowrap;
    letter-spacing: 0.2px;
}

.case-type-btn:hover {
    background: rgba(74,158,255,0.12);
    border-color: rgba(74,158,255,0.5);
    color: #fff;
    transform: translateY(-1px);
}

.case-type-btn.active {
    background: linear-gradient(135deg, rgba(74,158,255,0.25), rgba(46,125,50,0.2));
    border-color: rgba(74,158,255,0.6);
    color: #fff;
    box-shadow: 0 3px 12px rgba(74,158,255,0.2);
}

/* ========= CASE BOX ========= */
.case-container {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 18px;
    padding: 14px 16px;
    background: rgba(255,255,255,0.03);
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.06);
}

.case-box {
    position: relative;
    width: 130px;
    height: 100px;
    perspective: 1000px;
    cursor: pointer;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.case-box:hover {
    transform: scale(1.05);
}

.case-lid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 38%;
    background: linear-gradient(135deg, #4a9eff 0%, #7c3aed 50%, #4a9eff 100%);
    border-radius: 10px 10px 0 0;
    box-shadow: 0 4px 12px rgba(124,58,237,0.5);
    transform-origin: bottom;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid rgba(139,92,246,0.6);
    border-bottom: none;
}

.case-body {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 70%;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    border-radius: 0 0 10px 10px;
    box-shadow: inset 0 5px 15px rgba(0, 0, 0, 0.4), 0 0 20px rgba(74,158,255,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid rgba(74,158,255,0.3);
    border-top: none;
}

/* Shine sweep effect */
.case-body::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -60%;
    width: 40%;
    height: 200%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
    animation: shineSweep 4s ease-in-out infinite;
    pointer-events: none;
}

@keyframes shineSweep {
    0%   { left: -60%; }
    50%  { left: 120%; }
    100% { left: 120%; }
}

.case-logo {
    position: absolute;
    z-index: 2;
    width: 90%;
    height: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.case-logo img {
    width: 85%;
    height: 85%;
    object-fit: contain;
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.6)) brightness(1.15);
    animation: floatRotate 3s ease-in-out infinite;
    transform-origin: center;
}

@keyframes floatRotate {
    0%   { transform: rotate(0deg) translateY(0px) scale(1); }
    25%  { transform: rotate(5deg) translateY(-4px) scale(1.03); }
    50%  { transform: rotate(10deg) translateY(-8px) scale(1.06); }
    75%  { transform: rotate(5deg) translateY(-4px) scale(1.03); }
    100% { transform: rotate(0deg) translateY(0px) scale(1); }
}

.case-glow {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 80% !important;
    height: 60% !important;
    background: radial-gradient(circle, rgba(74, 158, 255, 0.3) 0%, transparent 70%) !important;
    border-radius: 50% !important;
    animation: pulse 2s infinite !important;
}

.case-info {
    flex: 1;
    color: #fff;
}

.case-info h3 {
    font-size: 19px;
    margin: 0 0 8px 0;
    color: #7ec8ff;
    font-weight: 700;
}

.case-info p {
    margin: 0 0 12px 0;
    color: rgba(255,255,255,0.6);
    font-size: 13px;
    line-height: 1.5;
}

.case-price {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: bold;
    color: #ffd700;
}

.sol-icon {
    font-size: 20px;
    color: #4a9eff;
}

/* ========= REWARDS GRID ========= */
.case-rewards {
    margin-bottom: 18px;
}

.case-rewards h4 {
    color: rgba(255,255,255,0.7);
    margin: 0 0 12px 0;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
}

.rewards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 8px;
}

.reward-item {
    background: rgba(255,255,255,0.04);
    border-radius: 10px;
    padding: 9px 6px 7px;
    text-align: center;
    border: 1px solid rgba(255,255,255,0.08);
    transition: all 0.18s ease;
    cursor: pointer;
}

.reward-item:hover {
    background: rgba(74,158,255,0.1);
    border-color: rgba(74,158,255,0.45);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.reward-item.common {
    border-color: rgba(156,163,175,0.35);
}

.reward-item.rare {
    border-color: rgba(59,130,246,0.4);
}

.reward-item.epic {
    border-color: rgba(139,92,246,0.4);
}

.reward-item.legendary {
    border-color: rgba(245,158,11,0.45);
    box-shadow: 0 0 14px rgba(245,158,11,0.15);
}

.reward-item.mythic {
    border-color: rgba(239,68,68,0.45);
    box-shadow: 0 0 14px rgba(239,68,68,0.15);
}

.reward-icon {
    width: 38px;
    height: 38px;
    margin: 0 auto 5px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.reward-name {
    font-size: 10.5px;
    color: rgba(255,255,255,0.9);
    margin: 0;
    line-height: 1.3;
    font-weight: 500;
}

.reward-chance {
    font-size: 9.5px;
    color: rgba(255,255,255,0.4);
    margin: 2px 0 0;
    font-weight: 400;
}

/* ========= CASE ACTIONS ========= */
.case-actions {
    text-align: center;
    padding-top: 4px;
}

.open-case-btn {
    background: linear-gradient(135deg, #3a8eef 0%, #1a5fc4 100%);
    color: white;
    border: none;
    padding: 13px 32px;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 16px rgba(58,142,239,0.3);
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 auto 12px;
    letter-spacing: 0.3px;
}

.open-case-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(58,142,239,0.4);
    background: linear-gradient(135deg, #4a9eff 0%, #2270d8 100%);
}

.open-case-btn:disabled {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.35);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.wallet-balance {
    color: rgba(255,255,255,0.45);
    font-size: 12.5px;
}

/* ========= CASE OPENING ANIMATION ========= */
.case-opening-modal {
    display: none;
    position: fixed;
    z-index: 10001;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

/* Toast notification */
.case-toast{
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.85);
    color: #fff;
    padding: 12px 16px;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    z-index: 10002;
    font-size: 14px;
    border: 1px solid rgba(255,255,255,0.15);
}

.case-opening-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.case-opening-modal.closing {
    animation: fadeOut 0.3s ease-in;
}

.case-opening-content.closing {
    animation: slideOut 0.3s ease-in;
}

.case-opening-content {
    background: linear-gradient(160deg, #12111f 0%, #161830 60%, #0e1e38 100%);
    border-radius: 20px;
    padding: 36px 40px;
    max-width: 800px;
    width: 90%;
    text-align: center;
    box-shadow: 0 28px 60px rgba(0,0,0,0.45), 0 0 0 1px rgba(74,158,255,0.12);
    border: 1.5px solid rgba(74,158,255,0.3);
}

.opening-animation {
    margin-bottom: 30px;
}

.case-opening-box {
    position: relative;
    width: 300px;
    height: 200px;
    margin: 0 auto 30px;
    perspective: 1000px;
}

.case-opening-lid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 40%;
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 50%, #ffd700 100%);
    border-radius: 10px 10px 0 0;
    box-shadow: 0 5px 15px rgba(255, 215, 0, 0.3);
    transform-origin: bottom;
    animation: caseOpen 2s ease-in-out;
}

.case-opening-body {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 70%;
    background: linear-gradient(135deg, #8b4513 0%, #a0522d 50%, #8b4513 100%);
    border-radius: 0 0 10px 10px;
    box-shadow: inset 0 5px 15px rgba(0, 0, 0, 0.3);
}

.case-opening-glow {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 80% !important;
    height: 60% !important;
    background: radial-gradient(circle, rgba(74, 158, 255, 0.5) 0%, transparent 70%) !important;
    border-radius: 50% !important;
    animation: glowPulse 1s infinite !important;
}

.rewards-scroll {
    width: 100%;
    height: 100px;
    overflow: hidden;
    border: 1px solid rgba(74,158,255,0.3);
    border-radius: 10px;
    background: rgba(0,0,0,0.2);
    position: relative;
}

.rewards-track {
    display: flex;
    height: 100%;
    transition: transform 3s ease-out;
}

.reward-scroll-item {
    min-width: 100px;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.reward-scroll-icon {
    width: 50px;
    height: 50px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    margin-bottom: 5px;
}

.reward-scroll-name {
    color: #fff;
    font-size: 12px;
    text-align: center;
}

.opening-result {
    margin: 24px 0;
    padding: 20px;
    background: rgba(255,255,255,0.04);
    border-radius: 14px;
    border: 1px solid rgba(74,158,255,0.25);
    animation: resultAppear 0.5s cubic-bezier(.34,1.4,.64,1);
    position: relative;
}

.result-arrow {
    font-size: 48px;
    color: #ffd700;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    margin-bottom: 10px;
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

.result-item {
    width: 100px;
    height: 100px;
    margin: 0 auto 15px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    animation: itemBounce 0.6s ease-out;
}

.result-rarity {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 10px;
    text-transform: uppercase;
}

.result-rarity.common { color: #9ca3af; }
.result-rarity.rare { color: #3b82f6; }
.result-rarity.epic { color: #8b5cf6; }
.result-rarity.legendary { color: #f59e0b; }
.result-rarity.mythic { color: #ef4444; }

.result-name {
    font-size: 20px;
    color: #fff;
    font-weight: bold;
}

.opening-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.claim-reward-btn, .open-another-btn {
    padding: 11px 26px;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.18s ease;
    letter-spacing: 0.2px;
}

.claim-reward-btn {
    background: linear-gradient(135deg, #0fa774 0%, #048055 100%);
    color: white;
    box-shadow: 0 3px 12px rgba(15,167,116,0.3);
}

.open-another-btn {
    background: linear-gradient(135deg, #3a8eef 0%, #1a5fc4 100%);
    color: white;
    box-shadow: 0 3px 12px rgba(58,142,239,0.3);
}

.claim-reward-btn:hover, .open-another-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.08);
    box-shadow: 0 6px 18px rgba(0,0,0,0.25);
}

/* ========= ANIMATIONS ========= */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes slideIn {
    from { 
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes slideOut {
    from { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to { 
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
}

@keyframes slideOutDown {
    from { 
        opacity: 1;
        transform: translateY(0);
    }
    to { 
        opacity: 0;
        transform: translateY(30px);
    }
}

@keyframes pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.8; }
}

@keyframes caseOpen {
    0% { transform: rotateX(0deg); }
    50% { transform: rotateX(-90deg); }
    100% { transform: rotateX(0deg); }
}

@keyframes glowPulse {
    0%, 100% { opacity: 0.3; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 0.8; transform: translate(-50%, -50%) scale(1.1); }
}

@keyframes resultAppear {
    from { 
        opacity: 0;
        transform: scale(0.5);
    }
    to { 
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes itemBounce {
    0% { transform: scale(0) rotate(0deg); }
    50% { transform: scale(1.2) rotate(180deg); }
    100% { transform: scale(1) rotate(360deg); }
}

/* ========= RESPONSIVE — TABLET ========= */
@media (max-width: 900px) {
    .case-modal-content {
        padding: 18px 18px 20px;
        max-width: 96vw;
    }
    .case-opening-content {
        padding: 28px 24px;
    }
}

/* ========= RESPONSIVE — PHONE ========= */
@media (max-width: 600px) {
    /* Modal takes full bottom-sheet style on phone */
    .case-modal {
        align-items: flex-end !important;
    }
    .case-modal-content {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 20px 20px 0 0 !important;
        padding: 16px 14px 24px !important;
        max-height: 92vh;
    }
    .case-modal-header h2 {
        font-size: 18px;
    }

    /* Case type buttons — single horizontal scroll row */
    .case-selection {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        justify-content: flex-start !important;
        gap: 6px !important;
        padding-bottom: 4px;
        scrollbar-width: none;
    }
    .case-selection::-webkit-scrollbar { display: none; }
    .case-type-btn {
        flex-shrink: 0 !important;
        font-size: 11.5px !important;
        padding: 7px 12px !important;
    }

    /* Holder cases — horizontal scroll too */
    .case-modal-content > div[style*="border-top"] > div[style*="flex"] {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    /* Case container — tighter on phone */
    .case-container {
        padding: 10px 12px;
        gap: 12px;
    }
    .case-box {
        width: 100px;
        height: 78px;
    }
    .case-info h3 { font-size: 16px; }
    .case-info p  { font-size: 12px; }
    .case-price   { font-size: 16px; }

    /* Rewards grid — 4 columns on phone */
    .rewards-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 7px !important;
    }
    .reward-icon { width: 34px; height: 34px; }
    .reward-name { font-size: 9.5px; }
    .reward-chance { font-size: 9px; }

    /* Open button — full width */
    .open-case-btn {
        width: 100%;
        justify-content: center;
        padding: 14px 20px;
        font-size: 15px;
    }
    #openCaseTokenBtn { font-size: 13px !important; }

    /* Opening animation modal */
    .case-opening-content {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 20px 20px 0 0 !important;
        padding: 24px 16px !important;
    }
    .case-opening-box {
        width: 200px;
        height: 140px;
        margin-bottom: 16px;
    }
    .rewards-scroll { height: 85px; }
    .result-item { width: 80px; height: 80px; }
    .result-name { font-size: 17px; }
    .opening-actions { gap: 10px; }
    .claim-reward-btn, .open-another-btn {
        padding: 12px 18px;
        font-size: 13px;
    }
}
