html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: Arial, sans-serif;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #2c2f36;
}

#topbar {
  flex-shrink: 0;
  height: 50px;
  background: #1f2328;
  color: white;
  padding: 10px 20px;
  font-weight: 700;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 5px rgba(0,0,0,0.15);
  user-select: none;
}

.title-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

#chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-title {
  font-family: 'Minecraft', Arial, sans-serif;
  font-size: 24px;
  letter-spacing: 1px;
}

.chat-logo {
  height: 42px;
  width: auto;
  object-fit: contain;
}

.auth-button {
  background: white;
  border: none;
  color: black;
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: background-color 0.3s, color 0.3s;
  display: flex;
  align-items: center;
}

.auth-button:hover {
  background-color: #f0f0f0;
  color: black;
}

.auth-button.primary {
  background: #1f2328;
  color: white;
  border: 1px solid #444b56;
}

.auth-button.primary:hover {
  background: #2c2f36;
  color: white;
}

.auth-button .button-icon {
  width: 16px;
  height: 16px;
  margin-right: 6px;
  position: relative;
  top: 2px;
}

#logout-button {
  background: transparent;
  border: 1.5px solid white;
  color: white;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: background-color 0.3s, color 0.3s;
}

#logout-button:hover {
  background-color: white;
  color: #3498db;
}

#log {
  flex: 1;
  flex-grow: 1;
  overflow-y: auto;
  padding: 10px;
  background: #2c2f36;
  box-sizing: border-box;
}

.message {
  position: relative;
  width: 100%;
  max-width: 100%;
  margin-bottom: 12px;
  padding: 12px 15px;
  border-radius: 8px;
  background: #32363d;
  color: #e0e0e0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  word-wrap: break-word;
  box-sizing: border-box;
  animation: slideUp 0.3s ease-out;
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.85em;
  margin-bottom: 4px;
  color: #555;
}

.message-content {
  color: #ffffff;
  line-height: 1.4;
  padding-bottom: 8px;
  margin-right: 60px;
  word-break: break-word;
}

.sender, .username {
  font-weight: bold;
  display: block;
  margin-bottom: 5px;
}

.sender {
  color: #ffffff;
}

.username {
  color: #3498db;
  font-size: 0.95em;
}

.password-group {
  position: relative;
}

.password-group .password-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.2s ease;
  filter: invert(1);
}

.password-group .password-toggle:hover {
  opacity: 1;
}

.timestamp {
  position: absolute;
  right: 10px;
  bottom: 5px;
  font-size: 0.9em;
  color: #8a8f98;
  cursor: default;
}

.timestamp::after {
  content: attr(data-fulltime);
  position: absolute;
  bottom: 100%;
  right: 0;
  background: rgba(32, 36, 42, 0.9);
  color: white;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 1em;
  white-space: nowrap;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 10;
}

.timestamp:hover::after {
  visibility: visible;
  opacity: 1;
}

.options-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 16px;
  height: 16px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  display: none;
}

.options-btn img {
  width: 100%;
  height: 100%;
  filter: brightness(0) invert(1);
}

.message.own:hover .options-btn {
  display: block;
}

.options-menu {
  position: absolute;
  top: 28px;
  right: 0;
  display: flex;
  flex-direction: column;
  background: #2c2f36;
  border-radius: 6px;
  padding: 4px 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  z-index: 10;
}

.option-btn, .options-menu button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: #fff;
  font-size: 0.85em;
  transition: background 0.2s;
}

.options-menu button {
  gap: 8px;
  font-size: 0.9em;
  padding: 6px 12px;
}

.options-menu button:hover {
  background: #40444b;
}

.options-menu button img {
  width: 16px;
  height: 16px;
  filter: brightness(0) invert(1);
}

#form {
  flex-shrink: 0;
  min-height: 60px;
  max-height: 200px;
  padding: 10px;
  background: #1f2328;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  box-sizing: border-box;
  position: relative;
}

