:root {
  /* Colors - Dark Theme */
  --bg-body: #09090b;
  --bg-card: #18181b;
  --bg-card-hover: #27272a;
  --bg-elevated: #27272a;
  
  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  
  --border-subtle: #27272a;
  --border-active: #3f3f46;
  
  --accent-primary: #3b82f6; /* Blue */
  --accent-secondary: #8b5cf6; /* Purple */
  --accent-success: #10b981;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;
  
  --gradient-primary: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  --gradient-gold: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  
  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  
  /* Radius */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: --bg-body;
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  margin-top: 0;
  color: var(--text-primary);
  font-weight: 700;
  letter-spacing: -0.02em;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

p { margin: 0 0 1rem 0; color: var(--text-secondary); }
small { font-size: 0.875rem; color: var(--text-muted); }

/* Layout Utils */
.container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 var(--spacing-lg);
  width: 100%;
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.gap-lg { gap: var(--spacing-lg); }

.grid { display: grid; }
.w-full { width: 100%; }
.h-full { height: 100%; }

/* Navigation */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(9, 9, 11, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  padding: var(--spacing-md) 0;
}

.nav-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  font-size: 1.5rem;
  font-weight: 800;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.nav-links {
  display: flex;
  gap: var(--spacing-lg);
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  transition: color 0.2s;
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-sm);
}

.nav-link:hover { color: var(--text-primary); background: var(--bg-card-hover); }
.nav-link.active { color: var(--accent-primary); background: rgba(59, 130, 246, 0.1); }

/* Stats Bar */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: var(--spacing-xs);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-change {
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}
.stat-change.positive { color: var(--accent-success); }
.stat-change.negative { color: var(--accent-danger); }

/* Dashboard Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: var(--spacing-lg);
  align-items: start;
  min-height: calc(100vh - 200px);
}

@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* Card/Panel Container */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 800px; /* Limit height for scrolling lists */
  box-shadow: var(--shadow-lg);
}

.panel-header {
  padding: var(--spacing-md) var(--spacing-lg);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}

.panel-body {
  padding: var(--spacing-md);
  overflow-y: auto;
  flex: 1;
}

/* Squad List (Left Panel) */
.player-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.player-list-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-sm);
  background: var(--bg-body);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  cursor: grab;
}

.player-list-item:hover {
  border-color: var(--accent-primary);
  transform: translateX(4px);
  background: var(--bg-card-hover);
}

.player-avatar-sm {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border: 2px solid var(--border-active);
}

.player-info {
  flex: 1;
}

.player-name {
  font-weight: 600;
  font-size: 0.9rem;
  display: block;
}

.player-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Team Grid (Right Panel) */
.field-view {
  background: 
    linear-gradient(rgba(9, 9, 11, 0.9), rgba(9, 9, 11, 0.9)),
    repeating-linear-gradient(0deg, transparent, transparent 49px, rgba(255,255,255,0.03) 50px);
  padding: var(--spacing-lg);
  border-radius: var(--radius-md);
  min-height: 600px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid var(--border-subtle);
}

.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-xl);
}

.team-section-title {
  text-align: center;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: var(--spacing-md);
  position: relative;
}

.team-section-title::before, .team-section-title::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: var(--border-subtle);
}
.team-section-title::before { left: 0; }
.team-section-title::after { right: 0; }

/* Player Card (Grid Item) */
.player-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--spacing-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s;
}

.player-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent-primary);
}

.player-card-image {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--bg-elevated);
  margin-bottom: var(--spacing-sm);
  border: 2px solid var(--border-active);
  position: relative;
}

.role-badge {
  position: absolute;
  bottom: -4px;
  right: -4px;
  font-size: 0.6rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: var(--bg-body);
  border: 1px solid var(--border-subtle);
}

.badge-wk { color: var(--accent-warning); border-color: var(--accent-warning); }
.badge-bat { color: var(--accent-primary); border-color: var(--accent-primary); }
.badge-bwl { color: var(--accent-success); border-color: var(--accent-success); }
.badge-all { color: var(--accent-secondary); border-color: var(--accent-secondary); }

.card-name {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.card-team {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

.card-points {
  font-size: 0.75rem;
  color: var(--text-primary);
  background: var(--bg-elevated);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  margin-top: var(--spacing-xs);
}

.remove-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--accent-danger);
  color: var(--accent-danger);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}

.player-card:hover .remove-btn { opacity: 1; }

