/* ==========================================================================
   MINIJUEGO DEL PERRO PIRATA - ESTILOS (Playa de la Suerte)
   ========================================================================== */

/* Botones principales unificados (mismo tamaño, borde blanco y estilo) */
.controls #generateBtn,
.controls .btn-pirate-game,
.controls .btn-tarot-promo {
    width: 100%;
    max-width: 440px;
    background: linear-gradient(135deg, #fde047 0%, #d4af37 50%, #996515 100%) !important;
    color: #07070a !important;
    border: 2px solid #ffffff !important;
    border-radius: 16px !important;
    padding: 0.8rem 1.25rem !important;
    font-size: 1.05rem !important;
    font-weight: 800 !important;
    text-decoration: none !important;
    cursor: pointer;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.85rem !important;
    box-shadow: 0 8px 24px rgba(212, 175, 55, 0.4), inset 0 1px 0 rgba(255,255,255,0.6) !important;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
    position: relative;
    overflow: hidden;
    box-sizing: border-box !important;
    min-height: 64px;
}

.controls #generateBtn:hover,
.controls .btn-pirate-game:hover,
.controls .btn-tarot-promo:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 12px 30px rgba(212, 175, 55, 0.55), inset 0 1px 0 rgba(255,255,255,0.8) !important;
}

.controls #generateBtn:active,
.controls .btn-pirate-game:active,
.controls .btn-tarot-promo:active {
    transform: translateY(1px) scale(0.99);
}

.controls #generateBtn svg {
    flex-shrink: 0;
    stroke-width: 2.5;
}

.btn-pirate-game:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 12px 30px rgba(212, 175, 55, 0.55);
}

.btn-pirate-game:active {
    transform: translateY(1px) scale(0.99);
}

.pirate-avatar-img,
.tarot-promo-img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    background: #0f111a;
    border: 2px solid #07070a;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.btn-pirate-game:hover .pirate-avatar-img,
.btn-tarot-promo:hover .tarot-promo-img {
    transform: rotate(-6deg) scale(1.1);
}

.pirate-btn-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    line-height: 1.2;
}

.pirate-btn-text small {
    font-size: 0.78rem;
    font-weight: 700;
    color: #422006;
    letter-spacing: 0.3px;
    margin-top: 2px;
}

/* Modal del Minijuego */
.pirate-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    box-sizing: border-box;
}

.pirate-modal.hidden {
    display: none !important;
}

.pirate-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(7, 7, 10, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.pirate-game-card {
    position: relative;
    z-index: 2;
    background: #0c0e14;
    border: 2px solid #d4af37;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 35px rgba(212, 175, 55, 0.25);
    width: 100%;
    max-width: 820px;
    max-height: 94vh;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    animation: piratePopIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes piratePopIn {
    0% { transform: scale(0.92); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Header del Minijuego */
.pirate-game-header {
    background: linear-gradient(180deg, #161922 0%, #0d0f17 100%);
    border-bottom: 1px solid rgba(212, 175, 55, 0.3);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.pirate-header-left {
    display: flex;
    flex-direction: column;
}

.pirate-badge {
    font-size: 0.72rem;
    font-weight: 800;
    color: #fde047;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#pirateGameTitle {
    margin: 2px 0 0 0;
    font-size: 1.15rem;
    font-weight: 800;
    color: #ffffff;
}

/* Slots de monedas en el header */
.pirate-slots-row {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.pirate-slot {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.04);
    border: 2px dashed rgba(212, 175, 55, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    font-weight: 800;
    color: rgba(212, 175, 55, 0.5);
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.5);
}

.pirate-slot.filled {
    background: linear-gradient(135deg, #fde047 0%, #d4af37 60%, #b45309 100%);
    border: 2px solid #ffffff;
    color: #07070a;
    font-size: 1.05rem;
    box-shadow: 0 4px 14px rgba(253, 224, 71, 0.5), inset 0 1px 0 rgba(255,255,255,0.8);
    transform: scale(1.08);
}

.pirate-close-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #e2e8f0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.4rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
}

.pirate-close-btn:hover {
    background: #ef4444;
    color: #fff;
    border-color: #ef4444;
}

/* Escenario interactivo */
.pirate-stage-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: 58vh;
    background: #000;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    cursor: default;
    flex-shrink: 0;
    transition: max-height 0.35s ease;
}

.pirate-stage-container.stage-completed {
    max-height: 30vh;
}

.pirate-stage-bg {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

/* Capa interactiva de X */
.pirate-interactive-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: auto;
}

/* Marcas X en la arena */
.sand-x-mark {
    position: absolute;
    width: 44px;
    height: 44px;
    transform: translate(-50%, -50%);
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), filter 0.2s;
    filter: drop-shadow(0 3px 6px rgba(0,0,0,0.45));
    animation: sandXFloat 2.4s ease-in-out infinite alternate;
}

@keyframes sandXFloat {
    0% { transform: translate(-50%, -50%) scale(1); }
    100% { transform: translate(-50%, -50%) scale(1.08); }
}

.sand-x-mark:hover {
    transform: translate(-50%, -50%) scale(1.22);
    filter: drop-shadow(0 0 10px rgba(239, 68, 68, 0.8));
}

.sand-x-mark img {
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
}

/* Cofre desenterrado */
.sand-chest {
    position: absolute;
    width: 62px;
    height: 62px;
    transform: translate(-50%, -50%);
    z-index: 6;
    pointer-events: none;
    animation: chestEmerge 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.6));
}

@keyframes chestEmerge {
    0% { transform: translate(-50%, -10%) scale(0.4); opacity: 0; }
    70% { transform: translate(-50%, -60%) scale(1.15); }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.sand-chest img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Moneda voladora que sale del cofre */
.flying-coin {
    position: absolute;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #fde047 0%, #d4af37 60%, #b45309 100%);
    border: 2px solid #ffffff;
    box-shadow: 0 0 20px #fde047, 0 6px 14px rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    font-weight: 900;
    color: #07070a;
    transform: translate(-50%, -50%);
    z-index: 20;
    pointer-events: none;
    animation: coinPop 0.85s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes coinPop {
    0% { transform: translate(-50%, -50%) scale(0.2); opacity: 0; }
    50% { transform: translate(-50%, -140%) scale(1.3); opacity: 1; }
    100% { transform: translate(-50%, -110%) scale(1.1); opacity: 1; }
}

/* Sprite del Perrito Pirata */
.pirate-dog-sprite {
    position: absolute;
    width: 72px;
    height: 72px;
    transform: translate(-50%, -50%);
    z-index: 10;
    pointer-events: none;
    transition: left 0.75s cubic-bezier(0.25, 0.46, 0.45, 0.94), top 0.75s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5));
}

.pirate-dog-sprite img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.pirate-dog-sprite.flip-left img {
    transform: scaleX(-1);
}

/* Animación de escarbar (sacudida rápida de patitas) */
.pirate-dog-sprite.digging {
    animation: dogDigShake 0.12s linear infinite alternate;
}

@keyframes dogDigShake {
    0% { transform: translate(-50%, -50%) rotate(-4deg); }
    100% { transform: translate(-50%, -46%) rotate(4deg); }
}

/* Partículas de arena */
.sand-particle {
    position: absolute;
    background: #d4a359;
    border-radius: 50%;
    pointer-events: none;
    z-index: 12;
    animation: sandFly 0.5s ease-out forwards;
}

@keyframes sandFly {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(var(--dx), var(--dy)) scale(0.3); opacity: 0; }
}

/* Footer del Minijuego */
.pirate-game-footer {
    background: #0d0f17;
    border-top: 1px solid rgba(212, 175, 55, 0.25);
    padding: 14px 16px 18px;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    text-align: center;
    flex-shrink: 0;
}

.pirate-status-msg {
    font-size: 0.95rem;
    color: #cbd5e1;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

/* Panel de Victoria */
.pirate-win-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
    animation: pirateWinFade 0.4s ease-out;
}

.pirate-win-panel.hidden {
    display: none !important;
}

@keyframes pirateWinFade {
    0% { opacity: 0; transform: translateY(8px); }
    100% { opacity: 1; transform: translateY(0); }
}

.pirate-win-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: #fde047;
}

