/* Variables de charte communes : voir css/theme.css (chargé avant ce fichier) */
:root {
  --bg: var(--off-white);
  --panel: var(--white);
  --panel-alt: var(--tint);
  --primary: var(--navy-soft);
  --primary-dark: var(--navy);
  --success: #15803d;
  --text: var(--gray-900);
  --muted: var(--gray-600);
  --border: rgba(var(--brand-rgb), 0.14);
  --danger: #c44f57;
  --danger-hover: #ac3d47;
  --button-blue: #36536f;
  --button-blue-hover: #29435c;
  --warning: #f59e0b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: linear-gradient(180deg, var(--tint) 0%, var(--bg) 100%);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:disabled,
input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.app-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  position: relative;
}

.mobile-menu-toggle {
  display: none;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--navy);
  font-size: 2rem;
  line-height: 1;
}

.mobile-menu-toggle::before {
  content: "☰";
  display: block;
  line-height: 1;
}

.topbar-actions {
  display: flex;
  flex-wrap: nowrap;
  flex-shrink: 0;
  gap: 8px;
  align-items: center;
}

.topbar-actions button {
  height: 38px;
  padding: 0 14px;
  font-size: 0.82rem;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
}

.topbar-actions .menu-action {
  gap: 8px;
  height: 42px;
  padding: 0 10px;
  border-radius: 9px;
  background: transparent;
  color: var(--navy);
  white-space: nowrap;
}

.topbar-actions .menu-action:hover {
  background: var(--tint);
  color: var(--navy-dark);
  transform: none;
}

.menu-icon {
  display: inline-flex;
  width: 26px;
  align-items: center;
  justify-content: center;
  color: var(--navy-soft);
  font-size: 1.35rem;
  line-height: 1;
  font-weight: 700;
}

.topbar-actions .menu-primary {
  background: var(--lime);
  color: var(--navy);
  padding: 0 14px;
  margin-left: 0;
  border: 0;
}

.topbar-actions .menu-primary:hover {
  background: var(--lime-dark);
  color: var(--navy);
}

.topbar-actions .menu-primary .menu-icon {
  color: var(--pink);
}

.topbar-actions .menu-danger {
  margin-left: 6px;
  padding-left: 16px;
  border-left: 1px solid var(--border);
  color: var(--danger);
}

.topbar-actions .menu-danger .menu-icon {
  color: var(--danger);
}

.topbar-actions .menu-logout {
  position: relative;
  margin-left: 2px;
  padding-left: 14px;
  border-left: 1px solid var(--border);
  color: var(--danger);
}

.topbar-actions .menu-logout .menu-icon {
  color: var(--danger);
}

@media (min-width: 861px) {
  .topbar-actions .menu-logout {
    width: 42px;
    padding: 0;
    justify-content: center;
  }

  .topbar-actions .menu-logout .menu-label {
    display: none;
  }

  .topbar-actions .menu-logout::after {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 20;
    padding: 6px 9px;
    border-radius: 7px;
    background: var(--navy);
    color: var(--white);
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-3px);
    transition: opacity 0.15s ease, transform 0.15s ease;
  }

  .topbar-actions .menu-logout:hover::after,
  .topbar-actions .menu-logout:focus-visible::after {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 861px) {
  .topbar > div:first-child {
    flex: 0 0 auto;
  }

  .topbar h1 {
    white-space: nowrap;
    font-size: 1.5rem;
  }
}

.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

h1,
h2,
p {
  margin-top: 0;
}

h1,
h2 {
  font-family: var(--font-heading);
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 3vw, 2.4rem);
}

h2 {
  margin-bottom: 0;
}

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px;
  display: flex;
  flex-direction: column;
}

.panel-wide {
  grid-column: span 1;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.player-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  margin-bottom: 18px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.85rem;
}

.sort-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.tournament-selection-controls,
.member-list-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.tournament-selection-controls {
  justify-content: space-between;
}

