/* 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;
}

/* Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* App shell */
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, Noto Sans, Apple Color Emoji, Segoe UI Emoji;
  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: 1.95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 15px;
  font-family: 'Droid Serif', serif;
}

.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;
  position: relative;
  padding-bottom: 8px;
}

/* Sliding underline indicator */
.nav::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 1px;
  background: rgba(22, 101, 52, 1);
  transition: all 0.3s ease;
  width: 0;
  opacity: 0;
}

/* Position underline based on active button */
.nav:has(.nav-btn:nth-child(1).active)::after {
  width: 41px; /* Width of "Setup" */
  left: 0;
  opacity: 1;
}

.nav:has(.nav-btn:nth-child(2).active)::after {
  width: 87px; /* Width of "Registration" */
  left: calc(42px + 32px); /* Previous button width + gap */
  opacity: 1;
}

.nav:has(.nav-btn:nth-child(3).active)::after {
  width: 91px; /* Width of "Tournament" */
  left: calc(42px + 32px + 87px + 32px); /* Sum of previous widths + gaps */
  opacity: 1;
}

.nav:has(.nav-btn:nth-child(4).active)::after {
  width: 49px; /* Width of "Config" */
  left: calc(42px + 32px + 87px + 32px + 82px + 32px); /* Sum of previous widths + gaps */
  opacity: 1;
}

.nav-btn {
  padding: 0;
  border: none;
  background: none;
  color: #444444;
  cursor: pointer;
  font-weight: 400;
  font-size: 16px;
  transition: color 0.15s ease;
}

.nav-btn:hover {
  color: #222222;
}

.nav-btn.active {
  color: #222222;
  font-weight: 400;
}

.header-tournament-status {
  position: absolute;
  right: 0;
  bottom: 0;
  color: #6b7280;
  font-size: 17px;
  font-weight: 400;
  text-align: right;
  line-height: 1.4;
}

.header-tournament-status strong {
  color: #111827;
  font-weight: 600;
}

/* 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;
  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;
}

/* 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;
}

.watermark-left {
  position: absolute;
  left: 30px;
  font-size: 16px;
  color: #696969;
}

.watermark-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  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-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;
}

.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,
#resetConfirmationInput {
  border-radius: 0 !important;
  -webkit-border-radius: 0 !important;
  -moz-border-radius: 0 !important;
}

.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;
}

/* 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 !important;
    color: #ffffff !important;
    transform: scale(1.1) !important;
}

.help-modal {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif !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-match-action-btn {
  padding: 6px 12px;
  border: none;
  border-radius: 0;
  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-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;
}

/* Tournament Completion Celebration Podium */
.tournament-celebration {
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  border-radius: 0;
  padding: 40px;
  margin: 15px auto;
  text-align: center;
  box-shadow: 0 8px 25px rgba(0,0,0,0.15);
  color: #1a202c;
  max-width: 800px;
}

.celebration-header {
  margin-bottom: 20px;
}

.celebration-title {
  font-size: 1.8rem;
  font-weight: bold;
  color: #2d3748;
  margin-bottom: 8px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.celebration-subtitle {
  font-size: 1rem;
  color: #4a5568;
  margin-bottom: 15px;
}

.podium-container {
  display: flex;
  justify-content: center;
  align-items: end;
  gap: 20px;
  margin: 20px 0;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.podium-position {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.podium-position.first {
  order: 2;
}

.podium-position.second {
  order: 1;
}

.podium-position.third {
  order: 3;
}

.podium-block {
  width: 80px;
  background: linear-gradient(145deg, #e2e8f0, #cbd5e0);
  border-radius: 8px 8px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.2rem;
  color: #2d3748;
  box-shadow: inset 0 2px 4px rgba(255,255,255,0.5), 0 4px 8px rgba(0,0,0,0.1);
  border: 2px solid #a0aec0;
}

.podium-block.first {
  height: 100px;
  background: linear-gradient(145deg, #fed7aa, #fdba74);
  border-color: #f97316;
  color: #9a3412;
}

.podium-block.second {
  height: 80px;
  background: linear-gradient(145deg, #d1d5db, #9ca3af);
  border-color: #6b7280;
  color: #374151;
}

.podium-block.third {
  height: 60px;
  background: linear-gradient(145deg, #fde68a, #fbbf24);
  border-color: #d97706;
  color: #92400e;
}

.podium-player {
  margin-bottom: 10px;
  padding: 10px;
  background: rgba(255,255,255,0.8);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  min-width: 100px;
}

.podium-medal {
  font-size: 2rem;
  margin-bottom: 5px;
  display: block;
}

.podium-rank {
  font-size: 0.9rem;
  font-weight: bold;
  color: #4a5568;
  margin-bottom: 5px;
}

.podium-name {
  font-size: 1rem;
  font-weight: 600;
  color: #2d3748;
  word-break: break-word;
}

.celebration-highlights {
  margin: 20px 0;
  padding: 15px;
  background: rgba(255,255,255,0.6);
  border-radius: 0;
  border: 1px solid #e2e8f0;
}

.highlights-title {
  font-size: 1.1rem;
  font-weight: bold;
  color: #2d3748;
  margin-bottom: 10px;
}

.highlights-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  margin-top: 10px;
}

.highlight-item {
  background: rgba(255,255,255,0.8);
  padding: 10px;
  border-radius: 0;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.highlight-label {
  font-size: 0.9rem;
  color: #4a5568;
  font-weight: 500;
  margin-bottom: 5px;
}

.highlight-value {
  font-size: 1.1rem;
  font-weight: bold;
  color: #2d3748;
}

.celebration-actions {
  margin-top: 25px;
  display: flex;
  justify-content: center;
  gap: 15px;
  flex-wrap: wrap;
}

.celebration-export-btn {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.celebration-export-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
  background: linear-gradient(135deg, #2563eb, #1e40af);
}

.celebration-export-btn:active {
  transform: translateY(0);
}

/* 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;
}

/* 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 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;
  padding: 8px 10px;
  font-size: 13px;
  color: #374151;
  cursor: pointer;
  transition: all 0.2s ease;
}

.referee-suggestion-item:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
}

.referee-suggestion-name {
  font-weight: 500;
  color: #111827;
}

.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;
}

/* 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 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: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
}

/* 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: 1rem;
  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;
  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;
  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: collapse;
  font-size: 14px;
  margin: 0;
}

.results-table th {
  background: #f9f9f9;
  border: 1px solid #e8e8e8;
  padding: 8px;
  text-align: center;
  font-weight: 600;
  color: #222222;
}

.results-table th:nth-child(1),
.results-table th:nth-child(2) {
  text-align: left;
}

.results-table td {
  border: 1px solid #e8e8e8;
  padding: 8px;
  color: #333333;
}

.results-table tr:nth-child(even) {
  background: #fafafa;
}

.results-table tr:hover {
  background: #f3f4f6;
}


/* Cell styling */
.results-table .rank {
  font-weight: 600;
  color: #333333;
  width: 5%;
  text-align: center;
}

.results-table .player-name {
  font-weight: 500;
  color: #333333;
  width: 25%;
}

.results-table .points {
  font-weight: 600;
  color: #166534;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Courier New', monospace;
  width: 10%;
  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;
}
