/* ═══════════════════════════════════════════════════════════════
   DESIGN TOKENS — Nyan Studios Theme
   ═══════════════════════════════════════════════════════════════ */
:root {
  --bg:       #0d0d14;
  --surface:  #14141f;
  --border:   #1e1e2e;
  --accent:   #7c6af7;
  --accent2:  #4fc3c3;
  --text:     #e2e0f0;
  --muted:    #6b6880;

  --font-main: 'Space Mono', 'Courier New', monospace;
  --font-heading: 'Space Grotesk', 'Space Mono', sans-serif;

  --radius-sm:   8px;
  --radius-md:   10px;
  --radius-lg:   16px;
  --radius-full: 9999px;

  --ease-out:  cubic-bezier(0.16, 1, 0.3, 1);
  --duration:  0.2s;
}

/* ═══════════════════════════════════════════════════════════════
   RESET & BASE
   ═══════════════════════════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: var(--font-main);
  background: var(--bg-custom, var(--bg));
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s ease;
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

input, button {
  font-family: var(--font-main);
}

/* ═══════════════════════════════════════════════════════════════
   SCREENS
   ═══════════════════════════════════════════════════════════════ */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s var(--ease-out);
}
.screen.active {
  opacity: 1;
  pointer-events: all;
}

/* ═══════════════════════════════════════════════════════════════
   LOBBY SCREEN
   ═══════════════════════════════════════════════════════════════ */
#lobby-screen {
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 40px 20px;
}

.lobby-container {
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Logo */
.lobby-header {
  text-align: left;
  margin-bottom: 4px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
}
.logo-icon {
  width: 48px;
  height: 48px;
  background: #050508;
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent2);
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font-main);
}
.logo h1 {
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
}
.logo h1 span {
  color: var(--accent);
}
.lobby-subtitle {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
}

/* Card panels */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}
.card h2 {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

/* Input row */
.input-row {
  display: flex;
  gap: 10px;
}
.input-row input {
  flex: 1;
}

input[type="text"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color var(--duration), box-shadow var(--duration);
}
input[type="text"]::placeholder {
  color: var(--muted);
}
input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(124, 106, 247, 0.15);
}

/* Buttons */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--duration), background var(--duration), transform var(--duration);
  white-space: nowrap;
}
.btn-primary .arrow {
  color: var(--muted);
  transition: color var(--duration);
}
.btn-primary:hover {
  border-color: var(--accent);
  background: #16151f;
  transform: translateY(-1px);
}
.btn-primary:hover .arrow {
  color: var(--accent);
}
.btn-primary:active {
  transform: translateY(0);
}
.btn-primary.btn-sm {
  padding: 8px 14px;
  font-size: 12px;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg);
  color: var(--accent2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--duration), background var(--duration), transform var(--duration);
}
.btn-secondary:hover {
  border-color: var(--accent2);
  background: rgba(79, 195, 195, 0.08);
  box-shadow: 0 0 12px rgba(79, 195, 195, 0.12);
  transform: translateY(-1px);
}

.btn-ghost {
  padding: 8px 14px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--duration), color var(--duration);
}
.btn-ghost:hover {
  background: var(--surface);
  color: var(--text);
}

.btn-icon {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  transition: border-color var(--duration), color var(--duration), background var(--duration);
  flex-shrink: 0;
}
.btn-icon:hover {
  border-color: var(--accent);
  color: var(--text);
  background: #16151f;
}

/* Rooms section */
.rooms-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.rooms-header h2 {
  margin-bottom: 0;
}

.create-room-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
  padding: 14px;
  background: var(--bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  animation: slideDown 0.25s var(--ease-out);
}
.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Room list */
.room-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
}

.room-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--duration), background var(--duration), transform var(--duration);
  animation: fadeInUp 0.3s var(--ease-out) both;
}
.room-item:hover {
  border-color: var(--accent);
  background: #16151f;
  transform: translateY(-1px);
}
.room-item:active {
  transform: translateY(0);
}

.room-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.room-item-name {
  font-weight: 500;
  font-size: 14px;
  color: var(--text);
}
.room-item-users {
  font-size: 11px;
  color: var(--muted);
}

.room-item-arrow {
  color: var(--muted);
  font-size: 16px;
  transition: color var(--duration), transform var(--duration);
}
.room-item:hover .room-item-arrow {
  color: var(--accent);
  transform: translateX(3px);
}

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

/* Empty state */
.empty-state {
  text-align: center;
  padding: 28px 16px;
  color: var(--muted);
  font-size: 11px;
}

/* Footer */
.footer {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  margin-top: 4px;
}

/* Hidden */
.hidden {
  display: none !important;
}

/* ═══════════════════════════════════════════════════════════════
   CHAT SCREEN
   ═══════════════════════════════════════════════════════════════ */
#chat-screen {
  background: var(--bg);
}

/* Header */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 10;
  flex-shrink: 0;
  position: relative;
}
.chat-header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  opacity: 0.4;
}
.chat-header-info {
  flex: 1;
  min-width: 0;
}
.chat-header-info h2 {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-count {
  font-size: 11px;
  color: var(--muted);
}

/* Chat body */
.chat-body {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
}

/* Messages area */
.messages-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: #050508;
}

