/* ═══════════════════════════════════════════════════
   TWITCHRACE 3D — Feuille de style
   Esthétique : Neon Cyberpunk Racing
   ═══════════════════════════════════════════════════ */

/* ── Tokens ── */
:root {
  --bg-deep:      #04050f;
  --bg-panel:     #080c1a;
  --bg-card:      #0d1228;
  --border:       #1a2240;
  --border-glow:  #1e3a6e;

  --neon-cyan:    #00fff7;
  --neon-purple:  #bf00ff;
  --neon-orange:  #ff6b00;
  --neon-green:   #00ff88;
  --neon-yellow:  #ffe600;
  --neon-pink:    #ff2d78;

  --text-primary:   #e8eaf6;
  --text-secondary: #6a7499;
  --text-hint:      #3a4568;

  --panel-w: 300px;
  --radius:  8px;

  --font-display: 'Courier New', 'Consolas', monospace;
  --font-body:    system-ui, -apple-system, sans-serif;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-body);
  overflow: hidden;
}

/* ══════════════════════════════════════
   LAYOUT PRINCIPAL
══════════════════════════════════════ */
body {
  display: flex;
  flex-direction: row;
}

/* ══════════════════════════════════════
   PANNEAU DE CONTRÔLE
══════════════════════════════════════ */
#control-panel {
  width: var(--panel-w);
  min-width: var(--panel-w);
  height: 100vh;
  background: var(--bg-panel);
  border-right: 1px solid var(--border-glow);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 0;
  box-shadow: 4px 0 24px rgba(0, 255, 247, 0.05);
  scrollbar-width: thin;
  scrollbar-color: var(--border-glow) transparent;
}

#control-panel::-webkit-scrollbar { width: 4px; }
#control-panel::-webkit-scrollbar-thumb { background: var(--border-glow); border-radius: 2px; }

/* Header / Logo */
#panel-header {
  padding: 24px 20px 20px;
  text-align: center;
  background: linear-gradient(180deg, #050820 0%, var(--bg-panel) 100%);
  border-bottom: 1px solid var(--border);
  position: relative;
}

.logo-mark {
  font-size: 2rem;
  color: var(--neon-cyan);
  text-shadow: 0 0 20px var(--neon-cyan), 0 0 40px var(--neon-cyan);
  animation: pulse-logo 2.5s ease-in-out infinite;
  display: block;
  margin-bottom: 8px;
}

@keyframes pulse-logo {
  0%, 100% { text-shadow: 0 0 20px var(--neon-cyan), 0 0 40px var(--neon-cyan); opacity: 1; }
  50%       { text-shadow: 0 0 10px var(--neon-cyan), 0 0 20px var(--neon-cyan); opacity: 0.7; }
}

#panel-header h1 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: var(--text-primary);
  text-transform: uppercase;
}

#panel-header h1 span {
  color: var(--neon-cyan);
  text-shadow: 0 0 12px var(--neon-cyan);
}

.tagline {
  font-size: 0.68rem;
  color: var(--text-secondary);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-top: 4px;
}

/* Sections */
.panel-section {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

/* Input */
label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.input-row {
  display: flex;
  gap: 8px;
}

input[type="text"] {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius);
  padding: 9px 12px;
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 0 2px rgba(0,255,247,0.12), inset 0 0 8px rgba(0,255,247,0.05);
}

input[type="text"]::placeholder { color: var(--text-hint); }

