html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: Arial, sans-serif;
  background-color: #000000;
  color: #ffffff;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

#scoreboard {
  background: #ebebeb;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 4px 1px rgba(0, 0, 0, 0.1);
  text-align: center;
  flex-grow: 1;
  overflow-y: auto;
}

.navbar {
  background-color: #000;
  color: white;
  padding: 10px 0;
  display: flex;
  justify-content: center;
  position: sticky;
  top: 0;
  width: 100%;
  z-index: 1000;
}

.navbar-content {
  width: 100%;
  max-width: 100vw;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-left {
  font-size: 1.2rem;
  font-weight: bold;
}

.nav-right {
  display: flex;
  gap: 20px;
}

.nav-link {
  color: white;
  text-decoration: none;
}

.nav-link.active {
  color: #888;
  font-weight: bold;
}

#teamsContainer {
  margin-top: 65px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  padding: 20px 0;
}

.constructor-card-wrapper {
  position: relative;
  margin-bottom: 60px; /* Extra space for car positioning */
}

.constructor-car {
  position: absolute;
  top: -60px; /* Position car above the card */
  left: 30%;
  transform: translateX(-50%);
  z-index: 10;
  width: 120px;
  height: 60px;
  overflow: visible;
}

.car-image {
  width: 300px;
  height: auto;
  object-fit: contain;
  background: transparent;
}

.constructor-card {
  margin-bottom: 40px;
  border: 2px solid #444;
  border-radius: 15px;
  padding: 20px;
  width: 340px;
  background-color: #000000;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  cursor: pointer;
  position: relative;
  z-index: 5;
}

.constructor-card:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 10px rgba(255, 255, 255, 0.5);
}

.constructor-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 20px;
  color: white;
}

.constructor-logo {
  width: 80px;
  height: 80px;
  object-fit: contain;
  background: white;
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 15px;
}

.constructor-name {
  font-size: 1.5rem;
  font-weight: bold;
  text-align: center;
  margin: 10px 0;
}

.constructor-rank {
  font-size: 0.9rem;
  color: #ccc;
  text-align: center;
}

.constructor-stats {
  display: flex;
  justify-content: space-around;
  align-items: center;
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 15px;
  margin-top: 15px;
}

.stat-item {
  text-align: center;
  flex: 1;
}

.stat-label {
  font-size: 0.8rem;
  color: #ccc;
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: bold;
  color: white;
}

.footer {
  background-color: #000;
  color: white;
  text-align: center;
  padding: 10px 0;
  font-size: 1rem;
  position: relative;
  bottom: 0;
  width: 100%;
}

.footer-link {
  color: white;
  text-decoration: none;
  margin: 0 10px;
}

.footer-link:hover {
  color: #888;
}

/* Navigation dropdown styles */
.dropdown-link.active {
  background-color: #444;
  font-weight: bold;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  gap: 4px;
}

.nav-toggle .bars {
  width: 25px;
  height: 3px;
  background-color: white;
}

.dropdown-menu {
  display: none;
  flex-direction: column;
  position: absolute;
  top: 60px;
  right: 20px;
  background-color: #000;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  z-index: 1000;
}

.dropdown-menu.active {
  display: flex;
}

.dropdown-link {
  color: white;
  text-decoration: none;
  padding: 10px 20px;
  text-align: center;
}

.dropdown-link:hover {
  background-color: #333;
}

/* F1 Standings Styles */
.standings-container {
  margin-top: 20px;
  overflow-x: auto;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.standings-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 800px;
  background: white;
}

.standings-table thead {
  background: #f8f9fa;
  border-bottom: 2px solid #dee2e6;
}

.standings-table th {
  padding: 12px 8px;
  text-align: left;
  font-weight: bold;
  font-size: 0.85rem;
  color: #495057;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-right: 1px solid #dee2e6;
}

.pos-header {
  width: 60px;
  text-align: center;
}

.driver-header {
  width: 200px;
}

.pts-header {
  width: 80px;
  text-align: center;
}

.circuit-header {
  width: 50px;
  text-align: center;
  font-size: 0.75rem;
}

.driver-row {
  border-bottom: 1px solid #dee2e6;
  transition: background-color 0.2s ease;
}

.driver-row:hover {
  background-color: #f8f9fa;
}

.driver-row:nth-child(even) {
  background-color: #fdfdfd;
}

.driver-row td {
  padding: 12px 8px;
  border-right: 1px solid #dee2e6;
  vertical-align: middle;
}

.pos-cell {
  text-align: center;
  font-weight: bold;
  font-size: 0.9rem;
  color: #495057;
}

.driver-cell {
  padding: 8px 12px;
}

