/* Barbouille — styles (mobile-first, sombre & néon) */
:root {
  --bg: #0d1220;
  --panel: #161d31;
  --line: #2a3654;
  --text: #eef2ff;
  --muted: #94a1c4;
  --you: #22d3ee;
  --opp: #fb7185;
  --you-soft: rgba(34, 211, 238, .14);
  --opp-soft: rgba(251, 113, 133, .14);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: radial-gradient(1200px 700px at 50% -10%, #1b2340, var(--bg) 60%);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.hidden { display: none !important; }

#app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 10px calc(6px + env(safe-area-inset-bottom));
}

/* ------------------------------- HUD ---------------------------------- */
#hud { display: flex; flex-direction: column; gap: 6px; padding-top: 2px; }
.hud-names { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pname {
  font-weight: 700; font-size: .95rem;
  max-width: 34%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pname.you { color: var(--you); }
.pname.opp { color: var(--opp); text-align: right; }
.timer {
  font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.25rem;
  letter-spacing: .04em;
}
.bar {
  display: flex; height: 10px; border-radius: 6px; overflow: hidden;
  background: #202844; border: 1px solid var(--line);
}
.seg { height: 100%; width: 50%; transition: width .35s ease; }
.seg.you { background: linear-gradient(90deg, #0ea5c9, var(--you)); }
.seg.opp { background: linear-gradient(270deg, #e4576f, var(--opp)); }
.hud-sub { display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); }
.pct.you { color: var(--you); font-weight: 700; font-variant-numeric: tabular-nums; }
.pct.opp { color: var(--opp); font-weight: 700; font-variant-numeric: tabular-nums; }
.hint { text-align: center; }

/* ------------------------------ Scène ---------------------------------- */
#stage {
  position: relative; flex: 1; min-height: 0;
  touch-action: none;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
#game {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .45);
  touch-action: none;
}
#foot { text-align: center; color: var(--muted); font-size: .72rem; }

/* ---------------------------- Overlays --------------------------------- */
.overlay {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(8, 11, 20, .66);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fadein .18s ease;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.card {
  width: 100%; max-width: 380px; max-height: 92vh; overflow-y: auto;
  background: linear-gradient(180deg, #1b2440, #12182b);
  border: 1px solid var(--line); border-radius: 18px;
  padding: 22px 20px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .5);
  display: flex; flex-direction: column; gap: 12px;
  animation: pop .22s ease;
}
@keyframes pop { from { transform: scale(.96); opacity: .6; } to { transform: scale(1); opacity: 1; } }
.card.center { text-align: center; align-items: center; }
h1 { font-size: 1.7rem; letter-spacing: -.01em;
  background: linear-gradient(90deg, var(--you), var(--opp));
  -webkit-background-clip: text; background-clip: text; color: transparent; }
h2 { font-size: 1.25rem; }
.sub { color: var(--muted); font-size: .9rem; line-height: 1.45; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: .82rem; color: var(--muted); }
input {
  background: #0e1428; color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 12px; font-size: 1rem; width: 100%;
  outline: none;
}
input:focus { border-color: var(--you); }
#in-code { text-transform: uppercase; letter-spacing: .35em; text-align: center; font-weight: 800; width: 120px; }
.row { display: flex; gap: 10px; align-items: stretch; }
.row.join { justify-content: space-between; }
.grow { flex: 1; }
.btn {
  appearance: none; border: 1px solid var(--line);
  background: #222c4a; color: var(--text);
  font-size: .95rem; font-weight: 600; font-family: inherit;
  padding: 12px 16px; border-radius: 12px;
  cursor: pointer; min-height: 46px;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
  touch-action: manipulation;
}
.btn:hover { border-color: #3d4c78; background: #283354; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: linear-gradient(90deg, #0ea5c9, #22d3ee); color: #06202b; border: none; }
.btn.primary.big { min-height: 54px; font-size: 1.05rem; }
.btn.primary:hover { filter: brightness(1.08); }
.err { color: #fca5a5; font-size: .85rem; text-align: center; }
.help { font-size: .85rem; color: var(--muted); }
.help summary { cursor: pointer; font-weight: 600; color: var(--text); padding: 4px 0; }
.help ul { margin: 6px 0 0 18px; display: grid; gap: 6px; line-height: 1.4; }
.room-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 2.6rem; font-weight: 800; letter-spacing: .28em;
  color: var(--you); text-indent: .28em;
  background: #0e1428; border: 1px dashed var(--line);
  border-radius: 14px; padding: 10px 18px;
}
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid #2c3860; border-top-color: var(--you);
  animation: spin .9s linear infinite;
}
.spinner.small { width: 22px; height: 22px; border-width: 2px; margin-top: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }
.end-score { font-size: 1.15rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.end-score .you { color: var(--you); }
.end-score .opp { color: var(--opp); }
.end-stats { font-size: .84rem; color: var(--muted); line-height: 1.6; }

/* --------------------------- Éléments canvas ---------------------------- */
#cd {
  position: absolute; inset: 0; z-index: 4;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none; gap: 6px;
}
#cd-num {
  font-size: clamp(3.4rem, 16vw, 6rem); font-weight: 900; color: #fff;
  text-shadow: 0 0 26px rgba(34, 211, 238, .85), 0 0 60px rgba(34, 211, 238, .4);
  animation: cdpulse .9s ease infinite;
}
#cd-num.go { animation: gozoom .6s ease; color: #a7f3d0; text-shadow: 0 0 30px rgba(52, 211, 153, .9); }
@keyframes cdpulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.12); } }
@keyframes gozoom { from { transform: scale(.4); opacity: 0; } 60% { transform: scale(1.25); opacity: 1; } to { transform: scale(1); } }
#cd-vs { color: #cbd5f5; font-weight: 600; font-size: .95rem; text-shadow: 0 1px 6px #000; }
#joy { position: absolute; z-index: 3; width: 112px; height: 112px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.28); background: rgba(255,255,255,.06);
  transform: translate(-50%, -50%); pointer-events: none; }
#joy-knob { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px;
  border-radius: 50%; background: rgba(34, 211, 238, .75); box-shadow: 0 0 16px rgba(34,211,238,.6); }
