* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-tertiary: #0f3460;
  --accent: #e94560;
  --accent-hover: #ff6b81;
  --text-primary: #eee;
  --text-secondary: #aaa;
  --message-own: #e94560;
  --message-other: #2a2a4a;
  --input-bg: #2a2a4a;
  --border: #3a3a5a;
  --online: #4ade80;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
}

/* === Screens === */
.screen {
  display: none;
  height: 100vh;
}
.screen.active {
  display: flex;
}

/* === Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.3s ease;
}

.modal-overlay.hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-box {
  background: var(--bg-secondary);
  border: 2px solid var(--accent);
  border-radius: 20px;
  padding: 40px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(233, 69, 96, 0.3);
  animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-icon {
  font-size: 72px;
  margin-bottom: 15px;
  animation: wiggle 0.6s ease;
}

@keyframes wiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-10deg); }
  75% { transform: rotate(10deg); }
}

.modal-box h2 {
  font-size: 24px;
  margin-bottom: 20px;
  color: var(--online);
}

.modal-details {
  background: var(--bg-primary);
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 20px;
  text-align: left;
}

.modal-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.modal-row:last-child {
  border-bottom: none;
}

.modal-label {
  color: var(--text-secondary);
  font-size: 13px;
}

.modal-row code {
  color: var(--accent-hover);
  font-size: 11px;
  word-break: break-all;
  max-width: 200px;
  text-align: right;
}

.modal-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 25px;
  line-height: 1.5;
}

.modal-btn {
  padding: 14px 40px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.modal-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(233, 69, 96, 0.4);
}

/* === Auth Screen === */
#auth-screen {
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, var(--bg-primary), var(--bg-secondary));
}

.auth-container {
  text-align: center;
  padding: 40px;
  background: var(--bg-secondary);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  max-width: 400px;
  width: 90%;
}

.logo {
  font-size: 64px;
  margin-bottom: 10px;
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.auth-container h1 {
  font-size: 28px;
  margin-bottom: 8px;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--text-secondary);
  margin-bottom: 30px;
}

#auth-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

#username-input {
  padding: 15px 20px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 16px;
  outline: none;
  transition: border-color 0.3s;
}

#username-input:focus {
  border-color: var(--accent);
}

#auth-btn {
  padding: 15px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

#auth-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(233, 69, 96, 0.4);
}

.hint {
  margin-top: 20px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* === Messenger Layout === */
.messenger {
  display: flex;
  width: 100%;
  height: 100vh;
}

/* === Sidebar === */
.sidebar {
  width: 280px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 15px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 16px;
}

#logout-btn {
  background: transparent;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 5px;
  border-radius: 8px;
  transition: background 0.2s;
}

#logout-btn:hover {
  background: var(--input-bg);
}

.rooms-section, .users-section {
  padding: 15px;
}

.rooms-section h3, .users-section h3 {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 10px;
  letter-spacing: 1px;
}

#rooms-list, #users-list {
  list-style: none;
}

.room-item {
  padding: 10px 15px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.room-item:hover {
  background: var(--input-bg);
}

.room-item.active {
  background: var(--accent);
  color: white;
}

.room-icon {
  font-weight: bold;
  color: var(--text-secondary);
}

.room-item.active .room-icon {
  color: white;
}

.users-section {
  flex: 1;
  overflow-y: auto;
}

.user-item {
  padding: 8px 10px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.user-item .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--online);
}

.cookie-info {
  padding: 15px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.cookie-file-section {
  background: var(--input-bg);
  padding: 8px;
  border-radius: 8px;
  margin-bottom: 8px;
}

.cookie-path {
  display: block;
  color: var(--online);
  font-family: monospace;
  margin-top: 4px;
}

.cookie-info code {
  font-size: 10px;
  color: var(--accent);
  word-break: break-all;
}

/* === Chat Main === */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.chat-header {
  padding: 15px 25px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.chat-header h2 {
  font-size: 18px;
}

#room-topic {
  font-size: 12px;
  color: var(--text-secondary);
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px 25px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.welcome-message {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px;
  background: var(--bg-secondary);
  border-radius: 12px;
  margin: auto;
}

/* === Messages === */
.message {
  max-width: 70%;
  animation: slideIn 0.3s ease;
}

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

.message.own {
  align-self: flex-end;
}

.message.other {
  align-self: flex-start;
}

.message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}

.message-author {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-hover);
}

.message-time {
  font-size: 10px;
  color: var(--text-secondary);
}

.message-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  line-height: 1.4;
  word-wrap: break-word;
}

.message.own .message-bubble {
  background: var(--message-own);
  border-bottom-right-radius: 4px;
}

.message.other .message-bubble {
  background: var(--message-other);
  border-bottom-left-radius: 4px;
}

/* === Message Input === */
.message-input-area {
  padding: 20px 25px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}

#message-form {
  display: flex;
  gap: 12px;
}

#message-input {
  flex: 1;
  padding: 15px 20px;
  border: 2px solid var(--border);
  border-radius: 25px;
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  transition: border-color 0.3s;
}

#message-input:focus {
  border-color: var(--accent);
}

#send-btn {
  width: 50px;
  height: 50px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: white;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

#send-btn:hover {
  transform: scale(1.1);
}

/* === Scrollbar === */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* === Responsive === */
@media (max-width: 768px) {
  .sidebar {
    display: none;
  }
  
  .message {
    max-width: 90%;
  }
}
