:root {
  --bg: #000;
  --fg: #0F0;
  --accent: #4CAF50;
  --error-bg: #300;
  --error-fg: #F00;
  --box-bg: #111;
  --font: 'Courier New', monospace;
}

* {
  box-sizing: border-box;
}

body {
  font-family: var(--font);
  background-color: var(--bg);
  color: var(--fg);
  margin: 0;
  padding: 20px;
  line-height: 1.5;
  transition: background 0.3s, color 0.3s;
}

#login, #chat {
  max-width: 650px;
  margin: auto;
  padding: 25px;
  border: 2px solid var(--fg);
  background-color: var(--box-bg);
  box-shadow: 0 0 15px rgba(0, 255, 0, 0.4);
  border-radius: 10px;
  animation: fadeIn 0.6s ease;
}

h2 {
  color: var(--fg);
  border-bottom: 1px dashed var(--fg);
  padding-bottom: 5px;
  margin-top: 0;
  text-align: center;
}

input, button {
  background-color: var(--bg);
  color: var(--fg);
  border: 1px solid var(--fg);
  padding: 10px;
  margin: 8px 0;
  width: 100%;
  font-family: var(--font);
  outline: none;
  border-radius: 5px;
  transition: all 0.3s ease;
}

input:focus {
  box-shadow: 0 0 8px rgba(0, 255, 0, 0.6);
}

button {
  cursor: pointer;
}

button:hover {
  background-color: var(--fg);
  color: var(--bg);
  box-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
}

#messages {
  background-color: var(--bg);
  border: 1px solid var(--fg);
  padding: 12px;
  height: 300px;
  overflow-y: auto;
  margin-bottom: 10px;
  border-radius: 5px;
  animation: fadeIn 1s ease;
}

.system-message {
  color: #888;
  font-style: italic;
  margin-bottom: 6px;
}

.user-message {
  color: #FFF;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  margin-bottom: 6px;
  animation: messageFade 0.3s ease;
}

.user-message .timestamp {
  color: #888;
  margin-right: 6px;
  font-size: 0.85em;
}

.user-message .username {
  font-weight: bold;
  margin-right: 6px;
}

.user-message .message-text {
  word-break: break-word;
}

#typing-notification {
  color: var(--accent);
  font-style: italic;
  padding: 4px 8px;
  font-size: 0.9em;
  background-color: rgba(0, 255, 0, 0.1);
  border-left: 3px solid var(--accent);
  margin-bottom: 10px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#typing-notification.show {
  opacity: 1;
}

#error {
  background-color: transparent;
  color: var(--error-fg);
  padding: 6px;
  display: none;
  text-align: center;
}

#error.show {
  display: block;
  background-color: var(--error-bg);
  border-radius: 5px;
}

#messages::-webkit-scrollbar {
  width: 10px;
}
#messages::-webkit-scrollbar-track {
  background: var(--bg);
}
#messages::-webkit-scrollbar-thumb {
  background: var(--fg);
}
#messages::-webkit-scrollbar-thumb:hover {
  background: #0C0;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes messageFade {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

#messageInput::after {
  content: "|";
  animation: blink 1s step-end infinite;
}

/* Responsive */
@media only screen and (max-width: 768px) {
  body {
    padding: 10px;
    font-size: 15px;
  }

  #login, #chat {
    width: 95%;
    padding: 20px;
  }

  input, button {
    font-size: 16px;
    padding: 12px;
  }

  #messages {
    height: 50vh;
  }

  #messageInput {
    position: fixed;
    bottom: 10px;
    left: 10px;
    right: 120px;
    width: auto;
    z-index: 99;
  }

  #chat button {
    position: fixed;
    bottom: 10px;
    right: 10px;
    width: 100px;
    z-index: 99;
  }

  #typing-notification {
    position: fixed;
    bottom: 60px;
    left: 10px;
    background: rgba(0,0,0,0.8);
    padding: 6px 12px;
    border-radius: 6px;
    z-index: 100;
  }
}
