/* Layout: une colonne, import en haut, classement en dessous.
   Couleurs reprises de la légende d'une carte de CO : papier, tracé violet, forêt, ouvert. */
:root {
  --bg: #f4f6f2;
  --surface: #ffffff;
  --ink: #1c2420;
  --muted: #5a675f;
  --line: #d6ddd5;
  --course: #a8137a;
  --course-soft: #f6e4ef;
  --forest: #dcefd2;
  --forest-ink: #2b5a1a;
  --open: #faefb4;
  --open-ink: #675700;
  --none-ink: #5a675f;
  --warn: #8a3b00;
  --warn-bg: #fde8d4;
  --font-display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --font-body: "IBM Plex Sans", system-ui, sans-serif;
  --font-data: "IBM Plex Mono", ui-monospace, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111713;
    --surface: #19211c;
    --ink: #e5ebe6;
    --muted: #9aa99f;
    --line: #2c3a31;
    --course: #ec6fc3;
    --course-soft: #3a1c31;
    --forest: #213a1a;
    --forest-ink: #a9dc8f;
    --open: #3a3410;
    --open-ink: #ecd873;
    --none-ink: #9aa99f;
    --warn: #ffb878;
    --warn-bg: #3d2410;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111713;
  --surface: #19211c;
  --ink: #e5ebe6;
  --muted: #9aa99f;
  --line: #2c3a31;
  --course: #ec6fc3;
  --course-soft: #3a1c31;
  --forest: #213a1a;
  --forest-ink: #a9dc8f;
  --open: #3a3410;
  --open-ink: #ecd873;
  --none-ink: #9aa99f;
  --warn: #ffb878;
  --warn-bg: #3d2410;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  padding-block: 28px 56px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.wrap { max-width: 1040px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }
.top { display: flex; flex-direction: column; gap: 10px; }
.course-line { width: 190px; max-width: 60%; height: auto; color: var(--course); }
h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  line-height: 1;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  margin: 0;
  text-wrap: balance;
}
.lead { margin: 0; color: var(--muted); max-width: 62ch; }
h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.35rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0 0 6px;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.hint { margin: 0; color: var(--muted); max-width: 70ch; }
textarea {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  font-family: var(--font-data);
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px;
  white-space: pre;
  overflow: auto;
}
.row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
button, select, input[type="number"], input[type="search"] {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 7px 12px;
}
button { cursor: pointer; font-weight: 500; }
button:hover { border-color: var(--course); }
button.primary { background: var(--course); color: #fff; border-color: var(--course); }
:root[data-theme="dark"] button.primary { color: #1a0c14; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) button.primary { color: #1a0c14; } }
:focus-visible { outline: 2px solid var(--course); outline-offset: 2px; }
input[type="number"] { width: 5.2em; font-family: var(--font-data); }
label { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.info { color: var(--muted); font-size: 13px; }
.banner {
  background: var(--warn-bg);
  color: var(--warn);
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 14px;
}
.summary { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 0; padding: 0; }
.summary div { display: flex; flex-direction: column; min-width: 0; }
.summary dt { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.summary dd { margin: 0; font-family: var(--font-data); font-size: 18px; font-weight: 500; }
.tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.tools .row { gap: 10px; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; min-width: 700px; }
th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-family: var(--font-data); font-variant-numeric: tabular-nums; }
th.num { font-family: var(--font-body); }
.rank { font-family: var(--font-data); font-variant-numeric: tabular-nums; color: var(--muted); }
.team { font-weight: 600; }
.lig { font-family: var(--font-data); font-size: 12px; color: var(--muted); }
.members { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; font-size: 13px; min-width: 15rem; }
.members li { display: flex; gap: 6px; min-width: 0; }
.members .sx { font-family: var(--font-data); color: var(--course); width: 1ch; flex: none; }
.members .nm { overflow-wrap: anywhere; }
.members .pt { font-family: var(--font-data); color: var(--muted); margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }
.members li:nth-child(2) { margin-bottom: 5px; padding-bottom: 5px; border-bottom: 1px dotted var(--line); }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; white-space: nowrap; }
.pill.Q { background: var(--forest); color: var(--forest-ink); }
.pill.C { background: var(--open); color: var(--open-ink); }
.pill.X { background: transparent; color: var(--none-ink); border: 1px solid var(--line); }
.tie { display: block; margin-top: 4px; font-size: 12px; color: var(--warn); }
tr.Q td:first-child { box-shadow: inset 4px 0 0 var(--forest-ink); }
tr.C td:first-child { box-shadow: inset 4px 0 0 var(--open-ink); }
tr.cutline td { border-bottom: 2px solid var(--course); }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
details { color: var(--muted); font-size: 14px; }
summary { cursor: pointer; font-weight: 500; color: var(--ink); }
details ul { margin: 8px 0 0; padding-left: 1.2em; }
.foot { color: var(--muted); font-size: 13px; max-width: 76ch; margin: 0; }
@media (prefers-reduced-motion: no-preference) {
  button { transition: border-color 0.15s; }
}

.top-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
button.ghost { background: transparent; color: var(--muted); }
.flash { border-radius: 4px; padding: 8px 12px; font-size: 14px; }
.flash.ok { background: var(--forest); color: var(--forest-ink); }
.flash.error { background: var(--warn-bg); color: var(--warn); }
code { font-family: var(--font-data); font-size: 0.92em; }
h3 { font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; letter-spacing: 0.04em; text-transform: uppercase; margin: 0; }
.admin { margin-top: 4px; }
.admin > summary { color: var(--ink); }
.stack { display: flex; flex-direction: column; gap: 10px; padding-top: 14px; }
input[type="password"] { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 7px 12px; }
form.tools { margin: 14px 0 10px; }
details.panel { display: block; }

/* --- connexion, écarts de points --- */
.topbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px 16px; }
.logo { color: var(--course); display: inline-flex; }
.topbar .course-line { width: 150px; }
form.inline { display: inline; margin: 0; }
a.btnlink { font: inherit; font-weight: 500; color: var(--ink); text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 7px 12px; display: inline-block; }
a.btnlink:hover { border-color: var(--course); }
a { color: var(--course); }
.narrow { max-width: 460px; }
.field { flex-direction: column; align-items: stretch; gap: 4px; }
.field input { width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 7px 12px; }
.admin .field { min-width: 11rem; flex: 1 1 11rem; }
input[type="text"] { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 7px 12px; }
.tablenote { margin: 0 0 8px; }
.gap { display: block; font-family: var(--font-data); font-variant-numeric: tabular-nums; font-weight: 500; white-space: nowrap; }
.gap.pos { color: var(--forest-ink); }
.gap.neg { color: var(--ink); }
.gap.zero { color: var(--warn); }
.gap.na { color: var(--muted); font-weight: 400; }
.gapnote { display: block; font-size: 12px; color: var(--muted); max-width: 17ch; line-height: 1.3; }
table { min-width: 860px; }
.foot strong { color: var(--ink); font-weight: 600; }
section .foot { margin-top: 10px; }

/* case « mode sombre » */
.switch { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); cursor: pointer; user-select: none; }
.switch input { width: 1.1rem; height: 1.1rem; accent-color: var(--course); cursor: pointer; margin: 0; }

