:root {
  --color-primary: #1864af;
  --color-primary-dark: #124a82;
  --color-primary-darker: #0e3863;
  --color-primary-hover: #2d92cb;
  --color-accent: #f4a300;
  --color-accent-dark: #c97f00;
  --color-success: #2e9e5b;
  --color-success-bg: #e8f6ee;
  --color-danger: #d63b3b;
  --color-bg: #f5f8fc;
  --color-card: #ffffff;
  --color-text: #2d2d2d;
  --color-muted: #6b7280;
  --radius: 16px;
  --shadow: 0 4px 14px rgba(24, 100, 175, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
}

/* ===== Top bar ===== */
.topbar {
  background: linear-gradient(120deg, var(--color-primary), var(--color-primary-darker));
  color: #fff;
  min-height: 112px;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  box-shadow: var(--shadow);
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 16px;
  font-weight: 700;
  font-size: 1.3rem;
}

.brand .logo {
  width: 236px;
  height: 79px;
  object-fit: contain;
  background: #fff;
  border-radius: 6px;
  padding: 4px;
  flex-shrink: 0;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 18px 60px;
}

footer {
  text-align: center;
  padding: 20px;
  color: var(--color-muted);
  font-size: 0.8rem;
}

/* ===== Hero ===== */
.page-hero {
  text-align: center;
  padding: 10px 20px 24px;
}

.page-hero h1 {
  font-size: 1.7rem;
  color: var(--color-primary-darker);
  margin: 6px 0 4px;
}

.page-hero p {
  color: var(--color-muted);
  max-width: 700px;
  margin: 0 auto;
}

/* ===== Cartes ===== */
.card {
  background: var(--color-card);
  border-radius: var(--radius);
  border: 1px solid #e2e9f3;
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 22px;
}

.card h2 {
  margin: 0 0 14px;
  font-size: 1.15rem;
  color: var(--color-primary-darker);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card h2 .step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: 0.85rem;
  flex-shrink: 0;
}

/* ===== Sélecteur du nombre de joueurs ===== */
.count-selector {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.count-btn {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 2px solid #dbe4f0;
  background: #fff;
  color: var(--color-primary-darker);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition: 0.2s;
}

.count-btn:hover {
  border-color: var(--color-primary-hover);
}

.count-btn.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
  transform: scale(1.06);
}

/* ===== Joueurs ===== */
.player-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.player-field {
  display: flex;
  align-items: center;
  gap: 10px;
}

.player-field .order-badge {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #eaf3fc;
  color: var(--color-primary-darker);
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-field input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #dbe4f0;
  font-size: 0.95rem;
  color: var(--color-text);
  background: #fff;
}

.player-field input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(24,100,175,0.12);
}

.hint {
  font-size: 0.82rem;
  color: var(--color-muted);
  margin-top: 10px;
}

/* ===== Boutons ===== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 13px 26px;
  border-radius: 24px;
  cursor: pointer;
  transition: 0.2s;
  box-shadow: var(--shadow);
}

.btn-primary:hover { background: var(--color-primary-dark); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid #dbe4f0;
  color: var(--color-primary-darker);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 10px 18px;
  border-radius: 20px;
  cursor: pointer;
  transition: 0.2s;
}

.btn-secondary:hover {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.actions-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 20px;
}

/* ===== Notes / alertes ===== */
.note {
  background: #fff7e6;
  border: 1px solid #f4d792;
  color: #8a6d1f;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.note.info {
  background: #eaf3fc;
  border-color: #bcd7f2;
  color: var(--color-primary-darker);
}

/* ===== Tours de jeu ===== */
.tour-block {
  margin-bottom: 20px;
}

.tour-block h3 {
  margin: 0 0 10px;
  font-size: 1rem;
  color: var(--color-primary-darker);
  display: flex;
  align-items: center;
  gap: 8px;
}

.tour-block h3 .tour-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 12px;
  background: var(--color-accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
}

.match-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #f9fbff;
  border: 1px solid #e2e9f3;
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.billard-badge {
  flex-shrink: 0;
  background: var(--color-primary-darker);
  color: #fff;
  font-weight: 700;
  font-size: 0.78rem;
  padding: 6px 12px;
  border-radius: 20px;
  min-width: 92px;
  text-align: center;
}

.billard-badge.exempt {
  background: var(--color-muted);
}

.match-players {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  min-width: 200px;
  flex-wrap: wrap;
}

.match-players .vs {
  color: var(--color-muted);
  font-weight: 400;
  font-size: 0.85rem;
}

.pname {
  color: var(--color-text);
}

.pname.placeholder {
  color: var(--color-muted);
  font-style: italic;
  font-weight: 400;
}

.winner-select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #dbe4f0;
  font-size: 0.85rem;
  background: #fff;
  color: var(--color-text);
}

.winner-select-label {
  font-size: 0.78rem;
  color: var(--color-muted);
  margin-right: 4px;
}

/* ===== Table poule fixe (5 et 6 joueurs) ===== */
.tour-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 8px;
  font-size: 0.92rem;
}

.tour-table th, .tour-table td {
  border: 1px solid #e2e9f3;
  padding: 10px 12px;
  text-align: center;
}

.tour-table th {
  background: var(--color-primary);
  color: #fff;
  font-weight: 700;
}

.tour-table tr:nth-child(even) td {
  background: #f9fbff;
}

.tour-table .exempt-cell {
  color: var(--color-muted);
  font-style: italic;
}

/* ===== Rencontre unique (poule de 2) ===== */
.duel-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 26px;
  background: linear-gradient(120deg, #eaf3fc, #f9fbff);
  border-radius: var(--radius);
  border: 1px solid #dbe4f0;
  flex-wrap: wrap;
  text-align: center;
}

.duel-card .duel-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-primary-darker);
}

.duel-card .duel-vs {
  font-size: 1rem;
  color: var(--color-muted);
  font-weight: 600;
}

.duel-format {
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--color-muted);
  text-align: center;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 0.88rem;
  color: var(--color-muted);
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-muted);
}

.empty-state .emoji {
  font-size: 2.6rem;
  display: block;
  margin-bottom: 10px;
}

@media (max-width: 700px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .match-row { flex-direction: column; align-items: stretch; }
  .billard-badge { text-align: left; }
}

@media print {
  .topbar, footer, .no-print { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: none; }
}
