.nsip-overlay {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at top, rgba(255,255,255,0.12) 0, transparent 55%),
        radial-gradient(circle at bottom, rgba(0,0,0,0.95) 0, rgba(0,0,0,1) 65%);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    padding: 20px;
    box-sizing: border-box;
    overflow: hidden;
}

/* Dragones estilizados detrás del castillo */
.nsip-overlay::before,
.nsip-overlay::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 220px;
    height: 260px;
    background:
        radial-gradient(circle at 30% 25%, rgba(255,255,255,0.35) 0, transparent 45%),
        radial-gradient(circle at 70% 35%, rgba(255,255,255,0.2) 0, transparent 50%),
        radial-gradient(circle at 50% 100%, rgba(0,0,0,1) 0, transparent 70%);
    opacity: 0.16;
    filter: blur(1px);
    pointer-events: none;
    z-index: 1;
}

.nsip-overlay::before {
    left: 4%;
    transform: translateY(-50%) rotate(-16deg);
}

.nsip-overlay::after {
    right: 4%;
    transform: translateY(-50%) rotate(16deg) scaleX(-1);
}

.nsip-popup {
    position: relative;
    background: #25252e;
    border-radius: 20px;
    border: 6px solid #b7b7c2;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    box-shadow:
        0 0 0 4px #3f3f48,
        0 24px 52px rgba(0,0,0,0.85);
    padding: 44px 18px 18px 18px; /* espacio superior para almenas */
    box-sizing: border-box;
    z-index: 3;
}

/* Almenas tipo castillo */
.nsip-popup::before {
    content: "";
    position: absolute;
    top: 0;
    left: -8px;
    right: -8px;
    height: 28px;
    background:
        repeating-linear-gradient(
            to right,
            #d0d2da 0,
            #d0d2da 34px,
            #25252e 34px,
            #25252e 50px
        );
    border-bottom: 3px solid #9f9fa4;
    border-radius: 14px 14px 0 0;
    box-shadow:
        0 4px 0 rgba(0,0,0,0.45),
        0 8px 14px rgba(0,0,0,0.7);
    z-index: 0;
}

/* Estandarte medieval */
.nsip-popup::after {
    content: "";
    position: absolute;
    top: 4px;
    left: 32px;
    width: 0;
    height: 0;
    border-right: 16px solid transparent;
    border-left: 0 solid transparent;
    border-bottom: 34px solid #b32424;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.7));
    z-index: 2;
}

.nsip-image-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    padding: 18px;
    box-sizing: border-box;
    background-image:
        linear-gradient(135deg, #30323b 0, #25252e 100%),
        linear-gradient(45deg, rgba(255,255,255,0.06) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.04) 50%, rgba(255,255,255,0.04) 75%, transparent 75%, transparent);
    background-size: auto, 32px 32px;
    background-blend-mode: overlay;
    border-radius: 12px;
    border: 2px solid rgba(255,255,255,0.08);
}

/* Marco dorado interior */
.nsip-image-wrapper::before {
    content: "";
    position: absolute;
    inset: 10px;
    border-radius: 10px;
    background:
        linear-gradient(135deg, rgba(255,255,255,0.15), transparent 32%, transparent 68%, rgba(255,255,255,0.1)),
        linear-gradient(90deg, #9a712e, #ffd27a, #9a712e);
    opacity: 0.28;
    mix-blend-mode: screen;
    pointer-events: none;
}

/* Gárgola central encima del marco */
.nsip-image-wrapper::after {
    content: "";
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 34px;
    background:
        radial-gradient(circle at 25% 40%, #f5f5f5 0, #f5f5f5 2px, transparent 4px),
        radial-gradient(circle at 75% 40%, #f5f5f5 0, #f5f5f5 2px, transparent 4px),
        radial-gradient(circle at 50% 90%, #19191f 0, transparent 70%);
    background-color: #555761;
    border-radius: 50% 50% 40% 40%;
    box-shadow:
        0 4px 6px rgba(0,0,0,0.9),
        0 0 0 2px #3c3e46;
}

.nsip-image-wrapper img {
    display: none;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
    border-radius: 10px;
    border: 3px solid rgba(0,0,0,0.7);
    box-shadow:
        0 16px 30px rgba(0,0,0,0.9),
        0 0 0 1px rgba(255,255,255,0.04);
    position: relative;
    z-index: 1;
}

.nsip-image-wrapper img.nsip-active {
    display: block;
}

.nsip-close {
    position: absolute;
    top: 10px;
    right: 16px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid #dedee5;
    background: radial-gradient(circle at 30% 30%, #fefefe 0, #d8d8e0 35%, #74747e 75%);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    color: #1e1f25;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 3px 6px rgba(0,0,0,0.7),
        inset 0 1px 2px rgba(255,255,255,0.9);
    z-index: 4;
}

.nsip-close:hover {
    filter: brightness(1.08);
    color: #000;
    transform: translateY(-1px);
}

.nsip-close:active {
    transform: translateY(1px);
    box-shadow:
        0 1px 3px rgba(0,0,0,0.85),
        inset 0 1px 3px rgba(0,0,0,0.9);
}

/* Antorchas laterales (glow en los lados del castillo) */
.nsip-popup::marker { /* evitar warnings en algunos navegadores */ }

.nsip-popup .nsip-torch-left,
.nsip-popup .nsip-torch-right {
    display: none;
}

.nsip-overlay .nsip-torch-left,
.nsip-overlay .nsip-torch-right {
    display: none;
}

/* Usamos sombras simuladas sobre el overlay para antorchas */
.nsip-overlay::before {
    box-shadow:
        0 0 30px 10px rgba(255, 179, 71, 0.45),
        0 -80px 120px 20px rgba(255, 179, 71, 0.25);
}

.nsip-overlay::after {
    box-shadow:
        0 0 30px 10px rgba(255, 179, 71, 0.45),
        0 -80px 120px 20px rgba(255, 179, 71, 0.25);
}

@media (max-width: 768px) {
    .nsip-popup {
        padding: 38px 10px 10px 10px;
        border-width: 4px;
    }

    .nsip-popup::before {
        height: 24px;
    }

    .nsip-image-wrapper {
        padding: 12px;
    }

    .nsip-close {
        width: 30px;
        height: 30px;
        font-size: 18px;
    }
}