/* Boutons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-icon { font-size: 1rem; }

.btn-primary {
  background: var(--bg-card);
  border: 1px solid var(--neon-cyan);
  color: var(--neon-cyan);
  text-shadow: 0 0 8px var(--neon-cyan);
  box-shadow: inset 0 0 8px rgba(0,255,247,0.05);
}
.btn-primary:hover {
  background: rgba(0,255,247,0.1);
  box-shadow: 0 0 14px rgba(0,255,247,0.25), inset 0 0 12px rgba(0,255,247,0.1);
}

.btn-race {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, rgba(191,0,255,0.15), rgba(0,255,247,0.1));
  border: 1px solid var(--neon-purple);
  color: #fff;
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  box-shadow: 0 0 16px rgba(191,0,255,0.2);
  text-shadow: 0 0 10px rgba(255,255,255,0.5);
}
.btn-race:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(191,0,255,0.3), rgba(0,255,247,0.2));
  box-shadow: 0 0 28px rgba(191,0,255,0.4), 0 0 50px rgba(0,255,247,0.1);
  transform: translateY(-1px);
}
.btn-race:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

.btn-reset {
  width: 100%;
  padding: 12px;
  background: rgba(255,107,0,0.1);
  border: 1px solid var(--neon-orange);
  color: var(--neon-orange);
  text-shadow: 0 0 8px var(--neon-orange);
}
.btn-reset:hover {
  background: rgba(255,107,0,0.2);
  box-shadow: 0 0 16px rgba(255,107,0,0.3);
}

/* Badge */
.badge {
  background: var(--neon-cyan);
  color: var(--bg-deep);
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 12px;
  min-width: 24px;
  text-align: center;
}

/* Status */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 20px;
  width: fit-content;
  transition: all 0.3s;
}

.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-offline { background: rgba(255,45,120,0.1); color: var(--neon-pink); border: 1px solid rgba(255,45,120,0.3); }
.status-offline .status-dot { background: var(--neon-pink); box-shadow: 0 0 6px var(--neon-pink); }

.status-online { background: rgba(0,255,136,0.1); color: var(--neon-green); border: 1px solid rgba(0,255,136,0.3); }
.status-online .status-dot { background: var(--neon-green); box-shadow: 0 0 6px var(--neon-green); animation: blink 1.2s ease-in-out infinite; }

.status-connecting { background: rgba(255,230,0,0.1); color: var(--neon-yellow); border: 1px solid rgba(255,230,0,0.3); }
.status-connecting .status-dot { background: var(--neon-yellow); animation: blink 0.6s ease-in-out infinite; }

@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } }

/* Hint */
.hint {
  font-size: 0.72rem;
  color: var(--text-hint);
  line-height: 1.5;
}
.hint code {
  background: var(--bg-card);
  border: 1px solid var(--border-glow);
  color: var(--neon-cyan);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--font-display);
}

/* Liste des pilotes */
#driver-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 180px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#driver-list li {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.78rem;
  font-family: var(--font-display);
  transition: border-color 0.2s;
  animation: slide-in 0.25s ease-out;
}

#driver-list li:hover { border-color: var(--border-glow); }

@keyframes slide-in {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}

.car-dot {
  width: 10px; height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}

/* Timer */
.timer-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.timer-display {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 900;
  color: var(--neon-cyan);
  text-shadow: 0 0 20px var(--neon-cyan);
  letter-spacing: 0.05em;
  line-height: 1;
}

.progress-bar-wrap {
  height: 4px;
  background: var(--bg-card);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-purple));
  border-radius: 2px;
  box-shadow: 0 0 8px var(--neon-cyan);
  transition: width 0.5s linear;
}

/* Légende */
.legend-items { display: flex; flex-direction: column; gap: 6px; }
.legend-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.72rem; color: var(--text-secondary);
}
.leg-dot {
  width: 8px; height: 8px; border-radius: 50%;
  box-shadow: 0 0 6px currentColor; flex-shrink: 0;
}

/* ══════════════════════════════════════
   ARÈNE DE COURSE
══════════════════════════════════════ */
#race-arena {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg-deep);
}

#race-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: crisp-edges;
}

/* ══════════════════════════════════════
   OVERLAY
══════════════════════════════════════ */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 5, 15, 0.88);
  backdrop-filter: blur(4px);
  z-index: 20;
  transition: opacity 0.4s;
}

