/* GoldZone – Luxury Purple + Gold Theme */
:root {
  --bg-deep: #0f0a1a;
  --bg-panel: #1a1229;
  --bg-elevated: #241a36;
  --bg-hover: #2d2244;
  --border: rgba(167, 139, 250, 0.12);
  --border-strong: rgba(167, 139, 250, 0.25);
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --primary: #a78bfa;
  --primary-dark: #8b5cf6;
  --primary-glow: rgba(167, 139, 250, 0.35);
  --gold: #fbbf24;
  --gold-dim: #d97706;
  --success: #34d399;
  --danger: #f87171;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --font: 'Inter', system-ui, sans-serif;
  --font-display: 'Outfit', var(--font);
  --sidebar-w: 72px;
  --rooms-w: 260px;
  --users-w: 280px;
}

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

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--gold); }

/* ---------- Auth ---------- */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.auth-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 20%, rgba(139, 92, 246, 0.25), transparent),
    radial-gradient(ellipse 60% 50% at 80% 80%, rgba(251, 191, 36, 0.12), transparent),
    var(--bg-deep);
  z-index: 0;
}

.auth-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  padding: 24px;
}

.auth-card {
  background: rgba(26, 18, 41, 0.75);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 32px;
  box-shadow: var(--shadow);
}

.auth-brand {
  text-align: center;
  margin-bottom: 28px;
}

.logo-mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), var(--gold));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: #0f0a1a;
  box-shadow: 0 0 24px var(--primary-glow);
}

.logo-mark.small {
  width: 36px;
  height: 36px;
  font-size: 1rem;
  border-radius: 10px;
  margin: 0;
}

.auth-brand h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.75rem;
  background: linear-gradient(90deg, var(--primary), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline { color: var(--text-muted); font-size: 0.875rem; margin-top: 4px; }

.auth-form .form-group { margin-bottom: 16px; }
.auth-form label { display: block; font-size: 0.8rem; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }

.input-icon {
  position: relative;
}
.input-icon i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 0.9rem;
}
.input-icon input {
  width: 100%;
  padding: 12px 14px 12px 40px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input-icon input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  font-size: 0.85rem;
}
.checkbox { display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text-muted); }
.link-muted { color: var(--text-muted); }
.link-muted:hover { color: var(--primary); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff;
  box-shadow: 0 4px 16px var(--primary-glow);
}
.btn-primary:hover { box-shadow: 0 6px 24px var(--primary-glow); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
}
.btn-ghost:hover { background: var(--bg-hover); }
.btn-block { width: 100%; }
.btn-send {
  background: var(--primary);
  color: #fff;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  padding: 0;
}

.auth-divider {
  display: flex;
  align-items: center;
  margin: 24px 0;
  color: var(--text-dim);
  font-size: 0.8rem;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.auth-divider span { padding: 0 12px; }

.auth-switch { text-align: center; margin-top: 20px; font-size: 0.9rem; color: var(--text-muted); }
.auth-footer { text-align: center; margin-top: 24px; font-size: 0.75rem; color: var(--text-dim); }

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.9rem;
}
.alert-error { background: rgba(248, 113, 113, 0.15); border: 1px solid rgba(248, 113, 113, 0.3); color: #fca5a5; }
.alert-success { background: rgba(52, 211, 153, 0.15); border: 1px solid rgba(52, 211, 153, 0.3); color: #6ee7b7; }

/* ---------- App Shell ---------- */
.app-body { height: 100vh; overflow: hidden; }

.app-shell {
  display: flex;
  height: 100%;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  flex-shrink: 0;
  z-index: 20;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 24px;
}
.brand-text {
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 0 10px;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 0;
  border-radius: 12px;
  color: var(--text-muted);
  font-size: 0.65rem;
  transition: background 0.2s, color 0.2s;
}
.nav-item i { font-size: 1.2rem; }
.nav-item:hover, .nav-item.active {
  background: var(--bg-hover);
  color: var(--primary);
}
.nav-item.active { color: var(--gold); }

.sidebar-footer {
  width: 100%;
  padding: 0 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.user-mini {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}
.user-mini .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
  position: relative;
  overflow: hidden;
}
.user-mini .avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-mini-info { display: none; }
.logout-form { width: 100%; }
.logout { width: 100%; background: none; border: none; cursor: pointer; }

/* ---------- Chat Layout ---------- */
.main-content {
  flex: 1;
  display: flex;
  min-width: 0;
  height: 100%;
}

.chat-layout {
  display: flex;
  width: 100%;
  height: 100%;
}

.panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  height: 100%;
}

.rooms-panel { width: var(--rooms-w); flex-shrink: 0; }
.chat-panel { flex: 1; min-width: 0; border-right: none; }
.users-panel { width: var(--users-w); flex-shrink: 0; border-right: none; border-left: 1px solid var(--border); }

.panel-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-header h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
}
.badge {
  background: var(--primary);
  color: #fff;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
}

