/* ==========================================================================
   Fly Reflex Racer - F1 Telemetry & Connectome Theme
   ========================================================================== */

:root {
  --bg-primary: #080c14;
  --bg-surface: rgba(16, 24, 39, 0.75);
  --bg-card: rgba(23, 32, 54, 0.6);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(239, 68, 68, 0.4);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --f1-red: #ef4444;
  --f1-red-glow: rgba(239, 68, 68, 0.65);
  --f1-green: #10b981;
  --f1-green-glow: rgba(16, 185, 129, 0.65);
  --f1-yellow: #f59e0b;
  --f1-cyan: #06b6d4;
  --f1-cyan-glow: rgba(6, 182, 212, 0.4);

  --font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(circle at 50% 0%, rgba(239, 68, 68, 0.08) 0%, transparent 60%),
    radial-gradient(circle at 100% 100%, rgba(6, 182, 212, 0.05) 0%, transparent 50%),
    linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 32px 32px, 32px 32px;
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

/* Header */
.header-bar {
  width: 100%;
  max-width: 1200px;
  padding: 1.5rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-badge {
  background: linear-gradient(135deg, var(--f1-red), #991b1b);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
}

.brand-name {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #fff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
}

.btn-secondary:hover {
  color: var(--text-primary);
  border-color: var(--border-focus);
}

/* Main Container */
.main-layout {
  width: 100%;
  max-width: 1200px;
  padding: 2rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

/* Gantry Section */
.gantry-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  backdrop-filter: blur(16px);
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.5);
  width: 100%;
}

.gantry-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.gantry-title-tag {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0;
}

/* F1 Start Lights Gantry - Horizontal Line of 5 Vertical Pods */
.f1-gantry {
  display: flex;
  flex-direction: row; /* The 5 pods are aligned in a horizontal line */
  justify-content: center;
  align-items: center;
  gap: 1.25rem;
  background: #020617;
  padding: 1rem 1.75rem;
  border-radius: 12px;
  border: 2px solid #1e293b;
  box-shadow: inset 0 4px 14px rgba(0,0,0,0.8), 0 8px 24px rgba(0,0,0,0.4);
}

.light-pod {
  display: flex;
  flex-direction: column; /* The bulbs inside each pod are arranged vertically */
  gap: 0.65rem;
  background: #0f172a;
  padding: 0.6rem;
  border-radius: 8px;
  border: 1px solid #334155;
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.5);
}

.light-bulb {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #1e293b;
  border: 2px solid #0f172a;
  transition: all 0.05s ease;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.6);
}

/* Red Active Light */
.light-bulb.active-red {
  background: var(--f1-red);
  box-shadow: 0 0 24px var(--f1-red-glow), 0 0 8px #ff6b6b;
  border-color: #fca5a5;
}

/* Green Active Light (Lights Out Trigger Flash) */
.light-bulb.active-green {
  background: var(--f1-green);
  box-shadow: 0 0 30px var(--f1-green-glow), 0 0 10px #6ee7b7;
  border-color: #a7f3d0;
}

/* Visual Looming Canvas Overlay */
.loom-container {
  margin-top: 0.75rem;
  width: 100%;
  max-width: 400px;
  height: 60px;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

#loomCanvas {
  width: 100%;
  height: 100%;
  border-radius: 8px;
}

/* Live Dynamic Status Banner */
.status-display {
  margin-top: 0.6rem;
  text-align: center;
  min-height: 48px;
}

.status-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.status-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
}

.state-idle .status-title { color: var(--text-primary); }
.state-countdown .status-title { color: var(--f1-yellow); }
.state-active .status-title { color: var(--f1-green); }
.state-false-start .status-title { color: var(--f1-red); }
.state-result-win .status-title { color: var(--f1-green); }
.state-result-loss .status-title { color: var(--f1-red); }

/* Big Action Trigger Button - Highly Visible Hero CTA */
.action-trigger-box {
  margin-top: 1.25rem;
  width: 100%;
  max-width: 460px;
}

