:root {
  --bg: #0a0e14; --panel: #111925; --panel2: #0f1620; --line: #1d2a3a;
  --text: #d7fbee; --muted: #6f8598; --accent: #00ff9c; --accent2: #ff5c8a;
  --on-accent: #06110b; --font: 'DM Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius: 12px;
}
* { box-sizing: border-box; }
/* IMPORTANT : sans ça, [hidden] est ecrase par .screen{display:flex} / .overlay{display:flex}
   et les ecrans caches restent affiches (piege classique du toggle par attribut hidden). */
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 50% -10%, #12203040, transparent), var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-tap-highlight-color: transparent;
  transition: background .2s, color .2s;
}
.screen { min-height: 100%; display: flex; flex-direction: column; align-items: center; padding: 24px 16px 40px; gap: 18px; }
h1, h2, h3 { margin: 0 0 8px; }
a { color: var(--accent); }

/* Accueil */
.brand { text-align: center; margin-top: 12px; }
.brand h1 { font-size: clamp(38px, 9vw, 64px); letter-spacing: -1px; text-shadow: 0 0 24px #00ff9c55; }
.tagline { color: var(--muted); margin: 0; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; width: 100%; max-width: 440px;
}
.cols { display: flex; gap: 16px; width: 100%; max-width: 900px; align-items: flex-start; flex-wrap: wrap; }
.cols .card { flex: 1 1 300px; max-width: none; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field span { color: var(--muted); font-size: 13px; }
input, select, button { font: inherit; }
input, select {
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 10px 12px; width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
.check { display: flex; gap: 8px; align-items: flex-start; color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.check input { width: auto; }
button {
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 10px 14px; cursor: pointer; transition: .12s;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 700; width: 100%; }
button.primary:hover { filter: brightness(1.08); }

.theme-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.theme-row > span { color: var(--muted); font-size: 13px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 7px 12px; font-size: 13px; border-radius: 999px; }
.chip.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 700; }

.join-row { display: flex; gap: 8px; margin-bottom: 16px; }
.join-row input { text-align: center; letter-spacing: 4px; font-weight: 700; }
.join-row button { flex: 0 0 auto; }
.rooms { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow: auto; }
.room { display: flex; justify-content: space-between; align-items: center; text-align: left; width: 100%; }
.room .rname { font-weight: 700; }
.room .rmeta { color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); font-size: 13px; }
.foot { color: var(--muted); font-size: 12px; margin-top: auto; }

/* Lobby */
.lobby-card { max-width: 480px; text-align: center; }
.code b { color: var(--accent); letter-spacing: 3px; }
.share { display: flex; gap: 8px; margin: 12px 0 18px; }
.share input { text-align: center; font-size: 13px; }
.lobby-players { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.plobby { display: flex; align-items: center; gap: 10px; background: var(--panel2); padding: 8px 12px; border-radius: 8px; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.lobby-actions { display: flex; gap: 10px; }
.lobby-actions .primary { flex: 1; }

/* Jeu */
#game { justify-content: flex-start; }
.hud {
  display: flex; gap: 16px; align-items: center; justify-content: center; flex-wrap: wrap;
  font-size: 14px; padding: 6px 14px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px;
}
.hud #hudTimer.danger { color: var(--accent2); font-weight: 700; }
.arena-wrap { position: relative; max-width: 100%; }
canvas { display: block; max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 10px; image-rendering: crisp-edges; }
.overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.5); border-radius: 10px; text-align: center;
}
.overlay h2 { font-size: clamp(24px, 5vw, 40px); text-shadow: 0 0 20px #00ff9c66; }
.controls-hint { color: var(--muted); font-size: 12px; }

/* Commandes tactiles : cachees sur desktop, visibles au toucher */
.touch { display: none; }
@media (hover: none) and (pointer: coarse) {
  .touch { display: flex; justify-content: space-between; align-items: flex-end; width: 100%; max-width: 440px; margin-top: 8px; }
  .controls-hint { display: none; }
}
.dpad { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.dpad-mid { display: flex; gap: 40px; }
.dpad button { width: 58px; height: 58px; font-size: 20px; border-radius: 12px; }
.bomb-btn { width: 84px; height: 84px; font-size: 34px; border-radius: 50%; }

#toast {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  background: var(--accent2); color: #1a0410; padding: 10px 18px; border-radius: 999px;
  font-weight: 700; z-index: 100;
}

/* Pastille de connexion (dans le footer) */
.conn { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); vertical-align: middle; }
.conn.connecting { background: #ffd23f; }
.conn.connected { background: var(--accent); }
.conn.offline { background: var(--accent2); }

/* Bandeau d'erreur visible (debug a distance) */
#errbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  background: #ff3b3b; color: #fff; padding: 10px 14px; font-size: 13px;
  text-align: center; font-weight: 700;
}

/* ---- Polish presentation ---- */
body { background:
  radial-gradient(900px 500px at 50% -8%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%),
  var(--bg); }
.brand h1 { text-shadow: 0 0 28px color-mix(in srgb, var(--accent) 55%, transparent); }
.boom { display: inline-block; animation: bob 2.4s ease-in-out infinite; filter: drop-shadow(0 0 10px color-mix(in srgb, var(--accent) 70%, transparent)); }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-8px) rotate(4deg); } }
.legend { color: var(--muted); font-size: 13px; margin: 6px 0 0; opacity: .9; }

