.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 1000;

    /* 使用 visibility 和 opacity 代替 display */
    visibility: hidden;
    opacity: 0;

    /* 始终使用 flex 布局，确保居中 */
    display: flex;
    align-items: center;
    justify-content: center;

    /* 平滑过渡 */
    transition: opacity 0.3s ease-out, visibility 0.3s ease-out;
}

.modal-overlay.active {
    visibility: visible;
    opacity: 1;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-container {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    width: 90%;
    max-width: 450px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;

    /* 默认不添加动画，需要时通过类名添加 */
}

/* 为登录和注册表单添加滑入动画 */
#loginModal .modal-container,
#registerModal .modal-container {
    animation: slideUp 0.4s ease-out;
}

.modal-container::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.modal-container {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 35px;
    height: 35px;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    color: #666;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.2);
    transform: rotate(90deg);
}

.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 35px 30px;
    text-align: center;
    color: white;
}

.modal-header h2 {
    font-size: 1.8rem;
    margin-bottom: 8px;
}

.modal-header p {
    opacity: 0.9;
    font-size: 0.95rem;
}

.modal-form {
    padding: 35px 30px;
}
