:root {
  --navy: #1b3a5c;
  --navy-2: #24507d;
  --orange: #e07b1a;
  --orange-soft: #fdf1e0;
  --bg: #f4f1ea;
  --card: #ffffff;
  --ink: #16202b;
  --muted: #66727f;
  --line: #dfd9cd;
  --green: #1f7a4d;
  --red: #b0342c;
  --shadow: 0 1px 2px rgba(20, 30, 45, .07), 0 4px 14px rgba(20, 30, 45, .06);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --navy: #0f2237;
    --navy-2: #1b3d61;
    --orange: #f0973f;
    --orange-soft: #33261a;
    --bg: #10161d;
    --card: #1a222c;
    --ink: #e8edf3;
    --muted: #93a1b0;
    --line: #2b3846;
    --green: #46b37c;
    --red: #e0685e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ------------------------------------------------------------------ header */

header {
  background: linear-gradient(160deg, var(--navy), var(--navy-2));
  color: #fff;
  padding: calc(14px + env(safe-area-inset-top)) 16px 14px;
  border-bottom: 3px solid var(--orange);
}

header h1 { margin: 0; font-size: 19px; letter-spacing: -.2px; }

.sub {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: rgba(255, 255, 255, .72);
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}

.sound {
  margin-left: auto;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 20px;
  padding: 4px 10px;
  font: 600 11.5px/1 inherit;
  cursor: pointer;
  white-space: nowrap;
}
.sound[aria-pressed="true"] { background: var(--orange); border-color: var(--orange); }

.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #7ee0a8; display: inline-block;
  box-shadow: 0 0 0 0 rgba(126, 224, 168, .7);
  animation: pulse 2.4s infinite;
}
.dot.off { background: #f0a6a0; animation: none; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(126, 224, 168, .6); }
  70%  { box-shadow: 0 0 0 7px rgba(126, 224, 168, 0); }
  100% { box-shadow: 0 0 0 0 rgba(126, 224, 168, 0); }
}

/* -------------------------------------------------------------------- tabs */

nav {
  position: sticky; top: 0; z-index: 20;
  display: flex; overflow-x: auto; gap: 2px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
nav::-webkit-scrollbar { display: none; }

nav button {
  flex: 0 0 auto;
  background: none; border: none;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font: 600 13.5px/1 inherit;
  letter-spacing: .3px;
  padding: 14px 15px 11px;
  cursor: pointer;
  white-space: nowrap;
}
nav button[aria-selected="true"] { color: var(--navy); border-bottom-color: var(--orange); }
@media (prefers-color-scheme: dark) { nav button[aria-selected="true"] { color: var(--orange); } }

main { padding: 14px 12px 40px; max-width: 720px; margin: 0 auto; }
section[hidden] { display: none; }

h2 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .9px;
  color: var(--muted); margin: 22px 4px 9px; font-weight: 700;
}
h2:first-child { margin-top: 4px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; margin-bottom: 10px;
}

.empty {
  text-align: center; color: var(--muted);
  padding: 30px 18px; font-size: 14.5px;
}

.banner {
  background: var(--orange-soft);
  border: 1px solid var(--orange);
  border-radius: var(--radius);
  padding: 11px 14px; margin-bottom: 12px;
  font-size: 14.5px;
}

/* ------------------------------------------------------------- match cards */

.match { padding: 12px 14px; }
.match + .match { border-top: 1px solid var(--line); }

.match-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 11.5px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .6px; font-weight: 600;
  margin-bottom: 9px;
}

.lane {
  background: var(--navy); color: #fff;
  border-radius: 5px; padding: 2.5px 7px;
  font-size: 10.5px; letter-spacing: .5px;
}
.lane.full { background: var(--orange); }