#form:not(.expanded) {
  align-items: center;
}

#msg {
  flex: 1;
  padding: 10px;
  border: 1px solid #444b56;
  border-radius: 4px;
  min-width: 0;
  background: #262b33;
  color: #e0e0e0;
  min-height: 40px;
  max-height: 180px;
  line-height: 1.4;
  overflow-y: hidden;
  white-space: pre-wrap;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: #444b56 #262b33;
}

#msg::-webkit-scrollbar {
  width: 6px;
}

#msg::-webkit-scrollbar-track {
  background: #262b33;
}

#msg::-webkit-scrollbar-thumb {
  background: #444b56;
  border-radius: 3px;
}

#msg::-webkit-scrollbar-thumb:hover {
  background: #555;
}

#msg:focus {
  outline: 2px solid rgba(52,152,219,0.7);
  outline-offset: 0;
  border-color: #3498db;
  box-shadow: none;
}

#form input[type="submit"] {
  padding: 10px 20px;
  background: #3498db;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.3s;
}

#form input[type="submit"]:hover {
  background: #277bb5;
}

#scrollToBottom {
  position: fixed;
  right: 20px;
  bottom: 70px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #3498db;
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  display: none;
  z-index: 100;
  transition: background 0.3s, bottom 0.3s;
}

#scrollToBottom:hover {
  background: #277bb5;
}

#scrollToBottom.show {
  display: block;
}

#login-modal, #register-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}

#login-modal .modal-content, #register-modal .modal-content {
  background: #2c2f36;
  padding: 32px;
  border-radius: 12px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.7);
  box-sizing: border-box;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  color: #e0e0e0;
}

#login-modal h2, #register-modal h2 {
  margin-bottom: 5px;
  font-size: 24px;
  font-weight: 700;
  color: #e0e0e0;
  background: #2c2f36;
}

#login-modal .subtitle, #register-modal .subtitle {
  font-size: 14px;
  color: #e0e0e0;
  background: #2c2f36;
  margin-bottom: 25px;
}

.input-group {
  position: relative;
  margin-bottom: 22px;
  text-align: left;
  box-sizing: border-box;
}

.input-group input {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  border: 1px solid #555;
  border-radius: 6px;
  background: #2c2f36;
  box-sizing: border-box;
  outline: none;
  color: #e0e0e0;
}

.input-group input:focus {
  border-color: #3498db;
  box-shadow: 0 0 5px #3498db;
}

.input-group.floating label {
  background: transparent;
  padding: 0 4px;
  position: absolute;
  top: 12px;
  left: 12px;
  font-size: 14px;
  color: #e0e0e0;
  pointer-events: none;
  transition: 0.2s ease all;
}

.input-group.floating input:focus + label,
.input-group.floating input:not(:placeholder-shown) + label {
  top: -10px;
  left: 8px;
  font-size: 12px;
  color: #3498db;
  background: #2c2f36;
  padding: 0 4px;
}

#login-modal button, #register-modal button {
  width: 100%;
  padding: 12px 0;
  background-color: #3498db;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.3s;
  margin-top: 10px;
}

#login-modal button:hover, #register-modal button:hover {
  background-color: #277bb5;
}

#login-error, #register-error {
  color: #e74c3c;
  font-size: 14px;
  min-height: 18px;
  margin-bottom: 10px;
  text-align: left;
}

#toggle-to-register-container, #toggle-to-login-container {
  margin-top: 18px;
  font-size: 14px;
  color: #8a8f98;
  user-select: none;
}

#toggle-to-register, #toggle-to-login {
  color: #3498db;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.3s;
}

#toggle-to-register:hover, #toggle-to-login:hover {
  color: #277bb5;
}

#log::-webkit-scrollbar {
  width: 8px;
}

#log::-webkit-scrollbar-track {
  background: transparent;
}

