/* briques.css — Duel de Briques (1v1 en ligne) */

:root {
  --bg: #0c0e1c;
  --bg-panel: #171a30;
  --bg-card: #212540;
  --border: #2e3355;
  --me: #3b9dff;
  --opp: #ff6b6b;
  --gold: #e8c257;
  --text: #e9ecf5;
  --text-dim: #979ec0;
  --danger: #e05555;
  --success: #7ed957;
}

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

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

h1 { font-family: Georgia, serif; }

.hidden { display: none !important; }
.dim { color: var(--text-dim); }

/* ── Écrans ── */
.screen { display: none; min-height: 100vh; }
.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: fade-in 0.3s ease;
  padding: 1rem;
}
#screen-game.active { justify-content: flex-start; padding: 0.4rem 0.8rem 0.8rem; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ── Boutons & champs ── */
.btn {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: filter 0.15s ease;
  font-family: inherit;
}

.btn:hover { filter: brightness(1.3); }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-primary {
  background: linear-gradient(180deg, var(--gold), #b8933a);
  border-color: #b8933a;
  color: #241d05;
  font-weight: 800;
}
.btn-big { font-size: 1.1rem; padding: 0.75rem 1.8rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 0.4rem 0.6rem; }

.field { display: flex; flex-direction: column; gap: 0.3rem; text-align: left; font-size: 0.88rem; color: var(--text-dim); width: 100%; }

input[type='text'] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 0.6rem 0.8rem;
  font-size: 1rem;
  outline: none;
  width: 100%;
}

input:focus { border-color: var(--me); }

/* ── Cartes (accueil, salon, fin) ── */
.card {
  width: min(430px, 100%);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1.8rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  text-align: center;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
}

.card-wide { width: min(560px, 100%); }
.card-art { font-size: 3.6rem; filter: drop-shadow(0 8px 20px rgba(255, 107, 107, 0.35)); }
.card-title { font-size: 2rem; color: var(--gold); }
.card-lead { color: var(--text-dim); font-size: 0.92rem; line-height: 1.55; }

.join-row { display: flex; gap: 0.5rem; width: 100%; }
.join-row input { width: 120px; text-align: center; text-transform: uppercase; letter-spacing: 0.35em; font-weight: 800; }
.join-row .btn { flex: 1; }

.rules { width: 100%; text-align: left; }
.rules summary { cursor: pointer; color: var(--text-dim); font-size: 0.9rem; }
.rules-body { display: grid; gap: 0.5rem; padding: 0.7rem 0.2rem 0; font-size: 0.84rem; color: var(--text-dim); line-height: 1.5; }
.rules-body strong { color: var(--text); }

.code-row { display: flex; align-items: center; gap: 0.6rem; }
.room-code {
  font-size: 2.6rem;
  font-weight: 900;
  letter-spacing: 0.35em;
  color: var(--gold);
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 0.3rem 0.6rem 0.3rem 1rem;
}

.players-list { list-style: none; display: flex; flex-direction: column; gap: 0.45rem; width: 100%; }
.player-chip { background: var(--bg-card); border-radius: 9px; padding: 0.5rem 0.7rem; font-size: 0.92rem; }
.player-chip.empty { color: var(--text-dim); border: 1px dashed var(--border); background: transparent; }
.room-hint { color: var(--text-dim); font-size: 0.86rem; }
.row-center { display: flex; gap: 0.7rem; justify-content: center; align-items: center; flex-wrap: wrap; }

/* ── En-tête de match ── */
.match-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  width: 100%;
  max-width: 1100px;
  padding: 0.3rem 0;
}

.mt-side { display: flex; align-items: center; gap: 0.6rem; }
.mt-side.right { flex-direction: row; }

