/* ============================================================
   ConceptTyping — Games CSS (Falling Words + Robot Race)
   ============================================================ */

/* ─── Game Config Modal ─────────────────────────────────────────────────── */
.game-config-overlay {
  position: fixed; inset: 0; z-index: 1050;
  background: rgba(0,0,0,0.8); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}
.game-config-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  width: 100%; max-width: 540px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateY(30px); opacity:0; } to { transform: translateY(0); opacity:1; } }

/* ─── FALLING WORDS ─────────────────────────────────────────────────────── */
#falling-game {
  position: relative;
  width: 100%; height: 100vh;
  min-height: 600px;
  overflow: hidden;
  background: var(--bg-primary);
  cursor: text;
  display: none;
}
#falling-game.active { display: block; }

/* Game canvas background grid */
#falling-game::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 60px 60px;
  opacity: 0.3; pointer-events: none;
}

/* Falling Words HUD */
.fw-hud {
  position: absolute; top: 0; left: 0; right: 0;
  background: rgba(15,15,17,0.95);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
  z-index: 10;
  backdrop-filter: blur(10px);
}
.fw-hud .hud-stat { text-align: center; }
.fw-hud .hud-stat .v { font-size: 1.3rem; font-weight: 800; font-family: var(--font-mono); display: block; }
.fw-hud .hud-stat .l { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; display: block; }
.fw-hud .hud-sep { width: 1px; height: 36px; background: var(--border); }
.hud-lives { display: flex; gap: 0.25rem; align-items: center; }
.life-icon { font-size: 1.2rem; transition: transform 0.2s, opacity 0.2s; }
.life-icon.lost { opacity: 0.2; transform: scale(0.8); }

.fw-hud-right { margin-left: auto; display: flex; gap: 0.75rem; align-items: center; }
.hud-btn {
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-secondary); padding: 0.4rem 0.75rem;
  border-radius: var(--radius-md); cursor: pointer; font-size: 0.82rem;
  transition: all var(--transition);
}
.hud-btn:hover { color: var(--text-primary); border-color: var(--border-hover); }

/* Falling words */
.falling-word {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  padding: 0.4rem 0.9rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  white-space: nowrap;
  user-select: none;
  cursor: default;
  transition: border-color 0.15s, background 0.15s;
  will-change: transform;
  box-shadow: var(--shadow-sm);
}
.falling-word.target    { border-color: var(--blue);  background: var(--blue-glow);  color: var(--blue-light); }
.falling-word.matched   { border-color: var(--green); background: var(--green-glow); color: var(--green); }
.falling-word.danger    { border-color: var(--red);   background: var(--red-glow);   color: var(--red); animation: wordShake 0.3s ease; }
.falling-word.destroyed {
  animation: wordDestroy 0.3s ease forwards;
}
@keyframes wordShake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes wordDestroy {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
  100% { transform: scale(0.1); opacity: 0; }
}

/* Danger zone */
.danger-zone {
  position: absolute; bottom: 120px; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--red), transparent);
  animation: dangerPulse 1.5s ease infinite;
  z-index: 5;
}
@keyframes dangerPulse { 0%,100% { opacity:0.4; } 50% { opacity:1; } }
.danger-label {
  position: absolute; bottom: 126px; right: 1rem;
  font-size: 0.65rem; color: var(--red); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
}

/* Input area */
.fw-input-area {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 1rem 1.5rem;
  background: rgba(15,15,17,0.95);
  border-top: 1px solid var(--border);
  display: flex; gap: 0.75rem;
  z-index: 10;
}
#fw-input {
  flex: 1;
  background: var(--bg-card) !important;
  border: 2px solid var(--border) !important;
  border-radius: var(--radius-md) !important;
  color: var(--text-primary) !important;
  font-family: var(--font-mono) !important;
  font-size: 1.1rem !important;
  padding: 0.7rem 1rem !important;
  transition: border-color var(--transition) !important;
}
#fw-input:focus { border-color: var(--blue) !important; }
#fw-input.has-match { border-color: var(--green) !important; }
#fw-input.no-match  { border-color: var(--red) !important; }

/* Particle effects */
.particle {
  position: absolute; pointer-events: none;
  width: 6px; height: 6px;
  border-radius: 50%;
  animation: particleFly var(--duration, 0.6s) ease forwards;
}
@keyframes particleFly {
  0%   { transform: translate(0,0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0); opacity: 0; }
}

/* Combo display */
.combo-display {
  position: absolute; top: 70px; right: 1.5rem;
  font-family: var(--font-mono); font-size: 2rem; font-weight: 900;
  color: var(--yellow);
  text-shadow: 0 0 20px rgba(255,211,42,0.5);
  animation: comboPop 0.3s ease;
  pointer-events: none; z-index: 6;
}
@keyframes comboPop { 0% { transform: scale(0.5); } 60% { transform: scale(1.2); } 100% { transform: scale(1); } }

/* Score popup */
.score-popup {
  position: absolute; pointer-events: none;
  font-family: var(--font-mono); font-weight: 800; font-size: 1.1rem;
  color: var(--green);
  animation: scoreFloat 0.8s ease forwards; z-index: 7;
}
@keyframes scoreFloat {
  0%   { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(-50px); opacity: 0; }
}

