/* =============================================
   NEON DRIFT — Retro-Futuristic Racing Game CSS
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Share+Tech+Mono&display=swap');

/* ---- CSS Variables ---- */
:root {
  --neon-cyan:   #00f5ff;
  --neon-pink:   #ff006e;
  --neon-yellow: #ffe600;
  --neon-green:  #39ff14;
  --dark-bg:     #06080f;
  --dark-mid:    #0d1120;
  --dark-card:   #111827;
  --grid-line:   rgba(0,245,255,0.08);
  --text-dim:    rgba(255,255,255,0.45);
  --font-display: 'Orbitron', sans-serif;
  --font-mono:    'Share Tech Mono', monospace;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--dark-bg);
  color: #fff;
  font-family: var(--font-mono);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* ---- Screens ---- */
.screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.4s ease;
  overflow: hidden;
}
.screen.active {
  opacity: 1; pointer-events: all;
}

/* ---- Background grid ---- */
.select-bg {
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, #06080f 0%, #0a0e1a 50%, #06080f 100%);
  z-index: 0;
}
.select-bg::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 40px 40px;
  animation: gridScroll 6s linear infinite;
}
.select-bg::after {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 80% 50% at 50% 60%,
    rgba(0,245,255,0.07) 0%, transparent 70%);
}
@keyframes gridScroll {
  0%   { background-position: 0 0; }
  100% { background-position: 0 40px; }
}

/* ---- Scanlines overlay ---- */
.scanlines {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.15) 2px,
    rgba(0,0,0,0.15) 4px
  );
}

/* =============================================
   SELECT SCREEN
   ============================================= */
#screen-select {
  gap: 24px;
  padding: 24px 16px;
}
#screen-select > * { position: relative; z-index: 2; }

.title-block {
  text-align: center;
  margin-bottom: 4px;
}
.title-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.35em;
  color: var(--neon-cyan);
  margin-bottom: 8px;
  opacity: 0.8;
}
.game-title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(52px, 12vw, 100px);
  line-height: 0.9;
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, var(--neon-cyan) 0%, #fff 40%, var(--neon-pink) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 20px rgba(0,245,255,0.4));
  animation: titlePulse 3s ease-in-out infinite;
}
@keyframes titlePulse {
  0%,100% { filter: drop-shadow(0 0 20px rgba(0,245,255,0.4)); }
  50%      { filter: drop-shadow(0 0 40px rgba(0,245,255,0.7)); }
}
.title-sub {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.28em;
  color: var(--text-dim);
  margin-top: 10px;
}

/* ---- Car Cards ---- */
.car-cards {
  display: flex;
  gap: 14px;
  flex-wrap: nowrap;
  justify-content: center;
  width: 100%;
  max-width: 780px;
  padding: 0 8px;
}

.car-card {
  flex: 1;
  min-width: 0;
  max-width: 180px;
  background: var(--dark-card);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 12px;
  padding: 16px 12px 14px;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  position: relative;
  overflow: hidden;
}
.car-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--card-accent, var(--neon-cyan));
  opacity: 0;
  transition: opacity 0.2s;
}
.car-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255,255,255,0.18);
}
.car-card.selected {
  border-color: var(--card-accent, var(--neon-cyan));
  box-shadow: 0 0 24px rgba(0,245,255,0.25), inset 0 0 30px rgba(0,245,255,0.04);
}
.car-card.selected::before { opacity: 1; }

.car-canvas-wrap {
  width: 80px; height: 80px;
  display: flex; align-items: center; justify-content: center;
}
.car-preview {
  width: 80px; height: 80px;
  display: block;
}

.car-name {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #fff;
  text-align: center;
}
.car-stats {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.stat-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}
.stat-label { width: 38px; flex-shrink: 0; }
.stat-bar {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
}
.stat-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--card-accent, var(--neon-cyan));
  transition: width 0.4s cubic-bezier(0.4,0,0.2,1);
}

/* ---- Start Button ---- */
.btn-start {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--dark-bg);
  background: var(--neon-cyan);
  border: none;
  border-radius: 8px;
  padding: 14px 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.2s, box-shadow 0.2s, transform 0.15s, opacity 0.2s;
  box-shadow: 0 0 20px rgba(0,245,255,0.4);
  position: relative;
  overflow: hidden;
}
.btn-start:disabled {
  opacity: 0.35;
  cursor: default;
  box-shadow: none;
}
.btn-start:not(:disabled):hover {
  background: #fff;
  box-shadow: 0 0 36px rgba(0,245,255,0.6);
  transform: scale(1.03);
}
.btn-start:not(:disabled):active { transform: scale(0.97); }

.btn-secondary {
  background: transparent;
  color: var(--neon-cyan);
  border: 1.5px solid var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0,245,255,0.2);
}
.btn-secondary:not(:disabled):hover {
  background: rgba(0,245,255,0.1);
}