.pirate-win-balls {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.pirate-win-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 4px;
}

.btn-pirate-restart {
    background: rgba(255, 255, 255, 0.08);
    color: #f1f5f9;
    border: 1px solid rgba(212, 175, 55, 0.4);
    padding: 0.6rem 1.1rem;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-pirate-restart:hover {
    background: rgba(212, 175, 55, 0.18);
    border-color: #fde047;
}

/* Adaptación Mobile */
@media (max-width: 640px) {
    .controls #generateBtn,
    .controls .btn-pirate-game {
        width: 100%;
        max-width: 100%;
        padding: 0.75rem 0.9rem !important;
        font-size: 0.98rem !important;
        min-height: 62px;
    }
    .pirate-avatar-img {
        width: 42px;
        height: 42px;
    }
    .pirate-btn-text {
        font-size: 0.96rem;
    }
    .pirate-btn-text small {
        font-size: 0.75rem;
    }
    .pirate-slots-row {
        gap: 5px;
    }
    .pirate-slot {
        width: 32px;
        height: 32px;
        font-size: 0.82rem;
    }
    .sand-x-mark {
        width: 38px;
        height: 38px;
    }
    .pirate-dog-sprite {
        width: 58px;
        height: 58px;
    }
    .sand-chest {
        width: 52px;
        height: 52px;
    }
    .pirate-stage-container {
        aspect-ratio: 4 / 3;
        max-height: 46vh;
    }
    .pirate-stage-container.stage-completed {
        max-height: 22vh;
    }
}


/* Panel de Límite Diario / Recarga MercadoPago */
.pirate-limit-box {
    padding: 1.5rem;
    text-align: center;
    background: linear-gradient(135deg, rgba(212,175,55,0.15) 0%, rgba(7,7,10,0.95) 100%);
    border: 2px solid #d4af37;
    border-radius: 16px;
    margin: 1rem auto;
    max-width: 500px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.6);
}

.pirate-limit-box h3 {
    color: #fde047;
    font-size: 1.3rem;
    margin: 0 0 0.5rem 0;
}

.pirate-limit-box p {
    color: #cbd5e1;
    font-size: 0.92rem;
    line-height: 1.5;
    margin: 0 0 1.2rem 0;
}

.btn-pirate-mp {
    background: linear-gradient(135deg, #009ee3 0%, #007eb5 100%);
    color: #ffffff;
    border: none;
    padding: 0.85rem 1.4rem;
    font-size: 1rem;
    font-weight: 800;
    border-radius: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 16px rgba(0, 158, 227, 0.4);
    transition: all 0.2s;
    width: 100%;
}

.btn-pirate-mp:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 158, 227, 0.6);
}
