/* Bag Tag – Disc Is'R · direction « hybride » : en-tête noir, corps clair, accents citron */

:root {
  --lime: #c4da0b;
  --lime-soft: #f1f6c6;
  --ink: #141414;
  --ink-2: #2a2a2a;
  --text: #141414;
  --muted: #555b52;
  --bg: #f5f6f0;
  --card: #ffffff;
  --line: #e1e4d8;
  --blue: #6cc4ee;
  --blue-ink: #1b5f84;
  --up-bg: #dcf2e4;
  --up-ink: #1b6b3e;
  --down-bg: #fbe2db;
  --down-ink: #a63a22;
  --danger: #b3261e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 14px rgba(0, 0, 0, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Arial Black", "Helvetica Neue", Impact, system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--lime); color: var(--ink);
  padding: 10px 16px; border-radius: 8px; font-weight: 700;
}
.skip-link:focus { top: 12px; }

:focus-visible {
  outline: 3px solid var(--blue-ink);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ En-tête */
.site-header {
  background: var(--ink);
  color: #fff;
  position: sticky; top: 0; z-index: 20;
}
.header-inner {
  max-width: 1120px; margin: 0 auto;
  padding: 10px 16px;
  display: flex; align-items: center; gap: 12px;
}
.logo {
  width: 56px; height: 56px; flex: none;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 3px var(--ink), 0 0 0 5px var(--lime);
}
.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.45rem; letter-spacing: .02em; line-height: 1.1;
}
.brand h1 span { color: var(--lime); }
.brand p { margin: 2px 0 0; color: #cfd3c7; font-size: .9rem; }

.tabs {
  max-width: 1120px; margin: 0 auto;
  display: flex; gap: 4px;
  padding: 0 12px;
}
.tab {
  flex: 1;
  min-height: 48px;
  background: transparent; color: #d9dcd2;
  border: 0; border-bottom: 4px solid transparent;
  font: inherit; font-weight: 700; font-size: 1rem;
  cursor: pointer;
}
.tab:hover { color: #fff; }
.tab[aria-selected="true"] { color: var(--lime); border-bottom-color: var(--lime); }
.tab:focus-visible { outline-color: var(--lime); outline-offset: -3px; }

/* ------------------------------------------------------------------ Mise en page */
main {
  max-width: 1120px; margin: 0 auto;
  padding: 20px 16px 64px;
}
.panel h2 {
  font-family: var(--font-display);
  font-size: 1.25rem; margin: 0 0 14px;
}
.section-title {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap;
}
.hint { color: var(--muted); font-size: .9rem; margin: 0; }

@media (min-width: 960px) {
  .tabs { justify-content: flex-start; }
  .tab { flex: 0 0 auto; padding: 0 22px; }
  /* Sur grand écran, classement et historique côte à côte */
  #tab-history { display: none; }
  body[data-view="ranking"] .boards { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

/* ------------------------------------------------------------------ Podium */
.podium {
  list-style: none; margin: 0 0 16px; padding: 0;
  display: grid; gap: 10px;
}
.podium li {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--card);
  border: 2px solid var(--lime);
  box-shadow: var(--shadow);
}
.podium li.first {
  background: var(--lime);
  border-color: var(--lime);
  padding: 18px 16px;
}
.podium .tag-num {
  font-family: var(--font-display);
  font-size: 2rem; line-height: 1;
  min-width: 2.2ch; text-align: center;
  font-variant-numeric: tabular-nums;
}
.podium li.first .tag-num { font-size: 2.8rem; }
.podium .crown { font-size: 1.6rem; margin-left: auto; }
.podium .who { min-width: 0; }
.podium .name { font-weight: 800; font-size: 1.15rem; }
.podium li.first .name { font-size: 1.35rem; }
.podium .nick { color: var(--muted); font-size: .95rem; }
.podium li.first .nick { color: #2f3410; }
.podium .empty .name { color: var(--muted); font-weight: 600; }

/* ------------------------------------------------------------------ Classement 4–20 */
.ranking {
  list-style: none; margin: 0; padding: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.ranking li {
  display: flex; align-items: center; gap: 14px;
  min-height: 52px; padding: 8px 16px;
  border-top: 1px solid var(--line);
}
.ranking li:first-child { border-top: 0; }
.tag-badge {
  flex: none;
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--ink); color: #fff;
  font-weight: 800; font-variant-numeric: tabular-nums;
}
.ranking .name { font-weight: 700; }
.ranking .nick { color: var(--muted); margin-left: 6px; }
.ranking li.empty .tag-badge { background: #e7e9e0; color: var(--muted); }
.ranking li.empty .name { color: var(--muted); font-weight: 500; font-style: italic; }

/* ------------------------------------------------------------------ Historique */
.season-picker { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.season-picker label { font-weight: 700; }
.rounds { display: grid; gap: 12px; }
.round h3 { margin: 0 0 2px; font-size: 1.05rem; }
.round h3::first-letter { text-transform: uppercase; }
.round .meta { color: var(--muted); font-size: .9rem; margin: 0 0 10px; }
.moves { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.moves li {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 0;
  border-top: 1px dashed var(--line);
}
.moves li:first-child { border-top: 0; }
.place {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  display: inline-grid; place-items: center;
  background: #eceee6; font-weight: 800; font-size: .85rem;
}
.moves li:first-child .place { background: var(--lime); }
.moves .mv-name { font-weight: 700; }
.moves .mv-nick, .moves .mv-sep { color: var(--muted); }
.delta {
  margin-left: auto; white-space: nowrap;
  font-variant-numeric: tabular-nums; font-weight: 700;
  padding: 3px 10px; border-radius: 999px;
  background: #eceee6; color: var(--ink-2);
}
.delta.up { background: var(--up-bg); color: var(--up-ink); }
.delta.down { background: var(--down-bg); color: var(--down-ink); }

details.final { margin-top: 12px; }
details.final summary { cursor: pointer; font-weight: 700; min-height: 44px; display: flex; align-items: center; }
details.final ol { margin: 6px 0 0; padding-left: 0; list-style: none; columns: 2; column-gap: 20px; }
details.final li { padding: 3px 0; break-inside: avoid; }

.empty-state {
  text-align: center; color: var(--muted);
  padding: 28px 16px;
  border: 2px dashed var(--line); border-radius: var(--radius);
  background: transparent;
}

/* ------------------------------------------------------------------ Formulaires */
.admin-grid { display: grid; gap: 18px; }
@media (min-width: 960px) {
  .admin-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; }
  .admin-grid .span-all { grid-column: 1 / -1; }
  .admin-side { display: grid; gap: 18px; }
}
.card h2 { margin-bottom: 6px; }
.field { display: grid; gap: 6px; margin: 14px 0; }
.field label, .label { font-weight: 700; }
.field .opt { font-weight: 400; color: var(--muted); }
input[type="text"], input[type="password"], input[type="date"], select {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  font: inherit; font-size: 16px; /* évite le zoom iOS */
  color: var(--text);
  background: #fff;
  border: 2px solid #c9cdbf;
  border-radius: 10px;
}
input:focus-visible, select:focus-visible { border-color: var(--blue-ink); outline-offset: 0; }
.inline { display: flex; gap: 8px; }
.inline > input { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 18px;
  font: inherit; font-weight: 800;
  border-radius: 10px; border: 2px solid var(--ink);
  background: #fff; color: var(--ink);
  cursor: pointer;
}
.btn:hover { background: #f0f2ea; }
.btn-primary { background: var(--ink); color: var(--lime); }
.btn-primary:hover { background: #000; }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: #fdecea; }
.btn-small { min-height: 44px; padding: 8px 14px; font-weight: 700; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* Sélection des joueurs dans l'ordre d'arrivée */
.picker {
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  margin: 10px 0 14px;
}
.pick {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  min-height: 56px; padding: 8px 12px;
  text-align: left;
  font: inherit;
  background: #fff; color: var(--ink);
  border: 2px solid #c9cdbf; border-radius: 12px;
  cursor: pointer;
}
.pick .pk-tag { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.pick .pk-name { font-weight: 700; line-height: 1.15; overflow-wrap: anywhere; }
.pick .pk-order {
  flex: none;
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-grid; place-items: center;
  background: #eceee6; color: var(--muted); font-weight: 800;
}
.pick[aria-pressed="true"] { border-color: var(--ink); background: var(--lime-soft); }
.pick[aria-pressed="true"] .pk-order { background: var(--ink); color: var(--lime); }

.counter {
  display: inline-block; font-weight: 800;
  padding: 4px 12px; border-radius: 999px;
  background: var(--down-bg); color: var(--down-ink);
}
.counter.ok { background: var(--up-bg); color: var(--up-ink); }

.preview { margin: 14px 0; }
.preview h3 { font-size: 1rem; margin: 0 0 6px; }

.danger-zone { border-color: #efc4c0; }

/* ------------------------------------------------------------------ Messages */
.toast-zone {
  position: fixed; z-index: 50;
  left: 50%; top: 12px; transform: translateX(-50%);
  width: min(560px, calc(100% - 24px));
  display: grid; gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 14px 14px 16px;
  border-radius: 12px;
  font-weight: 700; font-size: 1rem;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .25);
  border-left: 8px solid;
  animation: drop .2s ease-out;
}
.toast.success { background: #eaf7ef; color: #0f4d2a; border-color: #2e9b5a; }
.toast.error { background: #fdecea; color: #7a1b14; border-color: var(--danger); }
.toast .ico { font-size: 1.2rem; line-height: 1.2; }
.toast .msg { flex: 1; }
.toast button {
  flex: none; width: 36px; height: 36px; margin: -6px -4px -6px 0;
  border: 0; border-radius: 8px; background: transparent; color: inherit;
  font-size: 1.4rem; line-height: 1; cursor: pointer;
}
.toast button:hover { background: rgba(0, 0, 0, .08); }
@keyframes drop { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }

.loading { color: var(--muted); padding: 20px 0; }

.site-footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 0 16px 28px; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

@media (min-width: 600px) {
  .logo { width: 68px; height: 68px; }
  .brand h1 { font-size: 1.8rem; }
}

/* ------------------------------------------------------------------ Corrections */
.admin-main { display: grid; gap: 18px; }
.edit-banner {
  margin: -4px 0 12px; padding: 10px 12px;
  border-radius: 10px; border-left: 6px solid var(--blue-ink);
  background: #e3f3fb; color: #0e3b52;
}
#round-form.is-editing { border: 2px solid var(--blue-ink); }
#round-title:focus { outline: none; }
.edit-actions { margin-top: 10px; }
.round-list { list-style: none; margin: 10px 0 0; padding: 0; }
.round-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 10px 0; border-top: 1px solid var(--line);
}
.round-list li:first-child { border-top: 0; }
.round-list li.editing { background: #eef7fc; margin: 0 -16px; padding: 10px 16px; }
.round-list .rl-info strong:first-child::first-letter { text-transform: uppercase; }
