/* Modern Typography & Layout */
body {
  font-family: var(--font-family);
  color: var(--text);
  background: var(--bg-gradient);
  background-attachment: fixed;
  min-height: 100vh;
  font-weight: 400;
  line-height: 1.6;
}

/* Animated Background */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.1) 0%, transparent 50%),
              radial-gradient(circle at 80% 80%, rgba(236, 72, 153, 0.1) 0%, transparent 50%),
              radial-gradient(circle at 40% 60%, rgba(245, 158, 11, 0.05) 0%, transparent 50%);
  pointer-events: none;
  z-index: -1;
  animation: backgroundShift 20s ease-in-out infinite;
}

@keyframes backgroundShift {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  33% { transform: translate(-10px, -10px) rotate(1deg); }
  66% { transform: translate(10px, -5px) rotate(-1deg); }
}

/* Modern Button System */
.btn-primary {
  background: var(--gradient-primary);
  border: none;
  color: white;
  font-weight: var(--font-weight-semibold);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow), var(--shadow-glow);
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s;
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.btn-primary:hover::before {
  left: 100%;
}

.btn-primary:active {
  transform: translateY(0) scale(0.98);
}

.btn-primary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn-secondary {
  background: var(--surface-glass);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  backdrop-filter: blur(10px);
  font-weight: var(--font-weight-medium);
  transition: all var(--transition-base);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
  color: var(--text);
}

.btn-success {
  background: var(--gradient-success);
  border: none;
  color: white;
  font-weight: var(--font-weight-semibold);
  box-shadow: var(--shadow), 0 0 20px rgb(132 204 22 / 0.3);
}

.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), 0 0 25px rgb(132 204 22 / 0.4);
}

.btn-warning {
  background: var(--gradient-secondary);
  border: none;
  color: white;
  font-weight: var(--font-weight-semibold);
  box-shadow: var(--shadow), var(--shadow-orange-glow);
}

.btn-warning:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), var(--shadow-orange-glow);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  border: none;
  color: white;
  font-weight: var(--font-weight-semibold);
  box-shadow: var(--shadow), 0 0 20px rgb(239 68 68 / 0.3);
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), 0 0 25px rgb(239 68 68 / 0.4);
}

.btn-outline-primary {
  border: 2px solid var(--primary);
  color: var(--primary);
  background: transparent;
  font-weight: var(--font-weight-semibold);
  transition: all var(--transition-base);
}

.btn-outline-primary:hover {
  background: var(--primary);
  color: white;
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

/* Mobile-first button sizing */
.btn-lg {
  min-height: 48px;
  padding: var(--space-3) var(--space-6);
  font-size: 1.1rem;
  font-weight: 600;
}

@media (min-width: 768px) {
  .btn-lg {
    min-height: 56px;
    padding: var(--space-4) var(--space-8);
  }
}

/* Modern Card System */
.card {
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow-lg);
  position: relative;
  transition: all var(--transition-base);
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--gradient-rainbow);
  opacity: 0.5;
}

