/* NewTon DC - Tournament Manager
   Minimalistic flat 2D design
   - Clean, airy interface with muted colors
   - Selective accent colors for actions
   - Professional desktop-focused layout
   integrity: 4e-65-77-54-6f-6e-20-44-43
*/

/* Fonts */
@font-face {
  font-family: 'Droid Serif';
  src: url('../fonts/DroidSerif-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Droid Serif';
  src: url('../fonts/DroidSerif-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Insignia';
  src: url('../fonts/Insignia-Regular.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Inter';
  src: url('../fonts/Inter-VariableFont_opsz,wght.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Inter';
  src: url('../fonts/Inter-Italic-VariableFont_opsz,wght.ttf') format('truetype');
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'Manrope';
  src: url('../fonts/Manrope-VariableFont_wght.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Cascadia Code';
  src: url('../fonts/CascadiaCode-VariableFont_wght.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Cascadia Code';
  src: url('../fonts/CascadiaCode-Italic-VariableFont_wght.ttf') format('truetype');
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}

/* CSS Variables */
:root {
  --font-body: 'Manrope', sans-serif;
  --font-clock:'Cascadia Code', 'SF Mono', 'Monaco', 'Consolas', monospace;
}

/* Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* App shell */
body {
  font-family: var(--font-body);
  background: #f1f5f5;
  min-height: 100vh;
  color: #2a2a2a;
}

.container {
  width: 100%;
  margin: 0;
  padding: 20px;
}

/* Header */
.header {
  background: #ffffff;
  border: 1px solid #666666;
  padding: 24px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header h1 {
  color: #000000;
  font-size: 2.25rem;
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 15px;
  /* font-family: 'Droid Serif', serif; */
  font-family: 'Insignia';
}

.logo-placeholder {
  width: 60px;
  height: 60px;
  background: #f5f5f5;
  border: 1px solid #c0c0c0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666666;
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.5px;
  text-align: center;
  line-height: 1.2;
}

.club-logo {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid #e5e7eb;
  overflow: hidden;
}

/* Nav */
.nav {
  display: flex;
  gap: 32px;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.nav-btn {
  padding: 0;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  color: #444444;
  cursor: pointer;
  font-family: inherit;
  font-weight: 400;
  font-size: 16px;
  text-decoration: none;
  transition: color 0.15s ease;
}

.nav-btn:hover {
  color: #222222;
}

.nav-btn.active {
  color: #222222;
  font-weight: 400;
  border-bottom-color: rgba(22, 101, 52, 1);
}

/* Header clock - matches Match Controls clock styling */
.header-clock {
  font-family: var(--font-clock);
  font-size: 18px;
  font-weight: normal;
  border: 1px solid #ccc;
  padding: 8px 16px;
  border-radius: 6px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.24);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-tournament-status {
  color: #6b7280;
  font-size: 14px;
  font-weight: 400;
  text-align: right;
  line-height: 1.3;
  white-space: nowrap;
}

.header-tournament-status strong {
  color: #111827;
  font-weight: 600;
}

.header-tournament-status .status-prefix {
  display: none;
}

.header-tournament-wide strong {
  display: block;
  font-size: 15px;
}

.header-tournament-wide .tournament-date {
  font-size: 13px;
}

.header-tournament-narrow {
  display: none;
}

@media (max-width: 1120px) {
  .header-tournament-wide {
    display: none;
  }
  .header-tournament-narrow {
    display: block;
    text-align: center;
    padding-bottom: 8px;
    margin-bottom: 4px;
    border-bottom: 1px solid #e5e7eb;
  }
  .header-tournament-narrow .status-prefix {
    display: inline;
  }
  .header-clock {
    display: none;
  }
  .header h1 {
    font-size: 1.5rem;
  }
  .header {
    padding: 12px;
    margin-bottom: 12px;
    gap: 8px;
  }
  .history-page-subtitle {
    display: none;
  }
}

/* Tournament Page */
.page {
  display: none;
  background: #ffffff;
  border-radius: 0;
  padding: 24px;
  box-shadow: none;
  color: #111827; /* ensure readable text on light page */
}

.page.active {
  display: block;
}

/* Tournament page fullscreen override */
#tournament.page {
  padding: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  height: 100vh;
  overflow: hidden;
}

#tournament.page.active {
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 999;
}

/* Forms */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
  color: #111827;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 16px;
  color: #111827;
  background: #ffffff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input::placeholder {
  color: #6b7280;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #ff6b35;
  box-shadow: 0 0 0 3px rgba(255,107,53,0.15);
}

.form-group input:disabled,
.form-group select:disabled {
  background: #f3f4f6;
  color: #6b7280;
}

/* Buttons */
.btn {
  padding: 12px 20px;
  border: 1px solid #b0b0b0;
  border-radius: 6px;
  background: #ffffff;
  color: #333333;
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  transition: all 0.15s ease;
  margin-right: 10px;
  margin-bottom: 10px;
  height: 44px;
  box-sizing: border-box;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.btn:hover {
  background: #f8f8f8;
  border-color: #999999;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.12);
}

.btn-success {
  color: #166534;
  border-color: #166534;
}
.btn-success:hover {
  background: #dcfce7;
  border-color: #166534;
}

.btn-danger {
  color: #dc2626;
  border-color: #dc2626;
}
.btn-danger:hover {
  background: #fef2f2;
  border-color: #dc2626;
}

.btn-warning {
  color: #d97706;
  border-color: #d97706;
}
.btn-warning:hover {
  background: #fef3c7;
  border-color: #d97706;
}

/* Remove blue focus outline from buttons, except modal default buttons */
.btn:focus:not([style*="boxShadow"]),
.zoom-btn:focus,
.nav-btn:focus {
  outline: none;
}

/* Press feedback — subtle tactile shift on click */
.btn:active,
.nav-btn:active,
.zoom-btn:active,
.help-btn:active,
.cc-match-action-btn:active,
.achievement-export-btn:active,
.tournament-create-button:active,
.analytics-reset-btn:active,
.analytics-back-btn:active,
.close:active {
  transform: translate(1.5px, 1.5px);
}

/* Tournament info grid */
.tournament-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

/* Registration page flex layout - sticky footer */
/* !IMPORTANT CLEANUP: Could use higher specificity instead of !important - OPTIMIZATION CANDIDATE */
#registration.registration-page-flex {
  display: flex !important;
  flex-direction: column;
}

/* Only apply when page is actually active */
#registration:not(.active) {
  display: none !important;
}

.registration-page-header {
  flex-shrink: 0;
}

/* Registration page two-column layout */
.registration-layout {
  display: flex;
  flex-direction: row; /* Explicitly set horizontal layout */
  gap: 30px;
  margin-top: 20px;
  align-items: flex-start;
  flex: 1;
}

.players-column {
  width: 580px; /* Fixed width for player cards + breathing room */
  flex-shrink: 0;
}

.results-column {
  flex: 1; /* Takes remaining space */
  min-width: 0; /* Allows table to shrink if needed */
}

/* Player cards in single column */
.players-list {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

/* Results section adjustments */
#resultsSection {
  margin-top: 0; /* Remove top margin since it's now inline */
}

/* Bracket container (light) */
.bracket-container {
  position: relative;
  width: 100%;
  height: 100vh;
  background: #f5f5f5;
  border: 8px solid rgba(17,24,39,0.15);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 25px rgba(0,0,0,0.25);
}

.bracket-viewport {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
  cursor: grab;
  /* Prevent text selection on the viewport itself */
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.bracket-viewport:active { cursor: grabbing; }

.bracket-canvas {
  position: relative;
  width: 3000px;
  height: 3000px;
  background: #f5f5f5;
  transform-origin: 0 0;
  will-change: transform;
}

/* Bracket controls - CORRECTED 2x2 grid layout */
.bracket-controls {
  position: absolute;
  top: 20px;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 100;
  pointer-events: none;
}

.bracket-controls-middle-left {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
}

.bracket-controls-middle-right {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
}

/* Wide buttons for middle-left too */
.bracket-controls-middle-left .zoom-btn {
  width: 150px;
  font-size: 14px;
  font-weight: 700;
}

.bracket-controls-top,
.bracket-controls-middle,
.bracket-controls-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin: 0 20px;
  pointer-events: none; /* Changed from auto to none */
}

/* Only the button groups should capture pointer events, not the full-width containers */
.bracket-controls-top-left,
.bracket-controls-top-right,
.bracket-controls-middle-left,
.bracket-controls-middle-right,
.bracket-controls-bottom-left,
.bracket-controls-bottom-right {
  pointer-events: auto; /* Only these specific button groups capture events */
}

.bracket-controls-top-left,
.bracket-controls-top-right,
.bracket-controls-middle-right,
.bracket-controls-bottom-left,
.bracket-controls-bottom-right {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

/* Keep the middle row aligned to the right */
.bracket-controls-middle {
  justify-content: space-between;
}

/* Prevent text selection during canvas dragging */
.bracket-canvas,
.bracket-canvas * {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

/* Maintain grab cursor consistently across the canvas */
.bracket-canvas {
  cursor: inherit;
}

/* Override text selection for watermarks specifically */
/* Prevent text selection on all watermark elements */
.bracket-watermarks,
.bracket-watermarks * {
  user-select: none !important;
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
}

/* Disable pointer events by default, will be overridden for specific elements */
.bracket-watermarks {
  pointer-events: none;
}

/* Prevent text selection within match cards during drag operations */
.bracket-match * {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.zoom-btn {
  width: 45px;
  height: 45px;
  border: none;
  border-radius: 0;
  background: rgba(39, 39, 39, 0.95);
  color: #ffffff;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 2px 10px rgba(0,0,0,0.35);
  white-space: nowrap;
}

.zoom-btn:hover {
  background: rgba(17,24,39,1);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.35);
}

/* Subtle color tints for key tournament buttons */
.zoom-btn.match-controls-btn {
  background: rgba(22, 101, 52, 0.9); /* Subtle green tint */
}
.zoom-btn.match-controls-btn:hover {
  background: rgba(22, 101, 52, 1);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.35);
}

.bracket-controls-top-left .zoom-btn,
.bracket-controls-middle-left .zoom-btn,
.bracket-controls-bottom-left .zoom-btn {
  width: 150px;
  font-size: 14px;
  font-weight: 700;
}

/* Navigation button layout with left-aligned icon/arrow and centered text */
.nav-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-arrow,
.nav-icon {
  position: absolute;
  left: 12px;
  width: 20px;
  text-align: center;
}

.nav-text {
  flex: 1;
  text-align: center;
  padding-left: 32px; /* Account for icon space (12px left + 20px icon width) */
  padding-right: 12px; /* Balance the padding */
}

/* Bracket watermarks */
.bracket-watermarks {
  position: absolute;
  bottom: 0;
  left: 20px;
  right: 20px;
  height: 45px;
  z-index: 100;
  pointer-events: none;
  display: flex;
  align-items: center;
  overflow: visible;
}

.watermark-left {
  position: absolute;
  left: 30px;
  font-family: 'Inter';
  font-size: 16px;
  color: #696969;
}

.watermark-center {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  font-family: 'Inter';
  font-size: 16px;
  font-weight: 500;
  color: #333333;
  letter-spacing: normal;
  transition: all 0.2s ease;
}

.watermark-center.active {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(6px);
  border-radius: 8px;
  padding: 8px 16px;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.status-line1 {
  font-weight: 600;
  margin-bottom: 2px;
  text-align: center;
}

.status-line2 {
  font-weight: 400;
  font-size: 14px;
  opacity: 0.85;
  text-align: center;
}

#watermark-right {
  position: absolute;
  right: -20px;
  bottom: 0px;
  font-family: 'Courier New', 'Monaco', 'Menlo', monospace;
  font-size: 13px !important;
  font-weight: 400;
  color: #2c3e50;
  letter-spacing: 0.5px;
  background: rgba(255, 255, 255, 0.6);
  border-left: 1px solid #34495e;
  border-top: 1px solid #34495e;
  border-right: none;
  border-bottom: none;
  border-radius: 0px;
  padding: 0;
  line-height: 1.2;
  backdrop-filter: blur(6px);
  width: 336px;
}

/* CAD Title Block Structure */
#watermark-right .cad-header-container {
  display: flex;
  background: #ecf0f1;
  border-bottom: 1px solid #34495e;
}

#watermark-right .cad-header-title {
  flex: 1;
  padding: 7px 10px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: #2c3e50;
  letter-spacing: 1px;
}

#watermark-right .cad-header-clock {
  width: auto;
  padding: 7px 10px;
  text-align: center;
  font-weight: 600;
  font-size: 12px;
  color: #2c3e50;
  border-left: 1px solid #34495e;
}

#watermark-right .cad-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 36px 36px 36px;
  border-collapse: collapse;
}

#watermark-right .cad-cell {
  padding: 5px 7px;
  display: flex;
  align-items: center;
  font-size: 12px;
  line-height: 1.1;
}

