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

body {
  background: #0a0a0a;
  color: #fff;
  font-family: 'Courier New', Courier, monospace;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  flex-direction: column;
}

/* ─── Background canvas ───────────────────────────────────── */

#bg-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  opacity: 0.06;
  pointer-events: none;
}

/* ─── Screens ─────────────────────────────────────────────── */

.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 860px;
  padding: 24px;
}

.screen.active {
  display: flex;
}

/* ─── Home ────────────────────────────────────────────────── */

h1 {
  font-size: 5rem;
  letter-spacing: 0.6em;
  text-indent: 0.6em; /* compense l'espace après le dernier caractère */
  color: #fff;
  text-shadow: 0 0 30px rgba(255, 255, 255, 0.4);
  margin-bottom: 16px;
}

h2 {
  font-size: 2rem;
  letter-spacing: 0.2em;
  margin-bottom: 8px;
}

.divider {
  color: #555;
  font-size: 0.9rem;
  margin: 4px 0;
}

.join-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 320px;
}

input[type="text"],
select {
  width: 100%;
  padding: 10px 14px;
  font-size: 1rem;
  font-family: 'Courier New', monospace;
  background: #1a1a1a;
  color: #fff;
  border: 1px solid #333;
  outline: none;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

input[type="text"]::placeholder {
  text-transform: none;
  color: #555;
  letter-spacing: normal;
}

select {
  text-transform: none;
  letter-spacing: normal;
  cursor: pointer;
  appearance: none;
}

select option {
  background: #1a1a1a;
}

button {
  padding: 10px 24px;
  font-size: 1rem;
  font-family: 'Courier New', monospace;
  background: #fff;
  color: #000;
  border: none;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: background 0.15s, color 0.15s;
}

button:hover {
  background: #aaa;
}

.label {
  color: #aaa;
  font-size: 0.95rem;
}

.error-msg {
  color: #ff4444;
  font-size: 0.9rem;
  min-height: 1.2em;
  text-align: center;
}

/* ─── Waiting ─────────────────────────────────────────────── */

.code-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 32px;
  border: 1px solid #333;
  background: #111;
}

.code-label {
  font-size: 0.75rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

.room-code {
  font-size: 3rem;
  letter-spacing: 0.4em;
  color: #fff;
  font-weight: bold;
}

.url-box {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 480px;
}

.url-box input {
  flex: 1;
  font-size: 0.85rem;
  text-transform: none;
  letter-spacing: normal;
  color: #aaa;
  cursor: text;
}

.url-box button {
  white-space: nowrap;
  font-size: 0.85rem;
  padding: 10px 16px;
}

.waiting-status {
  color: #888;
  font-size: 0.95rem;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.copy-confirm {
  color: #4caf50;
  font-size: 0.85rem;
  height: 1.2em;
}

/* ─── Waiting ─── bouton retour ───────────────────────────── */

.btn-secondary {
  background: transparent;
  color: #555;
  border: 1px solid #333;
  font-size: 0.85rem;
  padding: 8px 20px;
  margin-top: 4px;
}

.btn-secondary:hover {
  background: #1a1a1a;
  color: #aaa;
}

/* ─── Game ────────────────────────────────────────────────── */

#score-display {
  font-size: 2.5rem;
  letter-spacing: 0.4em;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 8px;
}

.score-sep {
  color: #444;
}

.score-name {
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.7;
}

.score-name.mine {
  opacity: 1;
  font-weight: bold;
}

.p1-color { color: #ffffff; }
.p2-color { color: #4fc3f7; }

.game-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 800px;
  margin-top: 4px;
}

.ping-display {
  font-size: 0.7rem;
  color: #333;
  letter-spacing: 0.05em;
}

.canvas-wrapper {
  position: relative;
  line-height: 0;
  width: 100%;
  max-width: 800px;
}

#pong-canvas {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid #222;
  background: #000;
}

.game-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.5rem;
  letter-spacing: 0.1em;
  pointer-events: none;
  text-shadow: 0 0 30px rgba(255, 255, 255, 0.7);
  opacity: 0;
  transition: opacity 0.3s;
}

.game-overlay.visible {
  opacity: 1;
}

.role-label {
  color: #555;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

/* ─── Score flash ─────────────────────────────────────────── */

@keyframes score-flash {
  0%   { transform: scale(1);   color: #fff; }
  30%  { transform: scale(1.7); color: #ffe066; }
  100% { transform: scale(1);   color: #fff; }
}

.score-flash {
  display: inline-block;
  animation: score-flash 0.5s ease-out forwards;
}

/* ─── Pseudo (accueil) ────────────────────────────────────── */

#input-name {
  text-transform: none;
  letter-spacing: normal;
  width: 320px;
  margin-bottom: 4px;
}

/* ─── Résultat fin de partie ──────────────────────────────── */

.game-result {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 20px 32px;
  border: 1px solid #2a2a2a;
  background: #0d0d0d;
  width: 100%;
  max-width: 480px;
  text-align: center;
}

.game-result.visible {
  display: flex;
}

.result-text {
  font-size: 2rem;
  letter-spacing: 0.1em;
  text-shadow: 0 0 20px rgba(255,255,255,0.4);
}

.result-names {
  font-size: 0.85rem;
  color: #666;
}

.result-score {
  font-size: 1.6rem;
  letter-spacing: 0.3em;
  color: #aaa;
}

.result-buttons {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}

.result-vote-status {
  font-size: 0.8rem;
  color: #555;
  min-height: 1.2em;
}