.member-list-controls .members-search {
  flex: 1 1 260px;
}

.tournament-selection-controls .sort-control,
.member-list-controls .sort-control,
.member-list-controls .checkbox-label {
  margin: 0;
}

.sort-control select {
  min-width: 132px;
  padding-top: 8px;
  padding-bottom: 8px;
}

.checkbox-label input {
  accent-color: var(--primary);
}

.ratings-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.ratings-toggle input {
  appearance: none;
  flex: 0 0 44px;
  width: 44px;
  height: 24px;
  padding: 2px;
  border: 2px solid var(--muted);
  border-radius: 12px;
  background: white;
  cursor: pointer;
}

.ratings-toggle input::before {
  content: "";
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--muted);
}

.ratings-toggle input:checked {
  border-color: var(--navy);
  background: var(--navy);
}

.ratings-toggle input:checked::before {
  transform: translateX(20px);
  background: white;
}

.ratings-toggle input:focus-visible {
  outline: 2px solid var(--navy-soft);
  outline-offset: 3px;
}

.player-list-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.player-list-divider::before,
.player-list-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--border);
}

.player-form input,
.match-score,
.members-search,
.tournament-player-search > input {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
}

.tournament-player-search {
  position: relative;
  margin-bottom: 18px;
}

#players-modal .player-form input {
  min-width: 0;
}

.tournament-player-search > input {
  width: 100%;
}

.tournament-player-results {
  display: grid;
  gap: 8px;
  margin-top: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f9fbff;
}

.tournament-player-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.primary-btn {
  background: var(--lime);
  color: var(--navy);
}

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

.blue-btn,
.player-form button {
  background: var(--button-blue);
  color: var(--white);
}

.blue-btn:hover,
.player-form button:hover {
  background: var(--button-blue-hover);
}

.secondary-btn {
  background: #edf0f3;
  color: var(--navy);
}

.secondary-btn:hover {
  background: #dce2e7;
}

#history-toggle-btn:enabled {
  background: var(--button-blue);
  color: var(--white);
}

#history-toggle-btn:enabled:hover {
  background: var(--button-blue-hover);
}

.accent-btn {
  background: var(--lime);
  color: var(--navy);
}

.accent-btn:hover {
  background: var(--lime-dark);
}

.danger-btn {
  background: var(--danger);
  color: white;
}

.danger-btn:hover {
  background: var(--danger-hover);
}

.archive-delete-btn { background: var(--danger); color: var(--white); }
.archive-delete-btn:hover { background: var(--danger-hover); }

.success-btn {
  background: var(--lime);
  color: var(--navy);
}

.success-btn:hover {
  background: var(--lime-dark);
}

.player-list,
.ranking-list,
.matches-container,
.round-history,
.historical-player-list {
  display: grid;
  gap: 10px;
}

.player-item,
.ranking-item,
.history-item,
.historical-player-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f9fbff;
}

.player-meta,
.history-meta,
.player-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--primary-dark);
  background: linear-gradient(135deg, #dfeeff, #cfe3ff);
  overflow: hidden;
  border: 2px solid #dfe7f5;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.player-status {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.player-record {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: var(--primary-dark);
  font-size: 0.72rem;
  font-weight: 700;
}

.status-active {
  background: #dcfce7;
  color: #166534;
}

.status-inactive {
  background: #fef3c7;
  color: #92400e;
}

.status-removed {
  background: #fee2e2;
  color: #991b1b;
}

.selection-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #dcfce7;
  color: #166534;
  font-weight: 700;
}

.player-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.small-btn {
  padding: 6px 10px;
  font-size: 0.75rem;
  border-radius: 8px;
}

.modal button,
#player-list button,
.tournament-player-results button {
  min-height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
}

.modal .player-form button {
  width: 96px;
}

.toggle-btn {
  background: var(--lime);
  color: var(--navy);
}

