:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #111111;
  --bg-tertiary: #1a1a1a;
  --bg-elevated: #222222;
  --border-color: #2a2a2a;
  --border-hover: #444444;
  --text-primary: #f0f0f0;
  --text-secondary: #a0a0a0;
  --text-muted: #666666;
  --accent-primary: #d50f3b;
  --accent-primary-hover: #b10d31;
  --accent-gold: rgba(255, 215, 0, 0.1);
  --accent-gold-border: rgba(255, 215, 0, 0.25);
  --accent-top5: rgba(100, 100, 100, 0.08);
  --accent-top5-border: rgba(100, 100, 100, 0.2);
  --success: #d50f3b;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.6);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --transition: all 0.2s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

/* Subtle background pattern */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(ellipse at top, rgba(220, 38, 38, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at bottom, rgba(100, 100, 100, 0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
  position: relative;
  z-index: 1;
  min-width: fit-content;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 32px;
  padding: 40px 32px;
  background: 
    radial-gradient(ellipse at top, rgba(220, 38, 38, 0.08) 0%, transparent 60%),
    linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(220, 38, 38, 0.05);
  min-width: 100%;
  box-sizing: border-box;
  position: relative;
  overflow: hidden;
}

/* Header decorative pieces */
.header-decoration {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 100%;
  max-height: 180px;
  width: auto;
  pointer-events: none;
  opacity: 0.7;
  display: none;
}

.header-decoration-left {
  left: 32px;
}

.header-decoration-right {
  right: 32px;
}

/* Show decorations only on wide screens */
@media (min-width: 1100px) {
  .header-decoration {
    display: block;
  }
}

@media (min-width: 1300px) {
  .header-decoration {
    max-height: 220px;
  }
}

.header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #d50f3b, #f87171, #d50f3b);
  background-size: 200% 100%;
  animation: headerShine 3s linear infinite;
}

@keyframes headerShine {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.header-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #ffffff;
  background: linear-gradient(135deg, #d50f3b 0%, #b10d31 100%);
  padding: 6px 16px;
  border-radius: 16px;
  border: 1px solid #ef4444;
  margin-bottom: 16px;
  user-select: none;
  box-shadow: 0 0 20px rgba(220, 38, 38, 0.4), 0 2px 8px rgba(0,0,0,0.3);
  position: relative;
  z-index: 10;
}

.header-badge:hover {
  box-shadow: 0 0 30px rgba(220, 38, 38, 0.6), 0 3px 12px rgba(0,0,0,0.4);
  transform: translateY(-1px);
  transition: all 0.2s ease;
}

.header h1 {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.7px;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #ffffff 0%, #d50f3b 50%, #f87171 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 0 30px rgba(220, 38, 38, 0.2);
}

.header p {
  font-size: 15px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Controls Bar */
.controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding: 16px 20px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  flex-wrap: wrap;
  min-width: 100%;
  box-sizing: border-box;
}

.search-wrapper {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.search-wrapper::before {
  content: '🔍';
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  opacity: 0.6;
}

.search-wrapper input {
  width: 100%;
  padding: 10px 12px 10px 38px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  transition: var(--transition);
  outline: none;
}

.search-wrapper input::placeholder {
  color: var(--text-muted);
}

.search-wrapper input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: var(--transition);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.btn.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

.btn:hover:not(:disabled) {
  background: var(--bg-elevated);
  border-color: var(--border-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-primary-hover);
  border-color: var(--accent-primary-hover);
}

.last-updated {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: auto;
  white-space: nowrap;
}

/* Table Container */
.table-container {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  overflow-x: auto;
  overflow-y: visible;
  box-shadow: var(--shadow-md);
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  font-size: 13px;
}

thead {
  background: var(--bg-tertiary);
}

thead th {
  position: sticky;
  top: 0;
  padding: 14px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  border-bottom: 2px solid var(--border-color);
  z-index: 2;
  user-select: none;
}

thead th:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

thead th.active {
  color: var(--text-primary);
}

thead th.active::after {
  margin-left: 6px;
  font-size: 10px;
  font-weight: bold;
}

thead th.active.desc::after {
  content: " ↓";
}

thead th.active.asc::after {
  content: " ↑";
}

th:first-child, td:first-child,
th:nth-child(2), td:nth-child(2) {
  width: 80px;
  text-align: center;
}

thead th:first-child, thead th:nth-child(2) {
  color: var(--text-muted);
  font-size: 11px;
}

tbody tr {
  transition: var(--transition);
  border-bottom: 1px solid var(--border-color);
}

tbody tr:last-child {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--bg-tertiary);
}

tbody tr.top1 {
  background: rgba(255, 215, 0, 0.1);
}

tbody tr.top1:hover {
  background: rgba(255, 215, 0, 0.14);
  box-shadow: inset 2px 0 0 rgba(255, 215, 0, 0.25);
}

tbody tr.top2 {
  background: rgba(192, 192, 192, 0.08);
}

tbody tr.top2:hover {
  background: rgba(192, 192, 192, 0.12);
  box-shadow: inset 2px 0 0 rgba(192, 192, 192, 0.25);
}

tbody tr.top3 {
  background: rgba(205, 127, 50, 0.08);
}

tbody tr.top3:hover {
  background: rgba(205, 127, 50, 0.12);
  box-shadow: inset 2px 0 0 rgba(205, 127, 50, 0.25);
}

td {
  padding: 12px 16px;
  color: var(--text-primary);
}

td:first-child, td:nth-child(2) {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 12px;
}

.top1 .rank-badge {
  background: rgba(255, 215, 0, 0.15);
  color: #fbbf24;
}

.top2 .rank-badge {
  background: rgba(192, 192, 192, 0.15);
  color: #e5e7eb;
}

.top3 .rank-badge {
  background: rgba(205, 127, 50, 0.15);
  color: #f59e0b;
}

.driver-link {
  color: var(--text-primary);
  text-decoration: none;
  transition: var(--transition);
  font-weight: 500;
}

.driver-link:hover {
  color: var(--accent-primary);
}

.flag {
  width: 20px;
  height: 14px;
  margin-right: 8px;
  border-radius: 2px;
  vertical-align: middle;
  box-shadow: 0 0 4px rgba(0,0,0,0.3);
}

.numeric {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.rating-value {
  color: var(--accent-primary);
  font-weight: 600;
}

.rep-value {
  color: var(--success);
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 24px;
  padding: 16px 20px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  min-width: 100%;
  box-sizing: border-box;
}

.page-info {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 0 12px;
  font-variant-numeric: tabular-nums;
}

/* Loading state */
.loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.loading::after {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  margin-left: 8px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.loading-spinner {
  text-align: center;
  color: var(--text-primary);
}

.loading-spinner::after {
  content: '';
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-left: 12px;
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    padding: 12px;
  }

  .header {
    padding: 20px 16px;
  }

  .header h1 {
    font-size: 22px;
  }

  .controls {
    padding: 12px 16px;
    gap: 10px;
  }

  .search-wrapper {
    min-width: auto;
    flex: 1;
  }

  .last-updated {
    width: 100%;
    margin-left: 0;
    text-align: center;
  }

  .table-container {
    margin: 0 -12px;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  table {
    min-width: 800px;
  }

  thead th, td {
    padding: 10px 8px;
    font-size: 12px;
  }

  th:first-child, td:first-child,
  th:nth-child(2), td:nth-child(2) {
    width: 50px;
  }

  .table-container::after {
    display: block;
  }

  .btn {
    min-height: 44px;
    padding: 12px 16px;
  }

  .search-wrapper input {
    min-height: 44px;
  }
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-elevated);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* Mobile table improvements */
.table-container {
  position: relative;
}

.table-container::after {
  content: '↔ Scroll horizontally';
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.7;
  pointer-events: none;
  display: none;
}

/* Sticky first column */
th:first-child,
td:first-child {
  position: sticky;
  left: 0;
  background-color: inherit;
  z-index: 1;
  box-shadow: 2px 0 4px rgba(0,0,0,0.2);
}

thead th:first-child {
  z-index: 3;
}


/* Breadcrumb Navigation */
.breadcrumb-nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
  padding: 14px 20px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  min-width: 100%;
  box-sizing: border-box;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: all 0s ease;
  text-decoration: none;
  color: #fca5a5;
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid rgba(220, 38, 38, 0.25);
  text-align: center;
  position: relative;
  box-shadow: 0 0 8px rgba(220, 38, 38, 0.05);
}

.breadcrumb-item.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
  animation: breadcrumbActive 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes breadcrumbActive {
  0% {
    transform: scale(0.95);
  }
  50% {
    transform: scale(1.02);
  }
  100% {
    transform: scale(1);
  }
}

.breadcrumb-item:not(.disabled):hover {
  background: var(--bg-elevated);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.breadcrumb-item.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

.breadcrumb-item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Instant Custom Tooltips (no delay) */
.breadcrumb-item[data-tooltip] {
  position: relative;
}

.breadcrumb-item[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #111111;
  color: #ffffff;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  z-index: 100;
  border: 1px solid #444444;
  box-shadow: 0 4px 12px rgba(0,0,0,0.7);
  pointer-events: none;
}

.breadcrumb-item[data-tooltip]:hover::before {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid #111111;
  z-index: 101;
  pointer-events: none;
}

.breadcrumb-separator {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
}

/* Footer */
.footer {
  margin-top: 48px;
  padding: 32px 24px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  min-width: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 24px;
}

.footer-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
}

.footer-logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 202px;
  height: auto;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.footer-link {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  transition: var(--transition);
}

.footer-link:hover {
  color: var(--text-primary);
  transform: translateY(-1px);
}

@media (max-width: 768px) {
  .footer {
    flex-direction: column;
    text-align: center;
    padding: 24px 16px;
  }
  
  .footer-links {
    justify-content: center;
    gap: 16px;
  }
}
