@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;
}

/* ========= GAME TAB ========= */
.game-wrapper {
  display: grid;
  grid-template-rows: 1fr auto;
  /* top = canvas, bottom = bar */
  width: 100%;
  max-width: 1000px;
  /* optional max width */
  height: 79vh;
  /* responsive height relative to viewport */
  border: 2px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--color-background);
  margin: 0 auto;
  /* center horizontally */
}

/* Canvas fills the top row */
#game-canvas {
  width: 100%;
  height: 100%;
  background: var(--color-background);
  display: block;
}

/* Bottom bar fixed-height */
.game-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 1rem;
  background: var(--color-surface);
  border-top: 2px solid var(--color-border);
  flex-shrink: 0;
}

/* HUD styling */
.game-bar .hud span {
  margin-right: 1rem;
  font-weight: bold;
  color: var(--color-text);
}

/* Start button */
#start-game-btn {
  background: var(--color-accent-2);
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  color: var(--color-background);
  font-weight: bold;
  cursor: pointer;
  transition: 0.2s;
}

#start-game-btn:hover {
  background: var(--color-accent-1);
  color: var(--color-text);
}

/* ========= 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);
}

/* ========= FOOTER ========= */
footer {
  background: var(--color-surface);
  text-align: center;
  padding: 1rem;
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
}

/* Stack race-bottom-panel vertically on small screens */
@media (max-width: 900px) {
  .game-wrapper {
    height: 70vh;
  }

  .game-bar {
    flex-direction: column;
    gap: 0.5rem;
  }

  #start-game-btn {
    width: 100%;
  }
}

/* Very small screens (phones) */
@media (max-width: 500px) {
  nav {
    flex-direction: column;
    gap: 0.5rem;
  }

  nav button {
    width: 100%;
    margin-left: 0;
  }

  .game-wrapper {
    height: 60vh;
  }

  .game-bar {
    font-size: 0.9rem;
  }
}

/* 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;
  }
}