.btn-trigger {
  width: 100%;
  padding: 1.15rem 1.5rem;
  font-family: var(--font-family);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #fff;
  background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 10px 25px -5px rgba(239, 68, 68, 0.6), 0 0 24px rgba(239, 68, 68, 0.35);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  user-select: none;
  animation: pulseStartGlow 2.5s infinite ease-in-out;
}

@keyframes pulseStartGlow {
  0%, 100% {
    box-shadow: 0 10px 25px -5px rgba(239, 68, 68, 0.6), 0 0 20px rgba(239, 68, 68, 0.35);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 14px 35px -3px rgba(239, 68, 68, 0.85), 0 0 35px rgba(239, 68, 68, 0.6);
    transform: scale(1.02);
  }
}

.btn-trigger:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 16px 36px -4px rgba(239, 68, 68, 0.85), 0 0 35px rgba(239, 68, 68, 0.6);
}

.btn-trigger:active {
  transform: translateY(1px) scale(0.99);
  box-shadow: 0 6px 15px -3px rgba(239, 68, 68, 0.5);
}

.btn-trigger-hint {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  opacity: 0.85;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Dynamic Trigger State Styles */
.state-countdown .btn-trigger {
  background: linear-gradient(135deg, #f59e0b 0%, #b45309 100%);
  border-color: rgba(245, 158, 11, 0.5);
  box-shadow: 0 10px 25px -5px rgba(245, 158, 11, 0.6), 0 0 25px rgba(245, 158, 11, 0.4);
  animation: none;
}

.state-active .btn-trigger {
  background: linear-gradient(135deg, #10b981 0%, #047857 100%);
  border-color: rgba(16, 185, 129, 0.8);
  box-shadow: 0 0 40px rgba(16, 185, 129, 0.9), 0 0 20px #a7f3d0;
  animation: flashTriggerActive 0.4s infinite alternate;
}

@keyframes flashTriggerActive {
  from { transform: scale(1.01); filter: brightness(1); }
  to { transform: scale(1.04); filter: brightness(1.2); }
}

.state-false-start .btn-trigger {
  background: linear-gradient(135deg, #ef4444 0%, #7f1d1d 100%);
  animation: none;
}

.state-result-win .btn-trigger,
.state-result-loss .btn-trigger {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  border-color: rgba(56, 189, 248, 0.5);
  box-shadow: 0 10px 25px -5px rgba(2, 132, 199, 0.6), 0 0 25px rgba(56, 189, 248, 0.35);
  animation: pulseStartGlow 2.5s infinite ease-in-out;
}

/* Live Neural Signal Flow Pathway (Full Width Telemetry Card) */
.neural-visualizer-container {
  margin-top: 1.5rem;
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid rgba(6, 182, 212, 0.25);
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6), 0 8px 24px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(16px);
}

.neural-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.neural-badge {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  background: rgba(6, 182, 212, 0.2);
  color: var(--f1-cyan);
  border: 1px solid rgba(6, 182, 212, 0.4);
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
}

.neural-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.neural-canvas {
  width: 100%;
  height: 140px;
  display: block;
}

/* Telemetry Dashboard Grid */
.telemetry-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 768px) {
  .telemetry-grid {
    grid-template-columns: 1fr;
  }
}

.telemetry-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 1.75rem;
  backdrop-filter: blur(16px);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

/* Telemetry Numbers */
.metric-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1rem;
}

.metric-value-huge {
  font-family: var(--font-mono);
  font-size: 3rem;
  font-weight: 800;
  line-height: 1;
}

.metric-unit {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-muted);
}

.color-player { color: var(--f1-cyan); }
.color-fly { color: var(--f1-red); }
.color-green { color: var(--f1-green); }

/* Detailed Breakdown Tree */
.synaptic-breakdown {
  margin-top: 1.25rem;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  padding: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.breakdown-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  padding: 0.4rem 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
}

.breakdown-row:last-child {
  border-bottom: none;
  font-weight: 700;
  color: var(--text-primary);
}

.breakdown-label {
  color: var(--text-secondary);
}