/* Internal borders - only where needed for CAD style */

/* Row 1: Format spans two columns, Players on right */
#watermark-right .cad-format {
  grid-column: 1 / 3;
  grid-row: 1;
  border-right: 1px solid #34495e;
  border-bottom: 1px solid #34495e;
}

#watermark-right .cad-players {
  grid-column: 3;
  grid-row: 1 / 3;
  border-bottom: 1px solid #34495e;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}

/* Row 2: Bracket and Matches separate cells */
#watermark-right .cad-bracket {
  grid-column: 1;
  grid-row: 2;
  border-right: 1px solid #34495e;
  border-bottom: 1px solid #34495e;
  justify-content: center;
}

#watermark-right .cad-matches {
  grid-column: 2;
  grid-row: 2;
  border-right: 1px solid #34495e;
  border-bottom: 1px solid #34495e;
  justify-content: center;
}

/* Row 3: Date, Version, Status */
#watermark-right .cad-date {
  grid-column: 1;
  grid-row: 3;
  border-right: 1px solid #34495e;
  justify-content: center;
}

#watermark-right .cad-version {
  grid-column: 2;
  grid-row: 3;
  border-right: 1px solid #34495e;
  justify-content: center;
  position: relative;
  z-index: 100;
}

/* Allow version number to be clickable when cursor is pointer (developer mode enabled) */
#watermark-right .cad-version[style*="cursor: pointer"] {
  pointer-events: auto;
}

#watermark-right .cad-status {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 112px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: #e74c3c;
}

