/* General Styles */
body {
  background-color: #f8f9fa;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Splash Screen */
.splash-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.splash-container {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.splash-header {
  text-align: center;
  color: white;
  margin-bottom: 30px;
}

.splash-header i {
  font-size: 4rem;
  margin-bottom: 10px;
}

.splash-header h1 {
  font-size: 1.8rem;
  font-weight: bold;
}

/* Utility Classes */
.d-none {
  display: none !important;
}

/* Password cell hover effect */
.password-cell {
  cursor: pointer;
  position: relative;
  user-select: none;
}

.password-cell:hover {
  background-color: #fff3cd;
}

/* Admin Only Elements */
.admin-only {
  display: none;
}

body.admin .admin-only {
  display: block;
}

body.admin .admin-only.table-cell {
  display: table-cell;
}

body.admin #addPlayerCard,
body.admin #importExportCard,
body.admin #createTournamentCard {
  display: block;
}

/* Player Only Elements */
.player-only {
  display: none;
}

body.player .player-only {
  display: block;
}

body.player #addPlayerCard,
body.player #importExportCard,
body.player #createTournamentCard {
  display: none;
}

/* Password Strength Indicator */
.password-strength {
  height: 5px;
  margin-top: 5px;
  border-radius: 3px;
  transition: all 0.3s;
}

.password-weak {
  background-color: #dc3545;
  width: 33%;
}

.password-medium {
  background-color: #ffc107;
  width: 66%;
}

.password-strong {
  background-color: #28a745;
  width: 100%;
}

/* Match Cards */
.match-card {
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 20px;
  background-color: white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.match-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 2px solid #e9ecef;
}

.match-tournament {
  font-weight: bold;
  color: #495057;
}

.match-court {
  background-color: #e7f3ff;
  color: #0066cc;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
}

.match-status {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
}

.match-status.in-progress {
  background-color: #fff3cd;
  color: #856404;
}

.match-status.completed {
  background-color: #d4edda;
  color: #155724;
}

.team-section {
  padding: 15px;
  border-radius: 6px;
  margin-bottom: 15px;
}

.team-a {
  background-color: #e3f2fd;
  border-left: 4px solid #2196f3;
}

.team-b {
  background-color: #fce4ec;
  border-left: 4px solid #e91e63;
}

.team-name {
  font-weight: bold;
  font-size: 1.1rem;
  margin-bottom: 10px;
  color: #212529;
}

.team-players {
  font-size: 0.95rem;
  color: #6c757d;
}

.score-input {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.score-input label {
  font-weight: 600;
  margin: 0;
}

.score-input input {
  width: 80px;
}

.match-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.match-winner {
  text-align: center;
  padding: 10px;
  background-color: #d4edda;
  border-radius: 6px;
  font-weight: bold;
  color: #155724;
  margin-bottom: 10px;
}

/* Tournament Accordion */
.accordion-button:not(.collapsed) {
  background-color: #e7f3ff;
  color: #0066cc;
}

.tournament-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 8px;
  background-color: #f8f9fa;
  border-radius: 4px;
}

/* Statistics Cards */
.card h3 {
  color: #667eea;
  font-weight: bold;
  margin: 0;
}

.card .text-muted {
  margin: 0;
  font-size: 0.9rem;
}

/* Table Styles */
.table-hover tbody tr:hover {
  background-color: #f1f3f5 !important;
}

.table-hover tbody tr:hover td,
.table-hover tbody tr:hover th {
  background-color: #f1f3f5 !important;
}

.table-hover tbody tr:hover .actions-column {
  background-color: #e0e0e0 !important;
}

/* Center all table headers and cells */
.table th,
.table td {
  text-align: center !important;
  vertical-align: middle;
}

/* Matches table column headers - red font and white background */
#matchesContainer .table th,
#matchesContainer .table thead th {
  color: #dc3545 !important;
  background-color: #ffffff !important;
  font-weight: 600;
}

/* Center Result column (actions column) content */
.table .actions-column,
.table th.actions-column-header {
  text-align: center !important;
  vertical-align: middle;
  background-color: #d5d5d5 !important;
}