.card { transition: border-color .15s, transform .15s; }
.card:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.room:hover, .chip:hover { transform: translateY(-1px); }
button:active { transform: translateY(1px); }

.soundtoggle {
  position: fixed; top: 14px; right: 14px; z-index: 90;
  width: 42px; height: 42px; border-radius: 50%; font-size: 18px; padding: 0;
  background: var(--panel); border: 1px solid var(--line);
}
.soundtoggle:hover { border-color: var(--accent); }
.overlay h2 { text-shadow: 0 0 20px color-mix(in srgb, var(--accent) 60%, transparent); }

/* ---- Lobby : scores, resultat, chat ---- */
.result { color: var(--accent); font-weight: 700; margin: -4px 0 12px; }
.plobby { justify-content: flex-start; }
.plobby .pn { flex: 1; text-align: left; }
.plobby .wins { color: var(--accent); font-size: 13px; font-weight: 700; }
.chat { text-align: left; margin-bottom: 12px; }
.chatlog { height: 130px; overflow-y: auto; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-size: 13px; display: flex; flex-direction: column; gap: 3px; }
.chatline { word-break: break-word; }
.chatline b { margin-right: 4px; }
.chat-row { display: flex; gap: 8px; margin-top: 8px; }
.chat-row button { flex: 0 0 auto; }

/* Bouton Quitter dans le HUD de jeu */
.hud .hudbtn { padding: 5px 12px; border-radius: 999px; font-size: 13px; }
.hud .iconbtn { width: 34px; height: 34px; padding: 0; border-radius: 50%; font-size: 16px; line-height: 1; }

/* ---- Fond animé de l'accueil ---- */
#bg { position: fixed; inset: 0; z-index: 0; display: none; }
.screen { position: relative; z-index: 1; }

/* ---- Chat : heure + emoji ---- */
.chattime { color: var(--muted); font-size: 10px; opacity: .7; }
.emoji-btn { flex: 0 0 auto; }
.emoji-bar { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.emoji-bar .emoji { padding: 4px 6px; font-size: 18px; line-height: 1; }

/* ---- Taunt (rire) : visuel pour ceux sans son ---- */
.taunt-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; pointer-events: none; z-index: 60;
}
.taunt-overlay .taunt-emo { font-size: clamp(80px, 18vw, 190px); filter: drop-shadow(0 0 34px #ff3b6b); }
.taunt-overlay .taunt-name { font-size: clamp(18px, 4vw, 30px); font-weight: 700; text-shadow: 0 0 16px #000; }
.taunt-overlay.show { animation: tauntpop .5s ease-out; }
@keyframes tauntpop { 0% { transform: scale(.4); opacity: 0; } 40% { transform: scale(1.12); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }

/* Version / build discret en bas a droite */
.version { position: fixed; bottom: 6px; right: 10px; z-index: 80; font-size: 10px; color: var(--muted); opacity: .55; pointer-events: none; }