/* Bracket section titles */
.bracket-title {
  position: absolute;
  font-family: 'Inter';
  font-size: 28px;
  font-weight: 900;
  color: rgba(17,24,39,0.35);
  letter-spacing: 3px;
  text-transform: uppercase;
  z-index: 5;
  text-shadow: 2px 2px 4px rgba(255,255,255,0.8);
  pointer-events: none;
}
.bracket-title.finals {
  font-size: 24px;
  color: #ff6b35;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

/* Match cards (light) */
.bracket-match {
  position: absolute;
  width: 280px;
  height: 150px;
  background: #ffffff;
  border: 2px solid #d1d5db;
  transition: transform 0.3s ease-out, z-index 0s;
  transform-origin: center;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  font-size: 11px;
  transition: all 0.2s ease;
  cursor: pointer;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  color: #111827;
}

.bracket-match:hover {
  border-color: #ff6b35;
  box-shadow: 0 8px 20px rgba(255,107,53,0.25);
  transform: translateY(-2px);
  z-index: 20;
}

/* Match state styles */
.bracket-match.match-pending {
  background: #f8f9fa;
  border-color: #6b7280;
  opacity: 0.85;
}
.bracket-match.match-pending .match-player {
  color: #6b7280;
  cursor: default;
}
.bracket-match.match-pending:hover {
  border-color: #6b7280;
  transform: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.bracket-match.match-ready {
  background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
  border-color: rgba(240, 196, 25, 0.9);
  border-width: 3px;
}
.bracket-match.match-ready:hover {
  border-color: rgba(240, 196, 25, 1);
  box-shadow: 0 8px 22px rgba(240, 196, 25, 0.35);
}

.bracket-match.match-live,
.bracket-match.active {
  background: linear-gradient(135deg, #fff8f0 0%, #ffe8d6 100%);
  border-color: #ff6b35;
  border-width: 3px;
}
.bracket-match.match-live:hover,
.bracket-match.active:hover {
  border-color: #e55a2b;
  box-shadow: 0 10px 26px rgba(255,107,53,0.45);
}

/* Disable animation during zoom hover to prevent conflict */
.bracket-match.zoom-hover {
  animation: none !important;
  transform-origin: center;
}

.bracket-match.match-completed,
.bracket-match.completed {
  background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
  border-color: rgba(22, 101, 52, 1);
  border-width: 2px;
}
.bracket-match.match-completed:hover,
.bracket-match.completed:hover {
  border-color: rgba(22, 101, 52, 1);
  box-shadow: 0 8px 22px rgba(22, 101, 52, 0.32);
}

/* Match internals */
.match-header {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  padding: 6px 8px;
  font-weight: 800;
  font-size: 10px;
  text-align: center;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 24px;
  border-radius: 0;
  color: #111827;
}

.match-info {
  font-size: 12px;
  color: #374151;
}

.match-players {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.match-player {
  flex: 1;
  padding: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #f3f4f6;
  transition: background 0.15s ease;
  cursor: pointer;
  min-height: 36px;
  color: #111827;
}
.match-player:last-child { border-bottom: none; }
.match-player:hover { background: rgba(255,107,53,0.08); }

.match-player.disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.match-player.disabled:hover { background: none; }

.match-player.winner {
  background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
  font-weight: 800;
  min-height: 38px;
}

.match-player.first-throw {
  border-left: 4px solid #ff6b35;
  background: rgba(255,107,53,0.06);
}

.match-player.bye {
  color: #6b7280;
  font-style: italic;
  cursor: default;
}

.bracket-match.match-completed .match-player.bye,
.bracket-match.completed .match-player.bye {
  background: #e8f5e9;
}

.player-name-short {
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  font-weight: 600;
  color: #111827;
}

.player-eliminated {
  position: relative;
  color: #b87070;
  overflow: visible; /* allow ::after line to extend beyond clipped text bounds */
}

.player-eliminated::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  border-top: 1.5px solid #555;
  transform: rotate(-10deg);
  transform-origin: center;
}

.awaiting-player {
  font-style: italic;
  color: #999;
  font-weight: 400;
}

.winner-check {
  color: #16a34a;
  font-weight: 900;
  font-size: 18px;
  margin-left: 8px;
  min-width: 20px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

.match-controls {
  padding: 6px 10px;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-top: 1px solid #e5e7eb;
  font-size: 9px;
  display: flex;
  justify-content: space-between;
  min-height: 28px;
  align-items: center;
  border-radius: 0 0 8px 8px;
  color: #111827;
}

/* Round indicators */
.round-indicator {
  background: #2563eb;
  color: #ffffff;
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 8px;
  font-weight: 800;
}
.round-indicator.backside { background: #6f42c1; }
.round-indicator.final   { background: #f59e0b; color: #111827; }
.round-indicator.grand   { background: #dc2626; animation: glow 2s infinite alternate; }

/* State badges */
.match-state-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 8px;
  font-weight: 800;
  color: #ffffff;
  z-index: 20;
}
.match-state-badge.pending   { background: #6b7280; }
.match-state-badge.ready     { background: #f59e0b; color: #111827; }
.match-state-badge.live      { background: #ff6b35; animation: pulse 2s infinite; }
.match-state-badge.completed { background: #16a34a; }

/* Subtle hover glow */
.bracket-match::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: linear-gradient(45deg, transparent, rgba(255,107,53,0.12), transparent);
  border-radius: 12px;
  z-index: -1;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.bracket-match:hover::before { opacity: 1; }

/* Config sections */
.config-section {
  background: #f8f9fa;
  border-radius: 0;
  padding: 20px;
  margin-bottom: 20px;
  border: 1px solid #e5e7eb;
  color: #111827;
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  inset: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.5);
}

.modal-content {
  background-color: rgba(255, 255, 255, 0.9);
  margin: 5% auto;
  padding: 28px;
  border-radius: 0;
  width: 90%;
  max-width: 640px;
  max-height: 80vh; /* Limit modal height */
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
  color: #111827;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* Prevent content overflow */
}


/* Analytics Modal - Override default modal constraints */
.analytics-modal-content {
  margin: 1% auto !important;
  max-height: 98vh !important;
  max-width: none !important;
}

/* Remove rounded corners from all inputs in modals */
.modal-content input[type="text"],
.modal-content input[type="number"],
.modal-content input[type="date"],
.modal-content input[type="text"]:focus,
.modal-content input[type="number"]:focus,
.modal-content input[type="date"]:focus {
  border-radius: 0 !important;
  -webkit-border-radius: 0 !important;
  -moz-border-radius: 0 !important;
}

/* === Dialog system (.dlg) — newer modal pattern, used alongside .modal-content === */
/* Sits inside an existing .modal backdrop. Two layouts: default (single column) and --split (sidebar + main). */
.dlg {
  margin: 5% auto;
  width: 90%;
  max-width: 580px;
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(20, 25, 35, 0.06), 0 20px 50px rgba(20, 25, 35, 0.16);
  overflow: hidden;
  color: #2a2f3a;
}

.dlg__title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.3px;
  margin: 0;
  color: #1a1f2a;
  padding-bottom: 14px;
  border-bottom: 1px solid #ecedf1;
}

.dlg__desc {
  color: #6b7280;
  font-size: 14px;
  line-height: 1.55;
  margin: 0;
}

.dlg__note {
  background: #ffffff;
  border: 1px solid #ecedf1;
  border-radius: 8px;
  padding: 14px 16px;
  box-shadow: 0 1px 2px rgba(20, 25, 35, 0.04), 0 4px 12px rgba(20, 25, 35, 0.06);
}
.dlg__note > * + * { margin-top: 10px; }
.dlg__note .dlg__desc { color: #2a2f3a; }

.dlg__label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #4a5160;
  margin-bottom: 8px;
}

.dlg__input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d8dbe2;
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border 0.15s, box-shadow 0.15s;
}

.dlg__input:focus {
  border-color: #5b8def;
  box-shadow: 0 0 0 3px rgba(91, 141, 239, 0.15);
}

.dlg__foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 24px;
  background: #fbfbfc;
  border-top: 1px solid #ecedf1;
}

/* --split: metadata sidebar on the left, main content on the right */
.dlg--split { max-width: 720px; }
/* --wide: ~20% wider, used when content (long player names, 3-button footers) needs more room */
.dlg--wide  { max-width: 880px; }
.dlg__grid { display: grid; grid-template-columns: 260px 1fr; }
.dlg__sidebar {
  padding: 24px 20px;
  background: #f7f8fa;
  border-right: 1px solid #ecedf1;
}
.dlg__sidebar-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #8b91a0;
  margin-bottom: 4px;
}
.dlg__sidebar-value {
  font-size: 15px;
  font-weight: 600;
  color: #1a1f2a;
  margin-bottom: 14px;
}
.dlg__sidebar-value:last-child { margin-bottom: 0; }
.dlg__main { padding: 24px; }
.dlg__main > * + * { margin-top: 14px; }

.dlg__pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fef3c7;
  color: #d97706;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
}
.dlg__pill::before {
  content: "";
  width: 6px;
  height: 6px;
  background: #d97706;
  border-radius: 50%;
}
.dlg__pill--danger { background: #fee2e2; color: #dc2626; }
.dlg__pill--danger::before { background: #dc2626; }

.close {
  color: #6b7280;
  float: right;
  font-size: 28px;
  font-weight: 800;
  cursor: pointer;
  margin-top: -6px;
}
.close:hover { color: #111827; }

/* Alerts */
.alert {
  padding: 15px;
  margin: 15px 0;
  border: 1px solid transparent;
  border-radius: 10px;
  color: #111827;
}

.alert-info {
  color: #0b3a42;
  background-color: #d1ecf1;
  border-color: #bee5eb;
}

.alert-success {
  color: #0f5132;
  background-color: #d4edda;
  border-color: #c3e6cb;
}

.alert-warning {
  color: #5c3d00;
  background-color: #fff3cd;
  border-color: #ffeaa7;
}

/* Animations */
@keyframes pulse {
  0%   { box-shadow: 0 6px 18px rgba(255,107,53,0.28); }
  50%  { box-shadow: 0 10px 26px rgba(255,107,53,0.45); transform: translateY(-1px); }
  100% { box-shadow: 0 6px 18px rgba(255,107,53,0.28); }
}
@keyframes glow {
  0%   { text-shadow: 0 0 5px rgba(220,38,38,0.45); }
  100% { text-shadow: 0 0 20px rgba(220,38,38,0.8), 0 0 30px rgba(220,38,38,0.35); }
}

/* Footer */
footer {
  text-align: center;
  padding: 20px;
  color: #4b5563;
  font-size: 14px;
  border: 1px solid #666666;
  margin-top: 20px;
  background: #ffffff;
  border-radius: 0;
}

footer a {
  color: inherit;
  text-decoration: none;
}

footer a:hover {
  color: inherit;
  text-decoration: underline;
}

/* Utilities */
.text-center { text-align: center; }
.mt-20 { margin-top: 20px; }

/* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 4px; }
::-webkit-scrollbar-thumb { background: #9ca3af; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #6b7280; }

/* Links */
a { color: #1d4ed8; }
a:hover { color: #1e40af; }

/* Help system styles */
.help-btn {
    position: absolute !important;
    right: 20px !important;
    top: 20px !important;
    width: 32px !important;
    height: 32px !important;
    border-radius: 50% !important;
    border: 2px solid #ff6b35 !important;
    background: #ffffff !important;
    color: #ff6b35 !important;
    font-weight: bold !important;
    font-size: 16px !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s ease !important;
    z-index: 10 !important;
}

.help-btn:hover {
    background: #ff6b35;
    color: #ffffff;
    transform: scale(1.1);
}

.help-modal {
    font-family: var(--font-body) !important;
}

.help-modal h4 {
    margin: 0 0 10px 0 !important;
    color: #ff6b35 !important;
}

.help-modal ul, .help-modal ol {
    margin: 10px 0 !important;
    padding-left: 20px !important;
}

.help-modal li {
    margin: 5px 0 !important;
}

.help-modal p {
    margin: 10px 0 !important;
}

.help-modal strong {
    color: #111827 !important;
}

/* Validation message styles */
#legValidationMessage {
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    background: #fff5f5;
    color: #dc2626;
    border: 1px solid #fecaca;
}

/* Enhanced input styling for validation states */
#winnerLegs:invalid, #loserLegs:invalid {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1) !important;
}

#winnerLegs:valid, #loserLegs:valid {
    border-color: #16a34a !important;
}

/* Disabled confirm button styling */
#winnerConfirmOK:disabled {
    background: #6b7280 !important;
    cursor: not-allowed !important;
    opacity: 0.6 !important;
}

/* Help hint animation */
@keyframes slideDown {
    from { 
        transform: translateX(-50%) translateY(-100%); 
        opacity: 0; 
    }
    to { 
        transform: translateX(-50%) translateY(0); 
        opacity: 1; 
    }
}

/* Surgical Undo */
.winner-check .undo-icon {
  display: none;
  color: #065f46; /* Dark cold green */
  font-weight: bold;
  font-size: 18px;
}

.match-player.undoable:hover .winner-check .undo-icon {
  display: inline;
}

.match-player.undoable:hover .winner-check .checkmark {
  display: none;
}

/* Stats modal should appear above Command Center */
#statsModal {
  z-index: 1100 !important;
}

/* Match Command Center */
.cc-match-section {
  margin-bottom: 25px;
}

.cc-section-header {
  font-size: 16px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 15px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e5e7eb;
}

.cc-matches-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cc-match-card {
  background: #f8f9fa;
  border: 1px solid #e5e7eb;
  border-radius: 0;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.cc-match-card-live {
  box-shadow: 0 0 12px rgba(249, 115, 22, 0.4), 0 0 20px rgba(249, 115, 22, 0.1);
  border-color: #fb923c;
}

.cc-match-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  min-height: 36px;
}

.cc-match-id {
  font-weight: 600;
  font-size: 14px;
  color: #111827;
}

.cc-match-format {
  font-size: 12px;
  color: #6b7280;
}

.cc-match-players {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.cc-player-name {
  font-size: 16px;
  font-weight: 700;
  color: #065f46;
  cursor: pointer;
  text-decoration: none;
}

.cc-player-name:hover {
  text-decoration: underline;
}

.cc-vs-divider {
  color: #6b7280;
  font-weight: 400;
}

.cc-match-controls {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.cc-control-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cc-control-label {
  font-size: 12px;
  color: #6b7280;
  font-weight: 500;
  min-width: 30px;
}

.cc-match-dropdown {
  font-size: 12px;
  padding: 4px 8px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: white;
  color: #111827;
  min-width: 80px;
}

.cc-lane-dropdown {
  min-width: 0;
  width: 58px;
}

.cc-referee-dropdown {
  min-width: 0;
  width: 120px;
}

.cc-match-action-btn {
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.cc-btn-start {
  background: rgba(22, 101, 52, 0.9);
  color: white;
}

.cc-btn-start:hover {
  background: rgba(22, 101, 52, 1);
}

.cc-btn-stop {
  background: rgba(154, 52, 18, 0.9);
  color: white;
}

.cc-btn-stop:hover {
  background: rgba(154, 52, 18, 1);
}

.cc-btn-qr {
  background: white;
  color: #111827;
  border: 1px solid #d1d5db;
  margin-right: 8px;
}

.cc-btn-qr:hover {
  background: #f3f4f6;
}

.cc-btn-complete {
  background: rgba(180, 83, 9, 0.9);
  color: white;
}

.cc-btn-complete:hover {
  background: rgba(180, 83, 9, 1);
}

.cc-winner-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.cc-btn-winner {
  background: rgba(22, 101, 52, 0.9);
  color: white;
  flex: 1;
  min-width: 120px;
}

.cc-btn-winner:hover {
  background: rgba(22, 101, 52, 1);
}

/* Darker background for backside matches in Match Controls */
#backMatchesSection .cc-match-card {
  background: #d1d5db;
}

/* Keep backside matches darker even when live */
.cc-match-card-backside {
  background: #d1d5db; /* Darker gray for backside matches */
}

.cc-match-card-backside.cc-match-card-live {
  background: #d1d5db !important; /* Same darker gray as ready backside matches */
}

/* Referee conflict warning - frontside matches */
.cc-match-card-referee-conflict {
  background: #f5f0e8 !important; /* Muted beige for conflict warning */
}

/* Referee conflict warning - backside matches (darker beige) */
.cc-match-card-backside.cc-match-card-referee-conflict {
  background: #e8e0d5 !important; /* Darker beige for backside conflict */
}

/* Disabled start button for referee conflicts */
.cc-btn-start:disabled {
  background: #9ca3af;
  cursor: not-allowed;
  opacity: 0.6;
}

.cc-btn-start:disabled:hover {
  background: #9ca3af;
}

.cc-no-matches-message {
  text-align: center;
  color: #6b7280;
  font-style: italic;
  margin: 40px 0;
}

.cc-setup-message {
  text-align: center;
  color: #4b5563;
  margin: 40px 0;
  padding: 20px;
  background-color: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Tournament Configuration Display Grid */
.config-display-grid {
  display: grid;
  grid-template-columns: 17% 20% 35% 23%;
  gap: 20px;
  text-align: left;
  padding-left: 40px;
}

/* Tournament Completion Celebration Podium */
/* === Tournament Completion Celebration === */
.tournament-celebration {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #f0f4fa 0%, #f8f9fb 60%);
  border-radius: 16px;
  padding: 36px 40px;
  margin: 15px auto;
  max-width: 800px;
  color: #1a1f2a;
  box-shadow: 0 14px 50px rgba(20, 25, 35, 0.14);
}

/* Dynamic garland strands — decorative SVG behind the podium */
.celebration-garlands {
  position: absolute;
  left: 0;
  right: 0;
  top: 90px;
  height: 400px;
  z-index: 0;
  pointer-events: none;
}

/* Keep all content above the garlands */
.celebration-header,
.podium-container,
.celebration-highlights,
.celebration-analytics {
  position: relative;
  z-index: 1;
}

.celebration-header {
  text-align: center;
  margin-bottom: 28px;
}

.celebration-title {
  font-size: 22px;
  font-weight: 700;
  color: #1a1f2a;
  margin-bottom: 6px;
}

.celebration-subtitle {
  font-size: 13px;
  color: #7a8090;
}

/* Podium — tiered Olympic-style blocks with cards on top */
.podium-container {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 20px;
  max-width: 600px;
  margin: 0 auto;
}

.podium-position {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 180px;
}

.podium-card {
  background: white;
  border-radius: 14px 14px 0 0;
  padding: 24px 16px 22px;
  text-align: center;
  width: 100%;
  box-shadow: 0 -10px 28px rgba(20, 25, 35, 0.08);
  position: relative;
  z-index: 2;
}

/* Medal discs — CSS-only with metallic radial gradients */
.medal {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  border: 3px solid rgba(255, 255, 255, 0.35);
  flex-shrink: 0;
}

.podium-medal {
  width: 56px;
  height: 56px;
  font-size: 22px;
  margin: 0 auto 12px;
}

.medal--gold {
  background: radial-gradient(circle at 32% 30%, #f4d068, #e6b542 55%, #a07410);
  box-shadow: 0 4px 12px rgba(212, 175, 55, 0.45);
}
.medal--silver {
  background: radial-gradient(circle at 32% 30%, #d8dadc, #b6b9be 55%, #7a7e84);
  box-shadow: 0 4px 12px rgba(140, 144, 150, 0.40);
}
.medal--bronze {
  background: radial-gradient(circle at 32% 30%, #d49158, #b87333 55%, #7a4818);
  box-shadow: 0 4px 12px rgba(184, 115, 51, 0.45);
}

.podium-rank {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #8b91a0;
  font-weight: 600;
  margin-bottom: 4px;
}

.podium-name {
  font-size: 17px;
  font-weight: 600;
  color: #1a1f2a;
  letter-spacing: -0.2px;
  word-break: break-word;
}

/* Tiered blocks below each card */
.podium-block {
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 16px;
  font-size: 34px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  position: relative;
  z-index: 1;
  box-shadow: 0 16px 32px rgba(20, 25, 35, 0.40);
}

.podium-block::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.25);
}

.podium-block--gold {
  height: 160px;
  background: linear-gradient(180deg, #e6b542 0%, #a07410 100%);
}

.podium-block--silver {
  height: 120px;
  background: linear-gradient(180deg, #b6b9be 0%, #7a7e84 100%);
}

.podium-block--bronze {
  height: 88px;
  background: linear-gradient(180deg, #b87333 0%, #7a4818 100%);
}

/* Highlights */
.celebration-highlights {
  margin-top: 32px;
}

.highlights-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  background: white;
  border-radius: 12px;
  padding: 14px;
  border: 1px solid #ecedf1;
}

.highlight-item {
  text-align: center;
  padding: 10px;
}

.highlight-label {
  font-size: 11px;
  color: #8b91a0;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 600;
  margin-bottom: 4px;
}

.highlight-value {
  font-size: 17px;
  font-weight: 700;
  color: #1a1f2a;
}

.celebration-analytics {
  text-align: center;
  margin-top: 24px;
}

/* Tournament Achievements Column Styling */
.achievement-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.achievement-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 0;
  border: 1px solid #e5e7eb;
  font-size: 14px;
}

.achievement-label {
  font-weight: 600;
  color: #374151;
}

.achievement-value {
  font-weight: 500;
  color: #1f2937;
  text-align: right;
  word-break: break-word;
}

.achievement-export-section {
  text-align: center;
  padding: 10px 0;
}

.achievement-export-btn {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 0;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
  width: 100%;
  margin-bottom: 8px;
}

.achievement-export-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
  background: linear-gradient(135deg, #2563eb, #1e40af);
}

.achievement-export-btn:active {
  transform: translateY(0);
}

.export-description {
  font-size: 12px;
  color: #6b7280;
  margin: 0;
  font-style: italic;
}

/* Winner Confirmation — progression lines + sidebar stats buttons */
.winner-progression {
  margin: 14px 0;
}
.winner-progression__title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #8b91a0;
  margin-bottom: 6px;
}
.winner-progression__winner { color: #065f46; margin-bottom: 2px; }
.winner-progression__loser  { color: #dc2626; }
.winner-stats-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.winner-stats-stack .btn {
  width: 100%;
  margin: 0;
}

/* Light-touch alignment for non-.dlg modals — rounded corners + solid white background
   to match the .dlg aesthetic without restructuring the content inside. */
#statisticsModal .modal-content,
#matchQRModal .modal-content,
#qrResultScanModal .modal-content,
#matchDetailModal .modal-content,
#matchCommandCenterModal .modal-content,
#analyticsModal .modal-content {
  border-radius: 10px;
  background-color: #ffffff;
}
/* Title separator — mirrors the .dlg__title border-bottom for light-touch alignment */
#matchDetailModal .modal-content > h3,
#matchCommandCenterModal .modal-content > h3,
#analyticsModal .modal-content > h3 {
  border-bottom: 1px solid #ecedf1;
  padding-bottom: 14px;
}

/* Player Statistics editor — counter row + list editors */
#statsModal .dlg { max-width: 620px; }  /* slightly wider than default 580px for the 3-col counter row */

.stats-counter-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.stat-counter {
  background: #f8f9fa;
  border: 1px solid #ecedf1;
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}
.stat-counter__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #8b91a0;
  font-weight: 600;
  margin-bottom: 10px;
}
.stat-counter__controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.stat-counter__value {
  font-size: 22px;
  font-weight: 700;
  color: #1a1f2a;
  min-width: 28px;
  text-align: center;
}
.stat-counter__btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid #d8dbe2;
  background: white;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s, border-color 0.15s;
  font-family: inherit;
}
.stat-counter__btn:active { transform: translate(1.5px, 1.5px); }
.stat-counter__btn--minus { color: #dc2626; }
.stat-counter__btn--minus:hover { background: #fef2f2; border-color: #dc2626; }
.stat-counter__btn--plus { color: #166534; }
.stat-counter__btn--plus:hover { background: #dcfce7; border-color: #166534; }

.stat-list-editor__input-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.stat-list-editor__input-row .dlg__input { flex: 1; }
.stat-list-editor__input-row .btn { margin: 0; flex-shrink: 0; }

/* Chip list — segmented-control style, each chip is clickable to remove */
.stat-list-editor__items {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 10px;
  padding: 4px;
  background: #f3f5f7;
  border-radius: 8px;
}
.stat-list-editor__items:empty { display: none; }

.stat-list-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: white;
  border: 1px solid transparent;
  border-radius: 6px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: #1a1f2a;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.stat-list-item:hover {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fecaca;
}
.stat-list-item:active { transform: translate(1.5px, 1.5px); }

.stat-list-item__x {
  color: #b0b6c0;
  font-size: 16px;
  line-height: 1;
  transition: color 0.15s;
}
.stat-list-item:hover .stat-list-item__x { color: #dc2626; }

/* Bracket confirmation — read-only player chips in a scrollable wrap-flow */
.bracket-confirm-players {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  background: #f3f5f7;
  border-radius: 8px;
  max-height: 280px;
  overflow-y: auto;
}
.bracket-confirm-player {
  background: white;
  border: 1px solid #ecedf1;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 600;
  color: #1a1f2a;
}

/* Upload modal — option cards (radio) + destination info */
.upload-source-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.upload-source-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #f8f9fa;
  border: 1px solid #ecedf1;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-size: 14px;
  color: #1a1f2a;
}
.upload-source-option:hover { background: #ecedf1; }
.upload-source-option input[type="radio"] { margin: 0; }
.upload-destination {
  background: #f3f5f7;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
}
.upload-destination__title {
  font-weight: 600;
  margin-bottom: 6px;
  color: #4a5160;
}
.upload-destination__list {
  margin: 0;
  padding-left: 18px;
  color: #6b7280;
}
.upload-destination__list li { margin: 2px 0; }

/* Enhanced Undo Confirmation Modal */
.undo-header {
  font-size: 16px;
  margin-bottom: 20px;
  color: #111827;
  text-align: center;
}

.undo-matches-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding-right: 8px; /* Space for scrollbar */
  margin-bottom: 20px; /* Space before buttons */
  max-height: 40vh; /* Reasonable max height with scrolling */
}

.undo-match-card {
  background: #f8f9fa;
  border: 1px solid #e5e7eb;
  border-radius: 0;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.undo-match-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.undo-match-id {
  font-weight: 600;
  font-size: 14px;
  color: #111827;
}

.undo-bracket-type {
  font-size: 12px;
  color: #6b7280;
  font-weight: 500;
}

.undo-match-players {
  font-size: 14px;
  color: #374151;
  text-align: center;
  padding: 8px;
  background: #ffffff;
  border-radius: 4px;
  border: 1px solid #e5e7eb;
}

.undo-no-matches {
  text-align: center;
  color: #6b7280;
  font-style: italic;
  padding: 20px;
  background: #f9fafb;
  border-radius: 0;
  margin-bottom: 20px;
}

.undo-achievements {
  margin: 16px 0 8px;
  padding: 12px 14px;
  background: #fef9ec;
  border: 1px solid #f59e0b;
  border-radius: 4px;
  font-size: 14px;
}

.undo-achievements-title {
  font-weight: 600;
  margin-bottom: 6px;
  color: #92400e;
}

.undo-achievement-row {
  margin-bottom: 3px;
  color: #374151;
}

.undo-achievements-warning {
  margin-top: 12px;
  font-size: 13px;
  color: #6b7280;
  font-style: italic;
}

.undo-achievements-info {
  margin-top: 12px;
  font-size: 13px;
  color: #166534;
  font-style: italic;
}

/* Completion modal achievements summary */
.completion-achievements-box {
  margin: 16px 0 4px;
  padding: 12px 14px;
  background: #f0fdf4;
  border: 1px solid #6ee7b7;
  border-radius: 4px;
  font-size: 14px;
}

.completion-achievements-title {
  font-weight: 600;
  margin-bottom: 6px;
  color: #065f46;
}

.completion-achievement-row {
  margin-bottom: 3px;
  color: #374151;
}

/* Undo modal content area - natural sizing */
#undoConfirmMessage {
  margin: 20px 0 !important;
  line-height: 1.5 !important;
}

/* Fix outer modal wrapper behavior - only when visible */
#undoConfirmModal[style*="display: flex"] {
  align-items: flex-start !important;
}

/* Undo modal - natural sizing, not flexbox */
#undoConfirmModal .modal-content {
  margin: 2% auto !important;
  display: block !important;
  height: auto !important;
  max-height: none !important;
  min-height: auto !important;
}

/* Undo modal button container */
#undoConfirmModal .text-center.mt-20 {
  margin-top: 20px;
}

/* Match Controls Modal - Same Flexbox Layout as Undo Dialog */
.match-controls-modal {
  display: flex !important;
  flex-direction: column !important;
  margin: 1% auto !important;
  max-height: 98vh !important;
  overflow: hidden !important;
}

.match-controls-modal h3 {
  flex-shrink: 0; /* Don't shrink title */
  margin-bottom: 20px;
}

/* Two-column layout container */
.match-controls-main-container {
  display: flex;
  gap: 20px;
  flex: 1;
  min-height: 0;
}

.match-controls-container {
  flex: 2; /* Takes 2/3 of the space */
  overflow-y: auto;
  padding-right: 8px; /* Space for scrollbar */
  margin-bottom: 20px; /* Space before buttons */
  min-height: 0; /* Allow flexbox shrinking */
}

/* Referee suggestions column */
.referee-suggestions-container {
  width: 380px; /* Fixed width - approximately 60% of previous 1/3 space */
  flex-shrink: 0;
  border-left: 2px solid #e5e7eb;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.referee-suggestions-content {
  flex: 1;
  overflow-y: auto;
  padding-right: 8px;
  min-height: 0;
}

.referee-section {
  margin-bottom: 20px;
}

.referee-subsection-header {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid #e5e7eb;
}

.referee-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.referee-suggestion-item {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  padding: 10px 12px;
  font-size: 14px;
  color: #374151;
  cursor: pointer;
  transition: all 0.2s ease;
}

.referee-suggestion-item:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
}

.referee-suggestion-name {
  font-weight: 600;
  color: #111827;
}

/* Color-coded left borders per category */
#refereeLosersContainer .referee-suggestion-item {
  border-left: 3px solid #d4a0a0;
}

#refereeWinnersContainer .referee-suggestion-item {
  border-left: 3px solid #a0c4a0;
}

#refereeAssignmentsContainer .referee-suggestion-item {
  border-left: 3px solid #a0b4c4;
}

.referee-suggestion-round {
  color: #6b7280;
  font-size: 11px;
  margin-left: 4px;
}

/* Backside color scheme for referee suggestions */
.referee-suggestion-item.referee-suggestion-backside {
  background: #d1d5db; /* Same darker gray as backside matches */
}

.referee-suggestion-item.referee-suggestion-backside:hover {
  background: #c1c6cd; /* Slightly darker on hover for backside */
  border-color: #9ca3af;
}

.referee-empty-message {
  text-align: center;
  color: #6b7280;
  font-style: italic;
  padding: 20px;
  margin-top: 20px;
}

.referee-setup-message {
  text-align: center;
  color: #4b5563;
  padding: 20px;
  margin-top: 20px;
  background-color: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Match Controls modal button container - keep buttons at bottom */
.match-controls-modal .text-center.mt-20 {
  flex-shrink: 0; /* Don't shrink button area */
  margin-top: 20px;
}

/* Match Controls Clock */
.match-controls-clock {
  display: inline-block;
  font-weight: normal;
  font-family: var(--font-clock);
  border: 1px solid #ccc;
  padding: 8px 16px;
  border-radius: 6px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.24);
}

/* Match History Styles */
.match-history-item {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 0;
  padding: 12px;
  margin-bottom: 8px;
  transition: all 0.2s ease;
}

.match-history-item:hover {
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  border-color: #d1d5db;
}

.match-history-item.walkover {
  background: #f9fafb;
  border-color: #e5e7eb;
  color: #6b7280;
  font-style: italic;
}

/* Backside match styling - darker header background */
.match-history-item.backside .match-header {
  background: #d1d5db; /* Use backside darker color for entire header */
}
.match-history-item.backside .match-id {
  background: transparent; /* Remove separate background, blend with header */
}

.match-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.match-id {
  font-size: 14px;
  font-weight: 700;
  color: #374151;
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 0;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
}

.match-winner {
  font-size: 12px;
  font-weight: 600;
  color: #059669;
}

.match-history-item.walkover .match-winner {
  color: #6b7280;
}

.match-result {
  font-size: 14px;
  color: #111827;
  line-height: 1.4;
}

.match-history-item.walkover .match-result {
  color: #6b7280;
}

.match-result-enhanced {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: #111827;
  line-height: 1.4;
  padding-left: 8px;
  padding-right: 8px;
}

.match-history-item.walkover .match-result-enhanced {
  color: #6b7280;
}

.match-history-item.walkover .match-id {
  font-weight: 400;
  font-size: 12px;
}

.player-info {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-info span,
.player-info .winner-name,
.player-info .progression-info {
  display: inline !important;
  white-space: nowrap !important;
}

.result-score {
  font-weight: 600;
  color: #374151;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  margin-left: 12px;
}

.match-details {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid #e5e7eb;
}

.match-meta {
  font-size: 11px;
  color: #6b7280;
  font-weight: 500;
}

.match-history-item.walkover .match-details {
  border-top-color: #f3f4f6;
}

.match-history-item.walkover .match-meta {
  color: #9ca3af;
}

.progression-info {
  color: #6b7280;
  font-size: 12px;
  font-weight: 500;
  font-style: italic;
}

.winner-name {
  color: #059669;
  font-weight: 600;
}

.auto-completed {
  font-size: 10px;
  font-weight: 400;
  color: #6b7280;
  font-style: italic;
  font-family: var(--font-body);
}

/* Stats Modal Scrolling Fixes */
#statsModal .modal-content {
  display: flex !important;
  flex-direction: column !important;
  max-height: 80vh !important;
  overflow: hidden !important;
}

#statsModal .modal-content > *:not(:last-child) {
  flex-shrink: 0; /* Keep header and form elements fixed */
}

#statsModal .modal-content > *:last-child {
  flex-shrink: 0; /* Keep button area fixed */
  margin-top: auto; /* Push buttons to bottom */
}

