Is it illegal if the landlord refuses to refund the deposit and makes a mess when I leave?

There are no clear legal regulations on whether the room can be soiled or messed up when renting out, so it is not illegal. Both parties should handle it according to the agreement or trading habits.

Relevant legal provisions

"People's Republic of China and Civil Code"

Article 510: After the contract comes into effect, the parties shall If the remuneration, place of performance, etc. are not agreed upon or the agreement is unclear, they may be supplemented by agreement; if a supplementary agreement cannot be reached, they shall be determined in accordance with the relevant terms of the contract or transaction practices.

Article 709 The lessee shall use the leased property in accordance with the agreed method. If there is no agreement on the use of the leased object or the agreement is unclear, and it cannot be determined according to the provisions of Article 510 of this Law, the use shall be based on the nature of the leased object.

Article 710 If the lessee uses the leased property in accordance with the agreed method or according to the nature of the leased property, causing damage to the leased property, he shall not be liable for compensation.

Article 711 If the lessee fails to use the leased property in accordance with the agreed method or in accordance with the nature of the leased property, causing losses to the leased property, the lessor may terminate the contract and request compensation for losses.