.add-btn {
  background: transparent;
  border: 1px solid var(--border-active);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.add-btn:hover {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

/* Validation Footer/Bar */
.validation-bar {
  display: flex;
  gap: var(--spacing-lg);
  margin-top: var(--spacing-md);
  padding-top: var(--spacing-md);
  border-top: 1px solid rgba(255,255,255,0.1);
  flex-wrap: wrap;
}

.validation-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.validation-item.valid { color: var(--accent-success); }
.validation-item.invalid { color: var(--accent-danger); }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

/* Floating Action / Save */
.action-area {
  margin-top: auto;
  padding-top: var(--spacing-lg);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--spacing-md);
}

.btn {
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

/* Utilities */
.text-right { text-align: right; }
.badge {
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-subtle { background: var(--bg-elevated); color: var(--text-secondary); }

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-active);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Admin Styles */
.admin-sidebar {
    width: 260px;
    background: var(--bg-card);
    border-right: 1px solid var(--border-subtle);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    padding: var(--spacing-lg);
    display: flex;
    flex-direction: column;
}

.admin-main {
    margin-left: 260px;
    padding: var(--spacing-lg);
    width: calc(100% - 260px);
}

.admin-nav-item {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
    font-size: 0.9rem;
}

.admin-nav-item:hover, .admin-nav-item.active {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.admin-nav-item.active {
    color: var(--accent-primary);
    background: rgba(59, 130, 246, 0.1);
}

.table-container {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-card);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th {
    background: var(--bg-elevated);
    color: var(--text-muted);
    font-weight: 600;
    text-align: left;
    padding: 12px 16px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-card-hover); cursor: pointer; }

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.search-input {
    background: var(--bg-body);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    width: 300px;
}

/* Squad Editor Styles */
.editor-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--spacing-lg);
    align-items: start;
}

.editor-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    position: sticky;
    top: var(--spacing-lg);
}

.form-group {
    margin-bottom: var(--spacing-md);
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-input, .form-select {
    width: 100%;
    background: var(--bg-elevated);
    border: 1px solid var(--border-active);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.squad-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.squad-stat-item {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    text-align: center;
}

/* Helper Classes */
.row-highlight {
    cursor: pointer;
    background: rgba(59, 130, 246, 0.05);
}

.avatar-accent {
    background: var(--accent-primary);
    color: white;
    border: none;
}

.text-accent-primary {
    color: var(--accent-primary);
}

.btn-sm {
    padding: 4px 12px;
    font-size: 0.8rem;
    text-decoration: none;
}

/* Scoreboard Styles */
.scoreboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--spacing-lg);
    margin-top: var(--spacing-lg);
}

.scoreboard-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s, box-shadow 0.2s;
}

.scoreboard-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-active);
}

.scoreboard-card-header {
    padding: var(--spacing-md);
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    border-bottom: 1px solid var(--border-subtle);
    background: linear-gradient(to bottom, var(--bg-elevated), var(--bg-card));
}

.scoreboard-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 2px solid var(--border-active);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.scoreboard-info {
    flex: 1;
}

.scoreboard-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
    display: block;
}

.scoreboard-team {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 6px;
}

.scoreboard-points {
    text-align: right;
}

.points-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--accent-primary);
    line-height: 1;
}

.points-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    display: block;
    margin-top: 4px;
}

.scoreboard-details {
    padding: 0;
}

.match-dropdown {
    width: 100%;
}

.match-dropdown summary {
    padding: var(--spacing-md);
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: background 0.2s;
}

.match-dropdown summary:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.match-dropdown summary::-webkit-details-marker {
    display: none;
}

.match-dropdown summary::after {
    content: '';
    width: 20px;
    height: 20px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    transition: transform 0.3s;
}

.match-dropdown[open] summary::after {
    transform: rotate(180deg);
}

.match-list {
    background: var(--bg-elevated);
    border-top: 1px solid var(--border-subtle);
    padding: var(--spacing-sm);
}

.match-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-sm);
    margin-bottom: 2px;
}

.match-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

.match-info {
    font-size: 0.9rem;
    font-weight: 500;
}

.match-points {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.points-pill {
    background: var(--bg-card);
    border: 1px solid var(--border-active);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 700;
    min-width: 40px;
    text-align: center;
}

.explanation-link {
    font-size: 0.8rem;
    color: var(--accent-primary);
    text-decoration: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

.explanation-link:hover {
    text-decoration: underline;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal-overlay:target, .modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    transform: translateY(20px);
    transition: transform 0.3s;
    overflow: hidden;
}

.modal-overlay:target .modal, .modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-elevated);
}

.modal-title {
    margin: 0;
    font-size: 1.25rem;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
}

.modal-close:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
}

.modal-body {
    padding: var(--spacing-lg);
}

.point-breakdown {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.breakdown-row {
    display: flex;
    justify-content: space-between;
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--border-subtle);
}

.breakdown-row:last-child {
    border-bottom: none;
}

.breakdown-label {
    color: var(--text-secondary);
}

.breakdown-value {
    font-weight: 600;
    color: var(--text-primary);
}