.toolbar {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
  margin-bottom: 14px;
}

.toolbar-end {
  justify-content: flex-end;
  margin-top: 18px;
  margin-bottom: 0;
}

.round-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.round-actions button {
  flex: 1 1 180px;
}

.round-top-actions {
  display: none;
}

.modal .modal-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  flex: 0 0 36px;
  background: transparent;
  color: var(--navy);
}

.modal .modal-close-btn:hover {
  background: var(--tint);
}

.round-notice {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-left: 3px solid var(--warning);
  border-radius: 8px;
  background: #fffbeb;
  color: #92400e;
  font-size: 0.88rem;
}

.round-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 2px;
}

.player-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.8rem;
}

.match-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 14px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fbfdff;
}

.match-card .match-players:first-child {
  align-items: center;
  text-align: center;
}

.score-panel {
  display: flex;
  align-items: center;
  gap: 8px;
}

.match-players {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.96rem;
  text-align: center;
}

.match-tag {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.match-score {
  width: 78px;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 700;
  -moz-appearance: textfield;
}

.match-score::-webkit-outer-spin-button,
.match-score::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.vs {
  color: var(--muted);
  font-weight: 700;
}

.empty-state {
  color: var(--muted);
  font-style: italic;
}

.ranking-item strong {
  display: inline;
}

.ranking-label {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 5px;
}

.ranking-index {
  color: var(--muted);
  font-size: 0.8rem;
  font-style: italic;
  font-weight: 400;
}

.ranking-score {
  font-weight: 700;
  color: var(--primary-dark);
}

.winner-pill {
  background: #dcfce7;
  color: #166534;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.55);
  padding: 20px;
  overflow-y: auto;
}

.modal.hidden {
  display: none;
}

.modal-content {
  width: min(720px, 100%);
  max-height: calc(100dvh - 32px);
  background: white;
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
  overflow-y: auto;
}

.modal-small {
  width: min(400px, 100%);
}

#open-merge-members-btn {
  margin: 0 0 16px;
}

.merge-field {
  display: block;
  margin: 14px 0 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
}

#merge-target-select,
#merge-source-select,
#merge-confirmation {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--white);
  color: var(--text);
}

.modal-podium-content {
  width: min(760px, 100%);
}

.podium {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: end;
  gap: 12px;
  min-height: 260px;
  padding: 24px 12px 0;
}

.podium-place {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  min-width: 0;
  padding: 14px 10px;
  border-radius: 12px 12px 0 0;
  text-align: center;
}

.podium-silver {
  min-height: 150px;
  padding-top: 18px;
  background: #e5e7eb;
}

.podium-gold {
  min-height: 205px;
  padding-top: 18px;
  background: #fde68a;
}

.podium-bronze {
  min-height: 104px;
  gap: 4px;
  padding-top: 8px;
  padding-bottom: 8px;
  background: #fed7aa;
}

.podium-bronze .podium-medal {
  font-size: 2.65rem;
}

.podium-medal {
  font-size: 3.2rem;
  line-height: 1;
}

.podium-rank {
  color: var(--navy);
  font-size: 0.85rem;
}

.podium-names {
  display: block;
  max-width: 100%;
  max-height: 8rem;
  font-size: 1rem;
  line-height: 1.25;
  font-weight: 700;
  overflow-wrap: anywhere;
  overflow-y: auto;
}

.podium-person > span,
.podium-wins {
  display: block;
}

.podium-person + .podium-person {
  margin-top: 8px;
}

.podium-wins {
  margin-top: 2px;
  font-size: max(0.65rem, 0.75em);
  font-style: italic;
  font-weight: 400;
  line-height: 1.3;
}

.podium-bronze .podium-names {
  font-size: 0.95rem;
}

.podium-gold .podium-names {
  font-size: 1.3rem;
}

.podium-silver .podium-names {
  font-size: 1.1rem;
}