/* Make the scrollable content area for stats */
#statsModal form {
  flex: 1 !important;
  overflow-y: auto !important;
  min-height: 0 !important;
  padding-right: 8px !important; /* Space for scrollbar */
  margin-bottom: 20px !important;
}

/* ==========================================
   NEW FLAT DESIGN STYLES FOR REDESIGNED PAGES
   ========================================== */

/* Form Elements - Only for redesigned pages */
.setup-page-flex input[type="text"],
.setup-page-flex input[type="number"],
.setup-page-flex input[type="date"],
.setup-page-flex select,
.registration-page-flex input[type="text"],
.registration-page-flex input[type="number"],
.registration-page-flex input[type="date"],
.registration-page-flex select,
.config-page input[type="text"],
.config-page input[type="number"],
.config-page input[type="date"],
.config-page select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #c0c0c0;
  border-radius: 0;
  background: #ffffff;
  color: #2a2a2a;
  font-size: 14px;
  height: 44px;
  box-sizing: border-box;
  transition: border-color 0.15s ease;
}

.setup-page-flex input[type="text"]:focus,
.setup-page-flex input[type="number"]:focus,
.setup-page-flex input[type="date"]:focus,
.setup-page-flex select:focus,
.registration-page-flex input[type="text"]:focus,
.registration-page-flex input[type="number"]:focus,
.registration-page-flex input[type="date"]:focus,
.registration-page-flex select:focus,
.config-page input[type="text"]:focus,
.config-page input[type="number"]:focus,
.config-page input[type="date"]:focus,
.config-page select:focus {
  outline: none;
  border-color: rgba(180, 83, 9, 1);
  box-shadow: 0 0 0 2px rgba(180, 83, 9, 0.1);
}

