/* ==========================================================================
   ZOMBIE RUNNING RACE — SINGLE SCREEN ROAD & ARCADE STYLES
   ========================================================================== */

:root {
  --lane-player: #00f0ff;
  --lane-bot1: #10b981;
  --lane-bot2: #a855f7;
  --lane-bot3: #ef4444;
  --lane-bot4: #f59e0b;
  --asphalt-dark: #121722;
  --asphalt-mid: #182030;
  --asphalt-light: #222c42;
  --road-curb-red: #ef4444;
  --road-curb-white: #ffffff;
}

/* Full Single-Screen Layout */
body.race-body {
  background: radial-gradient(circle at 50% 20%, #0d1527 0%, #060a12 100%);
  color: var(--text-primary);
  font-family: var(--font-body);
  overflow-x: hidden;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

@media (min-width: 1024px) {
  body.race-body {
    height: 100vh;
    max-height: 100vh;
    overflow-y: hidden; /* Fits in a single desktop screen! */
  }
}

.race-container {
  max-width: 1360px;
  margin: 0 auto;
  padding: 0.4rem 1rem 0.6rem 1rem;
  width: 100%;
  box-sizing: border-box;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.5rem;
}

/* ==========================================================================
   TOP RACE HUD
   ========================================================================== */
.race-top-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: var(--radius-md);
  padding: 0.4rem 1rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
}

.race-hud-left, .race-hud-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.race-hud-center {
  text-align: center;
  flex: 1;
}

.race-level-tag {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 900;
  color: #fff;
  letter-spacing: 0.5px;
  text-shadow: 0 0 12px rgba(0, 240, 255, 0.4);
  line-height: 1.2;
}

.race-level-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.race-btn-stages {
  background: rgba(0, 240, 255, 0.12);
  border: 1px solid var(--cyan);
  color: #fff;
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.race-btn-stages:hover {
  background: var(--cyan);
  color: #000;
  box-shadow: 0 0 12px var(--cyan-glow);
}

/* ==========================================================================
   5-LANE REALISTIC ASPHALT ROAD TRACK
   ========================================================================== */
.race-track-board {
  /* High-Res Asphalt Highway Texture with Road Shoulder */
  background: 
    radial-gradient(ellipse at 50% 50%, rgba(20, 28, 45, 0.4) 0%, rgba(6, 10, 18, 0.9) 100%),
    linear-gradient(180deg, #2b1f14 0%, #151b27 3%, #0f1420 97%, #2b1f14 100%);
  border: 2px solid #334155;
  border-radius: var(--radius-md);
  padding: 0.35rem 0.65rem;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.8), inset 0 0 40px rgba(0, 0, 0, 0.7);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

/* Racing Curb Rumble Strips (Red & White Alternating Stripes) */
.race-track-board::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: repeating-linear-gradient(
    90deg,
    var(--road-curb-red) 0,
    var(--road-curb-red) 16px,
    var(--road-curb-white) 16px,
    var(--road-curb-white) 32px
  );
  z-index: 2;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.race-track-board::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: repeating-linear-gradient(
    90deg,
    var(--road-curb-red) 0,
    var(--road-curb-red) 16px,
    var(--road-curb-white) 16px,
    var(--road-curb-white) 32px
  );
  z-index: 2;
  box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.5);
}

/* Track Header: Road Milestones */
.track-header-bar {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 0 10px 0.25rem 10px;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.15);
  margin-bottom: 0.35rem;
}

.lanes-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  position: relative;
}

/* Checkered Finish Line Bar */
.track-finish-line {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 45px;
  width: 16px;
  background-image: repeating-linear-gradient(
    45deg,
    #fff 0,
    #fff 6px,
    #000 6px,
    #000 12px
  );
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
  border-left: 2px solid #ef4444;
  border-right: 2px solid #ef4444;
  z-index: 2;
  opacity: 0.95;
  border-radius: 2px;
}