.countdown-message {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

.podium-empty {
  color: var(--muted);
  font-weight: 400;
}

.modal-message {
  font-size: 1rem;
  color: var(--text);
  white-space: pre-line;
}

select {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 36px 10px 12px;
  background-color: #fff;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'><path d='M1 1l6 6 6-6' fill='none' stroke='%230d3b39' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  color: var(--text);
  cursor: pointer;
}

.history-item,
.historical-player-item {
  font-size: 0.95rem;
}

.historical-player-item > .history-meta {
  min-width: 0;
  flex: 1 1 auto;
}

.historical-player-item .player-identity {
  min-width: 0;
  overflow-wrap: anywhere;
}

.historical-player-item .player-actions {
  flex: 0 0 auto;
}

.member-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.member-row .member-info {
  display: contents;
}

.member-row .member-info .player-identity {
  align-self: center;
  min-width: 0;
  display: block;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.member-row .member-info .player-identity strong {
  display: block;
}

.member-row .member-actions {
  align-items: center;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.history-meta-column {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  padding: 5px 8px;
  border-radius: 999px;
  background: #e0ecff;
  color: var(--primary-dark);
  font-weight: 700;
}

.modal-history-content {
  max-height: 80vh;
  overflow: auto;
}

.archived-round {
  display: block;
}

.history-round-title { display: block; width: 100%; padding: 8px 12px; border-radius: 6px; background: var(--button-blue); color: var(--white); }
.archived-team.is-winner { background: #edf5ce; color: #35541c; border-radius: 6px; padding: 6px 8px; font-weight: 700; }
.archived-score .is-winner { color: #35541c; }

.archived-round > .history-meta {
  width: 100%;
}

.archived-matches {
  display: grid;
  gap: 8px;
  width: 100%;
}

.archived-match {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 84px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}

.archived-team {
  min-width: 0;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.archived-match .archived-team:first-child {
  text-align: right;
}

.archived-score {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--navy);
  min-width: 72px;
  justify-content: center;
  font-size: 1.05rem;
}

.archived-vs {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.modal-help-content {
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
}

.help-intro {
  margin-bottom: 18px;
  color: var(--muted);
}

.help-sections {
  display: grid;
  gap: 14px;
}

.help-section {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.help-section:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.help-section h3 {
  margin: 0 0 5px;
  color: var(--navy);
  font-size: 1rem;
}

.help-section p {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.5;
}

.help-formula {
  padding: 10px 12px;
  border-left: 3px solid var(--pink);
  border-radius: 8px;
  background: var(--tint);
  color: var(--navy) !important;
  font-family: var(--font-heading);
  font-weight: 700;
}

.help-list {
  display: grid;
  gap: 6px;
  margin: 0 0 10px;
  padding-left: 20px;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.45;
}

.help-footer {
  margin: 20px 0 0;
  padding: 12px;
  border-radius: 10px;
  background: var(--tint);
  color: var(--navy);
  font-size: 0.82rem;
  line-height: 1.4;
}

@media (max-width: 860px) {
  .modal {
    align-items: flex-start;
    padding: 12px;
  }

  .modal-content {
    max-height: calc(100dvh - 24px);
    padding: 16px;
  }

  .modal-help-content {
    max-height: calc(100dvh - 24px);
  }

  .archived-match {
    grid-template-columns: minmax(0, 1fr) 64px;
    justify-items: stretch;
    text-align: left;
  }

  .archived-match .archived-team {
    grid-column: 1;
  }

  .archived-match .archived-team::after {
    content: " :";
  }

  .archived-match .archived-team:first-child {
    grid-row: 1;
    text-align: left;
  }

  .archived-match .archived-team:last-child {
    grid-row: 2;
  }

  .archived-score {
    display: contents;
  }

  .archived-score .archived-vs {
    display: none;
  }

  .archived-score strong {
    grid-column: 2;
    text-align: center;
  }

  .archived-score strong:first-child {
    grid-row: 1;
  }

  .archived-score strong:last-child {
    grid-row: 2;
  }

  .player-item,
  .historical-player-item {
    align-items: flex-start;
  }

  .player-item .player-meta,
  .historical-player-item .history-meta {
    min-width: 0;
  }

  .player-item .player-identity,
  .historical-player-item .player-identity {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .player-item > button,
  .historical-player-item > button {
    flex: 0 0 112px;
    width: 112px;
    white-space: normal;
  }

  .historical-player-item > .history-meta {
    flex-wrap: nowrap;
  }

  .historical-player-item > .history-meta > strong {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .panel-wide {
    grid-column: span 1;
  }

  .match-card {
    grid-template-columns: minmax(0, 1fr) 64px;
    justify-items: stretch;
    gap: 8px;
  }

  .match-card .match-players:first-child {
    grid-row: 1;
    align-items: flex-start;
    text-align: left;
  }

  .match-card .match-players {
    grid-column: 1;
    min-width: 0;
    align-items: flex-start;
    text-align: left;
    overflow-wrap: anywhere;
  }

  .match-card .match-players:last-child {
    grid-row: 2;
  }

  .match-card .match-players > span:last-child::after {
    content: " :";
  }

  .match-card .score-panel {
    display: contents;
  }

  .match-card .score-panel .vs {
    display: none;
  }

  .match-card .match-score {
    grid-column: 2;
    width: 64px;
    min-width: 0;
  }

  .match-card .match-score:first-child {
    grid-row: 1;
  }

  .match-card .match-score:last-child {
    grid-row: 2;
  }

  .topbar {
    align-items: center;
  }

  .mobile-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
  }

  .topbar-actions {
    display: none;
    position: absolute;
    z-index: 10;
    top: calc(100% + 8px);
    right: 0;
    width: min(260px, 100%);
    padding: 8px;
    flex-direction: column;
    align-items: stretch;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
  }

  .topbar.menu-open .topbar-actions {
    display: flex;
  }

  .topbar-actions button {
    width: 100%;
    justify-content: flex-start;
    gap: 12px;
    height: 44px;
    padding: 0 12px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--navy);
    font-size: 0.88rem;
    font-weight: 600;
    transform: none;
  }

  .topbar-actions .menu-primary,
  .topbar-actions .menu-danger,
  .topbar-actions .menu-logout {
    margin-left: 0;
    padding-left: 12px;
    border-left: 0;
  }

  .topbar-actions .menu-primary,
  .topbar-actions .menu-danger {
    display: none;
  }

  .round-top-actions {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
  }

  .round-top-actions button {
    width: 100%;
  }

  .tournament-selection-controls {
    align-items: stretch;
  }

  .tournament-selection-controls .primary-btn {
    width: 100%;
  }

  .member-list-controls {
    align-items: flex-start;
  }

  .topbar-actions .menu-logout .menu-label {
    display: inline;
  }

  .topbar-actions button:hover {
    background: var(--tint);
    color: var(--navy-dark);
    transform: none;
  }

  .menu-icon {
    display: inline-flex;
    width: 22px;
    justify-content: center;
    color: var(--navy-soft);
    font-size: 1.15rem;
    font-weight: 700;
  }

  .menu-primary {
    margin-top: 6px;
    border-top: 1px solid var(--border) !important;
    border-radius: 0 0 9px 9px !important;
    padding-top: 8px !important;
    height: 52px !important;
    color: var(--pink) !important;
  }

  .menu-primary .menu-icon {
    color: var(--pink);
  }

  .menu-logout {
    margin-top: 6px;
    border-top: 1px solid var(--border) !important;
    border-radius: 0 0 9px 9px !important;
    padding-top: 8px !important;
    height: 52px !important;
    color: var(--danger) !important;
  }

  .menu-logout .menu-icon {
    color: var(--danger);
  }
}

.hidden {
  display: none !important;
}

.login-logo { width: 96px; height: 96px; object-fit: contain; align-self: center; }
.flash-info-form { display: grid; gap: 10px; margin-bottom: 24px; }
.flash-info-form textarea,
.flash-info-form input {
  width: 100%;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  color: var(--text);
  background: var(--white);
}
.flash-info-form textarea { resize: vertical; }
.flash-info-form output { text-align: right; color: var(--muted); font-size: 0.8rem; }
.flash-info-dates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.flash-info-dates label { display: grid; gap: 6px; min-width: 0; }
.flash-info-dates input { width: 100%; min-width: 0; max-width: 100%; }
.flash-info-item { flex-direction: column; align-items: stretch; }
.flash-info-item .history-meta { align-items: flex-start; min-width: 0; }
.flash-info-item .player-actions { justify-content: flex-end; }
.flash-info-message { margin: 0; white-space: pre-line; overflow-wrap: anywhere; max-width: 100%; }

/* ===== Ecran de connexion ===== */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(180deg, var(--tint) 0%, var(--off-white) 100%);
}

.login-card {
  width: min(380px, 100%);
  background: var(--panel);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-card label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  margin-top: 6px;
}

.login-card input {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
}

.login-subtitle {
  color: var(--muted);
  font-size: 0.92rem;
}

.login-error {
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 600;
}

.login-back {
  margin-top: 10px;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: none;
}

.login-back:hover {
  color: var(--primary-dark);
}

.modal-hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.leaderboard-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.leaderboard-tabs {
  display: inline-flex;
  gap: 4px;
  margin-bottom: 16px;
  padding: 4px;
  border-radius: 10px;
  background: var(--tint);
}

.leaderboard-tab {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 7px;
  background: transparent;
  color: var(--navy);
  font-size: 0.82rem;
}

.leaderboard-tab:hover {
  background: rgba(255, 255, 255, 0.7);
}

.leaderboard-tab.is-active {
  background: var(--white);
  box-shadow: 0 1px 3px rgba(var(--brand-rgb), 0.16);
}

.leaderboard-columns h3 {
  margin-bottom: 10px;
}

.icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn,
.modal .icon-btn,
.topbar-actions .icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  min-width: 38px;
  padding: 0;
}

.members-hide-toggle { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; cursor: pointer; font-size: 0.85rem; }
.members-hide-toggle input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.member-filter-track { position: relative; display: inline-block; flex: 0 0 44px; height: 26px; border: 1px solid var(--border); border-radius: 999px; background: #e5e7eb; }
.member-filter-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--white); transition: transform 0.15s ease; }
.members-hide-toggle input:checked + .member-filter-track { background: var(--lime); }
.members-hide-toggle input:checked + .member-filter-track::after { transform: translateX(18px); }
.members-hide-toggle input:focus-visible + .member-filter-track { outline: 2px solid var(--navy-soft); outline-offset: 3px; }

.modal .member-status-toggle {
  position: relative;
  width: 82px;
  min-width: 82px;
  height: 36px;
  padding: 0 30px 0 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #e5e7eb;
  color: var(--navy);
  text-align: left;
}
.member-status-toggle::after {
  content: "";
  position: absolute;
  top: 5px;
  left: 5px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 1px 3px rgba(var(--brand-rgb), 0.2);
  transition: left 0.15s ease;
}
.modal .member-status-toggle[aria-checked="false"] { padding: 0 8px 0 34px; text-align: right; }
.modal .member-status-toggle[aria-checked="true"] { background: var(--lime); }
.member-status-toggle[aria-checked="true"]::after { left: 51px; }
.modal .member-status-toggle:not(:disabled):hover { background: #d1d5db; transform: none; }
.modal .member-status-toggle[aria-checked="true"]:not(:disabled):hover { background: var(--lime-dark); }
.member-status-toggle:focus-visible { outline: 2px solid var(--navy-soft); outline-offset: 3px; }
.modal .member-edit-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 6px; background: transparent; color: var(--button-blue); }
.modal .member-edit-btn:hover { background: #e5edf5; }
.tournament-player-result > .player-identity { min-width: 0; overflow-wrap: anywhere; }
.tournament-player-result > button { flex-shrink: 0; }

.management-nav { position: relative; }
@media (max-width: 860px) {
  #management-toggle-btn { display: none; }
  .management-nav { display: contents; }
  #management-menu { display: contents !important; }
}
.management-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 30;
  min-width: 180px;
  padding: 6px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.management-menu .menu-action { width: 100%; }
.tournament-start-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tournament-start-controls output { color: var(--navy); font-size: 0.85rem; font-weight: 600; white-space: nowrap; }
.tournament-start-controls #start-tournament-btn { width: auto; }
.modal #start-tournament-btn { background: var(--lime); color: var(--navy); }
.modal #start-tournament-btn:hover { background: var(--lime-dark); }
.tournament-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.finish-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: #865800; color: var(--white); }
.finish-btn:hover { background: #694500; }
.cancel-tournament-action { background: transparent; color: var(--danger); padding: 8px; font-size: 0.8rem; }
.cancel-tournament-action:hover { background: #fef2f2; }
#tournaments-list > .history-item { display: grid; grid-template-columns: minmax(0, 1fr) max-content; }
#tournaments-list .history-meta { min-width: 0; overflow-wrap: anywhere; }
#tournaments-list .player-actions { flex-wrap: nowrap; }

@media (min-width: 861px) and (max-width: 1100px) {
  .topbar { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 860px) {
  .management-menu { position: static; margin-top: 6px; box-shadow: none; }
  .tournament-start-controls { width: 100%; }
}

@media (max-width: 640px) {
  .member-row { grid-template-columns: 42px minmax(0, 1fr); }
  .member-row .member-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .round-actions { display: grid; grid-template-columns: minmax(0, 1fr); }
  .tournament-actions { flex-direction: column; align-items: stretch; }
  .tournament-actions button { width: 100%; }
  .flash-info-dates { grid-template-columns: 1fr; }
  .flash-info-form .toolbar { flex-wrap: wrap; }
  #tournaments-list > .history-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) max-content;
    align-items: start;
  }

  #tournaments-list .history-meta {
    display: contents;
  }

  #tournaments-list .history-meta > strong {
    grid-column: 1 / -1;
    white-space: nowrap;
  }

  #tournaments-list .history-meta > small {
    grid-column: 1;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  #tournaments-list .player-actions {
    grid-column: 2;
    grid-row: 2 / span 2;
    flex-direction: column;
    flex-wrap: nowrap;
    justify-content: flex-end;
    margin-left: auto;
  }

  #tournaments-list .player-actions button {
    width: 100%;
  }

  .leaderboard-columns {
    grid-template-columns: 1fr;
  }

  .podium {
    min-height: 210px;
    gap: 6px;
    padding: 16px 0 0;
  }

  .podium-place {
    padding: 8px 3px;
    gap: 3px;
    min-height: 0;
    overflow: hidden;
  }

  .podium-silver {
    height: 132px;
    min-height: 0;
  }

  .podium-gold {
    height: 176px;
    min-height: 0;
  }

  .podium-bronze {
    height: 104px;
    min-height: 0;
  }

  .podium-names {
    max-height: 5.5rem;
    font-size: 0.72rem;
    line-height: 1.15;
  }

  .podium-medal {
    font-size: 1.8rem;
  }

  .podium-rank {
    font-size: 0.72rem;
  }

  .podium-gold .podium-names {
    font-size: 0.82rem;
  }

  .podium-silver .podium-names,
  .podium-bronze .podium-names {
    font-size: 0.72rem;
  }

  .podium-bronze .podium-medal {
    font-size: 1.6rem;
  }
}