.badge {
  margin-left: auto; border-radius: 20px;
  padding: 3px 9px; font-size: 10.5px; letter-spacing: .5px;
}
.badge.live { background: var(--red); color: #fff; }
.badge.done { background: var(--line); color: var(--muted); }
.badge.next { background: var(--orange-soft); color: var(--orange); border: 1px solid var(--orange); }

/* ------------------------------------------------- chrono (vue arbitre) */

.stopwatch { display: flex; align-items: baseline; gap: 9px; margin: 6px 0 10px; }
.sw {
  font-variant-numeric: tabular-nums;
  font-weight: 700; font-size: 30px; line-height: 1;
  letter-spacing: 1px; color: var(--ink);
}
.sw.warn { color: var(--orange); }               /* moins d'une minute avant le plafond */
.sw.over { color: var(--red); animation: sw-blink 1s step-start infinite; }  /* plafond dépassé */
.sw-cap { font-size: 12.5px; color: var(--muted); }
@keyframes sw-blink { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .sw.over { animation: none; } }

/* ------------------------------------------- décompte (vue publique, live) */

.match-clock { margin: 2px 0 8px; }
.mc {
  display: inline-block;
  font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px;
  padding: 3px 10px; border-radius: 20px;
  background: var(--orange-soft); color: var(--orange);
  border: 1px solid var(--orange);
}
.mc.warn { background: var(--orange); color: #fff; }
.mc.over {
  background: var(--red); color: #fff; border-color: var(--red);
  animation: sw-blink 1s step-start infinite;
}
@media (prefers-reduced-motion: reduce) { .mc.over { animation: none; } }

/* QR d'accès arbitre : fond blanc explicite pour rester scannable en thème sombre */
.qr-admin {
  display: block; width: 100%; max-width: 260px; margin: 4px auto 8px;
  background: #fff; padding: 12px; border-radius: 12px;
}

.row {
  display: grid; grid-template-columns: 1fr auto;
  align-items: center; gap: 10px; padding: 4px 0;
}
.row .name { font-size: 16px; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.row .sc {
  font: 700 22px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  min-width: 34px; text-align: right; font-variant-numeric: tabular-nums;
}
.row.win .name { font-weight: 700; }
.row.win .sc { color: var(--green); }
.row.lose .name, .row.lose .sc { color: var(--muted); }
.row .sc.none { color: var(--line); }

.mine { box-shadow: inset 3px 0 0 var(--orange); }
.match-foot {
  margin-top: 8px; font-size: 12px; color: var(--muted);
  display: flex; gap: 10px; flex-wrap: wrap;
}

/* --------------------------------------------------------------- standings */

table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
thead th {
  background: var(--navy); color: #fff;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px;
  padding: 9px 4px; font-weight: 700;
}
thead th:first-child { padding-left: 12px; text-align: left; }
thead th.tl { text-align: left; }
tbody td { padding: 11px 4px; border-bottom: 1px solid var(--line); text-align: center; font-variant-numeric: tabular-nums; }
tbody td:first-child { padding-left: 12px; text-align: left; font-weight: 700; color: var(--muted); width: 30px; }
tbody td.tl { text-align: left; font-weight: 600; overflow-wrap: anywhere; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.qualified td:first-child { color: var(--green); }
tbody tr.qualified { background: rgba(31, 122, 77, .06); }
tbody tr.contested { background: rgba(224, 123, 26, .12); }
tbody tr.contested td:first-child { color: var(--orange); }
tbody tr.me { background: var(--orange-soft); }
tbody tr.me td.tl::after { content: " ←"; color: var(--orange); }
td.pts { font-weight: 700; }
.tie-flag { color: var(--orange); font-weight: 700; }

.legend {
  font-size: 12px; color: var(--muted);
  padding: 10px 13px; line-height: 1.6;
}
.legend b { color: var(--ink); font-weight: 600; }

/* ------------------------------------------------------------- my team tab */

.picker { display: flex; flex-wrap: wrap; gap: 7px; padding: 13px; }
.picker button {
  flex: 1 1 30%; min-width: 92px;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 8px; font: 600 14px inherit; cursor: pointer;
  overflow-wrap: anywhere;
}
.picker button.sel { background: var(--navy); color: #fff; border-color: var(--navy); }

.hero { padding: 16px 15px; text-align: center; }
.hero .rk { font: 800 42px/1 inherit; color: var(--navy); }
@media (prefers-color-scheme: dark) { .hero .rk { color: var(--orange); } }
.hero .nm { font-size: 18px; font-weight: 700; margin-top: 4px; overflow-wrap: anywhere; }
.hero .st { color: var(--muted); font-size: 13.5px; margin-top: 5px; }

.link {
  background: none; border: none; color: var(--orange);
  font: 600 13px inherit; cursor: pointer; padding: 0 0 12px; display: block;
  margin: 0 auto; text-decoration: underline;
}

/* --------------------------------------------------------------- bracket */

.bracket { padding: 13px; display: grid; gap: 9px; }
.slot {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; background: var(--bg);
}
.slot .lbl {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); font-weight: 700; margin-bottom: 6px;
  display: flex; justify-content: space-between; gap: 8px;
}
.slot.gf { border-color: var(--orange); background: var(--orange-soft); }
.slot .tbd { color: var(--muted); font-style: italic; }

/* ----------------------------------------------------------------- admin */

.admin-bar {
  background: var(--navy); color: #fff;
  padding: 9px 14px; font-size: 13px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.admin-bar .grow { margin-left: auto; }

.banner.warn { background: rgba(176, 52, 44, .1); border-color: var(--red); }

select {
  font: 15px inherit; padding: 11px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink); width: 100%;
}

input[type="text"], input[type="password"], input[type="number"] {
  font: 15px inherit; padding: 11px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink); width: 100%;
}

button.primary {
  background: var(--orange); color: #fff; border: none;
  border-radius: 10px; padding: 13px 16px;
  font: 700 15px inherit; cursor: pointer; width: 100%;
}
button.ghost {
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; font: 600 14px inherit; cursor: pointer;
}
button.ghost.danger { color: var(--red); border-color: var(--red); }
button:disabled { opacity: .45; cursor: default; }

.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button {
  width: 46px; height: 46px; flex: 0 0 auto;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink);
  font: 700 22px/1 inherit; cursor: pointer;
}
.stepper button:active { background: var(--navy); color: #fff; }
.stepper .val {
  font: 700 26px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  min-width: 42px; text-align: center; font-variant-numeric: tabular-nums;
}

.form { padding: 13px; display: grid; gap: 11px; }
.pad { padding: 13px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.note { font-size: 12.5px; color: var(--muted); }
.err { color: var(--red); font-size: 13.5px; }
.ok { color: var(--green); font-size: 13.5px; }

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg);
  padding: 11px 18px; border-radius: 22px;
  font-size: 14px; z-index: 100; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .2s;
  max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; }

/* --------------------------------------------------- programme : la soirée */

.timeline { list-style: none; margin: 0 0 14px; padding: 0; }

.tl-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card);
  border: 1px solid var(--line); border-left: 4px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 11px 13px; margin-bottom: 8px;
}
.tl-item.next { border-left-color: var(--orange); }
.tl-item.live { border-left-color: var(--red); }
.tl-item.done { opacity: .6; }
/* Reserved but no longer needed — struck off so nobody waits for it. */
.tl-item.skip { opacity: .45; }
.tl-item.skip .tl-time, .tl-item.skip .tl-body strong { text-decoration: line-through; }
.tl-item.aside { border-left-style: dashed; }
.tl-item.hi .tl-body strong { color: var(--orange); }

.tl-time {
  display: flex; flex-direction: column; align-items: flex-start;
  min-width: 56px; line-height: 1.2;
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 14px;
}
.tl-time span { font-weight: 400; font-size: 12px; color: var(--muted); }

.tl-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.tl-body strong { font-size: 15.5px; }
.tl-detail { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
