/* ---------- Muziki — thème bleu grec (Égée de nuit) ---------- */
:root {
  --bg: #0b1d33;
  --panel: #122b45;
  --panel-2: #0e2338;
  --border: #24466b;
  --text: #f4f3ec;
  --muted: #8ca6c0;
  --accent: #3fa7e8;
  --accent-deep: #1d6fb8;
  --ok: #5fc9a9;
  --bad: #f1655a;
  --warn: #e8b93f;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Archivo", system-ui, sans-serif;
  min-height: 100vh;
}
main { max-width: 680px; margin: 0 auto; padding: 24px 16px 64px; }

h1.logo {
  font-family: "Archivo Black", sans-serif;
  font-size: 2.6rem;
  letter-spacing: -0.02em;
  margin: 8px 0 0;
  text-align: center;
}
.tagline { text-align: center; color: var(--muted); font-family: "IBM Plex Mono", monospace; font-size: .8rem; margin-top: 4px; }

.eyebrow {
  font-family: "IBM Plex Mono", monospace;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: var(--accent);
}
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-top: 16px;
}
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.center { text-align: center; }
.muted { color: var(--muted); font-size: .85rem; }
.small { font-size: .78rem; }
.mono { font-family: "IBM Plex Mono", monospace; }
.accent { color: var(--accent); }
.ok { color: var(--ok); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }

input[type="text"], textarea {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 1rem;
}
textarea { font-family: "IBM Plex Mono", monospace; font-size: .85rem; resize: vertical; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
input.code {
  font-family: "IBM Plex Mono", monospace;
  font-size: 1.4rem;
  letter-spacing: .35em;
  text-transform: uppercase;
  text-align: center;
  color: var(--accent);
}
label.check { display: flex; gap: 8px; align-items: flex-start; font-size: .9rem; margin-top: 10px; cursor: pointer; }
label.check input { accent-color: var(--accent); margin-top: 3px; }

.btn {
  background: var(--accent);
  color: #06263f;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-family: inherit;
  font-weight: 700;
  font-size: .95rem;
  cursor: pointer;
  transition: background .15s;
}
.btn:hover { background: #63bdf5; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn.ok { background: var(--ok); color: #06301f; }
.btn.wide { width: 100%; margin-top: 12px; }
.btn.sm { padding: 5px 10px; font-size: .8rem; }
.btn:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.code-big {
  font-family: "IBM Plex Mono", monospace;
  font-size: 2.2rem;
  font-weight: 600;
  letter-spacing: .3em;
  color: var(--accent);
}
.chip {
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  margin: 3px;
  font-size: .85rem;
}
.chip.off { opacity: .45; }

/* ---------- Vumètre (signature) ---------- */
.vu { display: flex; align-items: flex-end; gap: 4px; height: 56px; justify-content: center; }
.vu span {
  width: 8px;
  border-radius: 2px;
  background: linear-gradient(to top, var(--accent-deep), var(--accent));
  height: 40%;
}
.vu.on span { animation: vu .8s ease-in-out infinite; }
.vu span:nth-child(2) { animation-duration: .65s; }
.vu span:nth-child(3) { animation-duration: .95s; }
.vu span:nth-child(4) { animation-duration: .7s; }
.vu span:nth-child(5) { animation-duration: 1.05s; }
.vu span:nth-child(6) { animation-duration: .75s; }
.vu span:nth-child(7) { animation-duration: .9s; }
@keyframes vu { 0%, 100% { height: 18%; } 50% { height: 96%; } }
.vu.off span { opacity: .25; }
@media (prefers-reduced-motion: reduce) { .vu span { animation: none !important; height: 50%; } }

/* ---------- Lecteur ---------- */
#yt-offscreen { position: fixed; left: -9999px; top: 0; width: 320px; height: 180px; }
.player-box { border-radius: 10px; overflow: hidden; border: 1px solid var(--border); margin-top: 10px; }
.player-box iframe, .player-box > div { width: 100%; height: 220px; display: block; border: 0; }

/* ---------- Flux des réponses (arbitre) ---------- */
.feed { max-height: 320px; overflow-y: auto; margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.feed-item {
  display: flex; gap: 10px; align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}
.feed-item .t { font-family: "IBM Plex Mono", monospace; font-size: .75rem; color: var(--muted); min-width: 64px; font-variant-numeric: tabular-nums; }
.feed-item .who { font-weight: 700; }
.feed-item .what { flex: 1; }

.guess-line { font-family: "IBM Plex Mono", monospace; font-size: .85rem; color: var(--muted); margin: 4px 0; }

/* ---------- Classement ---------- */
.board { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.board-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
}
.board-row.first { border-color: var(--accent); padding: 14px; font-size: 1.1rem; }
.board-row .pts { font-family: "IBM Plex Mono", monospace; color: var(--accent); }

/* Récap de fin de partie par catégorie */
.cat-block { padding: 10px 0; border-bottom: 1px solid var(--border); }
.cat-block:last-child { border-bottom: 0; padding-bottom: 0; }
.cat-block .chip { margin: 2px 4px 2px 0; }
.cat-block .mono { color: var(--accent); }

.answer-big { font-family: "Archivo Black", sans-serif; font-size: 1.5rem; color: var(--accent); margin: 6px 0; }
.volume { width: 120px; accent-color: var(--accent); }
.err { color: var(--bad); font-size: .85rem; margin-top: 8px; }
.notice { color: var(--muted); font-size: .8rem; font-family: "IBM Plex Mono", monospace; margin-top: 8px; text-align: center; }

/* ---------- Options avancées ---------- */
select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 6px 8px;
  font-family: inherit;
  font-size: .85rem;
}
select:focus { outline: none; border-color: var(--accent); }
details.panel summary { list-style: none; cursor: pointer; user-select: none; }
details.panel summary::-webkit-details-marker { display: none; }
details.panel summary::before { content: "▸ "; color: var(--accent); }
details.panel[open] summary::before { content: "▾ "; }
.optgrid { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.optrow {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  font-size: .9rem; padding: 6px 0; flex-wrap: wrap;
}
.optrow.sub, .muted.small.sub { margin-left: 22px; font-size: .85rem; color: var(--muted); }
.chip.ok { border-color: var(--ok); color: var(--ok); }

/* ---------- Équipes ---------- */
.team-block {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
}
.team-block.first { border-color: var(--accent); }
.team-head { font-weight: 700; font-size: 1.05rem; }
.team-member { padding: 3px 0 0 12px; color: var(--muted); }
.team-member .pts.small { font-size: .85rem; }

@media (max-width: 480px) {
  h1.logo { font-size: 2rem; }
  .code-big { font-size: 1.7rem; }
}

/* ---------- Mise en page élargie pendant la partie ---------- */
body.wide main { max-width: 1000px; }
.game-layout { display: grid; grid-template-columns: 1fr 260px; gap: 12px; align-items: start; }
.game-main { min-width: 0; }
.reveal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
@media (max-width: 760px) {
  .game-layout, .reveal-grid { grid-template-columns: 1fr; }
}

/* ---------- Overlay des joueurs ---------- */
.panel.overlay { position: sticky; top: 12px; }
.proster {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 9px; margin-top: 6px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px;
}
.proster.is-found { border-color: var(--ok); }
.proster .pname { flex: 1; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pstatus { font-size: .72rem; font-family: "IBM Plex Mono", monospace; padding: 2px 7px; border-radius: 999px; white-space: nowrap; }
.pstatus.found { background: rgba(95, 201, 169, .16); color: var(--ok); }
.pstatus.skip { background: rgba(232, 185, 63, .16); color: var(--warn); }
.pstatus.cd { background: rgba(63, 167, 232, .14); color: var(--accent); }
.pstatus.search, .pstatus.off { color: var(--muted); }
.tdot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.tdot.tA { background: var(--accent); }
.tdot.tB { background: #d8e4f0; }

/* ---------- Bouton kick / retirer ---------- */
.kickx {
  border: 1px solid var(--border); background: transparent; color: var(--muted);
  border-radius: 6px; cursor: pointer; font-size: .72rem; line-height: 1;
  padding: 3px 6px; margin-left: 4px;
}
.kickx:hover { border-color: var(--bad); color: var(--bad); }
.chip .kickx { margin-left: 6px; }

/* ---------- Réaction 😂 ---------- */
.laugh {
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  border-radius: 999px; cursor: pointer; font-size: .85rem; line-height: 1;
  padding: 4px 9px; white-space: nowrap;
}
.laugh:hover { border-color: var(--accent); }
.laugh.on { border-color: var(--warn); background: rgba(232, 185, 63, .18); }

/* ---------- Compte à rebours ---------- */
.count-big {
  font-family: "Archivo Black", sans-serif; font-size: 4.5rem; line-height: 1;
  color: var(--accent); margin: 8px 0;
}

/* ---------- Liste de pistes (cartes éditables) ---------- */
.track-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; max-height: 420px; overflow-y: auto; }
.track-card {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 10px;
}
.track-thumb { width: 48px; height: 36px; border-radius: 6px; object-fit: cover; flex: none; }
.track-thumb-empty {
  display: flex; align-items: center; justify-content: center;
  background: var(--panel); color: var(--muted); font-size: 1.1rem;
}
.track-status-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; flex: none; }
.track-status-dot.ok { background: var(--ok); }
.track-status-dot.warn { background: var(--warn); }
.track-status-dot.bad { background: var(--bad); }
.track-main { flex: 1; min-width: 0; }
.track-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.track-tags .chip { margin: 2px; }
.chip-name { font-weight: 700; border-color: var(--accent); }
input.track-add-alias {
  border: 1px dashed var(--border); background: transparent; color: var(--text);
  border-radius: 999px; padding: 4px 12px; font-size: .85rem; width: 90px;
}
input.track-url { flex: 1 1 220px; min-width: 0; font-family: "IBM Plex Mono", monospace; font-size: .8rem; }
/* Lien + genre sous les tags : passent à la ligne quand la carte est étroite */
.track-fields { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
input.track-genre { flex: 0 1 200px; min-width: 0; font-size: .8rem; }

/* ---------- Encart anti-triche (contrôles média du système) ---------- */

/* ---------- Toasts (« X a trouvé ! ») — hors de #app, survivent aux render() ---------- */
#toasts {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  z-index: 50; pointer-events: none; width: max-content; max-width: calc(100vw - 32px);
}
.toast {
  background: var(--panel); border: 1px solid var(--accent); color: var(--text);
  border-radius: 999px; padding: 8px 16px; font-weight: 700; font-size: .9rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
  animation: toast-in .25s ease-out; transition: opacity .4s, transform .4s;
}
.toast.ok { border-color: var(--ok); color: var(--ok); }
.toast.out { opacity: 0; transform: translateY(8px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; transition: none; } }

/* ---------- Aperçu d'une piste (lobby hôte) ---------- */
#preview {
  position: fixed; right: 16px; bottom: 16px; z-index: 40;
  width: min(360px, calc(100vw - 32px));
  background: var(--panel); border: 1px solid var(--accent); border-radius: 12px; padding: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
}
#preview iframe { width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 8px; margin-top: 8px; display: block; }

/* ---------- Cartes de pistes : ordre et doublons ---------- */
.track-move { display: flex; flex-direction: column; gap: 3px; flex: none; }
.track-move .kickx { margin-left: 0; padding: 2px 5px; }
.track-move .kickx:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.track-move .kickx:disabled { opacity: .3; cursor: default; }
.track-card.is-dup { border-color: var(--warn); }
.chip.warn-chip { border-color: var(--warn); color: var(--warn); font-size: .72rem; }

/* ---------- Révélation : lien vers la piste (sans miniature, pour ne rien dévoiler) ---------- */
.reveal-video { display: inline-block; margin: 6px 0; text-decoration: none; }
.reveal-video:hover { color: var(--accent); }