.room-list, .user-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.room-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: background 0.15s;
  margin-bottom: 2px;
}
.room-item:hover { background: var(--bg-hover); }
.room-item.active {
  background: linear-gradient(90deg, rgba(167,139,250,0.15), transparent);
  border-left: 3px solid var(--primary);
}
.room-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
}
.room-meta { flex: 1; min-width: 0; }
.room-meta strong { display: block; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-meta small { color: var(--text-dim); font-size: 0.75rem; }
.room-lock { color: var(--text-dim); font-size: 0.8rem; }

/* Chat header */
.chat-header {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
}
.chat-title h1 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
}
.topic { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.btn-icon:hover { background: var(--bg-hover); color: var(--primary); }

/* Messages */
.message-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  display: flex;
  gap: 12px;
  max-width: 85%;
  animation: fadeIn 0.25s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
  flex-shrink: 0;
  overflow: hidden;
}
.msg-avatar img { width: 100%; height: 100%; object-fit: cover; }

.msg-body {
  background: var(--bg-elevated);
  border-radius: 4px 16px 16px 16px;
  padding: 10px 14px;
  border: 1px solid var(--border);
}
.msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.msg-name { font-weight: 600; font-size: 0.9rem; }
.rank-badge {
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid;
  opacity: 0.9;
}
.msg-meta time { font-size: 0.7rem; color: var(--text-dim); margin-left: auto; }
.msg-content { font-size: 0.925rem; word-break: break-word; }

/* Composer */
.composer {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
}
.composer-inner {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 8px 10px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.composer-inner:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
#message-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  resize: none;
  max-height: 120px;
  padding: 8px 0;
  line-height: 1.4;
}
#message-input:focus { outline: none; }
#message-input::placeholder { color: var(--text-dim); }

/* User list */
.user-section { margin-bottom: 16px; }
.user-section h3 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  padding: 4px 8px 8px;
}

.user-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
  cursor: pointer;
}
.user-item:hover { background: var(--bg-hover); }

.user-item .avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.8rem;
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
}
.user-item .avatar img { width: 100%; height: 100%; object-fit: cover; }

.online-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--bg-panel);
  background: var(--text-dim);
}
.online-dot.on {
  background: #22d3ee;
  box-shadow: 0 0 6px #22d3ee;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 4px #22d3ee; }
  50% { box-shadow: 0 0 10px #22d3ee; }
}

.user-info { flex: 1; min-width: 0; }
.user-info strong { display: block; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info .mood { font-size: 0.7rem; color: var(--text-dim); }

.rank-pill {
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: 6px;
  font-weight: 600;
  flex-shrink: 0;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  gap: 12px;
}
.empty-state i { font-size: 2.5rem; opacity: 0.4; }

/* Mobile */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  z-index: 50;
  justify-content: space-around;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom);
}
.mob-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  padding: 10px 16px;
  cursor: pointer;
}
.mob-btn.active { color: var(--gold); }

.mobile-only { display: none; }

@media (max-width: 900px) {
  .rooms-panel, .users-panel {
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow);
  }
  .rooms-panel.open { transform: translateX(0); }
  .users-panel {
    right: 0;
    left: auto;
    transform: translateX(100%);
  }
  .users-panel.open { transform: translateX(0); }

  .mobile-nav { display: flex; }
  .mobile-only { display: flex; }
  .app-shell { padding-bottom: 60px; }
  .sidebar { display: none; }
  .chat-panel { border: none; }
}

