/* Chest / Case Opening Styles - User Requested Theme */

.chest-wrapper {
    width: 95%;
    /* Mobile friendly */
    max-width: 900px;
    background: #0f172a;
    /* Deep Blue from image */
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.05);
    position: relative;
    overflow: hidden;

    /* Prevent mobile shifting */
    contain: layout style;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .chest-wrapper {
        width: 98%;
        padding: 15px;
        max-width: 100%;
    }
}

.chest-header {
    margin-bottom: 20px;
}

.chest-header h2 {
    display: none;
    /* Reference image doesn't show big title, maybe "Kasayı Aç" is button */
}

.chest-header p {
    display: none;
}

/* THE RAIL - TOP SECTION */
.chest-rail-container {
    width: 100%;
    height: 160px;
    background: #162032;
    /* Slightly Lighter Blue */
    position: relative;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-top: none;
    border-bottom: none;
    overflow: hidden;
    margin-bottom: 30px;
    box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.8);
}

.chest-tape {
    display: flex;
    height: 100%;
    align-items: center;
    position: absolute;
    left: 50%;
    will-change: transform;

    /* Hardware acceleration for smooth animation */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* ITEM CARD STYLE (In Rail & Preview) */
.chest-item,
.preview-item {
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

/* In Rail Specifics */
.chest-item {
    width: 140px;
    height: 130px;
    margin: 0 5px;
    border-bottom: 4px solid transparent;
    /* Colored dynamically */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

/* Top line highlight matching image */
.chest-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 3px;
    background: inherit;
    /* Will inherit color from JS style */
    border-radius: 0 0 4px 4px;
    opacity: 0.8;
}

.chest-item img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    filter: drop-shadow(0 10px 10px rgba(0, 0, 0, 0.5));
    z-index: 1;
}

.chest-item span {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    color: #fff;
    margin-top: 8px;
    white-space: nowrap;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    z-index: 1;
}

.chest-item small {
    display: block;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 2px;
}

/* Center Marker - White Triangle / Line */
.chest-marker {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 100%;
    background: rgba(255, 255, 255, 0.3);
    z-index: 10;
}

.chest-marker::before,
.chest-marker::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
}

.chest-marker::before {
    top: -5px;
    border-top: 10px solid white;
}

.chest-marker::after {
    bottom: -5px;
    border-bottom: 10px solid white;
}

/* Button */
.chest-actions {
    text-align: center;
    width: 100%;
}

.chest-btn {
    background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
    /* Blue Button */
    color: white;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    font-weight: 700;
    text-transform: none;
    /* "Ücretsiz aç" */
    font-size: 1.1rem;
    padding: 14px 40px !important;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 0 #1d4ed8;
    /* 3D effect */
    transition: transform 0.1s;
    margin-bottom: 5px;
}

.chest-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #1d4ed8;
}

/* "Kalan dönüşler: 0" text */
.spins-left-text {
    color: #64748b;
    font-size: 0.9rem;
    margin-top: 10px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
}


/* Preview Grid - Bottom */
.chest-preview {
    width: 100%;
    text-align: left;
    border-top: none;
    padding-top: 20px;
}

.chest-preview h4 {
    color: #fff;
    margin-bottom: 15px;
    font-size: 1.1rem;
    font-weight: 700;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 12px;
    max-height: 400px;
    /* Expand height */
    overflow-y: visible;
}

.preview-item {
    height: 140px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: transform 0.2s;
    /* Bottom border colored by rarity in JS */
}

.preview-item:hover {
    transform: translateY(-5px);
    z-index: 5;
    background: #253347;
}

.preview-item img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    margin-bottom: 10px;
    filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.3));
}

.preview-item span {
    font-size: 0.85rem;
    color: #fff;
    font-weight: 700;
    text-align: center;
    line-height: 1.2;
}

.preview-item small {
    display: block;
    font-size: 0.75rem;
    color: #fbbf24;
    /* Gold for price */
    margin-top: 4px;
}

/* Rarity Colors Top Bar in Preview */
.preview-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 3px;
    background: inherit;
    /* Set via Inline Style border-color hack or separate element */
    border-radius: 0 0 4px 4px;
}

/* Result Popup Animation */
@keyframes chestPopupReveal {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }

    60% {
        transform: translate(-50%, -50%) scale(1.05);
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

@keyframes prizeGlow {
    0% {
        filter: drop-shadow(0 0 10px currentColor);
    }

    50% {
        filter: drop-shadow(0 0 30px currentColor);
    }

    100% {
        filter: drop-shadow(0 0 10px currentColor);
    }
}

#chest-result.active {
    display: flex !important;
    animation: chestPopupReveal 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

#chest-result {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: #0f172a;
    border: 2px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    padding: 35px;
    text-align: center;
    box-shadow: 0 0 100px rgba(0, 0, 0, 0.9);
    z-index: 15000;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 300px;
}

#chest-result h3 {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    font-weight: 800;
    font-size: 2rem;
    margin: 0;
    background: linear-gradient(180deg, #fff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 2px;
}

#c-result-msg {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    font-weight: 700;
    font-size: 1.5rem;
    margin-top: 10px;
}

#c-result-img {
    margin: 25px 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

#c-result-img img {
    width: 130px;
    height: 130px;
    object-fit: contain;
    animation: prizeGlow 2s infinite ease-in-out;
}

#chest-result button {
    background: #6366f1;
    border: none;
    padding: 14px 40px;
    border-radius: 12px;
    color: white;
    font-weight: 800;
    font-size: 1.1rem;
    margin-top: 15px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
    transition: 0.2s;
    text-transform: uppercase;
}

#chest-result button:hover {
    transform: translateY(-2px);
    background: #4f46e5;
}