@import url(root.css);

/* ========= RESET & BASE ========= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--color-background);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 {
  font-weight: 700;
}

p, li, label {
  color: var(--color-text-muted);
  line-height: 1.5;
}

/* ========= HEADER ========= */
header {
  background: var(--color-surface);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--color-border);
}

header .logo {
  font-size: 1.8rem;
  color: var(--color-accent-2);
}

nav button {
  background: transparent;
  border: 2px solid var(--color-border);
  color: var(--color-text);
  margin-left: 1rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

nav button:hover {
  border-color: var(--color-accent-1);
  color: var(--color-accent-1);
}

/* ========= MAIN CONTENT ========= */
main {
  flex: 1;
  padding: 2rem;
}

.tab {
  display: none;
  animation: fadeIn 0.4s ease-in;
}

.tab.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========= HOME ========= */
#home h2 {
  color: var(--color-accent-1);
  margin-bottom: 0.5rem;
}

#home ul {
  list-style: square;
  margin-left: 1.5rem;
  margin-top: 1rem;
}

/* ========= RACE ========= */
.racer-selection {
  flex: 1;
  background: var(--color-surface);
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid var(--color-border);
}

.race-track {
  width: 100%;               /* full width */
  height: 360px;             /* fixed height */
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  padding: 1rem;
  margin-bottom: 1rem;       /* space below track */
}

.results {
  flex: 1;
  background: var(--color-surface);
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
}

/* Scrollable container for leaderboard */
#race-results-container {
  flex: 1;
  overflow-y: auto;           /* scroll if too many results */
  margin-top: 0.5rem;
  padding-left: 0.5rem;       /* add some margin */
  border-top: 1px solid var(--color-border);
}

.race-bottom-panel {
  display: flex;
  gap: 2rem;
  max-height: 400px;         /* fixed height to prevent stretching */
}

#track {
  background: linear-gradient(to right, var(--color-border) 2px, transparent 2px);
  background-size: 40px 100%;
  height: 360px;
  position: relative;
}

/* Placeholder racer style */
.racer {
  width: 60px;               /* make bigger */
  height: 30px;
  border-radius: 4px;
  position: absolute;
  left: 0;
  transition: left 0.2s linear;
}

/* ========= SETTINGS ========= */
#settings form {
  display: grid;
  gap: 1rem;
  max-width: 400px;
}

#settings label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--color-text);
}

#settings input, 
#settings select {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
}

#settings button {
  background: var(--color-accent-2);
  border: none;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  color: var(--color-background);
  font-weight: bold;
  transition: 0.2s;
}

#settings button:hover {
  background: var(--color-accent-1);
  color: var(--color-text);
}

.racer-selection {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin: 1rem 0;
}

#racer-select,
#add-racer-btn {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  padding: 0.4rem 0.8rem;
  border-radius: 0.5rem;
  font-size: 0.9rem;
}

#add-racer-btn {
  cursor: pointer;
  background: var(--color-accent-2);
  color: #000;
  font-weight: bold;
  transition: background 0.2s;
}
#add-racer-btn:hover {
  background: var(--color-accent-1);
  color: var(--color-text);
}

.selected-racers {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1rem;
}

.racer-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-text);
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.racer-card img {
  /* width: 40px;
  height: 40px; */
  border-radius: 0.5rem;
}

.racer-card .remove-racer {
  background: transparent;
  border: none;
  color: var(--color-error);
  font-size: 1.2rem;
  cursor: pointer;
}
.racer-card .remove-racer:hover {
  color: var(--color-accent-1);
}


/* ========= FOOTER ========= */
footer {
  background: var(--color-surface);
  text-align: center;
  padding: 1rem;
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
}

/* Each race container */
.race-result-container {
  margin-bottom: 1.5rem;
  padding: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

/* Heading for each race */
.race-result-container h3 {
  color: var(--color-accent-2); /* neon blue */
  margin-bottom: 0.5rem;
}

/* Ordered list for results */
.race-result-container ol {
  padding-left: 1.2rem; /* indent numbers */
}

.race-result-container li {
  margin-bottom: 0.3rem;
  color: var(--color-text); /* normal text color for racer names */
}

/* Stack race-bottom-panel vertically on small screens */
@media (max-width: 900px) {
  .race-bottom-panel {
    flex-direction: column;
    max-height: none; /* allow it to expand */
  }

  .racer-selection, .results {
    width: 100%;
  }

  .race-track {
    height: 360px; /* slightly smaller for smaller screens */
    padding: 0.5rem;
  }

  .racer {
    width: 50px;
    height: 25px;
  }
}

/* Very small screens (phones) */
@media (max-width: 500px) {
  nav {
    flex-direction: column;
    gap: 0.5rem;
  }

  nav button {
    width: 100%;
    margin-left: 0;
  }

  .race-track {
    height: 360px;
  }

  .racer {
    width: 40px;
    height: 20px;
  }

  .results, .racer-selection {
    padding: 0.5rem;
  }
}

/* Home list spacing on small screens */
@media (max-width: 600px) {
  #home ul {
    margin-left: 1rem;
  }
}

/* Settings form adjusts width */
@media (max-width: 500px) {
  #settings form {
    max-width: 100%;
    padding: 0 1rem;
  }
}