.table .actions-column .d-flex,
.table .actions-column .match-score-inputs {
  justify-content: center !important;
  align-items: center !important;
  margin: 0 auto;
}

.table .actions-column .btn,
.table .actions-column button {
  margin: 0 auto;
}

/* Score Column Styling - Bigger font, centered, with winner/loser colors */
.table .score-column {
  text-align: center !important;
  font-size: 1.3rem !important;
  font-weight: 600;
  vertical-align: middle;
  padding: 1rem 0.5rem !important;
}

.table .score-column strong {
  font-size: 1.3rem;
  font-weight: 600;
}

/* Ensure score colors are visible */
.table .score-column span[style*="color: #28a745"] {
  color: #28a745 !important;
  font-weight: bold;
}

.table .score-column span[style*="color: #dc3545"] {
  color: #dc3545 !important;
}

/* Charts */
canvas {
  max-height: 400px;
}

/* Court Distribution Preview */
.court-preview {
  padding: 10px;
  margin-bottom: 10px;
  background-color: #f8f9fa;
  border-left: 3px solid #667eea;
  border-radius: 4px;
  font-size: 0.85rem;
}

.court-preview h6 {
  color: #667eea;
  font-weight: bold;
  margin-bottom: 5px;
  font-size: 0.9rem;
}

.court-preview ul {
  margin: 0;
  padding-left: 20px;
  font-size: 0.8rem;
}

.court-preview li {
  font-size: 0.8rem;
}

/* Player Selection List */
.player-selection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.player-selection-btn {
  padding: 12px 16px;
  border: 2px solid #dee2e6;
  border-radius: 8px;
  background-color: white;
  color: #212529;
  font-size: 0.75rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  position: relative;
}

.player-selection-btn:hover {
  border-color: #667eea;
  background-color: #f8f9fa;
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.player-selection-btn.selected {
  background-color: #667eea;
  border-color: #667eea;
  color: white;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.player-selection-btn.selected:hover {
  background-color: #5568d3;
  border-color: #5568d3;
}

.player-selection-text {
  flex-grow: 1;
  font-weight: 500;
  font-size: 0.7rem;
}

.player-selection-check {
  font-size: 1.2rem;
  color: white;
  flex-shrink: 0;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .splash-header h1 {
    font-size: 1.5rem;
  }
  
  .match-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  
  .match-actions {
    flex-direction: column;
    width: 100%;
  }
  
  .match-actions button {
    width: 100%;
  }
  
  .player-selection-grid {
    grid-template-columns: 1fr;
  }
  
  .player-selection-btn {
    width: 100%;
  }
}

/* Zoom matches tab to 95% - applies to all screen sizes */
#matches {
  zoom: 0.95;
  -ms-zoom: 0.95;
  font-size: 95%;
}

#matches .table,
#matches .table th,
#matches .table td,
#matches .form-control,
#matches .form-select,
#matches .btn,
#matches .card,
#matches .card-header,
#matches .card-body,
#matches h1,
#matches h2,
#matches h3,
#matches h4,
#matches h5,
#matches h6,
#matches p,
#matches span,
#matches label {
  font-size: 0.95em !important;
}

#matches .table .score-column {
  font-size: calc(1.3rem * 0.95) !important;
}

