:root {
  --neon-pink: #ff006e;
  --neon-blue: #00f5ff;
  --neon-purple: #8b5cf6;
  --neon-yellow: #ffbe0b;
  --neon-green: #00ff87;
  --neon-red: #ff3333;
  --bg-dark: #0a0a1a;
  --bg-darker: #050510;
  --bg-card: rgba(26, 26, 46, 0.9);
  --bg-card-hover: rgba(36, 36, 66, 0.95);
  --text-primary: #e0e0ff;
  --text-secondary: #8888aa;
  --text-glow: 0 0 10px currentColor, 0 0 20px currentColor;
  --border-glow: 0 0 5px var(--neon-blue), inset 0 0 5px rgba(0,245,255,0.1);
  --font-main: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-display: 'Impact', 'Arial Black', sans-serif;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
  
  --team-red: #ff006e;
  --team-blue: #00f5ff;
  --team-yellow: #ffbe0b;
  --team-green: #00ff87;
}

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

body {
  background-color: var(--bg-dark);
  color: var(--text-primary);
  font-family: var(--font-main);
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 100dvh;
  overscroll-behavior: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

button, input, select {
  font-family: inherit;
  color: inherit;
  outline: none;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-darker);
}
::-webkit-scrollbar-thumb {
  background: var(--neon-blue);
  border-radius: var(--radius-sm);
  box-shadow: 0 0 5px var(--neon-blue);
}

/* Utilities */
.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}
.flex-col {
  display: flex;
  flex-direction: column;
}
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.gap-lg { gap: 24px; }
.text-glow { text-shadow: var(--text-glow); }
.hidden { display: none !important; }

/* Components */
.neon-card {
  background-color: var(--bg-card);
  border: 1px solid rgba(0, 245, 255, 0.3);
  border-radius: var(--radius-md);
  padding: 16px;
  backdrop-filter: blur(10px);
  box-shadow: var(--border-glow);
}

.neon-btn {
  background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(0,0,0,0.2));
  min-height: 48px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  border: 1px solid currentColor;
  transition: all var(--transition-fast);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.neon-btn:hover {
  box-shadow: var(--border-glow);
  background: rgba(255,255,255,0.1);
}
.neon-btn:active {
  transform: scale(0.95);
}

.neon-btn--primary { color: var(--neon-pink); border-color: var(--neon-pink); box-shadow: 0 0 5px var(--neon-pink), inset 0 0 5px rgba(255,0,110,0.1); }
.neon-btn--secondary { color: var(--neon-blue); }
.neon-btn--success { color: var(--neon-green); border-color: var(--neon-green); box-shadow: 0 0 5px var(--neon-green), inset 0 0 5px rgba(0,255,135,0.1); }
.neon-btn--danger { color: var(--neon-red); border-color: var(--neon-red); box-shadow: 0 0 5px var(--neon-red), inset 0 0 5px rgba(255,51,51,0.1); }
.neon-btn--warning { color: var(--neon-yellow); border-color: var(--neon-yellow); box-shadow: 0 0 5px var(--neon-yellow), inset 0 0 5px rgba(255,190,11,0.1); }

.neon-input {
  background: var(--bg-darker);
  border: 1px solid rgba(255,255,255,0.2);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  color: white;
  transition: all var(--transition-fast);
}
.neon-input:focus {
  border-color: var(--neon-blue);
  box-shadow: var(--border-glow);
}

.neon-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: bold;
  background: rgba(255,255,255,0.1);
  border: 1px solid currentColor;
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: var(--bg-darker);
  border: 2px solid var(--text-secondary);
}

.timer-bar {
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--neon-green), var(--neon-yellow), var(--neon-red));
  transform-origin: left;
  transition: transform 1s linear;
}

.score-display {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--neon-yellow);
  text-shadow: 0 0 10px var(--neon-yellow);
}

.team-card {
  border-left: 4px solid var(--neon-blue);
}

.player-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.1);
  padding: 4px 12px 4px 4px;
  border-radius: 99px;
}
.player-chip .avatar {
  width: 32px;
  height: 32px;
  font-size: 1rem;
}

.connection-status {
  background: var(--neon-green);
  transition: background 0.3s, box-shadow 0.3s;
}
.connection-status.offline { background: var(--neon-red); box-shadow: 0 0 8px var(--neon-red); }
.connection-status.connecting { background: var(--neon-yellow); box-shadow: 0 0 8px var(--neon-yellow); }

.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--neon-blue);
  color: white;
  padding: 12px 24px;
  border-radius: var(--radius-lg);
  box-shadow: var(--border-glow);
  z-index: 1000;
  animation: slide-up var(--transition-normal);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.modal {
  width: 90%;
  max-width: 500px;
}

.confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
}

.audio-controls {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  gap: 10px;
  z-index: 900;
}
.audio-controls button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--neon-purple);
  color: white;
}