.setup-page-flex .form-group,
.registration-page-flex .form-group,
.config-page .form-group {
  margin-bottom: 16px;
}

.setup-page-flex .form-group label,
.registration-page-flex .form-group label,
.config-page .form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  color: #222222;
  font-size: 14px;
}

/* Setup Page Styles */
.page.setup-page-flex.active {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 200px);
  overflow: hidden;
  border: 1px solid #666666;
}

.setup-page-header {
  flex-shrink: 0;
  padding: 24px;
  background: #f5f5f5;
  border-bottom: 1px solid #e8e8e8;
  border: 1px solid #e8e8e8;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.setup-page-header h2 {
  margin: 0;
  color: #222222;
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0px;
}

.setup-page-header .form-group {
  margin-bottom: 0;
  margin-top: 16px;
}

.setup-page-header .btn {
  margin-bottom: 0;
}

.setup-page-flex .alert {
  border: none;
  background: none;
  border-radius: 0;
  padding: 0;
  margin: 0;
  color: #666666;
  font-size: 14px;
}

.tournament-creation-row {
  display: flex;
  align-items: end;
  gap: 16px;
  width: 1000px;
  margin-bottom: 24px;
}

.tournament-creation-row .form-group {
  margin-bottom: 0;
}

.tournament-creation-row input {
  margin-top: -2px;
}

