/* ========================================
   TREASURE SPRITE SYSTEM - CLEAN VERSION
   ======================================== */

/* Container */
.treasure-sprite-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 16px;
    width: 160px;
    height: 160px;
    flex-shrink: 0;
}

/* Small note below treasure (claim limitation) */
.treasure-claim-note {
    position: absolute;
    bottom: -18px; /* place just below container */
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.6);
    text-align: center;
    width: 200px;
    line-height: 1.2;
    pointer-events: none;
}

/* Cell - outer container with border and effects */
.treasure-sprite-cell {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 160px;
    height: 160px;
    background: linear-gradient(135deg, rgba(74, 222, 128, 0.1), rgba(34, 197, 94, 0.05));
    border: 4px solid rgba(74, 222, 128, 0.3);
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(74, 222, 128, 0.2);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: transform 0.15s ease-in-out, border-color 0.3s ease, box-shadow 0.3s ease;
}

.treasure-sprite-cell:hover {
    transform: scale(1.05);
    border-color: rgba(74, 222, 128, 0.6);
    box-shadow: 0 8px 32px rgba(74, 222, 128, 0.3);
}

/* Wrap - inner container for the sprite */
.treasure-sprite-wrap {
    position: relative;
    width: 128px;
    height: 128px;
    overflow: hidden;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.05);
}

/* Canvas (hidden) */
.treasure-sprite-wrap canvas.treasure-canvas {
    position: absolute;
    width: 128px;
    height: 128px;
    opacity: 0;
    pointer-events: none;
    z-index: 1;
}

/* Sprite image - the actual sprite display */
.treasure-sprite-wrap::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 128px;
    height: 128px;
    background-image: url('../coleccion-cajas-tesoro-antiguas-diseno-plano.png');
    background-repeat: no-repeat;
    background-size: 256px 256px; /* 2x2 grid: each quadrant is 128px when total is 256px */
    background-position: 0px 0px; /* Start with top-left quadrant */
    image-rendering: -moz-crisp-edges;
    image-rendering: -webkit-crisp-edges;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    z-index: 2;
    /* Default animation - will be overridden by JavaScript */
    animation: treasure-auto-animate 4s steps(2, end) infinite;

    /* Slightly enlarge only the treasure image (not the frame) */
    transform: scale(1.12);
    transform-origin: center;
}

/* Auto animation keyframes - exactly like test-farm.html but doubled */
@keyframes treasure-auto-animate {
    0% { background-position: 0px 0px; }      /* Top-left quadrant */
    50% { background-position: -128px 0px; }   /* Top-right quadrant */
    100% { background-position: 0px 0px; }    /* Back to top-left quadrant */
}

/* Pause animation on hover */
.treasure-sprite-cell:hover .treasure-sprite-wrap::before {
    animation-play-state: paused;
}

/* Glow effect */
.treasure-sprite-cell::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border: 2px solid rgba(74, 222, 128, 0.5);
    border-radius: 20px;
    animation: treasure-glow 4s infinite;
    pointer-events: none;
    z-index: 1;
}

@keyframes treasure-glow {
    0%, 100% {
        box-shadow: 0 0 16px rgba(74, 222, 128, 0.4);
        border-color: rgba(74, 222, 128, 0.6);
    }
    50% {
        box-shadow: 0 0 24px rgba(255, 215, 0, 0.5);
        border-color: rgba(255, 215, 0, 0.7);
    }
}

/* Click hint */
.treasure-sprite-cell::before {
    content: '👆';
    position: absolute;
    top: -50px;
    right: -20px;
    font-size: 32px;
    opacity: 0;
    animation: click-hint 3s infinite;
    pointer-events: none;
    z-index: 10;
}

@keyframes click-hint {
    0%, 90% { opacity: 0; transform: translateY(0); }
    5%, 15% { opacity: 1; transform: translateY(-6px); }
    10% { opacity: 0.7; transform: translateY(0); }
}

/* Hide hint after click */
.treasure-sprite-cell.clicked::before {
    display: none;
}

/* Pulse effect */
.treasure-sprite-cell.pulse {
    animation: treasure-pulse 0.6s ease-in-out;
}

@keyframes treasure-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Responsive */
@media (max-width: 768px) {
    .treasure-sprite-container {
        width: 120px;
        height: 120px;
        margin-right: 10px;
        margin-bottom: 10px;
    }
    
    .treasure-sprite-cell {
        width: 120px;
        height: 120px;
        border: 3px solid rgba(74, 222, 128, 0.3);
        border-radius: 12px;
    }
    
    .treasure-sprite-wrap {
        width: 96px;
        height: 96px;
        border-radius: 9px;
    }
    
    .treasure-sprite-wrap::before {
        width: 96px;
        height: 96px;
        background-size: 192px 192px;
    }
    
    .treasure-sprite-wrap canvas.treasure-canvas {
        width: 96px;
        height: 96px;
    }
    
    .treasure-sprite-cell::before {
        font-size: 24px;
        top: -35px;
        right: -15px;
    }
}