/* Terminal-style message lines */
.msg-line {
  font-size: 13px;
  line-height: 1.6;
  padding: 1px 0;
  word-break: break-word;
  animation: lineIn 0.15s var(--ease-out) both;
}

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

.msg-ts {
  color: var(--muted);
  user-select: none;
}
.msg-user {
  color: var(--accent2);
  font-weight: 700;
}
.msg-user-self {
  color: var(--accent);
}
.msg-text {
  color: var(--text);
}

/* System messages */
.msg-line-system {
  opacity: 0.7;
}
.msg-system-text {
  color: var(--muted);
  font-style: italic;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  font-size: 11px;
  color: var(--muted);
  animation: fadeIn 0.2s var(--ease-out);
}
.typing-dots {
  display: flex;
  gap: 3px;
}
.typing-dots span {
  width: 5px;
  height: 5px;
  background: var(--accent2);
  border-radius: 50%;
  animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
  30% { transform: translateY(-4px); opacity: 1; }
}

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

/* User sidebar */
.user-sidebar {
  width: 200px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 20px 14px;
  overflow-y: auto;
  flex-shrink: 0;
  transition: width 0.25s var(--ease-out), padding 0.25s var(--ease-out), opacity 0.25s;
}
.user-sidebar.collapsed {
  width: 0;
  padding: 0;
  opacity: 0;
  overflow: hidden;
}
.user-sidebar h3 {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 14px;
  letter-spacing: 0.02em;
}
.user-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.user-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  animation: fadeInUp 0.25s var(--ease-out) both;
}
.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  text-transform: uppercase;
}
.user-online-dot {
  width: 7px;
  height: 7px;
  background: var(--accent2);
  border-radius: 50%;
  margin-left: auto;
  flex-shrink: 0;
  box-shadow: 0 0 8px rgba(79, 195, 195, 0.5);
}

/* Message input bar — terminal prompt style */
.message-input-bar {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0;
  background: #050508;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.message-input-bar::before {
  content: '>';
  color: var(--accent2);
  font-size: 14px;
  font-weight: 700;
  padding: 12px 0 12px 16px;
  flex-shrink: 0;
}
.message-input-bar input {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 12px 10px;
  font-size: 13px;
  color: var(--text);
  outline: none;
}
.message-input-bar input::placeholder {
  color: var(--muted);
}

.btn-send {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-left: 1px solid var(--border);
  border-radius: 0;
  color: var(--accent2);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: color var(--duration), background var(--duration);
}
.btn-send:hover {
  color: var(--accent);
  background: rgba(124, 106, 247, 0.08);
}
}
.btn-send:active {
  transform: scale(0.95);
}

/* ═══════════════════════════════════════════════════════════════
   TOASTS
   ═══════════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  animation: toastIn 0.3s var(--ease-out);
  max-width: 320px;
}
.toast.toast-error {
  border-color: rgba(248, 113, 113, 0.3);
  border-left: 3px solid #f87171;
}
.toast.toast-out {
  animation: toastOut 0.25s var(--ease-out) forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(30px); }
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .user-sidebar {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 20;
    width: 220px;
    box-shadow: -6px 0 24px rgba(0, 0, 0, 0.4);
  }
  .user-sidebar.collapsed {
    width: 0;
    box-shadow: none;
  }

  .msg {
    max-width: 88%;
  }

  .lobby-container {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .chat-header {
    padding: 10px 14px;
  }
  .messages {
    padding: 14px;
  }
  .message-input-bar {
    padding: 10px 14px;
  }
  .card {
    padding: 22px 18px;
  }
}

/* ═══════════════════════════════════════════════════════════════
   THEME CUSTOMIZER MODAL STYLING
   ═══════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 8, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.modal-overlay:not(.hidden) {
  opacity: 1;
  pointer-events: all;
}

.theme-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 480px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  max-height: 85vh;
  position: relative;
  overflow: hidden;
  animation: modalScaleIn 0.25s var(--ease-out);
}
.theme-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}

@keyframes modalScaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

.theme-card-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.theme-card-header h3 {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.btn-close-text {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  transition: color var(--duration);
}
.btn-close-text:hover {
  color: var(--accent);
}

.theme-card-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.theme-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.theme-group label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.theme-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.preset-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 11px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--duration), background var(--duration);
}
.preset-btn:hover {
  border-color: var(--accent);
  background: rgba(124, 106, 247, 0.08);
}

.theme-select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px;
  border-radius: var(--radius-md);
  outline: none;
  font-size: 13px;
  font-family: var(--font-main);
  cursor: pointer;
}

.sub-group {
  padding: 12px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border);
}

.color-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.color-row input[type="color"] {
  -webkit-appearance: none;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: transparent;
}
.color-row input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}
.color-row input[type="color"]::-webkit-color-swatch {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.color-text-input, .theme-text-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  outline: none;
}

.gradient-settings-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.gradient-settings-row input[type="color"] {
  -webkit-appearance: none;
  border: none;
  width: 32px;
  height: 32px;
  cursor: pointer;
  background: transparent;
}
.gradient-settings-row input[type="color"]::-webkit-color-swatch {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.range-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 150px;
}
.range-wrapper input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}
.range-wrapper span {
  font-size: 12px;
  color: var(--muted);
  min-width: 35px;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.theme-card-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

@media (max-width: 480px) {
  .theme-grid {
    grid-template-columns: 1fr;
  }
}