#banner {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  z-index: 6; background: rgba(127, 29, 29, .92); border: 1px solid #b91c1c;
  color: #fee2e2; font-size: .82rem; font-weight: 600;
  padding: 8px 14px; border-radius: 999px; white-space: nowrap;
  animation: blinker 1.4s ease infinite;
}
@keyframes blinker { 50% { opacity: .55; } }
#toasts { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  z-index: 7; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: max-content; max-width: 92%; }
.toast {
  background: rgba(16, 22, 40, .94); border: 1px solid var(--line);
  padding: 9px 14px; border-radius: 12px; font-size: .87rem; font-weight: 600;
  box-shadow: 0 8px 26px rgba(0,0,0,.45);
  animation: toastin .22s ease;
}
@keyframes toastin { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* --------------------------- Boutons coins ------------------------------ */
.corner {
  position: fixed; z-index: 40; top: calc(8px + env(safe-area-inset-top)); left: 10px;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: rgba(22, 29, 49, .9); color: var(--text);
  font-size: 1rem; cursor: pointer;
}
.corner.right { left: auto; right: 10px; }
.corner:active { transform: scale(.94); }
.corner.confirm { background: #7f1d1d; border-color: #b91c1c; width: auto; border-radius: 10px; padding: 0 12px; font-weight: 700; }

@media (max-width: 380px) {
  .room-code { font-size: 2rem; }
  .hud-sub .hint { display: none; }
}

#cd-tip { color: #9fb0d6; font-size: .8rem; font-weight: 600; text-shadow: 0 1px 6px #000; }
