:root {
  --bs-body-bg: #0f172a;
  --bs-body-color: #ffffff;
  --bs-primary: #3b82f6;
  --bs-secondary: #ec4899;
  --bs-info: #00f2ff;
  --bs-dark: #0f172a;
  --derby-bg-deep: #0f172a;
  --derby-bg-dark: #1e1b4b;
  --derby-neon-blue: #3b82f6;
  --derby-neon-pink: #ec4899;
  --derby-neon-purple: #a855f7;
  --derby-neon-gold: #fbbf24;
  --neon-green: #00E676;
  --derby-cyan: #00F3FF;
  --derby-text-white: #ffffff;
  --derby-glass-bg: rgba(255, 255, 255, 0.05);
  --derby-glass-border: rgba(255, 255, 255, 0.1);
  --glass-bg: rgba(30, 27, 75, 0.4);
  --glass-border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ========================================================================
   DERBY GOLD STANDARD (GLOBAL CSS)
   ======================================================================== */
.card-gold-standard {
    background: rgba(30, 41, 59, 0.95) !important; /* Deep navy/slate #1e293b approx */
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    overflow: hidden;
}

.card-gold-standard:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 230, 118, 0.2);
    border-color: rgba(0, 230, 118, 0.4) !important;
}

.input-gold-standard {
    background-color: #1a1a1a !important;
    color: #fff !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.input-gold-standard:focus {
    border-color: var(--neon-green) !important;
    box-shadow: 0 0 10px rgba(0, 230, 118, 0.3) !important;
    background-color: #222 !important;
    outline: none;
}

.btn-neon {
    background-color: transparent;
    color: var(--neon-green);
    border: 2px solid var(--neon-green);
    border-radius: 30px;
    font-weight: bold;
    padding: 0.5rem 1.5rem;
    transition: all 0.3s ease;
    display: inline-block;
}

.btn-neon:hover {
    background-color: var(--neon-green);
    color: #111 !important;
    box-shadow: 0 0 15px rgba(0, 230, 118, 0.4);
}

.btn-cyan {
    background-color: transparent;
    color: var(--derby-cyan);
    border: 2px solid var(--derby-cyan);
    border-radius: 30px;
    font-weight: bold;
    padding: 0.5rem 1.5rem;
    transition: all 0.3s ease;
    display: inline-block;
}

.btn-cyan:hover {
    background-color: var(--derby-cyan);
    color: #111 !important;
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.4);
}

.glass-modal-swal {
    background: #1a1a1a !important;
    border: 1px solid rgba(255,255,255,0.1) !important;
    border-radius: 15px !important;
    color: #fff !important;
}