.mt-player { display: flex; flex-direction: column; align-items: flex-start; min-width: 110px; }
.mt-side.right .mt-player { align-items: flex-end; }
.mt-name { font-size: 0.75rem; color: var(--text-dim); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-player.me .mt-name { color: var(--me); }
.mt-player.opp .mt-name { color: var(--opp); }
.mt-score { font-size: 1.5rem; font-weight: 900; font-variant-numeric: tabular-nums; }

.mt-center { display: flex; flex-direction: column; align-items: center; }

.hud-timer {
  font-size: 1.9rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.1rem 1.2rem;
}

.hud-timer.urgent { color: var(--danger); border-color: var(--danger); animation: pulse-danger 1s ease-in-out infinite; }

@keyframes pulse-danger {
  0%, 100% { box-shadow: 0 0 0 rgba(224, 85, 85, 0); }
  50% { box-shadow: 0 0 18px rgba(224, 85, 85, 0.55); }
}

.mt-coins { font-size: 0.9rem; color: var(--gold); font-weight: 800; margin-top: 0.15rem; }

/* ── Effets actifs ── */
.effects-row {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 1100px;
  min-height: 24px;
  gap: 0.5rem;
}

.effects { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.effects.opp { justify-content: flex-end; }

.chip { font-size: 0.72rem; padding: 0.12rem 0.5rem; border-radius: 99px; font-variant-numeric: tabular-nums; }
.chip-buff { background: rgba(126, 217, 87, 0.14); border: 1px solid var(--success); color: var(--success); }
.chip-malus { background: rgba(224, 85, 85, 0.14); border: 1px solid var(--danger); color: var(--danger); }

/* ── Canvas ── */
.canvas-wrap {
  position: relative;
  width: 100%;
  max-width: min(1100px, calc((100vh - 260px) * 1.5375));
  aspect-ratio: 984 / 640;
  margin: 0.3rem auto;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 10px;
  cursor: default; /* la souris ne contrôle pas la raquette */
}

/* combo flottant */
.combo-box {
  position: absolute;
  top: 10px;
  left: 12px;
  background: rgba(12, 14, 28, 0.85);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 0.35rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  pointer-events: none;
}

.combo-n { font-weight: 900; color: var(--gold); font-size: 1rem; }
.combo-mult { font-size: 0.72rem; color: var(--text-dim); }
.combo-track { height: 4px; background: var(--bg); border-radius: 2px; overflow: hidden; width: 110px; }
.combo-bar { height: 100%; background: var(--gold); transition: width 0.1s linear; }

/* bandeau (prolongation, séries…) */
.banner {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background: rgba(12, 14, 28, 0.9);
  border: 1px solid var(--gold);
  color: var(--gold);
  font-weight: 900;
  font-size: 1.15rem;
  padding: 0.6rem 1.4rem;
  border-radius: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  text-align: center;
  max-width: 90%;
}

.banner.visible { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* ── Malus (8 boutons cliquables) + légende ── */
.bottom-row {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  width: 100%;
  max-width: 1100px;
  flex-wrap: wrap;
}

.malus-block { flex: 1; min-width: 340px; display: flex; flex-direction: column; gap: 0.3rem; }
.malus-title { font-size: 0.68rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }

.malus-bar {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.35rem;
}

.malus-item {
  position: relative;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--danger);
  border-radius: 9px;
  color: var(--text);
  padding: 0.35rem 0.15rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.05rem;
  transition: filter 0.12s ease, box-shadow 0.15s ease;
  font-family: inherit;
}

.malus-item.unknown { opacity: 0.4; cursor: default; border-left-color: var(--border); }
.malus-item.ready { box-shadow: 0 0 0 1px var(--danger), 0 0 10px rgba(224, 85, 85, 0.35); }
.malus-item.ready:hover { filter: brightness(1.4); }
.malus-item.blocked { opacity: 0.45; }
.malus-item:not(.ready):not(.unknown) { opacity: 0.6; }

.mi-emoji { font-size: 1.1rem; }
.mi-name { font-size: 0.54rem; color: var(--text-dim); text-align: center; line-height: 1.05; }

.mi-cd {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.95rem;
  pointer-events: none;
}

.mi-cd:empty { display: none; }
.malus-item .mi-cd:not(:empty) {
  background: rgba(8, 10, 22, 0.72);
  border-radius: 9px;
}

/* ── Combo permanent (sous le chrono) ── */
.perm-combo {
  margin-top: 0.15rem;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--gold);
  background: rgba(232, 194, 87, 0.1);
  border: 1px solid rgba(232, 194, 87, 0.4);
  border-radius: 99px;
  padding: 0.12rem 0.8rem;
}

/* ── Choix de la durée (salon) ── */
.duration-block { width: 100%; display: flex; flex-direction: column; gap: 0.45rem; }
.duration-label { font-size: 0.85rem; color: var(--text-dim); }

.duration-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.4rem; }

.duration-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 0.55rem 0.2rem;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: filter 0.12s ease;
}

.duration-btn:hover:not(:disabled) { filter: brightness(1.35); }
.duration-btn.selected { border-color: var(--gold); color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.duration-btn:disabled { cursor: default; opacity: 0.75; }

.end-title { font-family: Georgia, serif; font-size: 2rem; }

.legend {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.62rem;
  color: var(--text-dim);
}

.legend span { display: flex; align-items: center; gap: 0.3rem; }
.legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }

/* ── Fin ── */
.end-stats { border-collapse: collapse; font-size: 0.9rem; width: 100%; }
.end-stats th, .end-stats td { padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--border); text-align: center; }
.end-stats th { color: var(--text-dim); font-size: 0.72rem; text-transform: uppercase; }
.winner-row { background: rgba(232, 194, 87, 0.08); }

/* ── Toasts & connexion ── */
.toasts {
  position: fixed;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  z-index: 400;
  pointer-events: none;
  width: min(440px, calc(100vw - 2rem));
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.visible { opacity: 1; transform: none; }
.toast-danger { border-color: var(--danger); }
.toast-success { border-color: var(--success); }

.conn-status {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  background: var(--bg-card);
  border: 1px solid var(--gold);
  border-radius: 99px;
  padding: 0.45rem 1.1rem;
  font-size: 0.88rem;
}

/* ── Responsive ── */
@media (max-width: 860px) {
  .malus-bar { grid-template-columns: repeat(4, 1fr); }
  .mi-name { display: none; }
  .legend { display: none; }
  .mt-score { font-size: 1.15rem; }
  .hud-timer { font-size: 1.4rem; }
  .perm-combo { font-size: 0.7rem; }
  .canvas-wrap { max-width: 100%; }
}