/* onglets */
.tabs { display: flex; flex-wrap: wrap; gap: 4px 20px; border-bottom: 1px solid var(--line); margin: 4px 0 16px; }
.tabs a { padding: 8px 2px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; font-weight: 500; }
.tabs a:hover { color: inherit; }
.tabs a[aria-current="page"] { color: inherit; border-bottom-color: var(--course); }
.loss { color: var(--warn); font-family: "IBM Plex Mono", monospace; font-size: 12px; margin-left: 6px; }
.flag { font-size: 11px; color: var(--muted); margin-left: 6px; }
.move.up { color: var(--forest-ink); } .move.down { color: var(--warn); }
.ecarts { white-space: pre-wrap; font-family: "IBM Plex Mono", monospace; font-size: 12px; user-select: all; }
.pts-fc { font-weight: 600; }
.pts-now { font-size: 12px; color: var(--muted); white-space: nowrap; }
.gaplabel { font-size: 12px; color: var(--muted); }

/* rouge = négatif / retard, vert = positif / avance */
:root { --bad: #b3261e; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --bad: #ff8f86; } }
:root[data-theme="dark"] { --bad: #ff8f86; }
.gap.neg { color: var(--bad); }
.move.down, .loss.down, .delta.down { color: var(--bad); }
.move.up, .loss.up, .delta.up { color: var(--forest-ink); }
.delta { font-family: var(--font-data); font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 500; }

/* titres de colonnes figés en faisant défiler la page */
th { position: sticky; top: 0; z-index: 2; background: var(--surface); border-bottom: 0; box-shadow: inset 0 -1px 0 var(--line); }
thead th:first-child { border-top-left-radius: 6px; }
thead th:last-child { border-top-right-radius: 6px; }
/* le conteneur à défilement horizontal bloquerait l'effet : on ne le garde que sur petit écran */
@media (min-width: 921px) { .tablewrap { overflow: visible; } }
.move { font-size: 12px; font-family: var(--font-data); white-space: nowrap; } .move.same { color: var(--muted); }
