/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Authentication Container */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.auth-box {
  background: white;
  padding: 40px;
  border-radius: 15px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.auth-box h2 {
  color: #333;
  margin-bottom: 10px;
  font-size: 28px;
  font-weight: 600;
}

.auth-box p {
  color: #666;
  margin-bottom: 30px;
  font-size: 16px;
}

/* Authentication Forms */
.auth-form {
  text-align: left;
}

.auth-form h3 {
  color: #333;
  margin-bottom: 20px;
  font-size: 20px;
  font-weight: 500;
}

.auth-form input {
  width: 100%;
  padding: 15px;
  margin-bottom: 15px;
  border: 2px solid #e1e5e9;
  border-radius: 8px;
  font-size: 16px;
  transition: border-color 0.3s ease;
}

.auth-form input:focus {
  outline: none;
  border-color: #667eea;
}

.auth-btn {
  width: 100%;
  padding: 15px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease;
  margin-bottom: 20px;
}

.auth-btn:hover {
  transform: translateY(-2px);
}

.auth-form p {
  text-align: center;
  margin-top: 15px;
}

.auth-form a {
  color: #667eea;
  text-decoration: none;
  font-weight: 500;
}

.auth-form a:hover {
  text-decoration: underline;
}

/* Error Message */
.error-message {
  color: #e74c3c;
  background: #fdf2f2;
  padding: 10px;
  border-radius: 5px;
  margin-top: 15px;
  display: none;
  font-size: 14px;
}

/* Main Content */
.main-content {
  width: 100%;
  min-height: 100vh;
  background: white;
  padding: 20px;
}

.user-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8f9fa;
  padding: 15px 20px;
  border-radius: 8px;
  margin-bottom: 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.user-info span {
  font-weight: 500;
  color: #333;
}

.logout-btn {
  background: #e74c3c;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.3s ease;
}

.logout-btn:hover {
  background: #c0392b;
}

/* Game container */
.gameloc {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 20px 0;
}

/* Responsive Design */
@media (max-width: 480px) {
  .auth-box {
    padding: 30px 20px;
    margin: 10px;
  }
  
  .auth-box h2 {
    font-size: 24px;
  }
  
  .main-content {
    padding: 15px;
  }
  
  .user-info {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }
}

/* Loading animation */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Floating Chat Window */
.chat-window {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 350px;
  height: 500px;
  background: white;
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: all 0.3s ease;
  border: 1px solid #e1e5e9;
}

.chat-window.collapsed {
  height: 60px;
}

.chat-window.collapsed .chat-body {
  display: none;
}

.chat-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 15px 20px;
  border-radius: 15px 15px 0 0;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  transition: background 0.3s ease;
}

.chat-header:hover {
  background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
}

.chat-title {
  font-size: 16px;
}

.chat-toggle {
  font-size: 20px;
  font-weight: bold;
  transition: transform 0.3s ease;
}

.chat-window.collapsed .chat-toggle {
  transform: rotate(180deg);
}

.chat-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #f8f9fa;
}

.chat-messages {
  flex: 1;
  padding: 15px;
  overflow-y: auto;
  max-height: 350px;
}

.message {
  margin-bottom: 15px;
  display: flex;
  flex-direction: column;
}

.message.user {
  align-items: flex-end;
}

.message.system {
  align-items: flex-start;
}

.message-time {
  font-size: 11px;
  color: #999;
  margin-bottom: 5px;
}

.message-content {
  padding: 10px 15px;
  border-radius: 18px;
  max-width: 80%;
  word-wrap: break-word;
  font-size: 14px;
  line-height: 1.4;
}

.message.user .message-content {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-bottom-right-radius: 5px;
}

.message.system .message-content {
  background: white;
  color: #333;
  border: 1px solid #e1e5e9;
  border-bottom-left-radius: 5px;
}

.chat-input-container {
  padding: 15px;
  background: white;
  border-top: 1px solid #e1e5e9;
  display: flex;
  gap: 10px;
  align-items: center;
}

#chat-input {
  flex: 1;
  padding: 12px 15px;
  border: 2px solid #e1e5e9;
  border-radius: 25px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.3s ease;
}

#chat-input:focus {
  border-color: #667eea;
}

.send-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 25px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: transform 0.2s ease;
  min-width: 60px;
}

.send-btn:hover {
  transform: translateY(-1px);
}

.send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Chat animations */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message {
  animation: slideIn 0.3s ease;
}

/* Responsive chat */
@media (max-width: 480px) {
  .chat-window {
    width: calc(100vw - 40px);
    height: 400px;
    bottom: 10px;
    right: 20px;
    left: 20px;
  }
  
  .chat-messages {
    max-height: 250px;
  }
}

/* Scrollbar styling for chat */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.modal-content {
  background: white;
  padding: 30px;
  border-radius: 15px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  width: 90%;
  max-width: 400px;
  text-align: center;
}

.modal-content h3 {
  color: #333;
  margin-bottom: 10px;
  font-size: 24px;
  font-weight: 600;
}

.modal-content p {
  color: #666;
  margin-bottom: 20px;
  font-size: 16px;
}

.modal-content input {
  width: 100%;
  padding: 15px;
  border: 2px solid #e1e5e9;
  border-radius: 8px;
  font-size: 16px;
  margin-bottom: 20px;
  outline: none;
  transition: border-color 0.3s ease;
}

.modal-content input:focus {
  border-color: #667eea;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.save-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.save-btn:hover {
  transform: translateY(-2px);
}

/* Updated Chat Message Styles */
.message {
  margin-bottom: 15px;
  display: flex;
  flex-direction: column;
  animation: slideIn 0.3s ease;
}

.message.user {
  align-items: flex-end;
}

.message.system {
  align-items: flex-start;
}

.message.other-user {
  align-items: flex-start;
}

.message-time {
  font-size: 11px;
  color: #999;
  margin-bottom: 5px;
}

.message-username {
  font-size: 12px;
  font-weight: 600;
  color: #667eea;
  margin-bottom: 3px;
}

.message-content {
  padding: 10px 15px;
  border-radius: 18px;
  max-width: 80%;
  word-wrap: break-word;
  font-size: 14px;
  line-height: 1.4;
}

.message.user .message-content {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-bottom-right-radius: 5px;
}

.message.system .message-content {
  background: white;
  color: #333;
  border: 1px solid #e1e5e9;
  border-bottom-left-radius: 5px;
}

.message.other-user .message-content {
  background: #f0f0f0;
  color: #333;
  border-bottom-left-radius: 5px;
}

/* Loading indicator for chat */
.chat-loading {
  text-align: center;
  padding: 20px;
  color: #666;
}

.chat-loading .loading {
  margin: 0 auto 10px;
}