/* Mobile Phone Optimizations (iPhone & Android) */
@media (max-width: 576px) {
  /* General Layout */
  body {
    font-size: 14px;
    overflow-x: hidden;
  }
  
  .container-fluid {
    padding-left: 10px;
    padding-right: 10px;
    max-width: 100%;
    overflow-x: hidden;
  }
  
  /* Prevent any horizontal overflow */
  #matchesContainer,
  #matchesContainer > * {
    max-width: 100%;
    overflow-x: hidden;
  }
  
  /* Navbar */
  .navbar-brand {
    font-size: 1.1rem;
  }
  
  .navbar-text {
    font-size: 0.85rem;
    margin-right: 8px !important;
  }
  
  .navbar .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
  }
  
  /* Tabs */
  .nav-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  
  .nav-tabs::-webkit-scrollbar {
    display: none;
  }
  
  .nav-tabs .nav-link {
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
    white-space: nowrap;
    min-width: auto;
  }
  
  .nav-tabs .nav-link i {
    margin-right: 3px;
    font-size: 0.9rem;
  }
  
  /* Cards */
  .card {
    margin-bottom: 15px;
  }
  
  .card-header h5 {
    font-size: 1rem;
  }
  
  .card-body {
    padding: 15px;
  }
  
  /* Forms */
  .form-label {
    font-size: 0.9rem;
    margin-bottom: 0.4rem;
  }
  
  .form-control,
  .form-select {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 0.5rem 0.75rem;
    min-height: 44px; /* Touch-friendly */
  }
  
  .form-control-sm {
    font-size: 16px;
    min-height: 38px;
  }
  
  /* Buttons - Touch-friendly sizing */
  .btn {
    min-height: 44px;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    touch-action: manipulation; /* Prevents double-tap zoom */
  }
  
  .btn-sm {
    min-height: 38px;
    padding: 0.375rem 0.75rem;
    font-size: 0.85rem;
  }
  
  /* Match action buttons (Win/Lost) */
  /* Match winner buttons - ensure they're touch-friendly */
  .match-winner-buttons {
    width: 100%;
  }
  
  .team-a-winner,
  .team-b-winner {
    min-height: 44px;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    flex: 1;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  
  .d-flex.gap-2 {
    gap: 8px !important;
  }
  
  /* Ensure buttons in table cells are properly sized */
  .table td .d-flex {
    flex-wrap: wrap;
  }
  
  .table td .btn {
    min-width: 80px;
  }
  
  /* Tables - No horizontal scroll, fit to viewport */
  .table-responsive {
    -webkit-overflow-scrolling: touch;
    overflow-x: hidden !important;
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0;
    padding: 0;
  }
  
  .table {
    font-size: 0.8rem;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    table-layout: fixed;
    margin: 0;
    border-collapse: collapse;
  }
  
  .table th,
  .table td {
    padding: 0.35rem 0.25rem;
    white-space: normal;
    word-wrap: break-word;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
  }
  
  .table th {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.4rem 0.25rem;
  }
  
  /* Court column - very narrow */
  .table th:nth-child(2),
  .table td:nth-child(2) {
    width: 8% !important;
    max-width: 35px !important;
    min-width: 30px !important;
    white-space: nowrap;
    text-align: center;
    padding: 0.3rem 0.15rem !important;
  }
  
  /* Phase column - narrow */
  .table th:nth-child(3),
  .table td:nth-child(3) {
    width: 12% !important;
    max-width: 55px !important;
    min-width: 45px !important;
    white-space: nowrap;
    padding: 0.3rem 0.15rem !important;
  }
  
  /* Team A column - flexible with text truncation */
  .table th:nth-child(4),
  .table .team-a-column,
  .table td:nth-child(4) {
    width: 40% !important;
    font-size: 0.7rem !important;
    line-height: 1.2;
    word-break: break-word;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0.3rem 0.2rem !important;
    white-space: normal;
  }
  
  /* Team B column - flexible with text truncation */
  .table th:nth-child(5),
  .table td:nth-child(5) {
    width: 40% !important;
    font-size: 0.7rem !important;
    line-height: 1.2;
    word-break: break-word;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0.3rem 0.2rem !important;
    white-space: normal;
  }
  
  /* Badge sizing in phase column */
  .table td:nth-child(3) .badge {
    font-size: 0.65rem;
    padding: 0.2em 0.4em;
    white-space: nowrap;
  }
  
  /* Tournament Info */
  .tournament-info {
    flex-direction: column;
    gap: 5px;
  }
  
  .tournament-info span {
    font-size: 0.85rem;
  }
  
  /* Accordion */
  .accordion-button {
    font-size: 0.9rem;
    padding: 0.75rem 1rem;
  }
  
  /* Modals */
  .modal-dialog {
    margin: 0.5rem;
    max-width: calc(100% - 1rem);
  }
  
  .modal-content {
    border-radius: 8px;
  }
  
  .modal-header {
    padding: 1rem;
  }
  
  .modal-title {
    font-size: 1.1rem;
  }
  
  .modal-body {
    padding: 1rem;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .modal-footer {
    padding: 0.75rem;
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .modal-footer .btn {
    width: 100%;
    margin: 0;
  }
  
  /* Player Selection Grid */
  .player-selection-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  
  .player-selection-btn {
    padding: 14px 16px;
    font-size: 0.9rem;
    min-height: 48px;
  }
  
  /* Statistics Cards */
  .card h3 {
    font-size: 1.8rem;
  }
  
  /* Charts */
  canvas {
    max-height: 250px;
  }
  
  /* Splash Screen */
  .splash-container {
    padding: 15px;
  }
  
  .splash-header i {
    font-size: 3rem;
  }
  
  .splash-header h1 {
    font-size: 1.3rem;
  }
  
  /* Filters Row */
  .row.mb-3 {
    margin-bottom: 1rem !important;
  }
  
  .row.mb-3 .col-md-3,
  .row.mb-3 .col-md-2,
  .row.mb-3 .col-md-6 {
    margin-bottom: 0.75rem;
  }
  
  /* Badges */
  .badge {
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
  }
  
  /* Court Cards in Round View */
  .col-md-6 {
    margin-bottom: 1rem;
  }
  
  /* Match Cards */
  .match-card {
    padding: 12px;
    margin-bottom: 15px;
  }
  
  .team-section {
    padding: 12px;
    margin-bottom: 12px;
  }
  
  .team-name {
    font-size: 1rem;
  }
  
  /* Toast adjustments already handled below */
}

/* Form Validation */
.form-text.text-danger {
  color: #dc3545 !important;
}

.form-text.text-success {
  color: #28a745 !important;
}

/* Loading Animation */
.spinner-border-sm {
  width: 1rem;
  height: 1rem;
  border-width: 0.2em;
}

/* Button Enhancements */
.btn {
  transition: all 0.3s ease;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Card Shadows */
.card {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: box-shadow 0.3s ease;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Navbar Enhancement */
.navbar-brand {
  font-size: 1.3rem;
  font-weight: bold;
}

.navbar-brand i {
  color: #ffc107;
}

/* Tab Enhancement */
.nav-tabs .nav-link {
  color: #6c757d;
  font-weight: 500;
}

.nav-tabs .nav-link.active {
  color: #667eea;
  font-weight: 600;
}

.nav-tabs .nav-link i {
  margin-right: 5px;
}

/* Different colors for each tab */
#players-tab {
  color: #0d6efd !important; /* Blue */
}

#players-tab.active {
  color: #0d6efd !important;
  border-bottom-color: #0d6efd !important;
}

#tournaments-tab {
  color: #198754 !important; /* Green */
}

#tournaments-tab.active {
  color: #198754 !important;
  border-bottom-color: #198754 !important;
}

