e('system', `Server says: ${data.message}`);
                    }
                } catch (e) {
                    addMessage('received', event.data);
                }
            };

            socket.onclose = function (event) {
                updateStatus('disconnected', 'ðŸ”´ Disconnected');
                addMessage('system', `Connection closed. Code: ${event.code}, Reason: ${event.reason || 'Unknown'}`);

                connectionStartTime = null;
                if (connectionTimer) {
   