</div>`;
                }
            } else {
                messageContent += `<div>${content}</div>`;
            }

            messageEl.innerHTML = messageContent;
            messagesEl.appendChild(messageEl);
            messagesEl.scrollTop = messagesEl.scrollHeight;
        }

        function connect() {
            if (socket && socket.readyState === WebSocket.OPEN) {
                addMessage('system', 'Already connected!');
                return;
            }

            updateStatus('co