.finish-flag-tag {
  position: absolute;
  top: -18px;
  right: 38px;
  font-size: 1rem;
  font-weight: 900;
  filter: drop-shadow(0 0 6px #fff);
}

/* Individual Asphalt Road Lane */
.race-lane {
  background: linear-gradient(90deg, rgba(22, 30, 46, 0.95) 0%, rgba(14, 19, 30, 0.98) 100%);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-bottom: 2px dashed rgba(255, 255, 255, 0.2); /* Dashed Highway Divider */
  border-radius: 4px;
  padding: 0.2rem 0.6rem;
  position: relative;
  height: 38px;
  min-height: 38px;
  display: flex;
  align-items: center;
  box-sizing: border-box;
  transition: all 0.2s ease;
}

.race-lane:last-child {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.race-lane.lane-player {
  background: linear-gradient(90deg, rgba(0, 240, 255, 0.15) 0%, rgba(14, 23, 40, 0.95) 100%);
  border: 1px solid rgba(0, 240, 255, 0.45);
  border-bottom: 2px dashed rgba(0, 240, 255, 0.6);
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.15);
}

.lane-info {
  width: 160px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  z-index: 3;
}

.lane-rank-badge {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 0.72rem;
  width: 20px;
  height: 20px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
}

.rank-1st { background: #eab308; color: #000; box-shadow: 0 0 8px rgba(234, 179, 8, 0.7); }
.rank-2nd { background: #94a3b8; color: #000; }
.rank-3rd { background: #b45309; color: #fff; }

.lane-name-group {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.lane-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.8rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.1;
}

.lane-wpm-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Track Road & Runner Sprite */
.lane-track-road {
  flex: 1;
  position: relative;
  height: 28px;
  margin-left: 0.5rem;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 3px;
  overflow: visible;
}

.lane-progress-strip {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  border-radius: 3px;
  opacity: 0.25;
  transition: width 0.1s linear;
}

.lane-player .lane-progress-strip { background: var(--cyan); opacity: 0.4; }
.lane-bot1 .lane-progress-strip { background: var(--lane-bot1); }
.lane-bot2 .lane-progress-strip { background: var(--lane-bot2); }
.lane-bot3 .lane-progress-strip { background: var(--lane-bot3); }
.lane-bot4 .lane-progress-strip { background: var(--lane-bot4); }

/* Runner Sprite Animation */
.runner-sprite {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  line-height: 1;
  transition: left 0.1s linear;
  z-index: 5;
  filter: drop-shadow(0 0 6px rgba(0, 0, 0, 0.9));
  user-select: none;
}

.runner-sprite.running {
  animation: runnerBob 0.3s infinite alternate ease-in-out;
}

.runner-sprite.turbo-boost {
  filter: drop-shadow(0 0 12px var(--cyan)) drop-shadow(0 0 20px var(--emerald));
  animation: turboShake 0.12s infinite alternate;
}

.runner-dust {
  position: absolute;
  right: 90%;
  top: 55%;
  font-size: 0.75rem;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.runner-sprite.running .runner-dust {
  opacity: 0.8;
  animation: dustPuff 0.35s infinite;
}

@keyframes runnerBob {
  0% { transform: translateY(-50%) translateY(-2px) rotate(-3deg); }
  100% { transform: translateY(-50%) translateY(2px) rotate(4deg); }
}

@keyframes turboShake {
  0% { transform: translateY(-50%) scale(1.15) rotate(-2deg); }
  100% { transform: translateY(-50%) scale(1.25) rotate(3deg); }
}

@keyframes dustPuff {
  0% { transform: translateX(0) scale(0.6); opacity: 0.8; }
  100% { transform: translateX(-12px) scale(1.1); opacity: 0; }
}

/* ==========================================================================
   LIVE RACE TELEMETRY HUD (Compact Strip)
   ========================================================================== */
.race-telemetry-hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  flex-shrink: 0;
}

.telemetry-card {
  background: rgba(13, 20, 36, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.6rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.telemetry-label {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.telemetry-val {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.25rem;
  line-height: 1;
}

/* ==========================================================================
   PARAGRAPH TYPING CONSOLE (Compact Screen-Fit)
   ========================================================================== */
.race-console-card {
  background: rgba(13, 20, 36, 0.95);
  border: 2px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 0.65rem 1rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6), 0 0 25px rgba(0, 240, 255, 0.1);
  position: relative;
  flex-shrink: 0;
}

.race-console-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.race-typing-box {
  background: rgba(8, 12, 22, 0.95);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  height: 80px; /* Clean 2-Line Screen-Fit Window */
  box-sizing: border-box;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 1.25rem;
  line-height: 2rem;
  color: var(--text-muted);
  position: relative;
  cursor: text;
  outline: none;
  transition: border-color var(--transition-fast);
}

.race-typing-box:focus-within, .race-typing-box.focused {
  border-color: var(--cyan);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.25);
}

/* ==========================================================================
   COUNTDOWN OVERLAY
   ========================================================================== */
.race-countdown-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 6000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
}

.race-countdown-overlay.active {
  opacity: 1;
  visibility: visible;
}

.countdown-number {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 5.5rem;
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 35px var(--cyan);
  animation: countdownPop 0.85s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.countdown-sub {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--cyan);
  letter-spacing: 2px;
  margin-top: 0.5rem;
  text-transform: uppercase;
}

@keyframes countdownPop {
  0% { transform: scale(0.4); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ==========================================================================
   LEVEL SELECT MODAL
   ========================================================================== */
.race-level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  max-height: 55vh;
  overflow-y: auto;
  margin-top: 0.75rem;
  padding: 0.25rem;
}

.race-level-card {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.race-level-card:hover:not(.locked) {
  border-color: var(--cyan);
  transform: translateY(-2px);
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.2);
}

.race-level-card.locked {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(0.8);
}

.race-level-card.active-level {
  border-color: var(--cyan);
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.15), rgba(15, 23, 42, 0.9));
}

/* ==========================================================================
   ADVANCED RESPONSIVE DESIGN & BROWSER WINDOW ADAPTABILITY
   ========================================================================== */

/* Laptops & Medium Screens (1024px - 1366px) */
@media (max-width: 1366px) {
  .race-container {
    padding: 0.3rem 0.6rem 0.4rem 0.6rem;
    gap: 0.35rem;
  }
  .race-lane {
    height: 32px;
  }
  .lane-info {
    width: 120px;
  }
  .runner-sprite {
    font-size: 1.3rem;
  }
  .race-telemetry-hud {
    gap: 0.4rem;
  }
  .telemetry-card {
    padding: 0.35rem 0.5rem;
  }
  .telemetry-val {
    font-size: 1.3rem;
  }
  .race-typing-box {
    font-size: 1.25rem;
    line-height: 2rem;
    height: 75px;
  }
}

/* Tablets (768px - 1024px) */
@media (max-width: 1024px) {
  .race-top-hud {
    padding: 0.3rem 0.5rem;
  }
  .race-level-tag {
    font-size: 0.9rem;
  }
  .lane-info {
    width: 105px;
  }
  .lane-name {
    font-size: 0.72rem;
  }
  .lane-wpm-sub {
    font-size: 0.58rem;
  }
  .race-telemetry-hud {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.35rem;
  }
  .telemetry-val {
    font-size: 1.15rem;
  }
  .race-typing-box {
    font-size: 1.15rem;
    line-height: 1.8rem;
    height: 68px;
  }
}

/* Tablets Portrait & Mobile (<= 768px) */
@media (max-width: 768px) {
  .race-top-hud {
    flex-wrap: wrap;
    gap: 0.3rem;
    padding: 0.3rem 0.4rem;
  }
  .race-hud-left, .race-hud-right {
    gap: 0.3rem;
  }
  .race-hud-center {
    order: 3;
    width: 100%;
  }
  .race-level-tag {
    font-size: 0.82rem;
  }
  .race-level-sub {
    font-size: 0.65rem;
  }
  .lane-info {
    width: 85px;
  }
  .lane-name {
    font-size: 0.65rem;
  }
  .lane-wpm-sub {
    display: none;
  }
  .runner-sprite {
    font-size: 1.15rem;
  }
  .track-finish-line {
    right: 25px;
  }
  .finish-flag-tag {
    right: 20px;
    font-size: 0.6rem;
  }
  .race-telemetry-hud {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.3rem;
  }
  .telemetry-card {
    padding: 0.25rem 0.4rem;
  }
  .telemetry-label {
    font-size: 0.58rem;
  }
  .telemetry-val {
    font-size: 1.05rem;
  }
  .race-typing-box {
    font-size: 1rem;
    line-height: 1.6rem;
    height: 60px;
    padding: 0.35rem 0.6rem;
  }
}

/* Small Mobile (< 480px) */
@media (max-width: 479px) {
  .race-container {
    padding: 0.2rem 0.3rem;
  }
  .race-lane {
    height: 28px;
  }
/* HIDE REDUNDANT VIRTUAL KEYBOARD ON MOBILE & TOUCH SCREENS */
@media (max-width: 900px), (pointer: coarse) {
  .tp-keyboard-wrapper,
  #visualKeyboardContainer,
  .virtual-keyboard {
    display: none !important;
  }
}
