* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Inter', sans-serif;
  background: #0a0e1a;
  color: #e2e8f0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

/* === LOBBY === */
.lobby {
  max-width: 500px;
  width: 100%;
  padding: 40px 20px;
  text-align: center;
}
.lobby h1 {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 8px;
  background: linear-gradient(90deg, #00e5ff, #ff0080);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.lobby-sub { color: #94a3b8; font-size: 0.9rem; margin-bottom: 24px; }
.lobby-status {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 16px;
}
.lobby-status p { margin-bottom: 12px; }
.btn-find {
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  padding: 14px 32px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  color: #0a0e1a;
  background: #00e5ff;
  box-shadow: none;
  transition: transform 0.2s;
  width: 100%;
}
.btn-find:hover { transform: translateY(-2px); }
.lobby-choix { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
#btnCreate { background: #6d28d9; color: #fff; }
#joinSection { display: flex; gap: 8px; align-items: center; }
#joinSection .btn-find { flex: 1; min-width: 0; padding-left: 12px; padding-right: 12px; background: #059669; color: #fff; }
#joinSection input {
  flex: 0 0 90px; min-width: 0; font-family: 'Inter', sans-serif; font-size: 1rem; font-weight: 700;
  text-align: center; text-transform: uppercase; padding: 12px; border: 1px solid rgba(255,255,255,0.15);
  border-radius: 12px; background: rgba(255,255,255,0.06); color: #00e5ff; letter-spacing: 0.15em; outline: none;
}
#joinSection input:focus-visible { border-color: #00e5ff; }
.btn-find:disabled { opacity: 0.5; cursor: default; transform: none; }
.btn-cancel {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  padding: 8px 20px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  background: none;
  color: #94a3b8;
  cursor: pointer;
  margin-top: 10px;
}
.btn-cancel:hover { color: #e2e8f0; border-color: rgba(255,255,255,0.3); }
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,0.15);
  border-top-color: #00e5ff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.match-info {
  background: rgba(0,229,255,0.08);
  border: 1px solid rgba(0,229,255,0.2);
  border-radius: 12px;
  padding: 20px;
  margin-top: 16px;
}
.match-vs {
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
}
.match-vs .cyan { color: #00e5ff; }
.match-vs .magenta { color: #ff0080; }

/* === GAME AREA === */
.game-area {
  width: 100%;
  padding: 8px;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.game-area.hidden { display: none; }
.game-area.visible { display: flex; }
.game-wrapper {
  position: relative;
  max-width: 800px;
  width: 100%;
}
.game-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 16px;
  font-weight: 700;
  font-size: 0.85rem;
}
.hud-player {
  display: flex;
  align-items: center;
  gap: 8px;
}
.hud-player.left .hud-name { color: #00e5ff; }
.hud-player.right .hud-name { color: #ff0080; }
.hud-score-big {
  font-size: 1.6rem;
  font-weight: 900;
  color: #fff;
  min-width: 30px;
  text-align: center;
}
.hud-sep { color: rgba(255,255,255,0.2); font-size: 1.2rem; }
#pongCanvas {
  display: block;
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.06);
  aspect-ratio: 800 / 500;
}

/* Countdown overlay */
.countdown-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.7);
  z-index: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.countdown-overlay.visible { opacity: 1; pointer-events: auto; }
.countdown-number {
  font-size: 6rem;
  font-weight: 900;
  color: #00e5ff;
  text-shadow: 0 0 40px rgba(0,229,255,0.5);
  animation: countPulse 1s ease-out;
}
@keyframes countPulse {
  0% { transform: scale(1.5); opacity: 0; }
  50% { opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* Score flash */
.score-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 400;
  opacity: 0;
  transition: opacity 0.1s;
}
.score-flash.cyan { background: radial-gradient(ellipse at center, rgba(0,229,255,0.15), transparent 60%); }
.score-flash.magenta { background: radial-gradient(ellipse at center, rgba(255,0,128,0.15), transparent 60%); }
.score-flash.active { opacity: 1; }

/* Game end overlay */
.game-end-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.88);
  z-index: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.game-end-overlay.visible { opacity: 1; pointer-events: auto; }
.game-end-card {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 36px 32px;
  text-align: center;
  max-width: 400px;
  width: 90%;
}
.game-end-card h2 { font-size: 1.8rem; margin-bottom: 8px; }
.game-end-card .win { color: #00e5ff; text-shadow: 0 0 20px rgba(0,229,255,0.4); }
.game-end-card .lose { color: #ff0080; text-shadow: 0 0 20px rgba(255,0,128,0.4); }
.game-end-card p { color: #94a3b8; margin-bottom: 16px; }
.game-end-card .final-score {
  font-size: 2rem;
  font-weight: 900;
  color: #fff;
  margin-bottom: 20px;
}
.final-score .s-cyan { color: #00e5ff; }
.final-score .s-magenta { color: #ff0080; }
.game-end-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.game-end-btns .btn {
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 10px 24px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.2s;
  text-decoration: none;
}
.game-end-btns .btn:hover { transform: translateY(-2px); }
.btn-primary { background: #00e5ff; color: #0a0e1a; }
.btn-secondary { background: rgba(255,255,255,0.08); color: #e2e8f0; border: 1px solid rgba(255,255,255,0.12); }