.driver-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.driver-flag {
  width: 20px;
  height: 15px;
  object-fit: cover;
  border-radius: 2px;
  border: 1px solid #dee2e6;
}

.driver-details {
  display: flex;
  flex-direction: column;
}

.driver-name {
  font-weight: bold;
  font-size: 0.9rem;
  color: #212529;
  margin-bottom: 2px;
}

.driver-team {
  font-size: 0.75rem;
  color: #6c757d;
  text-transform: uppercase;
}

.pts-cell {
  text-align: center;
  font-weight: bold;
  font-size: 1rem;
  color: #212529;
}

.circuit-cell {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 500;
}

.circuit-cell.has-points {
  color: #28a745;
  background-color: #f8fff9;
}

.circuit-cell.no-points {
  color: #6c757d;
  background-color: #f8f9fa;
}

.circuit-cell.future-race {
  color: #6c757d;
  background-color: #f8f9fa;
  font-style: italic;
}

.driver-points {
  font-size: 0.7rem;
  color: #28a745;
  font-weight: bold;
  margin-top: 2px;
}

/* Scheduled Races Styles */
.scheduled-container {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
  padding: 20px;
}

.race-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 24px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  border-left: 5px solid #e74c3c;
  cursor: pointer;
}

.footer-separator {
  margin: 0 10px;
  color: #888;
}

.footer-icon {
  width: 20px;
  height: 20px;
  vertical-align: middle;
  margin-right: -2.5px;
}

.race-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.result-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.race-header {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 16px;
}

.race-country-code {
  background: #e74c3c;
  color: white;
  padding: 8px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: bold;
  letter-spacing: 1px;
  min-width: 50px;
  text-align: center;
}

.race-name {
  font-size: 1.3rem;
  font-weight: bold;
  color: #2c3e50;
  flex: 1;
  line-height: 1.2;
}

.race-date {
  color: #7f8c8d;
  font-size: 0.95rem;
  line-height: 1.4;
  padding-top: 12px;
  border-top: 1px solid #ecf0f1;
}

/* Country flag styles */
.race-country-flag {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 60px;
  height: 40px;
}

.country-flag-img {
  width: 40px;
  height: 30px;
  object-fit: cover;
  border-radius: 4px;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.country-code-fallback {
  background: #e74c3c;
  color: white;
  padding: 8px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: bold;
  letter-spacing: 1px;
  text-align: center;
}

.circuit-flag {
  width: 24px;
  height: 18px;
  object-fit: cover;
  border-radius: 2px;
  border: 1px solid #dee2e6;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.circuit-code-fallback {
  color: #495057;
  font-weight: bold;
}

/* Race Results Styles */
.results-container {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  padding: 20px;
  max-width: 100%;
  box-sizing: border-box;
}

.result-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 24px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  /* border-left color now applied dynamically via inline styles */
  cursor: pointer;
  max-width: 100%;
  box-sizing: border-box;
}

.race-result-info {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #ecf0f1;
}

.race-winner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.winner-label {
  font-size: 0.9rem;
  color: #6c757d;
  font-weight: 500;
}

.winner-name {
  font-size: 1.1rem;
  font-weight: bold;
  /* color now applied dynamically via inline styles */
}

.winner-team {
  font-weight: bold;
  /* Color and text-shadow applied inline for dynamic team colors */
}