/* Animations */
.fade-in { animation: fade-in var(--transition-normal) forwards; }
.slide-up { animation: slide-up var(--transition-normal) forwards; }

@keyframes glow-pulse {
  0% { opacity: 0.5; }
  50% { opacity: 1; }
  100% { opacity: 0.5; }
}
@keyframes slide-up {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes spotlight {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@keyframes neon-flicker {
  0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% { text-shadow: var(--text-glow); opacity: 1; }
  20%, 24%, 55% { text-shadow: none; opacity: 0.5; }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}
@keyframes bounce-in {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

@media (max-width: 768px) {
  .modal { width: 95%; }
}
@media (max-width: 480px) {
  .audio-controls { bottom: 80px; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.05); }
}

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

/* === APP NAVBAR & SIDEBAR === */
.app-navbar {
  position: fixed; top: 0; left: 0; right: 0; height: 60px;
  background: rgba(10,10,20,0.9); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--neon-blue);
  display: flex; align-items: center; padding: 0 15px; z-index: 1000;
  box-shadow: 0 0 15px rgba(0,245,255,0.2);
}
.app-navbar h1 { 
  font-size: 1.65rem; 
  margin: 0; 
  flex-grow: 1; 
  color: var(--neon-pink); 
  font-family: var(--font-display); 
  cursor: pointer; 
  letter-spacing: 1px;
  text-shadow: 0 0 12px rgba(255, 20, 147, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 600px) {
  .app-navbar h1 { font-size: 1.3rem; }
}
.nav-actions { display: flex; gap: 10px; align-items: center; }
.hamburger-btn {
  background: none; border: none; color: var(--neon-blue);
  font-size: 1.8rem; cursor: pointer; padding: 5px; text-shadow: var(--neon-glow-blue);
}
.app-sidebar {
  position: fixed; top: 0; right: -300px; width: 280px; height: 100dvh;
  background: rgba(15,15,25,0.95); backdrop-filter: blur(15px);
  border-left: 2px solid var(--neon-pink); z-index: 1100;
  transition: right 0.3s ease; display: flex; flex-direction: column; padding: 16px; box-sizing: border-box;
}
.app-sidebar.open { right: 0; }
.sidebar-close {
  align-self: flex-end; background: none; border: none; color: #f55;
  font-size: 1.8rem; cursor: pointer; padding: 0; margin-bottom: 12px;
}
.sidebar-menu { display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 0; }
.sidebar-menu .nav-tab,
.sidebar-menu .neon-btn {
  flex: 0 0 auto !important;
  width: 100% !important;
  min-height: 38px !important;
  height: 38px !important;
  padding: 8px 14px !important;
  font-size: 0.88rem !important;
  font-weight: 600 !important;
  text-transform: none !important;
  letter-spacing: 0.5px !important;
  flex-direction: row !important;
  justify-content: flex-start !important;
  align-items: center !important;
  gap: 8px !important;
  border-radius: 8px !important;
  box-sizing: border-box !important;
}
.sidebar-menu .nav-tab::after {
  display: none !important;
}
.sidebar-menu .nav-tab.active {
  background: rgba(0,245,255,0.15) !important;
  border-color: var(--neon-blue) !important;
  color: var(--neon-blue) !important;
  box-shadow: 0 0 8px rgba(0,245,255,0.2) !important;
}


/* === CHAT FAB & OVERLAY === */
.chat-fab {
  position: fixed; bottom: 20px; right: 20px; width: 60px; height: 60px;
  border-radius: 50%; background: var(--neon-blue); color: #000;
  border: none; font-size: 1.5rem; cursor: pointer; z-index: 900;
  box-shadow: 0 0 15px var(--neon-blue); display: flex; align-items: center; justify-content: center;
}
.chat-badge {
  position: absolute; top: -5px; right: -5px; background: #f55; color: #fff;
  border-radius: 50%; width: 24px; height: 24px; font-size: 0.8rem;
  display: flex; align-items: center; justify-content: center; font-weight: bold;
}
.chat-overlay {
  position: fixed; bottom: 90px; right: 20px; width: 420px; height: 500px;
  max-height: calc(100dvh - 120px); max-width: calc(100vw - 40px);
  background: rgba(15,15,25,0.95); backdrop-filter: blur(10px);
  border: 1px solid var(--neon-blue); border-radius: var(--radius-lg);
  display: flex; flex-direction: column; z-index: 950; overflow: hidden;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

@media (max-width: 600px) {
  .chat-overlay {
    bottom: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: 75dvh;
    max-height: 100dvh;
    border-radius: 20px 20px 0 0;
    border: none;
    border-top: 2px solid var(--neon-blue);
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.5);
  }
}

.chat-header {
  background: rgba(0,245,255,0.1); padding: 10px 15px; display: flex;
  justify-content: space-between; align-items: center; font-weight: bold; border-bottom: 1px solid rgba(0,245,255,0.2);
}
.chat-header button { background: none; border: none; color: #fff; font-size: 1.2rem; cursor: pointer; }
.chat-messages-container { flex-grow: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.chat-input-area { display: flex; gap: 8px; padding: 10px; border-top: 1px solid rgba(255,255,255,0.1); align-items: stretch; }
.chat-input-area input { flex: 1; min-width: 0; margin-bottom: 0; }
.chat-input-area button { margin-top: 0; white-space: nowrap; }


/* === CHAT TABS === */
.chat-tab { flex:1; background:none; border:none; color:var(--text-secondary); padding:8px; cursor:pointer; font-weight:normal; }
.chat-tab.active { color:#0ff; font-weight:bold; border-bottom:2px solid #0ff; }



/* === SIDEBAR BACKDROP === */
.sidebar-backdrop {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); z-index: 1050; display: none;
}
.sidebar-backdrop.open { display: block; }


@keyframes pulse-ready {
  0% { transform: scale(1); box-shadow: 0 0 5px var(--neon-green); border-color: var(--neon-green); color: var(--neon-green); }
  100% { transform: scale(1.05); box-shadow: 0 0 20px var(--neon-green); border-color: #0ff; color: #fff; }
}
.btn-pulse-ready { animation: pulse-ready 1s infinite alternate !important; }

/* Custom Toggle Switch */
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider-global, .slider-perm {
  position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255,255,255,0.1); transition: .4s; border-radius: 34px;
}
.slider-global:before, .slider-perm:before {
  position: absolute; content: ""; left: 4px; bottom: 4px;
  background-color: #fff; transition: .4s; border-radius: 50%;
}
.slider-global:before { height: 20px; width: 20px; }
.slider-perm:before { height: 12px; width: 12px; }
.toggle-switch input:checked + .slider-global { background-color: var(--neon-green); box-shadow: 0 0 10px var(--neon-green); }
.toggle-switch input:checked + .slider-global:before { transform: translateX(22px); }
.toggle-switch input:checked + .slider-perm { background-color: var(--neon-blue); box-shadow: 0 0 8px var(--neon-blue); }
.toggle-switch input:checked + .slider-perm:before { transform: translateX(14px); }

/* ═══ AVATAR PICKER COMPONENT ═══ */
.avatar-picker-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
}

.avatar-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.avatar-category-bar {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 2px 0;
  flex: 1;
}
.avatar-category-bar::-webkit-scrollbar {
  display: none;
}

.avatar-cat-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-secondary);
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.avatar-cat-chip:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
.avatar-cat-chip.active {
  background: rgba(0, 245, 255, 0.2);
  border-color: var(--neon-blue);
  color: var(--neon-blue);
  font-weight: bold;
}

.avatar-nav-arrow {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}
.avatar-nav-arrow:hover {
  background: var(--neon-blue);
  color: #000;
  box-shadow: 0 0 10px rgba(0, 245, 255, 0.5);
}

.avatar-scroll-track {
  display: grid;
  grid-template-rows: repeat(4, 40px);
  grid-auto-flow: column;
  grid-auto-columns: 42px;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 6px 4px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
.avatar-scroll-track::-webkit-scrollbar {
  height: 6px;
}
.avatar-scroll-track::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}
.avatar-scroll-track::-webkit-scrollbar-thumb {
  background: rgba(0, 245, 255, 0.3);
  border-radius: 4px;
}
.avatar-scroll-track::-webkit-scrollbar-thumb:hover {
  background: var(--neon-blue);
}

.avatar-item-btn {
  font-size: 1.4rem;
  line-height: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.avatar-item-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: scale(1.1);
  border-color: rgba(0, 245, 255, 0.4);
}
.avatar-item-btn.selected {
  border-color: var(--neon-blue) !important;
  background: rgba(0, 245, 255, 0.22) !important;
  box-shadow: 0 0 12px rgba(0, 245, 255, 0.45);
  transform: scale(1.08);
}

/* Global SortableJS Drag & Drop Styles */
.sortable-ghost {
  opacity: 0.35 !important;
  background: rgba(0, 245, 255, 0.15) !important;
  border: 2px dashed var(--neon-blue) !important;
}

.sortable-chosen {
  cursor: grabbing !important;
  background: rgba(255, 190, 11, 0.15) !important;
  box-shadow: 0 4px 15px rgba(255, 190, 11, 0.25) !important;
}

.drag-handle, .tle-drag-handle, .se-drag-handle, .ee-q-drag-handle, .me-drag-handle, .qe-drag-handle, .tle-list-drag-handle, .se-cat-drag-handle {
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.drag-handle:active, .tle-drag-handle:active, .se-drag-handle:active, .ee-q-drag-handle:active, .me-drag-handle:active, .qe-drag-handle:active, .tle-list-drag-handle:active, .se-cat-drag-handle:active {
  cursor: grabbing;
}