#matches-tab {
  color: #dc3545 !important; /* Red */
}

#matches-tab.active {
  color: #dc3545 !important;
  border-bottom-color: #dc3545 !important;
}

#statistics-tab {
  color: #000000 !important; /* Black */
}

#statistics-tab.active {
  color: #000000 !important;
  border-bottom-color: #000000 !important;
}

#info-tab {
  color: #6f42c1 !important; /* Purple */
}

#info-tab.active {
  color: #6f42c1 !important;
  border-bottom-color: #6f42c1 !important;
}

/* Toast Notifications */
.toast-container {
  z-index: 9999;
}

.toast {
  min-width: 300px;
  max-width: 500px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-radius: 8px;
}

.toast-body {
  display: flex;
  align-items: center;
  padding: 12px 16px;
}

.toast-body i {
  font-size: 1.2rem;
  margin-right: 8px;
}

.toast.bg-success {
  background-color: #28a745 !important;
}

.toast.bg-danger {
  background-color: #dc3545 !important;
}

.toast.bg-warning {
  background-color: #ffc107 !important;
  color: #212529 !important;
}

.toast.bg-warning .toast-body {
  color: #212529 !important;
}

.toast.bg-info {
  background-color: #17a2b8 !important;
}

.toast.bg-warning .btn-close {
  filter: invert(1);
}