#log::-webkit-scrollbar-thumb {
  background-color: rgba(136, 136, 136, 0.25);
  border-radius: 4px;
  transition: background-color 0.2s;
}

#log::-webkit-scrollbar-thumb:hover {
  background-color: rgba(136, 136, 136, 0.5);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 950;
}

#group-icon {
  width: 32px; 
  height: 32px;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: transform 0.2s, background-color 0.2s;
  filter: invert(1) brightness(2);
}

#group-icon:hover {
  transform: scale(1.2);
  background-color: rgba(255, 255, 255, 0.1);
}

#group-icon.active {
  background-color: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

#online-users-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 280px;
  max-width: 100%;
  height: 100vh;
  background: linear-gradient(180deg, #2f3136 0%, #23262a 100%);
  color: #dcddde;
  padding: 20px;
  box-shadow: -4px 0 12px rgba(0, 0, 0, 0.4);
  z-index: 1000;
  transform: translateX(100%);
  transition: transform 0.3s ease-in-out;
  display: flex;
  flex-direction: column;
  font-family: 'Arial', sans-serif;
  user-select: none;
}

#online-users-panel::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  z-index: -1;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
  pointer-events: none;
}

#online-users-panel.visible::before {
  opacity: 1;
}

#online-users-panel.visible {
  transform: translateX(0);
}

#online-users-panel .panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid #3f4147;
}

#online-users-panel h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.5px;
}

#close-panel-button {
  background: none;
  border: none;
  color: #dcddde;
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  border-radius: 4px;
  transition: background-color 0.2s, color 0.2s;
}

#close-panel-button:hover {
  background-color: #23262a;
  color: #ffffff;
}

#online-users-list {
  list-style: none;
  padding: 0;
  margin: 0;
  flex-grow: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #43b581 #2f3136;
}

#online-users-list::-webkit-scrollbar {
  width: 6px;
}

#online-users-list::-webkit-scrollbar-track {
  background: #2f3136;
}

#online-users-list::-webkit-scrollbar-thumb {
  background-color: #43b581;
  border-radius: 3px;
}

#online-users-list li {
  display: flex;
  align-items: center;
  padding: 10px 8px;
  font-size: 16px;
  color: #dcddde;
  border-radius: 4px;
  transition: background-color 0.2s;
  margin-bottom: 4px;
  user-select: none;
}

#online-users-list li:hover {
  background-color: #36393f;
}

#online-users-list li:last-child {
  margin-bottom: 0;
}

#online-users-list .status-indicator {
  display: inline-block;
  width: 12px;
  height: 12px;
  background-color: #43b581;
  border-radius: 50%;
  margin-right: 12px;
  box-shadow: 0 0 6px rgba(67, 181, 129, 0.5);
  animation: pulse 2s infinite ease-in-out;
}

#online-users-list .user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  margin-right: 10px;
  background-color: #444b56;
}

.day-separator {
  display: flex;
  align-items: center;
  text-align: center;
  color: #888;
  font-size: 14px;
  margin: 20px 0;
}

.day-separator::before,
.day-separator::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid #ccc;
}

.day-separator:not(:empty)::before {
  margin-right: 10px;
}

.day-separator:not(:empty)::after {
  margin-left: 10px;
}

@keyframes pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 6px rgba(67, 181, 129, 0.5);
  }
  50% {
    transform: scale(1.2);
    box-shadow: 0 0 10px rgba(67, 181, 129, 0.8);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 6px rgba(67, 181, 129, 0.5);
  }
}