.tournament-name-field {
  width: 510px;
}

.tournament-date-field {
  width: 154px;
}

.tournament-create-button {
  width: 220px;
  margin-bottom: 0;
}

.setup-page-main {
  flex: 1;
  display: flex;
  gap: 24px;
  padding: 24px 24px 24px 0px;
  overflow: hidden;
}

.two-column-container {
  display: flex;
  gap: 24px;
  flex: 1;
}

.setup-page-flex .scrollable-column:first-child {
  flex: 0 0 55%;
}

.setup-page-flex .scrollable-column:last-child {
  flex: 0 0 45%;
}

/* ===============================================
   FLAT DESIGN STYLES - ACTIVE (v2.2.0+)
   =============================================== */
.scrollable-column {
  background: #ffffff;
  border: 1px solid #e8e8e8;
  border-radius: 0;
  color: #2a2a2a;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.scrollable-column h3 {
  color: #222222;
  margin: 0;
  padding: 0 24px;
  border-bottom: 1px solid #e8e8e8;
  flex-shrink: 0;
  height: 60px;
  min-height: 60px;
  max-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 1.15rem;
  font-weight: 600;
  background: #f5f5f5;
}

.scrollable-column h3 .btn {
  height: 28px;
  padding: 6px 12px;
  font-size: 12px;
  margin: 0;
}

.scrollable-column-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

/* Registration page - remove fixed heights and internal scrolling */
.registration-page-flex .scrollable-column-content {
  overflow-y: visible;
  min-height: initial;
}

/* Removed incorrect margin-right that broke the working spacing */

/* Tournament Items */
.tournament-item {
  border-bottom: 1px solid #e8e8e8;
  height: 72px;
  min-height: 72px;
  max-height: 72px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  transition: all 0.15s ease;
  cursor: pointer;
  border-left: 3px solid transparent;
  padding-left: 21px;
  margin-right: -24px;
  padding-right: 24px;
}

.tournament-item .btn,
.tournament-item button {
  height: 32px !important;
  padding: 6px 10px !important;
  font-size: 12px !important;
  margin: 0 2px !important;
  min-height: 32px !important;
  max-height: 32px !important;
}

.setup-page-flex .scrollable-column-content button,
.setup-page-flex .scrollable-column-content .btn {
  height: 32px !important;
  padding: 6px 10px !important;
  font-size: 12px !important;
  margin: 0 2px !important;
  min-height: 32px !important;
  max-height: 32px !important;
}

.tournament-item:first-child {
  padding-top: 0;
  margin-top: 0;
}

.tournament-item:last-child {
  border-bottom: 1px solid #e8e8e8;
}

.tournament-item:hover {
  border-left-color: #166534;
}

.tournament-item.active-tournament .tournament-name {
  font-size: 18px;
  font-weight: 700;
  color: #166534;
}

.tournament-name {
  font-size: 14px;
  font-weight: 500;
  color: #333333;
  margin-bottom: 4px;
}

.tournament-meta {
  font-size: 12px;
  color: #666666;
  display: flex;
  gap: 16px;
}

/* Match Results */
.match-result-item {
  border-bottom: 1px solid #e8e8e8;
  height: 72px;
  min-height: 72px;
  max-height: 72px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  transition: all 0.15s ease;
  cursor: pointer;
  border-left: 3px solid transparent;
  padding-left: 21px;
  margin-right: -24px;
  padding-right: 24px;
}

.match-result-item:first-child {
  padding-top: 0;
  margin-top: 0;
}

.match-result-item:last-child {
  border-bottom: 1px solid #e8e8e8;
}

.match-result-item:hover {
  border-left-color: #166534;
}

.match-result-item.backside .match-content {
  background: #f7f7f7;
  margin-left: -21px;
  margin-right: -24px;
  padding-left: 21px;
  padding-right: 24px;
}

.match-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-left: 8px;
  padding-right: 8px;
}

.match-header {
  font-size: 12px;
  color: #666666;
  font-weight: 500;
}

.setup-page-flex .match-players {
  font-size: 14px;
  color: #333333;
  font-weight: 500;
  display: block;
  white-space: nowrap;
}

.setup-page-flex .match-players span,
.setup-page-flex .match-players .player-name,
.setup-page-flex .match-players .match-text {
  display: inline !important;
  white-space: nowrap !important;
}

/* Registration Page Styles */
.page.registration-page-flex.active {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  border: 1px solid #666666;
}

.registration-page-header {
  flex-shrink: 0;
  padding: 24px;
  background: #f5f5f5;
  border-bottom: 1px solid #e8e8e8;
  border: 1px solid #e8e8e8;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 32px;
  align-items: stretch;
  position: relative;
}

.registration-page-header h2 {
  margin: 0;
  color: #222222;
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0px;
}

.registration-page-header .btn {
  margin-bottom: 0;
}

.player-registration-row {
  display: flex;
  align-items: end;
  gap: 16px;
  margin-bottom: 24px;
  margin-top: -6px;
}

.player-registration-row .form-group {
  margin-bottom: 0;
}

.player-registration-row .btn {
  margin-bottom: 0;
}

.player-name-field {
  width: 441px;
}

.control-buttons {
  display: flex;
  gap: 16px;
}

/* Registration Header - Two Column Layout */
.header-left-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.header-left-content h2 {
  margin-bottom: 0;
}

.header-right-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
  min-height: 100%;
}

.header-right-content img {
  height: 175px;
  width: auto;
  border: 1px solid #e8e8e8;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.header-right-content .player-count {
  font-size: 1rem;
  font-weight: 600;
  color: #222222;
  text-align: center;
  margin-top: auto;
}

.player-count {
  font-size: 1rem;
  font-weight: 600;
  color: #222222;
}

.registration-page-main {
  display: flex;
  gap: 24px;
  padding: 24px 24px 0px 0px;
  align-items: flex-start;
}

/* Column Proportions - Registration Page Only */
.registration-page-main .scrollable-column:first-child {
  flex: 0 0 34%;
}

.registration-page-main .scrollable-column:last-child {
  flex: 0 0 66%;
}

/* Registration Page Two-Column Layout */
.registration-page-main {
  height: calc(100vh - 140px); /* Account for header and form */
}

/* Player List Header */
.player-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 60px;
  min-height: 60px;
  max-height: 60px;
  padding: 0 16px;
  border-bottom: 1px solid #e8e8e8;
  background: #f5f5f5;
}

.player-list-header span {
  font-size: 16px;
  font-weight: 600;
  color: #222222;
}

.player-list-header button {
  height: 28px;
  padding: 6px 12px;
  font-size: 12px;
  margin: 0;
}

/* Saved Players Sections */
.saved-players-section {
  margin-bottom: 16px;
}

.saved-players-section-header {
  color: #222222;
  margin: 0;
  padding: 12px 16px;
  border-bottom: 1px solid #e8e8e8;
  font-size: 14px;
  font-weight: 600;
  background: #fafafa;
}

/* Player List Items */
.player-list-items {
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.player-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  background: white;
}

.player-list-item.in-tournament {
  background: #f0fdf4;
  border: 1px solid #d1d5db;
}

.player-list-item-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #111827;
}

.player-list-item.in-tournament .player-list-item-name {
  font-weight: normal;
  color: #111827;
}

.player-list-item-name .checkmark {
  color: #16a34a;
  font-size: 16px;
}

.player-list-item-actions {
  display: flex;
  gap: 8px;
}

.player-list-item-actions button {
  width: 24px;
  height: 24px;
  padding: 0;
  font-size: 18px;
  border: 1px solid #dc2626;
  border-radius: 6px;
  background: white;
  color: #dc2626;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.player-list-delete-btn:hover {
  background: #dc2626;
  color: white;
}

/* Player Grid */
.players-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.player-card {
  border: 1px solid #e8e8e8;
  height: 48px;
  min-height: 48px;
  max-height: 48px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  overflow: hidden;
  transition: all 0.15s ease;
  cursor: pointer;
  padding: 8px 12px;
  background: #ffffff;
  position: relative;
}

.player-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.player-card.paid {
  background: #f0f9f4;
  border-color: #166534;
}

.player-card.paid:hover {
  background: #dcfce7;
}

.player-card.unpaid {
  background: #ffffff;
  border-color: #d97706;
}

.player-card.unpaid:hover {
  background: #f9f9f9;
}

.player-card .player-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.player-name {
  font-size: 14px;
  font-weight: 500;
  color: #333333;
}

.player-status {
  font-size: 12px;
  font-weight: 400;
  color: #666666;
}

.player-card.paid .player-status {
  color: #166534;
}

.player-card.unpaid .player-status {
  color: #d97706;
}

.player-actions {
  display: flex;
  gap: 4px;
  position: relative;
  z-index: 2;
}

.btn-small {
  padding: 4px 8px;
  font-size: 14px;
  height: auto;
  font-weight: 400;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  background: #ffffff;
  color: #666666;
  transition: all 0.15s ease;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.btn-small:hover {
  background: #f8f8f8;
  border-color: #c0c0c0;
}

.btn-small.btn-danger {
  color: #dc2626;
  border-color: #dc2626;
}

.btn-small.btn-danger:hover {
  background: #fef2f2;
  border-color: #b91c1c;
}

/* Results Table */
.results-table-container {
  overflow-x: auto;
  width: 100%;
  margin: 0;
  padding: 0;
}

.results-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 3px;
  font-size: 13px;
  margin: 0;
}