/* Responsive toast adjustments */
@media (max-width: 576px) {
  .toast-container {
    left: 0;
    right: 0;
    padding: 10px;
    top: 0;
    bottom: auto;
  }
  
  .toast {
    min-width: auto;
    width: 100%;
    max-width: 100%;
    margin-bottom: 10px;
  }
  
  .toast-body {
    padding: 10px 14px;
    font-size: 0.9rem;
  }
}

/* Additional Mobile Optimizations */
@media (max-width: 480px) {
  /* Extra small phones */
  body {
    font-size: 13px;
  }
  
  .table {
    font-size: 0.8rem;
    min-width: 550px;
  }
  
  .btn {
    font-size: 0.85rem;
    padding: 0.45rem 0.9rem;
  }
  
  .card-header h5 {
    font-size: 0.95rem;
  }
  
  .modal-title {
    font-size: 1rem;
  }
  
  .nav-tabs .nav-link {
    font-size: 0.8rem;
    padding: 0.45rem 0.6rem;
  }
  
  .team-a-winner,
  .team-b-winner {
    font-size: 0.85rem;
    padding: 0.45rem 0.9rem;
  }
}

/* Landscape orientation adjustments */
@media (max-width: 768px) and (orientation: landscape) {
  .modal-body {
    max-height: calc(100vh - 150px);
  }
  
  .splash-container {
    max-width: 500px;
  }
}

/* Prevent text size adjustment on iOS */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
  select,
  textarea,
  input[type="text"],
  input[type="password"],
  input[type="datetime"],
  input[type="datetime-local"],
  input[type="date"],
  input[type="month"],
  input[type="time"],
  input[type="week"],
  input[type="number"],
  input[type="email"],
  input[type="url"],
  input[type="search"],
  input[type="tel"],
  input[type="color"] {
    font-size: 16px !important;
  }
}