@font-face {
  font-family: 'Minecraft';
  src: url('/chat/font/Minecraft_1.1.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 768px) {
  #topbar {
    padding: 10px 15px;
    font-size: 18px;
    height: 45px;
  }

  .chat-title {
    font-size: 20px;
  }

  .chat-logo {
    height: 35px;
  }

  .auth-button {
    padding: 5px 12px;
    font-size: 13px;
  }

  .auth-button .button-icon {
    width: 14px;
    height: 14px;
    margin-right: 4px;
  }

  #logout-button {
    padding: 5px 12px;
    font-size: 13px;
  }

  #log {
    padding: 8px;
  }

  .message {
    padding: 10px 12px;
    margin-bottom: 10px;
    border-radius: 6px;
  }

  .message-content {
    margin-right: 40px;
    font-size: 14px;
  }

  .username {
    font-size: 0.9em;
  }

  .timestamp {
    font-size: 0.8em;
    right: 8px;
    bottom: 4px;
  }

  .options-btn {
    width: 14px;
    height: 14px;
    top: 6px;
    right: 6px;
  }

  #form {
    min-height: 55px;
    padding: 8px;
    gap: 8px;
  }

  #msg {
    padding: 8px;
    font-size: 14px;
  }

  #form input[type="submit"] {
    padding: 8px 15px;
    font-size: 14px;
  }

  #scrollToBottom {
    right: 15px;
    bottom: 65px;
    width: 35px;
    height: 35px;
  }

  #login-modal .modal-content, #register-modal .modal-content {
    padding: 25px;
    max-width: 90%;
  }

  #login-modal h2, #register-modal h2 {
    font-size: 22px;
  }

  .input-group input {
    padding: 10px;
    font-size: 14px;
  }

  .input-group.floating label {
    font-size: 13px;
    top: 10px;
    left: 10px;
  }

  .input-group.floating input:focus + label,
  .input-group.floating input:not(:placeholder-shown) + label {
    top: -8px;
    left: 6px;
    font-size: 11px;
  }

  #login-modal button, #register-modal button {
    padding: 10px 0;
    font-size: 15px;
  }

  .topbar-actions {
    gap: 10px;
  }

  #group-icon {
    width: 28px;
    height: 28px;
    padding: 3px;
  }

  #online-users-panel {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 10px;
    left: 0;
    right: 0;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    position: fixed;
    top: 56px;
    z-index: 50;
  }

  #online-users-panel,
  #online-users-panel * {
    max-width: 100%;
    box-sizing: border-box;
  }

  #online-users-list {
    overflow-x: hidden;
    white-space: normal;
  }

  #online-users-list li {
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .day-separator {
    font-size: 12px;
    margin: 15px 0;
  }

  #log {
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .message {
    animation: slideUp 0.3s ease-out;
  }
}

@media (max-width: 480px) {
  #topbar {
    padding: 10px 10px;
    font-size: 16px;
    height: 40px;
  }

  .chat-title {
    font-size: 18px;
  }

  .chat-logo {
    height: 30px;
  }

  .auth-button {
    padding: 4px 10px;
    font-size: 12px;
  }

  #form {
    min-height: 50px;
    padding: 6px;
    gap: 6px;
  }

  #msg {
    padding: 6px;
    font-size: 13px;
  }

  #form input[type="submit"] {
    padding: 6px 12px;
    font-size: 13px;
  }

  #scrollToBottom {
    right: 10px;
    bottom: 60px;
    width: 30px;
    height: 30px;
  }

  #login-modal .modal-content, #register-modal .modal-content {
    padding: 20px;
  }

  #login-modal h2, #register-modal h2 {
    font-size: 20px;
  }

  .input-group {
    margin-bottom: 18px;
  }

  #online-users-panel {
    padding: 10px;
  }

  #online-users-panel h3 {
    font-size: 14px;
  }

  #close-panel-button {
    font-size: 16px;
    padding: 5px;
  }

  #online-users-list li {
    font-size: 13px;
    padding: 6px 4px;
  }

  #online-users-list .status-indicator {
    width: 8px;
    height: 8px;
    margin-right: 8px;
  }

  #online-users-list .user-avatar {
    width: 20px;
    height: 20px;
    margin-right: 6px;
  }
}