/* Section styles for in-progress and completed races */
.in-progress-section {
  margin-bottom: 30px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.completed-section {
  margin-top: 20px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.section-header {
  margin-bottom: 20px;
  text-align: center;
}

.section-title {
  color: rgb(0, 0, 0);
  font-size: 1.8rem;
  font-weight: 700;
  margin: 0;
  padding: 15px 0;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.in-progress-section .section-title {
  color: #27ae60;
  text-shadow: 1px 1px 3px rgba(39, 174, 96, 0.3);
}

.completed-section .section-title {
  color: #000000;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
}

.section-divider {
  height: 3px;
  background: linear-gradient(90deg, transparent, #27ae60, #2ecc71, #27ae60, transparent);
  margin: 40px 0;
  border-radius: 3px;
  box-shadow: 0 2px 10px rgba(39, 174, 96, 0.3);
  position: relative;
  width: 100%;
}

.section-divider::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(90deg, transparent, rgba(39, 174, 96, 0.5), rgba(46, 204, 113, 0.5), rgba(39, 174, 96, 0.5), transparent);
  border-radius: 3px;
  filter: blur(2px);
}

/* Ensure vertical stacking */
#resultsContainer {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
}

.in-progress-races {
  display: flex;
  flex-direction: column;
  gap: 15px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.completed-races {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  width: 100%;
  max-width: 100%;
  padding: 0 20px;
  box-sizing: border-box;
}

/* In-progress race card styles */
.in-progress-card {
  background: linear-gradient(135deg, #27ae60, #2ecc71);
  border-radius: 12px;
  padding: 20px;
  margin: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 15px rgba(46, 204, 113, 0.3);
  border: 2px solid #27ae60;
  transition: all 0.3s ease;
  min-height: 120px;
  width: calc(100% - 40px);
  max-width: calc(100vw - 80px);
  box-sizing: border-box;
}

.in-progress-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(46, 204, 113, 0.4);
}

.in-progress-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.race-header-in-progress {
  display: flex;
  align-items: center;
  gap: 15px;
}

.country-flag-img-large {
  width: 40px;
  height: 30px;
  object-fit: cover;
  border-radius: 4px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.country-code-fallback-large {
  font-weight: bold;
  color: white;
  background: rgba(255,255,255,0.2);
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 0.9rem;
}

.race-name-large {
  font-size: 1.5rem;
  font-weight: bold;
  color: white;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.3);
}

.circuit-name {
  font-size: 1.1rem;
  color: rgba(255,255,255,0.9);
  font-weight: 500;
}

.race-dates {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  color: rgba(255,255,255,0.8);
}

.date-divider {
  font-size: 1.2rem;
  font-weight: bold;
  color: rgba(255,255,255,0.6);
}

.in-progress-right {
  flex: 1;
  display: flex;
  justify-content: flex-end;
}

.competition-winners {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(255,255,255,0.1);
  padding: 15px;
  border-radius: 8px;
  backdrop-filter: blur(10px);
}

.competition-result {
  display: flex;
  align-items: center;
  gap: 10px;
}

.comp-label {
  font-weight: bold;
  color: white;
  min-width: 40px;
  font-size: 0.95rem;
}

.comp-winner {
  color: #ffffff;
  font-weight: 600;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
  font-size: 0.95rem;
}

/* Responsive design for in-progress cards */
@media (max-width: 768px) {
  .in-progress-card {
    flex-direction: column;
    gap: 15px;
    text-align: center;
    margin: 15px 10px;
    width: calc(100% - 20px);
    max-width: calc(100vw - 40px);
  }
  
  .in-progress-left,
  .in-progress-right {
    flex: none;
    width: 100%;
  }
  
  .competition-winners {
    justify-content: center;
  }
  
  .race-dates {
    flex-direction: column;
    gap: 5px;
  }
  
  .date-divider {
    display: none;
  }
  
  .section-title {
    font-size: 1.5rem;
    padding: 10px 0;
  }
  
  .section-divider {
    margin: 30px 10px;
    height: 2px;
  }
  
  .completed-races {
    grid-template-columns: 1fr;
    gap: 15px;
    padding: 0 10px;
  }
}

@media (max-width: 480px) {
  .race-name-large {
    font-size: 1.2rem;
  }
  
  .circuit-name {
    font-size: 1rem;
  }
  
  .competition-winners {
    padding: 10px;
    gap: 6px;
  }
  
  .comp-label,
  .comp-winner {
    font-size: 0.85rem;
  }
  
  .section-title {
    font-size: 1.2rem;
    letter-spacing: 0.5px;
  }
  
  .section-divider {
    margin: 20px 5px;
  }
  
  .in-progress-card {
    margin: 15px 5px;
    width: calc(100% - 10px);
    max-width: calc(100vw - 20px);
    padding: 15px;
  }
  
  .completed-races {
    padding: 0 5px;
  }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .standings-container {
    margin: 10px -10px;
    border-radius: 0;
  }
  
  .standings-table {
    font-size: 0.8rem;
  }
  
  .driver-name {
    font-size: 0.8rem;
  }
  
  .driver-team {
    font-size: 0.7rem;
  }
  
  .circuit-header {
    font-size: 0.7rem;
    padding: 8px 4px;
  }
  
  .circuit-cell {
    padding: 8px 4px;
    font-size: 0.75rem;
  }
  
  .scheduled-container {
    grid-template-columns: 1fr;
    gap: 15px;
    padding: 15px;
    margin: 10px -10px;
  }
  
  .race-card {
    padding: 20px;
  }
  
  .race-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  
  .race-name {
    font-size: 1.1rem;
  }
  
  .race-date {
    font-size: 0.9rem;
  }
  
  .winner-name {
    font-size: 1rem;
  }
}

@media (max-width: 525px) {
  .driver-info {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
  }
  
  .driver-flag {
    width: 16px;
    height: 12px;
  }
  
  .standings-table th,
  .standings-table td {
    padding: 6px 4px;
  }
  
  .nav-right {
  display: none;
}

.nav-toggle {
  display: flex;
}

.dropdown-menu.active {
  display: flex;
}
}

/* Team section styles for race game cards */
.team-section {
  margin-bottom: 40px;
  border: 2px solid #444;
  border-radius: 15px;
  padding: 20px;
  width: 315px;
  background-color: #000000;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.team-section:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 10px rgba(0, 0, 0, 0.5);
}

.team-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 20px;
  color: white;
}

.team-header h2 {
  margin: 0;
  margin-top: 10px;
  font-size: 1.2rem;
  font-weight: bold;
}

.team-logo {
  width: 60px;
  height: 60px;
  object-fit: contain;
  background: transparent;
  filter: brightness(0) invert(1);
}

.team-games {
  width: 100%;
}

/* Race game card styles - updated to stretch properly */
.race-game-card {
  background-color: #000000;
  border: 1px solid #444;
  border-radius: 10px;
  padding: 16px 20px;
  width: 100%; /* Changed from fixed width to 100% */
  min-height: 200px; /* Ensure minimum height */
  font-family: Arial, sans-serif;
  color: white;
  text-align: center;
  position: relative;
  box-shadow: 0 0 10px rgb(255, 255, 255);
  box-sizing: border-box; /* Include padding in width calculation */
  display: flex;
  flex-direction: column;
  justify-content: space-between; /* Distribute content evenly */
}

.championship-stats-grid {
  display: flex; /* This makes the children (the stat items) display in a row */
  justify-content: space-between; /* Optional: Adjusts the spacing between the items */
  gap: 20px; /* Optional: Adds some gap between each stat block */
}

.championship-stat {
  display: flex;
  flex-direction: column; /* Ensures the label and value are stacked vertically within each stat */
  align-items: center; /* Centers the text within each stat block */
}

.stat-label {
  font-weight: bold;
}

.stat-value {
  font-size: 1.2em;
}

.constructor-race-content {
  width: 100%;
  min-height: 200px;
  display: flex;
  flex-direction: column;
}

.race-event-header {
  margin-bottom: 15px;
  border-bottom: 1px solid #444;
  padding-bottom: 10px;
  flex-shrink: 0; /* Don't shrink the header */
}

.event-name {
  font-size: 1rem;
  font-weight: bold;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.competition-name {
  font-size: 0.9rem;
  color: #ccc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.team-drivers-container {
  flex: 1; /* Take up remaining space */
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin-bottom: 15px;
}

.driver-entry {
  display: flex;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  min-height: 50px; /* Ensure consistent height */
}

.driver-entry:last-child {
  border-bottom: none;
}

.team-logo-section {
  width: 40px;
  margin-right: 12px;
  flex-shrink: 0; /* Don't shrink the logo */
}

.driver-team-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
  background: transparent;
}

.driver-name-section {
  flex: 1;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0; /* Allow text to wrap/truncate */
}

.driver-full-name {
  font-weight: bold;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.driver-position {
  font-size: 0.8rem;
  color: #ccc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.driver-stats-section {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0; /* Don't shrink the stats */
  min-width: 80px; /* Ensure minimum width for stats */
}

.driver-time {
  font-weight: bold;
  font-size: 0.85rem;
  white-space: nowrap;
}

.driver-laps {
  font-size: 0.8rem;
  color: #ccc;
  white-space: nowrap;
}

.competition-date-time {
  font-size: 0.85rem;
  color: #ccc;
  border-top: 1px solid #444;
  padding-top: 10px;
  flex-shrink: 0; /* Don't shrink the footer */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Responsive adjustments for mobile */
@media (max-width: 768px) {
  .race-game-card {
    padding: 12px 16px;
    min-height: 180px;
  }
  
  .driver-entry {
    padding: 6px 0;
    min-height: 45px;
  }
  
  .team-logo-section {
    width: 35px;
    margin-right: 10px;
  }
  
  .driver-team-logo {
    width: 35px;
    height: 35px;
  }
  
  .driver-full-name {
    font-size: 0.85rem;
  }
  
  .driver-position {
    font-size: 0.75rem;
  }
  
  .driver-time {
    font-size: 0.8rem;
  }
  
  .driver-laps {
    font-size: 0.75rem;
  }
  
  .driver-stats-section {
    min-width: 70px;
  }
}

@media (max-width: 525px) {
  .race-game-card {
    padding: 10px 12px;
    min-height: 160px;
  }
  
  .driver-name-section {
    min-width: 0;
  }
  
  .driver-full-name {
    font-size: 0.8rem;
  }
  
  .event-name {
    font-size: 0.9rem;
  }
  
  .competition-name {
    font-size: 0.8rem;
  }
  
  .driver-stats-section {
    min-width: 60px;
  }
  
  .driver-time {
    font-size: 0.75rem;
  }
  
  .driver-laps {
    font-size: 0.7rem;
  }
}
