/* ==========================================================================
   MARBLE CLASH — STAKE-AESTHETIC UI THEME (client/style.css)
   Phase 6: Streamlined UI, Unified Profile Dropdown & Real-Time Community Chat
   ========================================================================== */

:root {
  --stake-bg-base: #0f1923;
  --stake-bg-surface: #1a2c38;
  --stake-bg-card: #213743;
  --stake-border: #2f4553;
  --stake-border-subtle: rgba(255, 255, 255, 0.08);
  --stake-green: #00e701;
  --stake-green-hover: #00c701;
  --stake-green-glow: rgba(0, 231, 1, 0.35);
  --stake-blue: #38bdf8;
  --stake-gold: #f59e0b;
  --stake-purple: #a855f7;
  --stake-text-bright: #ffffff;
  --stake-text-main: #b1bad3;
  --stake-text-muted: #64748b;
  --stake-danger: #ef4444;
}

/* ==========================================================================
   1. STREAMLINED HEADER BAR
   ========================================================================== */
header {
  height: 60px;
  background: var(--stake-bg-surface);
  border-bottom: 1px solid var(--stake-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  z-index: 50;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-text {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 1.5px;
  color: var(--stake-text-bright);
  display: flex;
  align-items: center;
  gap: 4px;
}

.logo-accent {
  color: var(--stake-green);
  text-shadow: 0 0 12px var(--stake-green-glow);
}

.badge-live {
  background: var(--stake-green);
  color: #000;
  font-size: 9px;
  font-weight: 900;
  padding: 3px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.header-center {
  display: flex;
  align-items: center;
  gap: 8px;
}

.race-chip {
  background: rgba(15, 25, 35, 0.8);
  border: 1px solid var(--stake-border);
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 11px;
  font-weight: 800;
  color: var(--stake-blue);
  display: flex;
  align-items: center;
  gap: 6px;
}

.state-indicator {
  background: rgba(15, 25, 35, 0.8);
  border: 1px solid var(--stake-border);
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--stake-green);
  box-shadow: 0 0 10px var(--stake-green);
  animation: pulse 1.2s infinite alternate;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wallet-pill {
  background: #0f1923;
  border: 1.5px solid rgba(0, 231, 1, 0.4);
  border-radius: 20px;
  padding: 4px 6px 4px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.6);
}

.balance-amount {
  font-size: 13px;
  font-weight: 900;
  font-family: monospace;
  color: #fff;
}

.currency-switch-btn {
  background: var(--stake-bg-card);
  border: 1px solid var(--stake-border);
  color: var(--stake-green);
  font-size: 10px;
  font-weight: 900;
  padding: 4px 8px;
  border-radius: 12px;
  cursor: pointer;
  transition: 0.2s;
}

.currency-switch-btn:hover {
  background: var(--stake-green);
  color: #000;
}

.deposit-cta-btn {
  background: var(--stake-green);
  color: #000;
  font-weight: 900;
  border: none;
  box-shadow: 0 0 14px var(--stake-green-glow);
  padding: 7px 16px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  transition: 0.2s;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.deposit-cta-btn:hover {
  background: var(--stake-green-hover);
  transform: translateY(-1px);
}

/* ==========================================================================
   2. UNIFIED USER PROFILE & SETTINGS DROPDOWN
   ========================================================================== */
.user-profile-pill {
  background: var(--stake-bg-card);
  border: 1px solid var(--stake-border);
  border-radius: 20px;
  padding: 4px 10px 4px 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  position: relative;
  transition: 0.2s;
}

.user-profile-pill:hover {
  border-color: var(--stake-blue);
  background: #253e4c;
}

.user-avatar-circle {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #0284c7;
  color: #fff;
  font-weight: 900;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.user-name-tag {
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-role-badge {
  font-size: 9px;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 4px;
}

.role-admin { background: #ef4444; color: #fff; }
.role-vip { background: #f59e0b; color: #000; }
.role-google { background: #0284c7; color: #fff; }
.role-user { background: #475569; color: #cbd5e1; }

.user-dropdown-menu {
  position: absolute;
  top: 42px;
  right: 0;
  width: 260px;
  background: var(--stake-bg-surface);
  border: 1px solid var(--stake-border);
  border-radius: 12px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  backdrop-filter: blur(16px);
  overflow: hidden;
  animation: dropIn 0.15s ease-out;
}

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

.user-dropdown-header {
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid var(--stake-border);
}

.user-dropdown-item {
  background: transparent;
  border: none;
  color: var(--stake-text-main);
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: 0.15s;
  width: 100%;
}

.user-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.user-dropdown-item.danger {
  color: #f87171;
  border-top: 1px solid var(--stake-border);
}

.user-dropdown-item.danger:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
}

.user-dropdown-item.admin-link {
  color: #fbbf24;
  font-weight: 800;
}

/* ==========================================================================
   3. LIVE COMMUNITY CHAT DRAWER (LEFT PANEL)
   ========================================================================== */
#left-panel {
  width: 270px;
  background: var(--stake-bg-base);
  border-right: 1px solid var(--stake-border);
  display: flex;
  flex-direction: column;
  z-index: 20;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

#left-panel.collapsed {
  width: 44px;
}

#left-panel.collapsed .chat-header-top .chat-title-group,
#left-panel.collapsed .chat-room-tabs,
#left-panel.collapsed .chat-messages,
#left-panel.collapsed .chat-input-area,
#left-panel.collapsed .chat-cooldown-banner,
#left-panel.collapsed .chat-emoji-drawer {
  display: none !important;
}

#left-panel.collapsed .chat-header {
  padding: 10px 6px;
}

#left-panel.collapsed .chat-header-top {
  justify-content: center;
}

.chat-header {
  padding: 10px 12px;
  background: var(--stake-bg-surface);
  border-bottom: 1px solid var(--stake-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-title-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--stake-green);
  box-shadow: 0 0 6px var(--stake-green);
}

.chat-title {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.8px;
  color: #fff;
}

.chat-online-badge {
  font-size: 10px;
  color: var(--stake-text-muted);
  font-family: monospace;
}

.chat-toggle-btn {
  background: transparent;
  border: 1px solid var(--stake-border);
  color: var(--stake-text-muted);
  font-size: 10px;
  padding: 3px 6px;
  border-radius: 4px;
  cursor: pointer;
  transition: 0.15s;
}

.chat-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.chat-room-tabs {
  display: flex;
  gap: 4px;
  background: var(--stake-bg-base);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--stake-border);
}

.chat-room-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--stake-text-muted);
  font-size: 10px;
  font-weight: 800;
  padding: 4px;
  border-radius: 6px;
  cursor: pointer;
  transition: 0.15s;
}

.chat-room-tab.active {
  background: var(--stake-bg-surface);
  color: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}

.chat-loading-state {
  text-align: center;
  font-size: 11px;
  color: var(--stake-text-muted);
  padding: 24px 10px;
}

.chat-msg-card {
  background: rgba(26, 44, 56, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 11px;
  transition: 0.15s;
}

.chat-msg-card:hover {
  background: rgba(26, 44, 56, 0.75);
}

.chat-msg-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.user-badge {
  font-size: 8px;
  font-weight: 900;
  padding: 1px 4px;
  border-radius: 3px;
  text-transform: uppercase;
}

.badge-admin { background: #ef4444; color: #fff; }
.badge-mod { background: #0284c7; color: #fff; }
.badge-vip { background: #f59e0b; color: #000; }
.badge-whale { background: #a855f7; color: #fff; }
.badge-user { background: #334155; color: #94a3b8; }
.badge-system { background: #38bdf8; color: #000; font-weight: 900; }

.chat-username {
  font-weight: 800;
  color: #e2e8f0;
  font-size: 11px;
}

.chat-time {
  margin-left: auto;
  font-size: 9px;
  color: var(--stake-text-muted);
  font-family: monospace;
}

.chat-msg-text {
  color: var(--stake-text-main);
  line-height: 1.4;
  word-break: break-word;
}

.chat-big-win-card {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(0, 231, 1, 0.12));
  border: 1.5px solid var(--stake-gold);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.25);
}

.big-win-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.big-win-badge {
  background: var(--stake-gold);
  color: #000;
  font-size: 8px;
  font-weight: 900;
  padding: 2px 5px;
  border-radius: 3px;
}

.big-win-content {
  color: #fff;
  font-weight: 700;
  font-size: 11px;
}

.chat-cooldown-banner {
  background: rgba(239, 68, 68, 0.15);
  border-top: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  font-size: 10px;
  padding: 4px 8px;
  text-align: center;
  font-weight: 800;
}

.chat-emoji-drawer {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 8px;
  background: var(--stake-bg-surface);
  border-top: 1px solid var(--stake-border);
}

.chat-emoji-btn {
  background: transparent;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: 0.15s;
}

.chat-emoji-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: scale(1.15);
}

.chat-input-area {
  padding: 8px 10px;
  background: var(--stake-bg-surface);
  border-top: 1px solid var(--stake-border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-input-wrapper {
  display: flex;
  align-items: center;
  background: var(--stake-bg-base);
  border: 1px solid var(--stake-border);
  border-radius: 8px;
  padding: 0 6px;
}

.chat-input-field {
  flex: 1;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 11px;
  padding: 7px 4px;
  outline: none;
}

.chat-emoji-toggle-btn {
  background: transparent;
  border: none;
  font-size: 14px;
  cursor: pointer;
  opacity: 0.7;
  transition: 0.15s;
}

.chat-emoji-toggle-btn:hover {
  opacity: 1;
}

.chat-action-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-char-counter {
  font-size: 9px;
  color: var(--stake-text-muted);
  font-family: monospace;
}

.chat-send-btn {
  background: var(--stake-green);
  color: #000;
  font-weight: 900;
  font-size: 10px;
  padding: 4px 10px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  transition: 0.15s;
}

.chat-send-btn:hover {
  background: var(--stake-green-hover);
}

/* ==========================================================================
   4. RELOCATED IN-RACE RUNNER LEADERBOARD (UNDER CAMERA CONTROLS)
   ========================================================================= */
#in-race-leaderboard {
  position: absolute;
  top: 48px;
  left: 16px;
  width: 135px;
  max-height: calc(100% - 64px);
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 0;
  pointer-events: auto;
  z-index: 15;
  scrollbar-width: none; /* Hide default scrollbar */
}

#in-race-leaderboard::-webkit-scrollbar {
  display: none;
}

.runner-card {
  background: rgba(15, 25, 35, 0.90);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 3px 6px;
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  backdrop-filter: blur(8px);
  transition: 0.15s ease;
  width: 100%;
  box-sizing: border-box;
}

.runner-card.is-picked {
  border-color: var(--stake-green);
  background: rgba(0, 231, 1, 0.15);
  box-shadow: 0 0 8px rgba(0, 231, 1, 0.3);
}

.runner-rank {
  font-size: 9px;
  font-weight: 900;
  font-family: monospace;
  color: var(--stake-text-muted);
  width: 16px;
  flex-shrink: 0;
}

.runner-rank.podium-1 { color: #f59e0b; }
.runner-rank.podium-2 { color: #cbd5e1; }
.runner-rank.podium-3 { color: #b45309; }

.runner-orb {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.5);
  flex-shrink: 0;
}

.runner-info {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.runner-name {
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  min-width: 52px;
}

.runner-progress-bar {
  width: 100%;
  height: 2px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 1px;
  margin-top: 2px;
  overflow: hidden;
}

.runner-progress-fill {
  height: 100%;
  background: var(--stake-green);
  transition: width 0.1s linear;
}

.runner-dist {
  flex: 0 0 auto;
  font-size: 9px;
  font-family: monospace;
  font-weight: 800;
  color: var(--stake-green);
  margin-left: 4px;
  white-space: nowrap;
}

/* ==========================================================================
   5. TOP-RIGHT CELEBRATION WIN TOAST (NON-OBTRUSIVE)
   ========================================================================== */
#win-banner-container {
  position: fixed;
  top: 75px;
  right: 20px;
  z-index: 9999;
  pointer-events: none;
}

.win-toast-card {
  background: linear-gradient(135deg, rgba(15, 25, 35, 0.98), rgba(26, 44, 56, 0.98));
  border: 2px solid var(--stake-green);
  border-radius: 12px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 10px 30px rgba(0, 231, 1, 0.4), 0 0 20px rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(12px);
  animation: toastSlideIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: auto;
  max-width: 320px;
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(50px); }
  to { opacity: 1; transform: translateX(0); }
}

.win-toast-trophy {
  font-size: 28px;
}

.win-toast-title {
  font-size: 13px;
  font-weight: 900;
  color: var(--stake-green);
  letter-spacing: 0.5px;
}

.win-toast-amount {
  font-size: 16px;
  font-weight: 900;
  color: #fff;
  font-family: monospace;
  margin-top: 1px;
}

.win-toast-sub {
  font-size: 9px;
  color: var(--stake-text-muted);
}