.btn-arrow { font-size: 16px; }

.select-hint {
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--text-dim);
  opacity: 0.6;
}

/* =============================================
   GAME SCREEN
   ============================================= */
#screen-game {
  padding: 0;
  justify-content: flex-start;
}

/* ---- HUD ---- */
.hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  align-items: flex-end;
  padding: 10px 16px;
  background: linear-gradient(180deg, rgba(6,8,15,0.9) 0%, transparent 100%);
  gap: 8px;
}
.hud-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.hud-center { flex: 1; align-items: center; }
.hud-right  { align-items: flex-end; }

.hud-label {
  font-size: 9px;
  letter-spacing: 0.2em;
  color: var(--text-dim);
}
.hud-value {
  font-family: var(--font-display);
  font-size: clamp(18px, 4vw, 26px);
  font-weight: 700;
  color: var(--neon-cyan);
  text-shadow: 0 0 10px var(--neon-cyan);
  line-height: 1;
}
.hud-unit {
  font-size: 8px;
  letter-spacing: 0.2em;
  color: var(--text-dim);
}

/* ---- Canvas ---- */
#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---- Touch Controls ---- */
.touch-controls {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 24px;
  background: linear-gradient(0deg, rgba(6,8,15,0.85) 0%, transparent 100%);
  gap: 12px;
}

.touch-btn {
  width: 72px; height: 72px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,245,255,0.3);
  background: rgba(0,245,255,0.07);
  color: var(--neon-cyan);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  flex-shrink: 0;
}
.touch-btn svg {
  width: 28px; height: 28px;
  stroke: currentColor; stroke-width: 2.5;
  fill: none; stroke-linecap: round; stroke-linejoin: round;
}
.touch-btn:active, .touch-btn.pressed {
  background: rgba(0,245,255,0.22);
  border-color: var(--neon-cyan);
  transform: scale(0.94);
}

.touch-center { flex: 1; display: flex; justify-content: center; }

.touch-boost {
  width: 90px; height: 56px;
  border-radius: 28px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.15em;
  border-color: rgba(255,230,0,0.35);
  background: rgba(255,230,0,0.07);
  color: var(--neon-yellow);
}
.touch-boost:active, .touch-boost.pressed {
  background: rgba(255,230,0,0.22);
  border-color: var(--neon-yellow);
}

/* =============================================
   GAME OVER SCREEN
   ============================================= */
#screen-over {
  gap: 0;
  padding: 24px;
}
#screen-over > * { position: relative; z-index: 2; }

.over-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  z-index: 2;
}
.over-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.35em;
  color: var(--neon-pink);
  opacity: 0.8;
}
.over-title {
  font-family: var(--font-display);
  font-size: clamp(56px, 14vw, 112px);
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, var(--neon-pink) 0%, #ff6bb5 60%, #fff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 24px rgba(255,0,110,0.5));
}
.over-score-block {
  text-align: center;
}
.over-label {
  font-size: 10px;
  letter-spacing: 0.25em;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.over-score {
  font-family: var(--font-display);
  font-size: 48px;
  font-weight: 900;
  color: var(--neon-cyan);
  text-shadow: 0 0 16px var(--neon-cyan);
}
.over-best {
  font-size: 28px;
  color: var(--neon-yellow);
  text-shadow: 0 0 12px var(--neon-yellow);
}
.over-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 480px) {
  .car-cards {
    gap: 10px;
  }
  .car-card {
    max-width: 140px;
    padding: 12px 10px;
  }
  .car-preview {
    width: 64px; height: 64px;
  }
  .car-canvas-wrap {
    width: 64px; height: 64px;
  }
  .car-name { font-size: 10px; }
  .game-title { font-size: clamp(44px, 16vw, 72px); }
  .touch-btn { width: 64px; height: 64px; }
  .touch-boost { width: 80px; height: 50px; }
}

@media (max-width: 360px) {
  .car-cards { flex-wrap: wrap; }
  .car-card { min-width: 140px; max-width: 160px; }
}

/* Hide touch controls on desktop if mouse detected */
@media (hover: hover) and (pointer: fine) {
  .touch-controls { display: none !important; }
}

/* =============================================
   UTILITY
   ============================================= */
.flash {
  animation: flashAnim 0.3s ease;
}
@keyframes flashAnim {
  0%   { opacity: 1; }
  50%  { opacity: 0.2; }
  100% { opacity: 1; }
}

/* ── Friends Edition Extra Styles ── */
.car-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  margin-bottom: -6px;
  opacity: 0.9;
}
.car-desc {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  text-align: center;
  letter-spacing: 0.05em;
  line-height: 1.3;
}
.car-canvas-wrap {
  width: 100px !important;
  height: 100px !important;
}
.car-preview {
  width: 100px !important;
  height: 100px !important;
  border-radius: 50%;
  background: rgba(255,255,255,0.03);
}