.overlay.hidden { opacity: 0; pointer-events: none; }
.overlay.visible { opacity: 1; }

.overlay-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 40px;
  border: 1px solid var(--border-glow);
  border-radius: 16px;
  background: var(--bg-panel);
  box-shadow: 0 0 60px rgba(0,255,247,0.08), 0 0 120px rgba(191,0,255,0.06);
  max-width: 420px;
}

.overlay-icon { font-size: 3.5rem; }

.overlay-content h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--neon-cyan);
  text-shadow: 0 0 16px var(--neon-cyan);
}

.overlay-content p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ══════════════════════════════════════
   COMPTE À REBOURS
══════════════════════════════════════ */
.countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 10rem;
  font-weight: 900;
  color: var(--neon-cyan);
  text-shadow: 0 0 40px var(--neon-cyan), 0 0 80px var(--neon-cyan);
  z-index: 30;
  pointer-events: none;
  animation: countdown-pulse 0.9s ease-in-out;
}

.countdown.hidden { display: none; }

@keyframes countdown-pulse {
  0%   { transform: scale(2); opacity: 0; }
  30%  { transform: scale(1); opacity: 1; }
  75%  { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.6); opacity: 0; }
}

/* ══════════════════════════════════════
   PODIUM
══════════════════════════════════════ */
.podium-panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  background: rgba(4, 5, 15, 0.92);
  backdrop-filter: blur(6px);
  z-index: 40;
  animation: fade-in 0.5s ease-out;
}

.podium-panel.hidden { display: none; }

@keyframes fade-in {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

.podium-header {
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--neon-yellow);
  text-shadow: 0 0 20px var(--neon-yellow);
}

.trophy { font-size: 2rem; }

.podium-slots {
  display: flex;
  align-items: flex-end;
  gap: 16px;
}

.podium-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: podium-rise 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.podium-slot:nth-child(1) { animation-delay: 0.1s; }
.podium-slot:nth-child(2) { animation-delay: 0.3s; }
.podium-slot:nth-child(3) { animation-delay: 0.5s; }

@keyframes podium-rise {
  from { opacity: 0; transform: translateY(40px); }
  to   { opacity: 1; transform: translateY(0); }
}

.podium-rank {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.podium-car-swatch {
  width: 48px; height: 24px;
  border-radius: 4px;
  box-shadow: 0 0 14px currentColor;
}

.podium-name {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 900;
  color: var(--text-primary);
  max-width: 90px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.podium-plinth {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 90px;
  border-radius: 6px 6px 0 0;
  padding-bottom: 8px;
}

.place-1 .podium-rank  { color: var(--neon-yellow); }
.place-1 .podium-plinth { height: 90px; background: rgba(255,230,0,0.12); border: 1px solid rgba(255,230,0,0.4); }

.place-2 .podium-rank  { color: #c0c0c0; }
.place-2 .podium-plinth { height: 65px; background: rgba(192,192,192,0.08); border: 1px solid rgba(192,192,192,0.3); }

.place-3 .podium-rank  { color: #cd7f32; }
.place-3 .podium-plinth { height: 45px; background: rgba(205,127,50,0.08); border: 1px solid rgba(205,127,50,0.3); }

/* ══════════════════════════════════════
   BOOST INDICATOR
══════════════════════════════════════ */
.boost-indicator {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255,107,0,0.15);
  border: 1px solid var(--neon-orange);
  color: var(--neon-orange);
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  padding: 8px 16px;
  border-radius: 8px;
  text-shadow: 0 0 12px var(--neon-orange);
  box-shadow: 0 0 20px rgba(255,107,0,0.3);
  z-index: 10;
  animation: boost-flash 0.4s ease-in-out infinite alternate;
}

.boost-indicator.hidden { display: none; }

@keyframes boost-flash {
  from { opacity: 1; }
  to   { opacity: 0.4; }
}