/* ------------------------------------------------------------------
   Time-Attack Grid Racer – Zen Aesthetic + Dynamic Grids + Level UI
------------------------------------------------------------------ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #f9f7f5;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: #2c2c2c;
  line-height: 1.5;
  padding: 2rem 1rem;
  min-height: 100vh;
  background-image: radial-gradient(circle at 10% 20%, rgba(138, 154, 123, 0.03) 2%, transparent 2.5%);
  background-size: 28px 28px;
}

.app-wrapper {
  max-width: 1200px;
  margin: 0 auto;
}

/* Cards */
.card {
  background: #ffffff;
  border-radius: 2rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.02), 0 2px 6px rgba(0, 0, 0, 0.05);
  padding: 1.75rem;
}

/* Auth Section */
.auth-section {
  max-width: 480px;
  margin: 2rem auto;
  text-align: center;
}
.auth-section h2 {
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}
.auth-form input {
  background: #f0eeea;
  border: none;
  padding: 0.85rem 1.25rem;
  border-radius: 3rem;
  font-size: 1rem;
}
.auth-form input:focus {
  outline: none;
  background: #e8e5e0;
  box-shadow: 0 0 0 3px rgba(138, 154, 123, 0.3);
}
.btn {
  border: none;
  background: #8a9a7b;
  color: white;
  font-weight: 600;
  padding: 0.75rem 1.75rem;
  border-radius: 3rem;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn:hover {
  background: #6f7f60;
  transform: scale(0.98);
}
.btn.primary { background: #8a9a7b; }
.btn.secondary { background: #b8c4aa; }
.start-btn { background: #8a9a7b; font-size: 1.1rem; }
.logout-btn { background: #d4cfc5; color: #3a3a3a; }
.logout-btn:hover { background: #bfb9ae; }

/* Game Header (timer/score) */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: white;
  border-radius: 2rem;
  padding: 1rem 2rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.timer-box, .score-box, .correct-wrong-box {
  text-align: center;
}
.label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #8a9a7b;
  font-weight: 600;
}
.timer-value {
  font-size: 3.5rem;
  font-weight: 700;
  font-family: monospace;
  color: #8a9a7b;
  line-height: 1;
}
.score-value {
  font-size: 2.5rem;
  font-weight: 700;
}
.correct { color: #6b8c5c; }
.wrong { color: #c9a87b; }

/* Control Bar */
.game-control-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: white;
  border-radius: 2rem;
  padding: 1rem 2rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.control-group {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  background: #f9f7f5;
  padding: 0.5rem 1.2rem;
  border-radius: 2rem;
}
.control-group select, .control-group button {
  margin: 0;
}
.target-large {
  text-align: center;
  background: #f9f7f5;
  padding: 0.5rem 2rem;
  border-radius: 3rem;
  min-width: 180px;
}
.target-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: #8a9a7b;
  display: block;
}
.target-number-large {
  font-size: 3.5rem;
  font-weight: 800;
  color: #8a9a7b;
  font-family: monospace;
  line-height: 1;
}
.context-note {
  font-size: 0.7rem;
  color: #8a9a7b;
  display: block;
  margin-top: 0.25rem;
}

/* Dynamic Grid */
.grid-wrapper {
  display: flex;
  justify-content: center;
  margin: 1.5rem 0;
}
.dynamic-grid {
  display: grid;
  gap: 1rem;
  justify-content: center;
  width: 100%;
}
.grid-size-2 { grid-template-columns: repeat(2, 1fr); max-width: 300px; }
.grid-size-3 { grid-template-columns: repeat(3, 1fr); max-width: 500px; }
.grid-size-4 { grid-template-columns: repeat(4, 1fr); max-width: 600px; }
.grid-size-5 { grid-template-columns: repeat(5, 1fr); max-width: 700px; }
.grid-size-6 { grid-template-columns: repeat(6, 1fr); max-width: 800px; }

.grid-btn {
  background: white;
  border: none;
  padding: 1.2rem 0.5rem;
  border-radius: 1rem;
  font-size: 1.2rem;
  font-weight: 600;
  font-family: monospace;
  box-shadow: 0 4px 8px rgba(0,0,0,0.05);
  transition: transform 0.1s, box-shadow 0.2s;
  cursor: pointer;
}
.grid-btn:hover {
  transform: scale(1.02);
  background: #fefcf9;
  box-shadow: 0 8px 16px rgba(0,0,0,0.1);
}

/* Feedback */
.feedback-message {
  text-align: center;
  font-style: italic;
  font-size: 0.9rem;
  color: #8a9a7b;
  min-height: 2rem;
  margin-bottom: 1rem;
}
.feedback-message.correct { color: #6b8c5c; }
.feedback-message.wrong { color: #c9a87b; }
.feedback-message.error { color: #d9534f; }

/* Stats & Leaderboard */
.stats-leaderboard {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 2rem;
}
.personal-best, .leaderboard, .game-history {
  background: white;
  border-radius: 1.5rem;
  padding: 1.5rem;
}
.personal-best h3, .leaderboard h3, .game-history h3 {
  font-weight: 600;
  margin-bottom: 1rem;
  border-left: 4px solid #8a9a7b;
  padding-left: 0.75rem;
}
.pb-value {
  font-size: 3rem;
  font-weight: 800;
  color: #8a9a7b;
  text-align: center;
}
.leaderboard-list, .history-list {
  list-style: none;
}
.leaderboard-list li, .history-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid #ece7e0;
  display: flex;
  justify-content: space-between;
}

/* Responsive */
@media (max-width: 860px) {
  .game-control-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .control-group, .target-large {
    justify-content: center;
  }
  .stats-leaderboard {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 640px) {
  .grid-btn { font-size: 1rem; padding: 0.8rem 0.3rem; }
  .timer-value { font-size: 2.5rem; }
  .target-number-large { font-size: 2.5rem; }
}