.breakdown-val {
  font-family: var(--font-mono);
  font-weight: 600;
}

/* Difficulty & Settings Bar */
.settings-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 1rem 1.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.settings-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.difficulty-tabs {
  display: flex;
  gap: 0.5rem;
}

.tab-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn.active {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--f1-red);
  color: #fff;
}

/* History Table */
.history-section {
  margin-top: 1.5rem;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.history-table th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-subtle);
}

.history-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

/* Scientific Info Modal - Glassmorphic HUD */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(2, 6, 23, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: none;
  justify-content: center;
  align-items: center;
  padding: 1.5rem;
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.modal-overlay.open {
  display: flex;
  opacity: 1;
}

.modal-card {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.9));
  border: 1px solid rgba(6, 182, 212, 0.35);
  border-radius: 20px;
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 2rem 2.25rem;
  box-shadow: 0 25px 60px -10px rgba(0, 0, 0, 0.8), 0 0 35px rgba(6, 182, 212, 0.2);
  animation: modalPopIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPopIn {
  from {
    transform: scale(0.92) translateY(15px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-close {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1;
}

.btn-close:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: var(--f1-red);
  color: #fff;
  transform: rotate(90deg);
}

.modal-body p {
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.65;
  margin-bottom: 1.1rem;
}

.modal-callout {
  background: rgba(6, 182, 212, 0.08);
  border-left: 4px solid var(--f1-cyan);
  padding: 1.1rem 1.25rem;
  border-radius: 0 10px 10px 0;
  margin: 1.25rem 0;
  border-top: 1px solid rgba(6, 182, 212, 0.15);
  border-right: 1px solid rgba(6, 182, 212, 0.15);
  border-bottom: 1px solid rgba(6, 182, 212, 0.15);
}

.modal-callout-title {
  font-weight: 800;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--f1-cyan);
  margin-bottom: 0.4rem;
}

/* ==========================================================================
   2.0 Grand Prix Dual Cockpit & Debris Evasion Styles
   ========================================================================== */

.dual-cockpit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  width: 100%;
}

@media (max-width: 860px) {
  .dual-cockpit-grid {
    grid-template-columns: 1fr;
  }
}

.cockpit-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(16px);
  box-shadow: 0 16px 32px -10px rgba(0, 0, 0, 0.5);
}

.cockpit-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.canvas-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 10px;
  overflow: hidden;
  background: #020617;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.cockpit-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.cockpit-overlay-tag {
  position: absolute;
  bottom: 8px;
  left: 10px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.6);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

.cockpit-telemetry {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.75rem;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.telemetry-stat {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
}

.stat-val {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
}

.stat-badge {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  text-align: center;
}

.badge-green {
  background: rgba(16, 185, 129, 0.2);
  color: var(--f1-green);
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.badge-red {
  background: rgba(239, 68, 68, 0.2);
  color: var(--f1-red);
  border: 1px solid rgba(239, 68, 68, 0.4);
}

/* Swerve Controls Grid */
.swerve-controls-grid {
  display: flex;
  gap: 1.25rem;
  justify-content: center;
  align-items: center;
  margin-top: 1.5rem;
  width: 100%;
  flex-wrap: wrap;
}

.btn-swerve {
  flex: 1;
  max-width: 220px;
  padding: 1.2rem 1rem;
  font-family: var(--font-family);
  font-size: 0.95rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #fff;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 8px 20px -5px rgba(0, 0, 0, 0.4);
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  user-select: none;
}

.btn-swerve:hover {
  border-color: var(--f1-cyan);
  box-shadow: 0 0 16px var(--f1-cyan-glow);
  transform: translateY(-2px);
}

.btn-swerve:active {
  transform: translateY(1px);
}

.swerve-hint {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.1em;
}

/* 10x Slow Motion Replay Scrubber */
.replay-bar {
  margin-top: 1.5rem;
  width: 100%;
  max-width: 650px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.replay-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--f1-yellow);
}

.replay-slider {
  width: 100%;
  accent-color: var(--f1-yellow);
  cursor: pointer;
}

.replay-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