.results-table th {
  background: #1f2937;
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px;
  text-align: center;
  border: none;
}

.results-table th:first-child {
  border-top-left-radius: 8px;
}

.results-table th:last-child {
  border-top-right-radius: 8px;
}

.results-table th:nth-child(1),
.results-table th:nth-child(2) {
  text-align: left;
}

.results-table tbody tr {
  background: #ffffff;
  border-radius: 6px;
}

.results-table td {
  border: none;
  border-top: 1px solid #eef0f2;
  border-bottom: 1px solid #eef0f2;
  padding: 8px;
  color: #333333;
}

.results-table td:first-child {
  border-left: 1px solid #eef0f2;
  border-top-left-radius: 6px;
  border-bottom-left-radius: 6px;
}

.results-table td:last-child {
  border-right: 1px solid #eef0f2;
  border-top-right-radius: 6px;
  border-bottom-right-radius: 6px;
}

.results-table tbody tr:nth-child(even) {
  background: #eef0f4;
}

.results-table tbody tr:hover {
  background: #f1f5f9;
}


/* Cell styling */
.results-table .rank {
  font-weight: 600;
  color: #333333;
  width: 9%;
  text-align: center;
}

.results-table .player-name {
  font-weight: 700;
  font-size: 15px;
  color: #333333;
  width: 24%;
}

.results-table .points {
  font-weight: 700;
  color: #166534;
  font-size: 15px;
  width: 9%;
  text-align: center;
}

.results-table .stat {
  color: #666666;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Courier New', monospace;
  text-align: center;
  width: 10%;
}

/* Config Page Styles */
.page.config-page.active {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: hidden;
  border: 1px solid #666666;
}

.config-page-header {
  flex-shrink: 0;
  padding: 24px;
  background: #f5f5f5;
  border-bottom: 1px solid #e8e8e8;
  border: 1px solid #e8e8e8;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.config-page-header h2 {
  margin: 0;
  color: #222222;
  font-size: 1.5rem;
  font-weight: 600;
}

.config-sections-container {
  flex: 1;
  display: flex;
  gap: 24px;
  padding: 24px 0px 24px 0px;
  overflow: hidden;
}

.config-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto;
}

.config-section {
  background: #ffffff;
  border: 1px solid #e8e8e8;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.config-section h3 {
  margin: 0;
  padding: 16px 24px;
  border: 1px solid #e8e8e8;
  color: #222222;
  font-size: 1rem;
  font-weight: 600;
  background: #f5f5f5;
  display: flex;
  align-items: center;
}

.config-content {
  padding: 24px;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.config-buttons {
  display: flex;
  gap: 16px;
  margin-top: 16px;
}

.checkbox-group {
  margin-bottom: 16px;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 400;
  color: #2a2a2a;
  line-height: 1.4;
}

.checkbox-label input[type="checkbox"] {
  margin: 0;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 2px;
}

.field-help {
  display: block;
  font-size: 12px;
  color: #666666;
  margin-top: 4px;
  font-style: italic;
}

.info-text {
  font-size: 14px;
  color: #2a2a2a;
  line-height: 1.5;
  padding: 16px;
  background: #f9f9f9;
  border: 1px solid #e8e8e8;
  border-radius: 4px;
}

/* Help Info Icon */
.help-info-icon {
  display: inline-block;
  margin-left: 8px;
  font-size: 1.2rem;
  color: #ff6b35;
  cursor: pointer;
  transition: transform 0.2s ease, color 0.2s ease;
  position: relative;
  vertical-align: middle;
  user-select: none;
}

.help-info-icon:hover {
  transform: scale(1.15);
  color: #e55a2b;
}

/* Storage Indicator */
.storage-link {
  float: right;
  font-size: 0.9rem;
  font-weight: normal;
  text-decoration: none;
  margin-left: 10px;
  transition: text-decoration 0.2s ease;
}

.storage-link:hover {
  text-decoration: underline;
}

.storage-link.storage-green {
  color: #166534;
}

.storage-link.storage-yellow {
  color: #ca8a04;
}

.storage-link.storage-amber {
  color: #dc2626;
}

/* Storage Modal Content Styles */
.storage-progress-bar {
  width: 100%;
  height: 24px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
  margin: 10px 0;
}

.storage-progress-fill {
  height: 100%;
  transition: width 0.3s ease, background-color 0.3s ease;
}

.storage-progress-fill.storage-green {
  background-color: #166534;
}

.storage-progress-fill.storage-yellow {
  background-color: #ca8a04;
}

.storage-progress-fill.storage-amber {
  background-color: #dc2626;
}

.storage-details {
  font-size: 0.95rem;
  color: #374151;
  margin-top: 8px;
}

/* Result QR Preview */
.qr-result-header {
    margin-bottom: 16px;
}
.qr-result-match {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 4px;
}
.qr-result-winner {
    font-size: 18px;
}
.qr-result-legs {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.qr-result-legs th,
.qr-result-legs td {
    border: 1px solid #e5e7eb;
    padding: 6px 10px;
    text-align: left;
}
.qr-result-legs th {
    background: #f3f4f6;
    font-weight: 600;
}
.qr-visits {
    font-family: monospace;
    color: #374151;
}

/* ---------------------------------------------------------------------------
   History Page
   --------------------------------------------------------------------------- */

#history.page.active {
    border: 1px solid #666666;
}

.history-page-header {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 24px;
    background: #f5f5f5;
    border: 1px solid #e8e8e8;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    margin-bottom: 16px;
}
.history-page-header h2 {
    margin: 0;
}
.history-page-subtitle {
    margin: 0;
    font-size: 14px;
    color: #6b7280;
}
.analytics-scope-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #166534;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    padding: 5px 14px;
    border-radius: 999px;
    cursor: pointer;
    width: fit-content;
}
.analytics-scope-indicator:hover {
    background: #dcfce7;
}
.analytics-scope-count {
    font-weight: 700;
}
.analytics-scope-tag {
    display: inline-block;
    padding: 1px 8px;
    background: rgba(22, 101, 52, 0.1);
    border-radius: 999px;
    font-size: 12px;
}
.analytics-scope-change {
    font-size: 12px;
    color: #15803d;
    text-decoration: underline;
}
.analytics-scope-change:hover {
    color: #166534;
}
.analytics-filter-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
}
.analytics-filter-label {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}
.analytics-text-filter {
    flex: 1;
    max-width: 360px;
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    outline: none;
}
.analytics-text-filter:focus {
    border-color: #1a5c2e;
    box-shadow: 0 0 0 2px rgba(26, 92, 46, 0.15);
}
.analytics-date-range {
    display: flex;
    align-items: center;
    gap: 8px;
}
.analytics-date-range label {
    font-size: 13px;
    color: #6b7280;
}
.analytics-date-input {
    padding: 7px 10px;
    font-size: 14px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    outline: none;
}
.analytics-date-input:focus {
    border-color: #1a5c2e;
    box-shadow: 0 0 0 2px rgba(26, 92, 46, 0.15);
}
.analytics-reset-btn {
    padding: 7px 14px;
    font-size: 13px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: #6b7280;
    background: #fff;
}
.analytics-reset-btn.has-filter {
    color: #92400e;
    border-color: #f59e0b;
    background: #fffbeb;
}
.analytics-reset-btn.has-filter:hover {
    background: #fef3c7;
    border-color: #d97706;
}
.analytics-reset-btn:hover {
    color: #374151;
    border-color: #9ca3af;
    background: #f9fafb;
}
.analytics-scope-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #1a5c2e;
}
.history-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.history-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 6px;
    font-size: 13px;
    line-height: 1.4;
}
.history-table th {
    background: #1f2937;
    color: #ffffff;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 5px 6px;
    text-align: left;
    border-bottom: none;
    position: sticky;
    top: 0;
    z-index: 10;
}
.history-table th:first-child {
    border-top-left-radius: 8px;
}
.history-table th:last-child {
    border-top-right-radius: 8px;
}
.history-table thead tr {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}
.history-table tbody tr {
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    border-radius: 6px;
}
.history-table tbody tr:nth-child(even) {
    background: #eef0f4;
}
.history-table td {
    padding: 7px 6px;
    border-top: 1px solid #eef0f2;
    border-bottom: 1px solid #eef0f2;
}
.history-table td:first-child {
    border-left: 1px solid #eef0f2;
    border-top-left-radius: 6px;
    border-bottom-left-radius: 6px;
}
.history-table td:last-child {
    border-right: 1px solid #eef0f2;
    border-top-right-radius: 6px;
    border-bottom-right-radius: 6px;
}
.history-row {
    cursor: pointer;
    transition: box-shadow 0.12s ease, background 0.12s ease;
}
.history-row:hover {
    background: #f1f5f9 !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1) !important;
}
.leaderboard-top {
    background: #d4edda !important;
}
.leaderboard-top td {
    border-color: #b8dcc2;
}
.leaderboard-top:nth-child(even) {
    background: #c8e6cf !important;
}
.leaderboard-top.history-row:hover {
    background: #b1dfbb !important;
}
.newton-table-badge-cell {
    background: transparent !important;
    padding: 0 !important;
    border: none !important;
}
.newton-table-badge-cell:first-child .newton-table-badge {
    margin-left: 0;
    border-top-left-radius: 6px;
    border-bottom-left-radius: 6px;
}
.newton-table-badge {
    background: rgba(31, 41, 55, 0.06);
    border-radius: 6px;
    padding: 7px 6px;
    margin: 0 4px;
}
.leaderboard-top .newton-table-badge {
    background: rgba(31, 41, 55, 0.08);
}
.history-back-row {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
}
.history-panel-title {
    font-size: 17px;
    font-weight: 700;
    color: #111827;
}
.match-detail-match-id {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}
.match-detail-players {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: #111827;
}
.history-panel-meta {
    font-size: 13px;
    color: #6b7280;
    margin-top: 2px;
}
.history-detail-header {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 14px;
    color: #374151;
}
.history-type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.history-type-chalker {
    background: #dbeafe;
    color: #1e40af;
}
.history-type-manual {
    background: #f3f4f6;
    color: #374151;
}
.history-type-final {
    background: #d1fae5;
    color: #065f46;
}