@media (max-width: 600px) {
  .rooms-panel, .users-panel { width: 85vw; max-width: 320px; }
  .message { max-width: 95%; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* Private Messages */
.pm-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.pm-avatar img { width: 100%; height: 100%; object-fit: cover; }

.pm-preview { display: block; color: var(--text-dim); font-size: 0.75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }

.message.mine {
  align-self: flex-end;
  flex-direction: row-reverse;
  margin-left: auto;
}
.message.mine .msg-body {
  background: linear-gradient(135deg, rgba(139,92,246,0.25), rgba(167,139,250,0.15));
  border-color: rgba(167,139,250,0.3);
  border-radius: 16px 4px 16px 16px;
}
.message.mine time { text-align: right; display: block; font-size: 0.65rem; color: var(--text-dim); margin-top: 4px; }
.message:not(.mine) time { display: block; font-size: 0.65rem; color: var(--text-dim); margin-top: 4px; }

.empty-hint {
  padding: 24px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.pm-list-panel .room-item .avatar { margin-right: 0; }

/* Page panels (wall, stories, games) */
.page-panel { flex:1; overflow-y:auto; padding:20px 24px; }
.page-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:20px; }
.page-header h1 { font-family:var(--font-display); font-size:1.3rem; }

.composer-card {
  background:var(--bg-panel); border:1px solid var(--border); border-radius:var(--radius);
  padding:16px; margin-bottom:20px;
}
.composer-card textarea {
  width:100%; background:var(--bg-elevated); border:1px solid var(--border); border-radius:10px;
  color:var(--text); padding:12px; font-family:inherit; resize:vertical; margin-bottom:10px;
}
.composer-card textarea:focus { outline:none; border-color:var(--primary); }

.wall-post {
  background:var(--bg-panel); border:1px solid var(--border); border-radius:var(--radius);
  padding:16px; margin-bottom:12px;
}
.wall-post-header { display:flex; gap:12px; align-items:center; margin-bottom:10px; }
.wall-post-header .avatar {
  width:36px; height:36px; border-radius:50%; background:var(--bg-elevated);
  display:flex; align-items:center; justify-content:center; font-weight:600;
}
.wall-post-header time { display:block; font-size:.75rem; color:var(--text-dim); }
.wall-post-body { font-size:.95rem; margin-bottom:10px; word-break:break-word; }
.wall-post-actions { display:flex; gap:16px; align-items:center; font-size:.85rem; color:var(--text-muted); }

.stories-rail { display:flex; gap:12px; overflow-x:auto; padding-bottom:12px; }
.story-card {
  min-width:140px; max-width:160px; height:220px; border-radius:16px; padding:14px;
  display:flex; flex-direction:column; justify-content:flex-end; color:#fff; flex-shrink:0;
}
.story-author { font-weight:600; font-size:.85rem; margin-bottom:6px; }
.story-text { font-size:.9rem; flex:1; overflow:hidden; }
.story-meta { font-size:.7rem; opacity:.8; margin-top:8px; }

.games-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(240px,1fr)); gap:16px; }
.game-card {
  background:var(--bg-panel); border:1px solid var(--border); border-radius:var(--radius);
  padding:20px;
}
.game-card h3 { font-family:var(--font-display); margin-bottom:8px; }
.game-card p { color:var(--text-muted); font-size:.85rem; margin-bottom:12px; }
.rps-btns { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:12px; }
.game-result { margin-top:12px; font-weight:600; color:var(--gold); min-height:1.2em; }

.emoji-panel {
  position: absolute; bottom: 100%; left: 0; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: 12px; padding: 8px;
  display: flex; flex-wrap: wrap; gap: 4px; max-width: 240px; z-index: 40;
}
.emoji-item {
  background: none; border: none; font-size: 1.25rem; cursor: pointer;
  padding: 4px; border-radius: 6px;
}
.emoji-item:hover { background: var(--bg-hover); }

.msg-actions { display: none; gap: 4px; margin-top: 4px; }
.message:hover .msg-actions { display: flex; }
.msg-actions button {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-size: 0.75rem; padding: 2px 6px; border-radius: 4px;
}
.msg-actions button:hover { background: var(--bg-hover); color: var(--primary); }

.reply-bar {
  display: none; align-items: center; gap: 8px; padding: 6px 12px;
  background: var(--bg-elevated); border-radius: 8px; margin-bottom: 6px;
  font-size: 0.8rem; color: var(--text-muted);
}
.reply-preview {
  font-size: 0.8rem; color: var(--text-dim); border-left: 2px solid var(--primary);
  padding-left: 8px; margin-bottom: 4px;
}
.typing-indicator {
  font-size: 0.8rem; color: var(--text-dim); padding: 4px 20px; min-height: 1.2em;
}
.rule-card {
  display: flex; gap: 14px; background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 10px;
}
.rule-num {
  width: 32px; height: 32px; border-radius: 50%; background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0;
}
.friend-item {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  background: var(--bg-panel); border-radius: 10px; margin-bottom: 8px;
}
.msg-image { max-width: 240px; border-radius: 10px; margin-top: 6px; }