html,
body {
  background: radial-gradient(circle at top, #1e1b4b 0%, #0f172a 100%) !important;
  height: 100%;
  margin: 0;
  color: #fff;
}

body {
  font-family: 'Cairo', sans-serif;
  color: var(--bs-body-color);
  direction: rtl;
  text-align: right;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Glassmorphism Navbar */
.glass-nav {
  background: var(--glass-bg) !important;
  backdrop-filter: blur(10px);
  border-bottom: var(--glass-border);
  z-index: 1000;
}

/* Modern Card Style */
.glass-panel {
  background: rgba(255, 255, 255, 0.05) !important;
  backdrop-filter: blur(15px);
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  transition: all 0.3s ease;
}

.glass-panel:hover {
  background: rgba(255, 255, 255, 0.08) !important;
  transform: translateY(-5px);
}

/* Pulse Animation */
@keyframes pulse-red {
  0% {
    transform: scale(0.95);
    opacity: 0.7;
  }

  70% {
    transform: scale(1.1);
    opacity: 1;
  }

  100% {
    transform: scale(0.95);
    opacity: 0.7;
  }
}

.live-indicator {
  display: inline-block;
  width: 10px;
  height: 10px;
  background-color: #ff4d4d;
  border-radius: 50%;
  margin-left: 8px;
  animation: pulse-red 2s infinite;
  box-shadow: 0 0 10px #ff4d4d;
}

/* Winner Styles */
.winner-gold {
  color: #ffd700;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
  font-weight: 800;
  transform: scale(1.1);
}

.winner-silver {
  color: #c0c0c0;
  font-weight: 600;
}

.winner-bronze {
  color: #cd7f32;
  font-weight: 600;
}

.podium-icon {
  font-size: 1.5rem;
  margin-left: 5px;
}

/* Custom Footer */
.footer {
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(5px);
  padding: 20px 0;
  margin-top: auto;
  flex-shrink: 0;
}

a {
  text-decoration: none;
}

.btn-primary {
  background-color: var(--bs-primary);
  border-color: var(--bs-primary);
}

.btn-primary:hover {
  background-color: #2c5282;
  border-color: #2c5282;
}

/* Form Controls Dark Mode Override */
.form-control,
.form-select {
  background-color: #2d2d2d;
  border: 1px solid #444;
  color: #fff;
}

.form-control:focus,
.form-select:focus {
  background-color: #333;
  color: #fff;
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 0.25rem rgba(58, 110, 165, 0.25);
}

/* Common Helpers */
.text-justify {
  text-align: right !important;
}

/* جديد */
/* ========================================================================
   GLOBAL RESPONSIVE SAFETY RULES - MOBILE BULLETPROOFING
   ======================================================================== */

/* -------------------------------------------------------------------------
   1. GLOBAL TEXT TRUNCATION UTILITY
   Prevents long text (names, emails, etc.) from breaking layout
   Usage: Add .mobile-truncate to any element with potentially long text
   ------------------------------------------------------------------------- */
.mobile-truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  display: block;
}

/* Apply automatic truncation to common long-text elements on mobile */
@media (max-width: 576px) {

  .card-title,
  .user-name,
  .user-email,
  .badge-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* -------------------------------------------------------------------------
   2. BOOTSTRAP CARD SAFETY
   Prevents cards from overflowing viewport and causing horizontal scroll
   ------------------------------------------------------------------------- */
.card {
  max-width: 100% !important;
  overflow: hidden;
  word-wrap: break-word;
  word-break: break-word;
}

.card-body {
  overflow-x: hidden;
  max-width: 100%;
}

/* Prevent images inside cards from breaking layout */
.card img {
  max-width: 100%;
  height: auto;
}

/* Ensure card text content never overflows */
.card-text,
.card-title,
.card-subtitle {
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
}

/* -------------------------------------------------------------------------
   3. RESPONSIVE FONT SCALING
   Reduces heading sizes on small screens to prevent overwhelming mobile UI
   ------------------------------------------------------------------------- */
@media (max-width: 576px) {
  h1 {
    font-size: 1.75rem !important;
    /* Down from ~2.5rem */
  }

  h2 {
    font-size: 1.5rem !important;
    /* Down from ~2rem */
  }

  h3 {
    font-size: 1.25rem !important;
    /* Down from ~1.75rem */
  }

  h4 {
    font-size: 1.1rem !important;
  }

  h5 {
    font-size: 1rem !important;
  }
}

/* -------------------------------------------------------------------------
   4. FLEXBOX SAFETY FOR VERY SMALL SCREENS
   Forces horizontal flex containers to stack vertically on tiny screens
   Prevents text overlap and improves readability
   ------------------------------------------------------------------------- */
@media (max-width: 400px) {

  /* Only stack d-flex by default if it's not explicitly protected */
  .d-flex:not(.keep-flex-mobile),
  .flex-row:not(.keep-flex-mobile),
  [class*="d-flex"]:not(.keep-flex-mobile) {
    flex-direction: column !important;
    align-items: flex-start !important;
  }

  /* Ensure flex items take full width when stacked */
  .d-flex:not(.keep-flex-mobile)>*,
  .flex-row:not(.keep-flex-mobile)>* {
    width: 100% !important;
    margin-bottom: 0.5rem;
  }
}

/* -------------------------------------------------------------------------
   5. USER PROFILE CARD - DASHBOARD SPECIFIC FIX
   Targets the typical Bootstrap user profile card structure
   Forces Avatar, Name, and Badge to stack vertically on mobile
   ------------------------------------------------------------------------- */
@media (max-width: 576px) {

  /* Profile card container */
  .card .user-profile,
  .card .profile-header,
  .card .d-flex.align-items-center {
    flex-direction: column !important;
    align-items: center !important;
    text-align: center;
  }

  /* Avatar/Image stacking */
  .user-profile img,
  .profile-header img,
  .card img.rounded-circle,
  .card .avatar {
    margin-bottom: 1rem;
    margin-right: 0 !important;
  }

  /* Profile text content */
  .user-profile .ms-3,
  .profile-header .ms-3,
  .user-info {
    margin-left: 0 !important;
    margin-top: 0.75rem;
    width: 100%;
  }

  /* Badges and user status */
  .user-profile .badge,
  .profile-header .badge,
  .user-badge {
    margin-top: 0.5rem;
    margin-left: 0 !important;
    display: inline-block;
  }

  /* User details list */
  .user-details,
  .profile-details {
    margin-top: 1rem;
  }
}

/* -------------------------------------------------------------------------
   6. ADDITIONAL MOBILE SAFETY MEASURES
   Prevents common layout breaking issues
   ------------------------------------------------------------------------- */

/* Prevent tables from causing horizontal scroll */
@media (max-width: 768px) {
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 100%;
  }
}

/* Ensure buttons stack nicely on mobile */
@media (max-width: 576px) {
  .btn-group {
    flex-direction: column;
  }

  .btn-group>.btn {
    width: 100%;
    margin-bottom: 0.5rem;
  }
}

/* Prevent long URLs or unbreakable strings from overflow */
a,
p,
span,
div {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Container safety - ensure no element exceeds viewport width */
* {
  max-width: 100%;
}

/* Exception for html and body */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

/* ========================================================================
   GLOBAL UI STANDARDIZATION
   ======================================================================== */

.hall-card-img {
  height: 150px !important;
  object-fit: cover !important;
  width: 100%;
  background-color: #1a1d20;
}

@media (max-width: 576px) {
  .card-body {
    padding: 0.75rem !important;
  }

  .card-title {
    font-size: 1rem !important;
  }

  .card-body .small,
  .card-body span:not(.btn span),
  .card-body .badge {
    font-size: 0.7rem !important;
  }
}

/* Icon Row - Forces horizontal layout on mobile */
.icon-row {
  display: flex !important;
  flex-direction: row !important;
  justify-content: center !important;
  gap: 1rem !important;
  flex-wrap: nowrap !important;
}

.icon-row i {
  font-size: 0.9rem !important;
}


.hall-card-fixed {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 380px;
}

.hall-card-fixed .card-body {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.text-shadow-sm {
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* Updated Pulse for Live Badge */
.live-pulse-v2 {
  width: 12px;
  height: 12px;
  background: #ff3e3e;
  border-radius: 50%;
  position: absolute;
  aspect-ratio: 1/1;
  /* Ensure circular shape */
  animation: pulse-ring-v3 1.8s cubic-bezier(0.24, 0, 0.38, 1) infinite;
}

@keyframes pulse-ring-v3 {
  0% {
    transform: scale(0.4);
    opacity: 0.9;
  }

  100% {
    transform: scale(3.5);
    opacity: 0;
  }
}

/* Horizontal Scroll Helpers */
.flex-nowrap {
  display: flex;
  flex-wrap: nowrap;
}

.horizontal-scroll-wrapper {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 1rem;
}

.horizontal-scroll-wrapper::-webkit-scrollbar {
  height: 4px;
}

.horizontal-scroll-wrapper::-webkit-scrollbar-thumb {
  background: rgba(0, 210, 255, 0.3);
  border-radius: 10px;
}

/* ========================================================================
   END OF MOBILE RESPONSIVE SAFETY RULES
   ======================================================================== */
/*جديد/*
   /* ========================================================================
   MOBILE TABLE SAFETY - PREVENT HEADER BREAKING & ENABLE SCROLL
   (Dark Mode Optimized)
   ======================================================================== */

@media (max-width: 768px) {

  /* 1. Force container to allow horizontal scrolling */
  .table-responsive,
  .table-container,
  div>table {
    display: block;
    width: 100%;
    overflow-x: auto;
    /* السماح بالسكرول الجانبي */
    -webkit-overflow-scrolling: touch;
    /* سكرول ناعم للموبايل */
    margin-bottom: 1rem;
  }

  /* 2. Prevent text wrapping in headers and cells */
  /* This stops headers like "اللاعب" from breaking vertically */
  .table th,
  .table td,
  table th,
  table td {
    white-space: nowrap !important;
    /* يمنع نزول الحروف تحت بعضها */
    vertical-align: middle;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  /* 3. Scrollbar Styling (Optimized for Dark Mode) */
  /* Webkit browsers (Chrome, Safari, Edge) */
  .table-responsive::-webkit-scrollbar,
  div>table::-webkit-scrollbar {
    height: 4px;
    /* ارتفاع الشريط */
  }

  .table-responsive::-webkit-scrollbar-track,
  div>table::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    /* مسار شفاف فاتح */
    border-radius: 10px;
  }

  .table-responsive::-webkit-scrollbar-thumb,
  div>table::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    /* مقبض أبيض شفاف ليظهر على الخلفية السوداء */
    border-radius: 10px;
  }

  /* Firefox */
  .table-responsive,
  div>table {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) rgba(255, 255, 255, 0.05);
  }
}

/* Snap Scrolling Container (Netflix style) */
.horizontal-scroll-snap {
  display: flex !important;
  overflow-x: auto !important;
  scroll-snap-type: x mandatory !important;
  gap: 1rem;
  padding: 1rem !important;
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

.horizontal-scroll-snap::-webkit-scrollbar {
  display: none !important;
}

.snap-item {
  scroll-snap-align: center;
  flex: 0 0 auto;
}

@media (max-width: 768px) {
  .snap-item {
    width: 85vw !important;
    /* Peek effect */
  }
}

/* Footer Avatar Fix - Prevents Distortion and adds Floating Effect */
.footer-player-avatar {
  width: 55px !important;
  height: 55px !important;
  min-width: 55px !important;
  min-height: 55px !important;
  object-fit: cover !important;
  border-radius: 50% !important;
  border: 4px solid #fbbf24 !important;
  /* Using gold primary */
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5) !important;
  margin-top: -20px !important;
  /* Overlap effect */
  background: #121212;
  transition: transform 0.3s ease;
}

.footer-player-avatar:hover {
  transform: scale(1.1) translateY(-5px);
}

/* ========================================================================
   SCROLL TO TOP BUTTON (Floating)
   ======================================================================== */
.scroll-to-top-btn {
  position: fixed;
  bottom: 30px;
  left: 30px;
  width: 50px;
  height: 50px;
  background: rgba(30, 27, 75, 0.7);
  backdrop-filter: blur(10px);
  border: 1px solid var(--derby-glass-border);
  border-radius: 50%;
  color: var(--derby-neon-blue);
  font-size: 1.5rem;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 9999;
  transition: all 0.3s ease;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.scroll-to-top-btn:hover {
  background: var(--derby-neon-blue);
  color: #fff;
  transform: translateY(-5px);
  box-shadow: 0 10px 25px rgba(59, 130, 246, 0.4);
}

.scroll-to-top-btn.show {
  display: flex;
  animation: fadeInUp 0.5s ease;
}

/* ========================================================================
   PAGE ANIMATIONS
   ======================================================================== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

.animate-fade-in-up {
  animation: fadeInUp 0.6s ease-out;
}

.animate-fade-in {
  animation: fadeIn 0.5s ease-out;
}

.animate-slide-right {
  animation: slideInRight 0.6s ease-out;
}

/* Staggered animation for cards */
.card:nth-child(1) { animation: fadeInUp 0.5s ease-out 0.1s both; }
.card:nth-child(2) { animation: fadeInUp 0.5s ease-out 0.2s both; }
.card:nth-child(3) { animation: fadeInUp 0.5s ease-out 0.3s both; }
.card:nth-child(4) { animation: fadeInUp 0.5s ease-out 0.4s both; }
.card:nth-child(5) { animation: fadeInUp 0.5s ease-out 0.5s both; }
.card:nth-child(6) { animation: fadeInUp 0.5s ease-out 0.6s both; }
.card:nth-child(7) { animation: fadeInUp 0.5s ease-out 0.7s both; }
.card:nth-child(8) { animation: fadeInUp 0.5s ease-out 0.8s both; }
.card:nth-child(9) { animation: fadeInUp 0.5s ease-out 0.9s both; }
.card:nth-child(10) { animation: fadeInUp 0.5s ease-out 1.0s both; }
.card:nth-child(11) { animation: fadeInUp 0.5s ease-out 1.1s both; }
.card:nth-child(12) { animation: fadeInUp 0.5s ease-out 1.2s both; }

/* Row items animation */
.row > div:nth-child(1) { animation: fadeInUp 0.5s ease-out 0.1s both; }
.row > div:nth-child(2) { animation: fadeInUp 0.5s ease-out 0.2s both; }
.row > div:nth-child(3) { animation: fadeInUp 0.5s ease-out 0.3s both; }
.row > div:nth-child(4) { animation: fadeInUp 0.5s ease-out 0.4s both; }
.row > div:nth-child(5) { animation: fadeInUp 0.5s ease-out 0.5s both; }
.row > div:nth-child(6) { animation: fadeInUp 0.5s ease-out 0.6s both; }
.row > div:nth-child(7) { animation: fadeInUp 0.5s ease-out 0.7s both; }
.row > div:nth-child(8) { animation: fadeInUp 0.5s ease-out 0.8s both; }

/* ========================================================================
   RESPONSIVE FIXES FOR VERY SMALL SCREENS (400px and below)
   ======================================================================== */
@media (max-width: 400px) {
  /* Fix profile circles to be perfectly round */
  .profile-circle,
  .rounded-circle,
  .player-avatar,
  .avatar {
    border-radius: 50% !important;
    aspect-ratio: 1 / 1 !important;
  }
  
  /* Ensure cards don't overflow */
  .card {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
  
  /* Reduce padding on very small screens */
  .container {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }
  
  .card-body {
    padding: 0.5rem !important;
  }
  
  /* Fix image containers */
  .hall-image-container,
  .avatar-wrapper {
    overflow: hidden;
    border-radius: 8px;
  }
  
  /* Ensure buttons stack properly */
  .btn-group,
  .d-flex.gap-2,
  .d-flex.gap-3 {
    flex-direction: column !important;
    width: 100% !important;
  }
  
  .btn-group > *,
  .d-flex.gap-2 > *,
  .d-flex.gap-3 > * {
    width: 100% !important;
  }
}