/* ---------------------------------------------------------------------------
   NewtonTable — sortable/paginated table utility
   --------------------------------------------------------------------------- */

.newton-table-sortable {
    cursor: pointer;
    user-select: none;
}

.newton-table-sortable:hover {
    background: #374151;
}

.newton-table-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px 4px;
    font-size: 13px;
    color: #6b7280;
}

.newton-table-page-nav {
    display: flex;
    align-items: center;
    gap: 10px;
}

.newton-table-page-info {
    font-weight: 500;
    min-width: 100px;
    text-align: center;
}

.newton-table-page-btn {
    font-size: 13px !important;
    padding: 7px 14px !important;
    border: 1px solid #d1d5db !important;
    border-radius: 6px !important;
    color: #6b7280 !important;
    background: #fff !important;
}
.newton-table-page-btn:hover:not(:disabled) {
    color: #374151 !important;
    border-color: #9ca3af !important;
    background: #f9fafb !important;
}

.newton-table-rpp {
    display: flex;
    align-items: center;
    gap: 4px;
}

.newton-table-rpp-label {
    font-weight: 600;
    margin-right: 4px;
}

.newton-table-rpp-btn {
    font-size: 13px !important;
    padding: 7px 14px !important;
    min-width: 32px;
    border: 1px solid #d1d5db !important;
    border-radius: 6px !important;
    color: #6b7280 !important;
    background: #fff !important;
}
.newton-table-rpp-btn:hover {
    color: #374151 !important;
    border-color: #9ca3af !important;
    background: #f9fafb !important;
}

.newton-table-rpp-active {
    background: #f0fdf4 !important;
    color: #166534 !important;
    border-color: #166534 !important;
    font-weight: 600 !important;
}

/* ---------------------------------------------------------------------------
   Analytics Controls
   --------------------------------------------------------------------------- */

.analytics-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 16px;
}

.analytics-view-tabs {
    display: flex;
    gap: 0;
}

.analytics-view-btn {
    padding: 12px 20px;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.analytics-view-btn:hover {
    color: #222222;
}

.analytics-view-btn.active {
    color: #222222;
    border-bottom-color: rgba(22, 101, 52, 1);
}

.register-sub-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 12px;
    border-bottom: 1px solid #e5e7eb;
}

.register-sub-tab {
    padding: 8px 16px;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.register-sub-tab:hover {
    color: #222222;
}

.register-sub-tab.active {
    color: #222222;
    border-bottom-color: rgba(22, 101, 52, 1);
    cursor: default;
}

.register-crumb-sep {
    color: #d1d5db;
    font-size: 13px;
    padding: 0 2px;
    align-self: center;
    user-select: none;
}

.analytics-point-mode {
    display: flex;
    align-items: center;
    gap: 10px;
}

.analytics-point-label {
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.analytics-point-toggle {
    display: flex;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    overflow: hidden;
}

.analytics-point-btn {
    padding: 6px 14px;
    border: none;
    background: #ffffff;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.analytics-point-btn:not(:last-child) {
    border-right: 1px solid #d1d5db;
}

.analytics-point-btn:hover {
    background: #f9fafb;
    color: #222222;
}

.analytics-point-btn.active {
    background: #f0fdf4;
    color: #166534;
    font-weight: 600;
}

.analytics-point-layers {
    display: flex;
    gap: 6px;
    margin-left: 12px;
}
.analytics-layer-btn {
    padding: 6px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #ffffff;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.analytics-layer-btn:hover {
    background: #f9fafb;
    color: #222222;
}
.analytics-layer-btn.active {
    background: #f0fdf4;
    color: #166534;
    font-weight: 600;
    border-color: #bbf7d0;
}

/* Analytics responsive — narrow viewports */
@media (max-width: 1120px) {
    .history-page-header {
        padding: 8px;
        margin-bottom: 4px;
    }
    .history-actions .btn {
        display: none;
    }
    .analytics-scope-indicator {
        margin-left: 0 !important;
        text-align: center;
        justify-content: center;
        width: 100%;
    }
    .analytics-controls {
        flex-direction: column;
        align-items: stretch;
        padding: 0;
        gap: 0;
        margin-bottom: 4px;
    }
    .analytics-view-tabs {
        justify-content: center;
        flex-wrap: wrap;
    }
    .analytics-view-btn {
        padding: 10px 14px;
        font-size: 13px;
    }
    .analytics-point-mode {
        justify-content: center;
        flex-wrap: wrap;
        padding: 8px 16px;
        border-top: 1px solid #e5e7eb;
    }
    .analytics-point-layers {
        margin-left: 0;
    }
    .analytics-filter-bar {
        flex-wrap: wrap;
    }
    .analytics-filter-bar .analytics-reset-btn:first-of-type {
        margin-left: auto;
    }
    .analytics-view {
        overflow-x: auto;
    }
    .container {
        padding: 2px;
    }
    .page {
        padding: 2px;
    }
    .config-page input[type="number"] {
        width: 80px;
    }
    .config-content {
        padding: 12px;
    }
    .config-section h3 {
        padding: 10px 12px;
    }
    .config-buttons {
        flex-wrap: wrap;
        gap: 8px;
    }
    .config-buttons .btn {
        padding: 8px 10px;
        font-size: 11px;
        white-space: nowrap;
    }
    .history-table,
    .results-table {
        border-spacing: 0 2px;
        font-size: 10px;
    }
    .history-table th,
    .results-table th {
        padding: 3px 2px;
        font-size: 9px;
    }
    .history-table td,
    .results-table td {
        padding: 2px 2px;
    }
    .history-table td strong,
    .history-table td span {
        font-size: 10px !important;
    }
    .newton-table-badge {
        padding: 2px 3px;
        margin: 0 2px;
    }
    .nav {
        gap: 16px;
        justify-content: center;
    }
}

/* Players tab — split layout */
.players-split {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.players-list-panel {
    width: 300px;
    min-width: 300px;
    max-height: 70vh;
    overflow-y: auto;
}

.players-profile-panel {
    flex: 1;
    min-width: 0;
}

#playersTableContainer {
    max-width: 100%;
}

#playersTableContainer .newton-table-pagination,
#playerProfileTableContainer .newton-table-pagination,
#playerComparisonTableContainer .newton-table-pagination {
    display: none;
}

@media (max-width: 1120px) {
    .players-split {
        flex-direction: column;
    }
    .players-list-panel {
        width: 100%;
        min-width: 0;
        max-height: 40vh;
    }
    #playersTableContainer {
        max-width: 100%;
    }
}

.leaderboard-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

/* Analytics views */
.analytics-view {
    display: none;
}

.analytics-view.active {
    display: block;
}

.analytics-placeholder {
    text-align: center;
    padding: 64px 24px;
    color: #9ca3af;
}

.analytics-placeholder h3 {
    margin: 0 0 8px;
    font-size: 1.25rem;
    color: #6b7280;
}

.analytics-placeholder p {
    margin: 0;
    font-size: 14px;
}

/* Analytics dashboard */
.analytics-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    padding: 24px;
}
@media (max-width: 1120px) {
    .analytics-dashboard {
        padding: 8px;
    }
}

.analytics-stat-card {
    background: #ffffff;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    padding: 24px 20px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.analytics-stat-card.clickable {
    cursor: pointer;
}

.analytics-stat-card.clickable:hover {
    border-color: #d1d5db;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.analytics-stat-value {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Courier New', monospace;
    font-size: 2.25rem;
    font-weight: 700;
    color: #166534;
    line-height: 1;
    margin-bottom: 8px;
}

.analytics-stat-label {
    font-size: 14px;
    font-weight: 600;
    color: #222222;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.analytics-stat-subtitle {
    font-size: 13px;
    color: #6b7280;
}

/* Analytics label on Tournament Setup */
.analytics-label {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: 10px;
    cursor: pointer;
    letter-spacing: 0.3px;
    vertical-align: middle;
}

.analytics-label--active {
    background: #e8f5e8;
    color: #166534;
    border: 1px solid #86efac;
}

.analytics-label--active:hover {
    background: #d1fae5;
}

.analytics-label--add {
    background: transparent;
    color: #8a7968;
    border: 1px dashed #d5c4b0;
}

.analytics-label--add:hover {
    background: #f5ebe0;
    color: #5c4a3a;
    border-color: #8a7968;
}

/* ==========================================================================
   App Mode: Analytics — CSS-driven visibility
   Body class "mode-analytics" set by PHP (Docker) or JS (URL parameter).
   All mode-specific hiding is here. No JavaScript display:none needed.
   ========================================================================== */

/* Hide tournament management nav tabs */
.mode-analytics .nav-btn[data-page="setup"],
.mode-analytics .nav-btn[data-page="registration"],
.mode-analytics .nav-btn[data-page="tournament"] {
    display: none;
}

/* Hide the Chalker link (nav-btn with href, no data-page) */
.mode-analytics .nav-btn[href] {
    display: none;
}


/* Limit Global Settings — hide all sections except Branding and Point Values */
.mode-analytics #headerTournamentStatus,
.mode-analytics #headerTournamentStatusNarrow {
    display: none;
}
.mode-analytics #config .config-section {
    display: none;
}
.mode-analytics #config #configLogo,
.mode-analytics #config #configBranding,
.mode-analytics #config #configPoints {
    display: block;
}

/* Back to Analytics button — hidden in full mode, shown in analytics mode */
.analytics-back-btn {
    display: none;
}
.mode-analytics .analytics-back-btn {
    display: inline-flex;
}

/* Default page — hide Setup in analytics mode, let JS showPage('history') activate Analytics */
.mode-analytics #setup.page {
    display: none;
}

/* Bracket controls — hide tournament management buttons in analytics mode */
.mode-analytics .bracket-controls-top-left .nav-btn:not(.analytics-back-btn) {
    display: none;
}
.mode-analytics .bracket-controls-middle-left .nav-btn {
    display: none;
}

/* Documentation link icons in settings */
.doc-link-icon {
    display: inline-block;
    text-decoration: none;
    font-size: 1.2rem;
    margin-left: 8px;
    vertical-align: middle;
    transition: transform 0.2s ease;
}

.doc-link-icon:hover {
    transform: scale(1.15);
}