/* Pause overlay */
.game-pause-overlay, .game-over-overlay {
  position: absolute; inset: 0; z-index: 20;
  background: rgba(0,0,0,0.85); backdrop-filter: blur(8px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1rem; text-align: center;
}
.game-over-overlay .title { font-size: 3rem; font-weight: 900; color: var(--red); margin-bottom: 0.5rem; }
.game-over-overlay .subtitle { color: var(--text-secondary); font-size: 1.1rem; }

/* ─── ROBOT RACE ─────────────────────────────────────────────────────────── */
#robot-race {
  display: none; padding: 0 0 3rem;
}
#robot-race.active { display: block; animation: fadeInUp 0.3s ease; }

.race-track-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.race-track-header {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex; justify-content: space-between; align-items: center;
}
.race-timer {
  font-size: 1.5rem; font-weight: 800; font-family: var(--font-mono);
  color: var(--orange);
}

/* Race lanes */
.race-track { padding: 2rem 1.5rem; }
.race-lane {
  display: flex; align-items: center; gap: 1rem;
  margin-bottom: 2rem;
  position: relative;
}
.lane-label {
  width: 80px; flex-shrink: 0;
  font-weight: 700; font-size: 0.9rem; color: var(--text-secondary);
  text-align: right;
}
.lane-road {
  flex: 1; height: 60px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 30px;
  position: relative; overflow: hidden;
}

/* Road markings */
.lane-road::before {
  content: '';
  position: absolute; top: 50%; left: 0; right: 0;
  height: 2px; transform: translateY(-50%);
  background: repeating-linear-gradient(90deg, var(--border) 0 15px, transparent 15px 30px);
}

/* Finish line */
.finish-line {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: 8px;
  background: repeating-linear-gradient(0deg, #fff 0 8px, #000 8px 16px);
  opacity: 0.3;
}

/* Vehicles */
.vehicle {
  position: absolute; top: 50%; transform: translateY(-50%);
  font-size: 2rem; transition: left 0.3s ease;
  filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.5));
  z-index: 2;
  line-height: 1;
}
.vehicle.user-car { animation: carBounce 0.5s ease infinite alternate; }
.vehicle.robot-car { animation: robotFloat 1s ease infinite alternate; }
@keyframes carBounce    { from { transform: translateY(-50%) rotate(-1deg); } to { transform: translateY(-54%) rotate(1deg); } }
@keyframes robotFloat   { from { transform: translateY(-50%); } to { transform: translateY(-56%); } }

/* Progress bars */
.race-lane .progress-row {
  width: 50px; flex-shrink: 0;
  text-align: center;
  font-size: 0.8rem; font-family: var(--font-mono); font-weight: 700;
  color: var(--text-secondary);
}

/* Win/Loss/Draw Banner */
.race-result-banner {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.9); backdrop-filter: blur(8px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 1.5rem;
  animation: fadeIn 0.4s ease;
}
.banner-result { font-size: 5rem; font-weight: 900; line-height: 1; }
.result-win  .banner-result { color: var(--green); text-shadow: 0 0 40px rgba(57,211,83,0.5); }
.result-loss .banner-result { color: var(--red);   text-shadow: 0 0 40px rgba(232,85,85,0.5); }
.result-draw .banner-result { color: var(--yellow); }

/* Race word display */
.race-word-area {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2rem;
  text-align: center;
  margin-bottom: 1.5rem;
}
.race-current-word {
  font-family: var(--font-mono);
  font-size: 2.5rem; font-weight: 800;
  letter-spacing: 0.1em;
  margin-bottom: 1rem;
  display: flex; justify-content: center; flex-wrap: wrap; gap: 2px;
}
.race-char.correct  { color: var(--green); }
.race-char.error    { color: var(--red); background: var(--red-glow); padding: 0 2px; border-radius: 2px; }
.race-char.upcoming { color: var(--text-disabled); }
.race-char.cursor   { color: var(--orange); border-bottom: 3px solid var(--orange); padding-bottom: 2px; }

#race-input {
  max-width: 400px; margin: 0 auto; display: block;
  background: var(--bg-elevated) !important;
  border: 2px solid var(--border) !important;
  border-radius: var(--radius-md) !important;
  color: var(--text-primary) !important;
  font-family: var(--font-mono) !important;
  font-size: 1.3rem !important; text-align: center !important;
  padding: 0.75rem !important;
}
#race-input:focus { border-color: var(--blue) !important; }
#race-input.correct { border-color: var(--green) !important; background: var(--green-glow) !important; }
#race-input.error   { border-color: var(--red) !important; animation: inputShake 0.3s ease; }
@keyframes inputShake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* Race stats */
.race-stats {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 1rem;
}
.race-stat {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 0.9rem; text-align: center;
}
.race-stat .rv { font-size: 1.4rem; font-weight: 800; font-family: var(--font-mono); display: block; }
.race-stat .rl { font-size: 0.68rem; color: var(--text-muted); text-transform: uppercase; }

/* Dashboard CSS */
.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.chart-container canvas { max-height: 280px; }

/* Admin table */
.admin-sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  min-height: 100vh; padding: 1.5rem 1rem;
}
.admin-nav-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.65rem 1rem; border-radius: var(--radius-md);
  color: var(--text-muted); font-size: 0.9rem; font-weight: 500;
  transition: all var(--transition); text-decoration: none; margin-bottom: 0.25rem;
}
.admin-nav-item:hover, .admin-nav-item.active {
  background: var(--bg-elevated); color: var(--text-primary);
}
.admin-nav-item.active { color: var(--blue); }
