.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: white;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 1001;
    opacity: 0;
    display: none;
    overflow-y: auto;
    will-change: transform, opacity;
    transition: none;

    /* Default auto-size */
    width: auto;
    min-width: 300px;
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 8px;
    padding: 2rem;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    opacity: 0;
    display: none;
    will-change: opacity;
}

[data-modal-close] {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    line-height: 1;
    transition: transform 0.2s ease;
}

[data-modal-close]:hover {
    transform: rotate(90deg);
}

/* Mobile optimization */
@media (max-width: 576px) {
    .modal {
        padding: 1.5rem;
        max-height: 95vh;
        min-width: 280px;
    }

    .modal-fullscreen {
        padding: 1rem;
    }

    [data-modal-close] {
        top: 0.5rem;
        right: 0.5rem;
    }
}