/* Touch-friendly improvements */
* {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

button, a, input, select, textarea {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

/* Improve scrolling on mobile */
html {
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

body {
  -webkit-overflow-scrolling: touch;
  overflow-x: hidden;
}

/* Table improvements for mobile */
@media (max-width: 576px) {
  .table-responsive {
    border: none;
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
  }
  
  /* Keep headers visible but make them sticky for better UX */
  .table thead th {
    position: sticky;
    top: 0;
    background-color: #f8f9fa;
    z-index: 10;
    box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.1);
    font-weight: 600;
  }
  
  /* Hide Tournament column on mobile */
  .table .tournament-column,
  .table th.tournament-column {
    display: none !important;
  }
  
  /* Hide Score, Status, and TeamA columns on mobile (they'll show as rows) */
  .table .score-column,
  .table .status-column,
  .table .actions-column,
  .table th.score-column-header,
  .table th.status-column-header,
  .table th.actions-column-header {
    display: none !important;
  }
  
  /* Ensure table fits viewport */
  .table {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    table-layout: fixed !important;
  }
  
  /* Calculate total visible columns: Court (8%) + Phase (12%) + Team A (40%) + Team B (40%) = 100% */
  .table th:nth-child(2),
  .table td:nth-child(2) {
    width: 10% !important;
  }
  
  .table th:nth-child(3),
  .table td:nth-child(3) {
    width: 15% !important;
  }
  
  .table th:nth-child(4),
  .table td:nth-child(4) {
    width: 37.5% !important;
  }
  
  .table th:nth-child(5),
  .table td:nth-child(5) {
    width: 37.5% !important;
  }
  
  /* Mobile info row styling */
  .match-mobile-info {
    background-color: #f8f9fa;
    border-top: none;
  }
  
  .match-mobile-info td {
    padding: 0 !important;
    border-top: 2px solid #dee2e6;
  }
  
  .mobile-info-cell {
    padding: 12px 15px !important;
  }
  
  .mobile-match-details {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  
  .mobile-detail-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background-color: white;
    border-radius: 6px;
    border: 1px solid #e9ecef;
  }
  
  /* Score row - bigger font and centered */
  .mobile-score-row {
    padding: 12px;
  }
  
  .mobile-score-value {
    flex: 1;
    text-align: center !important;
    font-size: 1.4rem !important;
    font-weight: 600;
    justify-content: center !important;
  }
  
  .mobile-label {
    font-weight: 600;
    color: #495057;
    font-size: 0.9rem;
    min-width: 60px;
  }
  
  .mobile-value {
    flex: 1;
    text-align: right;
    font-size: 0.9rem;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
  }
  
  .mobile-value .btn {
    min-height: 38px;
    font-size: 0.85rem;
  }
  
  .mobile-value .d-flex {
    justify-content: flex-end;
  }
  
  /* Ensure match rows don't have extra spacing on mobile */
  .match-row td {
    padding: 0.5rem 0.4rem;
  }
  
  /* Additional mobile optimizations */
  .table-responsive {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  
  /* Ensure no element causes overflow */
  .table,
  .table * {
    max-width: 100%;
    box-sizing: border-box;
  }
  
  /* Compact player names in team columns */
  .table .team-a-column,
  .table td:nth-child(4),
  .table td:nth-child(5) {
    font-size: 0.7rem !important;
    line-height: 1.2;
  }
  
  /* Make sure waiting info doesn't break layout */
  .table .team-a-column small {
    display: block;
    font-size: 0.65rem;
    margin-top: 2px;
  }
  
  /* Force table to fit viewport */
  .col-12 {
    max-width: 100%;
    overflow-x: hidden;
    padding-left: 5px;
    padding-right: 5px;
  }
  
  /* Ensure table wrapper doesn't overflow */
  #matchesContainer .col-12 {
    max-width: 100vw;
    overflow-x: hidden;
  }
}

/* Ensure modals are full-width on very small screens */
@media (max-width: 400px) {
  .modal-dialog {
    margin: 0.25rem;
    max-width: calc(100% - 0.5rem);
  }
  
  .modal-body {
    padding: 0.75rem;
  }
  
  .table {
    font-size: 0.75rem;
    min-width: 500px;
  }
  
  .btn-sm {
    font-size: 0.8rem;
    padding: 0.3rem 0.6rem;
  }
}

/* Sortable table headers */
.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
}

.sortable:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.sort-indicator {
  display: inline-block;
  margin-left: 5px;
  color: #007bff;
  font-weight: bold;
}

.sort-active {
  background-color: rgba(0, 123, 255, 0.1) !important;
}

.sort-active .sort-indicator {
  color: #0056b3;
}

/* Pool Distribution Preview in Modal */
#courtDistributionPreview,
#manageCourtDistributionPreview {
  border-left: 2px solid #dee2e6;
  padding-left: 15px;
  min-height: 200px;
  position: sticky;
  top: 0;
  font-size: 0.85rem;
}

#courtDistributionPreview h6,
#manageCourtDistributionPreview h6 {
  margin-bottom: 15px;
  color: #495057;
  font-weight: 600;
  font-size: 0.9rem;
}

#courtDistributionPreview .mb-2,
#manageCourtDistributionPreview .mb-2 {
  font-size: 0.8rem;
}

#courtDistributionPreview .mb-2 strong,
#manageCourtDistributionPreview .mb-2 strong {
  font-size: 0.85rem;
}

@media (max-width: 767.98px) {
  #courtDistributionPreview,
  #manageCourtDistributionPreview {
    border-left: none;
    border-top: 2px solid #dee2e6;
    padding-left: 0;
    padding-top: 15px;
    margin-top: 20px;
    position: static;
  }
}

/* Random shuffle buttons - red color */
#randomDistributeNewTournamentBtn,
#randomDistributePlayersBtn {
  background-color: #dc3545;
  border-color: #dc3545;
  color: white;
  display: none; /* Hidden by default, shown only for Random and K/Q formats */
}

#randomDistributeNewTournamentBtn:hover,
#randomDistributePlayersBtn:hover {
  background-color: #c82333;
  border-color: #bd2130;
  color: white;
}

#randomDistributeNewTournamentBtn:focus,
#randomDistributePlayersBtn:focus {
  background-color: #c82333;
  border-color: #bd2130;
  color: white;
  box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.5);
}
