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

html, body {
  height: 100%;
  background: #1b2a1b;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #fff;
  overflow: hidden;
}

#app { position: relative; width: 100vw; height: 100vh; }

canvas { display: block; width: 100%; height: 100%; }

.hidden { display: none !important; }

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(10, 20, 10, 0.78);
  text-align: center;
  padding: 20px;
}

h1 { font-size: 56px; letter-spacing: 2px; color: #ffd23f; text-shadow: 3px 3px 0 #c0392b; }
h2 { font-size: 40px; color: #ffd23f; }
.subtitle { font-size: 18px; opacity: 0.8; margin-bottom: 12px; }

button {
  font-size: 18px;
  font-weight: 600;
  padding: 14px 28px;
  min-width: 320px;
  border: none;
  border-radius: 10px;
  background: #e74c3c;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 0 #962d22;
}
button:hover:not(:disabled) { filter: brightness(1.1); }
button:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 #962d22; }
button:disabled { background: #555; box-shadow: 0 4px 0 #333; cursor: not-allowed; opacity: 0.7; }
button.secondary { background: #34495e; box-shadow: 0 4px 0 #1f2d3a; }

.controls { margin-top: 18px; line-height: 1.9; font-size: 16px; }
.controls .hint { opacity: 0.7; font-size: 14px; margin-top: 6px; }

.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin: 0 8px; vertical-align: middle; }
.p1 .dot, .dot.p1 { background: #e74c3c; }
.p2 .dot, .dot.p2 { background: #3498db; }

#hud { position: absolute; inset: 0; pointer-events: none; text-shadow: 2px 2px 0 #000; font-weight: 700; }
#hud-time {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  font-size: 28px; font-variant-numeric: tabular-nums;
  background: rgba(0,0,0,0.35); padding: 4px 14px; border-radius: 8px;
}
.hud-panel { position: absolute; top: 10px; padding: 8px 14px; font-size: 20px; line-height: 1.35; }
.hud-panel .pos { font-size: 44px; color: #ffd23f; }
.hud-panel .speed { position: absolute; top: auto; font-size: 22px; }
.hud-panel.left { left: 10px; }
.hud-panel.right { right: 10px; text-align: right; }
.hud-speed { position: absolute; bottom: 14px; font-size: 26px; font-variant-numeric: tabular-nums; }
#split-line { position: absolute; top: 0; bottom: 0; left: 50%; width: 4px; margin-left: -2px; background: #111; }
#minimap { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); width: 220px; height: 140px; opacity: 0.9; }
#toast {
  position: absolute; top: 70px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.6); padding: 10px 20px; border-radius: 10px; font-size: 22px; font-weight: 700;
  pointer-events: none;
}
#error-text { max-width: 560px; font-size: 18px; line-height: 1.5; }

#countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: min(160px, 28vh);
  font-weight: 900;
  color: #ffd23f;
  text-shadow: 6px 6px 0 #c0392b;
  pointer-events: none;
}

#results-list { list-style: none; font-size: 22px; line-height: 1.8; margin: 10px 0 16px; }
#results-list li span.time { font-variant-numeric: tabular-nums; opacity: 0.85; margin-left: 12px; }

/* --- Connexion, salon, barre utilisateur --- */
#userbar {
  position: absolute; top: 10px; right: 12px; z-index: 5;
  display: flex; align-items: center; gap: 10px; font-size: 15px;
  background: rgba(0,0,0,0.45); padding: 6px 8px 6px 14px; border-radius: 10px;
}
button.small { min-width: 0; padding: 6px 12px; font-size: 14px; box-shadow: none; }
.msg { font-size: 17px; opacity: 0.9; max-width: 560px; line-height: 1.5; min-height: 1em; }
.msg.error { color: #ff8a80; }
.or { margin-top: 10px; opacity: 0.8; }
.join { display: flex; gap: 10px; justify-content: center; }
.join input {
  width: 150px; font-size: 26px; font-weight: 700; text-align: center; letter-spacing: 6px;
  text-transform: uppercase; border-radius: 10px; border: none; padding: 10px;
}
.join button { min-width: 160px; }
#lobby-choice, #lobby-room { display: flex; flex-direction: column; align-items: center; gap: 12px; }
#room-code {
  font-size: 72px; font-weight: 900; letter-spacing: 14px; color: #ffd23f;
  text-shadow: 4px 4px 0 #c0392b; font-variant-numeric: tabular-nums;
}