.card-hover:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: var(--shadow-xl);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Special Card Variants */
.card-primary {
  border: 1px solid var(--primary);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.card-success {
  border: 1px solid var(--lime);
  box-shadow: var(--shadow-lg), 0 0 20px rgb(132 204 22 / 0.2);
}

.card-warning {
  border: 1px solid var(--orange);
  box-shadow: var(--shadow-lg), var(--shadow-orange-glow);
}

.card-glass {
  background: var(--surface-glass);
  backdrop-filter: blur(15px);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.card-body {
  padding: var(--space-6);
}

@media (min-width: 768px) {
  .card-body {
    padding: var(--space-8);
  }
}

/* Form Controls */
.form-control {
  background: var(--surface-2);
  border-color: rgba(55, 65, 81, 0.5);
  color: var(--text);
  border-radius: var(--radius-sm);
  min-height: 48px;
}

.form-control:focus {
  background: var(--surface-2);
  border-color: var(--brand-500);
  color: var(--text);
  box-shadow: 0 0 0 0.2rem rgba(61, 147, 255, 0.25);
}

.form-control::placeholder {
  color: var(--muted);
}

.form-label {
  color: var(--text);
  font-weight: 500;
  margin-bottom: var(--space-2);
}

/* Layout Utilities */
.stack {
  display: flex;
  gap: var(--space-4);
}

.stack-col {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.stack-sm {
  gap: var(--space-2);
}

.stack-lg {
  gap: var(--space-6);
}

/* Navigation */
.navbar {
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(55, 65, 81, 0.3);
}

.navbar-brand {
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--brand-400) !important;
}

.nav-link {
  color: var(--text) !important;
  font-weight: 500;
  transition: color 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
  color: var(--brand-400) !important;
}

/* Alert Overrides */
.alert {
  border-radius: var(--radius-sm);
  border: none;
  margin-bottom: var(--space-4);
}

.alert-success {
  background: rgba(22, 163, 74, 0.1);
  color: var(--success);
  border-left: 4px solid var(--success);
}

.alert-warning {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
  border-left: 4px solid var(--warning);
}

.alert-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border-left: 4px solid var(--danger);
}

/* Focus Styles */
*:focus-visible {
  outline: 2px solid var(--brand-300);
  outline-offset: 2px;
}

/* Interactive States */
.interactive {
  transition: all 0.2s ease;
}

.interactive:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

/* Text Colors */
.text-muted {
  color: var(--muted) !important;
}

.text-brand {
  color: var(--brand-500) !important;
}

/* Badge Overrides */
.badge {
  border-radius: var(--radius-sm);
  font-weight: 500;
  padding: var(--space-1) var(--space-3);
}

/* List Group */
.list-group-item {
  background: var(--surface);
  border-color: rgba(55, 65, 81, 0.3);
  color: var(--text);
}

.list-group-item:hover {
  background: var(--surface-2);
}

/* Game-specific Components */
.question-card {
  background: rgba(17, 24, 39, 0.9);
  border-radius: var(--radius);
  padding: var(--space-6);
  border: 1px solid rgba(55, 65, 81, 0.3);
  margin-bottom: var(--space-4);
}

.choice-btn, .choice-button {
  min-height: 56px;
  text-align: left;
  background: var(--surface);
  border: 2px solid rgba(55, 65, 81, 0.3);
  color: var(--text);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
  transition: all 0.2s ease;
}

.choice-btn:hover {
  border-color: var(--brand-500);
  background: rgba(61, 147, 255, 0.1);
  color: var(--text);
}

.choice-btn:focus-visible {
  outline: 2px solid var(--brand-300);
  outline-offset: 2px;
}

.choice-btn.selected {
  background: var(--brand-500);
  border-color: var(--brand-600);
  color: white;
}

.choice-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Progress Bar */
.progress {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  height: 8px;
}

.progress-bar {
  background: linear-gradient(90deg, var(--brand-500), var(--brand-400));
  border-radius: var(--radius-sm);
}

/* Responsive Utilities */
@media (max-width: 576px) {
  .container,
  .container-sm,
  .container-md,
  .container-lg,
  .container-xl,
  .container-xxl {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }
  
  .card-body {
    padding: var(--space-4);
  }
  
  .btn-lg {
    width: 100%;
    margin-bottom: var(--space-2);
  }
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: var(--z-toast);
}

.toast {
  background: var(--surface);
  color: var(--text);
  border: 1px solid rgba(55, 65, 81, 0.3);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
}

/* Reconnection Banner */
.reconnection-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--warning);
  color: var(--bg);
  padding: var(--space-2);
  text-align: center;
  font-weight: 500;
  z-index: var(--z-modal);
  transform: translateY(-100%);
  transition: transform 0.3s ease;
}

.reconnection-banner.show {
  transform: translateY(0);
}

/* Loading States */
.loading {
  position: relative;
  overflow: hidden;
}

.loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% { left: -100%; }
  100% { left: 100%; }
}

/* Game Status Indicators */
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 0.875rem;
  font-weight: 500;
}

.status-indicator::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.status-lobby::before { background: var(--warning); }
.status-active::before { background: var(--success); }
.status-completed::before { background: var(--muted); }

/* Animation Classes */
.fade-in {
  animation: fadeIn 0.3s ease-in-out;
}

.slide-up {
  animation: slideUp 0.3s ease-out;
}

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

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