/* ==========================================================================
   MK Pronos — style.css
   A real Mario Kart 8 Deluxe skin, zero borrowed assets. Plain CSS, no build.

   Grounded in the MK8D (Switch) menu system, pixel-verified from screenshots:
     - bright cyan-blue diagonal gradient background with a faint rotated
       checkerboard (light scheme); the same system deepened to the footer's
       royal blue for the dark scheme;
     - frosted-glass white panels with thin white edges, small radii (~10px);
     - angular accents: elongated-hexagon bars (the MK8D menu button) for the
       big CTAs and the active tab, slanted ends on card title strips;
     - selection = yellow-gold gradient fill with dark charcoal text;
     - footer = deep royal blue band with white labels (the tabbar).
   Motifs kept: red topbar + checkered start line, one rainbow-road hairline,
   gold/silver/bronze podium, coin disc on P1, red=Pilotes / violet=Pronos.

   1. Reset            6. Cards & leaderboards   11. Identity gate
   2. Tokens           7. Badges & pills         12. Toasts / modal / offline
   3. Base             8. Matchs & duels         13. Règles (long-form)
   4. Layout shell     9. Ranker                 14. Wide screens (>=640px)
   5. Buttons         10. Admin                  15. Reduced motion
   ========================================================================== */

/* 1. Reset — minimal, hand-written ---------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body, h1, h2, h3, p, ul, ol, li, figure, blockquote, table, dl, dd { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; }
img, svg { display: block; max-width: 100%; }
table { border-collapse: collapse; }
[hidden] { display: none !important; }

/* 2. Tokens ---------------------------------------------------------------- */

:root {
  /* type — display approximates MK8's FOT-New Rodin: heavy + rounded */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Hiragino Maru Gothic ProN", "Segoe UI", Verdana, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --fs-100: 0.6875rem;  /* 11 — micro labels */
  --fs-200: 0.8125rem;  /* 13 — meta, small */
  --fs-300: 0.9375rem;  /* 15 — dense UI */
  --fs-400: 1.0625rem;  /* 17 — body / rules */
  --fs-500: 1.3125rem;  /* 21 — card titles */
  --fs-600: 1.625rem;   /* 26 — screen titles */
  --fs-700: 2.125rem;   /* 34 — gate title */

  /* space & shape — MK8D is angular: small radii, hexagon cut for the CTAs */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px;
  --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
  --r-sm: 4px; --r-md: 6px; --r-lg: 12px; --r-pill: 999px;
  --hex: polygon(14px 0, calc(100% - 14px) 0, 100% 50%,
                 calc(100% - 14px) 100%, 14px 100%, 0 50%);
  /* real .tabbar height, safe-area excluded: 7px pad-top + 54px tab min-height
     + 4px pad-bottom. Everything that has to clear the bar (#app, .toasts,
     .offline-banner) measures off this, so keep it in sync with .tabbar. */
  --tabbar-h: 65px;
  --tap: 44px;

  /* MK8D menu daylight: cyan gradient sky, charcoal ink, glass panels */
  --bg: #0fc0e9;
  --bgfx:
    repeating-conic-gradient(from 35deg, rgb(255 255 255 / 0.05) 0% 25%, transparent 0% 50%),
    linear-gradient(165deg, #6fdbfd 0%, #07c6ed 38%, #0c95da 72%, #0a63b8 100%);
  --surface: #fdfeff;
  --surface-2: #e8f4fb;
  --glass: rgb(255 255 255 / 0.87);
  --glass-edge: rgb(255 255 255 / 0.95);
  --ink: #33363a;              /* MK8D text charcoal, not black */
  --ink-rgb: 51 54 58;
  --ink-2: #4c5560;
  /* ink-3 labels (.lb th, .lb__rank) are 11-15px, so they need 4.5:1 — and the
     glass panels are translucent, so the worst case is glass over the darkest
     sky stop (#0a63b8), not --surface. 4.6:1 there. Don't lighten. */
  --ink-3: #5f6974;
  --line: #d3e4ef;
  --line-strong: #a9c6d9;
  --edge: #8fb0c4;             /* hard 3D edge under tactile controls */
  --on-solid: #ffffff;
  --focus: #0a4782;
  --scrim: rgb(3 20 50 / 0.55);
  --shadow: 0 2px 4px rgb(5 40 80 / 0.08), 0 12px 24px -14px rgb(5 40 80 / 0.5);
  --checker-a: #33363a;
  --checker-b: #ffffff;

  /* constant across schemes: brand-red header, royal-blue footer band */
  --topbar: linear-gradient(180deg, #e52521, #c41a11);
  --footer: linear-gradient(180deg, #0a4782, #052572);

  /* hues — `--x` is the readable/solid colour, `--x-rgb` the vivid tint base */
  --red: #c9160c;      --red-rgb: 229 37 33;        /* 🏎️ Pilotes, danger */
  --violet: #6b2ed1;   --violet-rgb: 140 82 255;    /* 🔮 Pronos (anti-grav) */
  --green: #1e7a3c;    --green-rgb: 67 176 71;      /* go / ok / terminé */
  --amber: #7d5800;    --amber-rgb: 236 180 27;     /* verrouillé / warn */
  --tint: 0.10;        --tint-strong: 0.18;

  /* hexagon CTA fills (vertical gradient like the MK8D menu bars) */
  --green-hi: #33a45b; --green-lo: #177036;
  --red-hi: #ef4136;   --red-lo: #b5120a;

  /* the yellow-gold selection: gradient fill + dark text (verified) */
  --sel: #f2ce3e;
  --sel-rgb: 242 206 62;
  --sel-ink: #3a3a3a;
  --sel-grad: linear-gradient(180deg, #f6e154, #eccd65);
  --coin: radial-gradient(circle at 35% 30%, #ffe873, #fbd000 60%, #c98f00);

  /* podium metals */
  --gold: #a37500; --silver: #687181; --bronze: #96562c;

  /* the six karts — Mario cast palette */
  --p1-rgb: 229 37 33;  --p2-rgb: 240 130 12; --p3-rgb: 200 152 0;
  --p4-rgb: 44 156 68;  --p5-rgb: 4 140 200;  --p6-rgb: 140 82 230;

  /* per-component accent, re-pointed by .card--pilotes / .card--pronos */
  --accent: var(--ink);
  --accent-rgb: var(--ink-rgb);
}

@media (prefers-color-scheme: dark) {
  :root {
    /* the same menu, at night: the footer's royal blue takes over the sky */
    --bg: #071a4a;
    --bgfx:
      repeating-conic-gradient(from 35deg, rgb(255 255 255 / 0.03) 0% 25%, transparent 0% 50%),
      linear-gradient(165deg, #12408c 0%, #0a2a6e 45%, #061b4e 80%, #040f33 100%);
    --surface: #12275f;
    --surface-2: #1c3572;
    --glass: rgb(14 33 82 / 0.88);
    --glass-edge: rgb(140 180 255 / 0.28);
    --ink: #eef4ff;
    --ink-rgb: 238 244 255;
    --ink-2: #aabcdd;
    --ink-3: #92a4c7;   /* 4.6:1 on --surface-2, the lightest panel here */
    --line: #2b4585;
    --line-strong: #41639f;
    --edge: #030b24;
    --on-solid: #0c1c44;
    --focus: #33e0ff;          /* anti-gravity spark */
    --scrim: rgb(1 6 20 / 0.7);
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 12px 28px -18px rgb(0 0 0 / 0.9);
    --checker-a: #eef4ff;
    --checker-b: #071a4a;

    --topbar: linear-gradient(180deg, #d31d13, #9d0f08);

    --red: #ff8a70;      --red-rgb: 255 106 82;
    --violet: #c2a5ff;   --violet-rgb: 170 130 255;
    --green: #52d98a;    --green-rgb: 74 212 130;
    --amber: #ffd23e;    --amber-rgb: 255 210 62;
    --tint: 0.16;        --tint-strong: 0.26;

    --green-hi: #5fe09b; --green-lo: #2fb268;
    --red-hi: #ff9a84;   --red-lo: #f0654e;

    --gold: #ffcf4d; --silver: #c7cfdd; --bronze: #e59a62;

    --p1-rgb: 255 106 82; --p2-rgb: 255 164 56; --p3-rgb: 240 202 60;
    --p4-rgb: 84 214 128; --p5-rgb: 82 190 255; --p6-rgb: 190 140 255;
  }
}

/* 3. Base ------------------------------------------------------------------ */

body {
  font-family: var(--font);
  font-size: var(--fs-400);
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  /* dvh tracks Safari's retracting toolbars; plain 100vh is the large-viewport
     height, which leaves dead space under the fixed .tabbar in a browser tab.
     Standalone mode never sees the difference. Fallback first for iOS < 15.4. */
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* the menu sky: gradient + faint rotated checkerboard, as a fixed layer
   (a pseudo-element because background-attachment:fixed is broken on iOS) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: var(--bgfx);
  background-size: 180px 180px, auto;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* the MK display voice: heavy, rounded, leaning into the corner.
   Screen titles sit straight on the blue sky → white with a soft shadow. */
.screen__title {
  font-family: var(--display);
  font-size: var(--fs-600);
  font-weight: 900;
  font-style: italic;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  color: #ffffff;
  text-shadow: 0 1px 3px rgb(3 40 80 / 0.45);
  margin-bottom: var(--sp-4);
}

.hint { font-size: var(--fs-300); color: var(--ink-2); }

/* hints that sit straight on the blue background, not inside a panel */
.screen > .hint,
#matchs-list > .hint,
#match-detail > .hint {
  color: rgb(255 255 255 / 0.92);
  text-shadow: 0 1px 2px rgb(3 40 80 / 0.4);
}

/* the footer name band from MK8D: royal blue, white centered text */
.progress {
  font-size: var(--fs-300);
  font-weight: 700;
  color: #ffffff;
  text-align: center;
  padding: var(--sp-3) var(--sp-4);
  background: var(--footer);
  border-radius: var(--r-md);
  font-variant-numeric: tabular-nums;
}

/* app.js fills these on render; never leave an empty box behind */
.progress:empty,
#home-alert:empty,
#home-titles:empty { display: none; }

/* 4. Layout shell ---------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-4) calc(var(--sp-2) + 8px);
  padding-top: calc(var(--sp-2) + env(safe-area-inset-top));
  background: var(--topbar);
}

/* the start line: a checkered strip pinned to the bottom of the header */
.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 8px;
  background-image:
    repeating-conic-gradient(#16102a 0% 25%, #fffcf2 0% 50%);
  background-size: 16px 16px;
}

.topbar__title {
  font-family: var(--display);
  font-size: var(--fs-500);
  font-weight: 900;
  font-style: italic;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: #fffcf2;
  text-shadow: 0 2px 0 rgb(0 0 0 / 0.25);
}

#app {
  padding: var(--sp-4) var(--sp-4) 0;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--sp-6));
}

/* the MK8D footer: deep royal blue band, white labels */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 55;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--sp-1);
  padding: calc(var(--sp-1) + 3px) var(--sp-2) var(--sp-1);
  padding-bottom: calc(var(--sp-1) + env(safe-area-inset-bottom));
  background: var(--footer);
}

/* rainbow road: the one place the full ribbon appears */
.tabbar::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: inherit;
  background: linear-gradient(90deg,
    #ff3355, #ff9f1c, #ffe81a, #3ddc5a, #29c9ff, #7b5cff, #ff4fd8);
}

.tabbar__tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 54px;
  padding: var(--sp-1) 2px;
  border-radius: var(--r-md);
  font-size: 1.25rem;           /* the emoji */
  line-height: 1;
  color: rgb(255 255 255 / 0.78);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.tabbar__tab span {
  font-family: var(--display);
  font-size: var(--fs-100);
  font-weight: 800;
  letter-spacing: 0.02em; /* 5 tabs: "ACCUEIL" must fit a ~54px column at 320px */
  text-transform: uppercase;
}

/* the selected menu bar: yellow-gold gradient, dark text, hexagon cut */
.tabbar__tab[aria-current="page"] {
  color: var(--sel-ink);
  background: var(--sel-grad);
  clip-path: var(--hex);
  border-radius: 0;
}

.tabbar__tab[aria-current="page"]:focus-visible { clip-path: none; }

.tabbar__tab:focus-visible { outline-color: #ffffff; }

.tabbar__tab:active { background: rgb(255 255 255 / 0.15); }

/* the identity chip in the header — floats on the red banner */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  min-height: var(--tap);
  padding: 0 var(--sp-3);
  border-radius: var(--r-pill);
  border: 2px solid rgb(255 252 242 / 0.55);
  background: rgb(255 252 242 / 0.16);
  color: #fffcf2;
  font-size: var(--fs-300);
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease, background-color 0.15s ease;
}

.chip:active { transform: scale(0.96); background: rgb(255 252 242 / 0.3); }

.chip:focus-visible { outline-color: #fffcf2; }

/* 5. Buttons ----------------------------------------------------------------
   Default buttons stay tactile rectangles (solid edge below, press sinks).
   The big CTAs are MK8D menu bars: elongated hexagons, no border, gradient
   fill, press dims + nudges. clip-path would eat the focus ring, so keyboard
   focus temporarily restores the rectangle. */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: var(--tap);
  padding: 0 var(--sp-4);
  border-radius: var(--r-md);
  border: 2px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--display);
  font-size: var(--fs-300);
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--edge);
  transition: transform 0.08s ease, box-shadow 0.08s ease, background-color 0.15s ease,
              filter 0.08s ease;
}

.btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--edge); }

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: 0 3px 0 var(--edge);
  filter: saturate(0.35);
}

/* primary = the green "GO!" bar */
.btn--primary,
.btn--danger {
  border: 0;
  border-radius: 0;
  clip-path: var(--hex);
  padding: 0 var(--sp-5);
  color: var(--on-solid);
  box-shadow: none;
}

.btn--primary { background: linear-gradient(180deg, var(--green-hi), var(--green-lo)); }
.btn--danger { background: linear-gradient(180deg, var(--red-hi), var(--red-lo)); }

.btn--primary:active,
.btn--danger:active {
  transform: translateY(2px);
  filter: brightness(0.92);
  box-shadow: none;
}

.btn--primary:disabled,
.btn--danger:disabled { box-shadow: none; }

.btn--primary:focus-visible,
.btn--danger:focus-visible { clip-path: none; }

.btn--ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--ink-2);
  padding: 0 var(--sp-2);
}

.btn--ghost:active {
  transform: none;
  box-shadow: none;
  background: var(--surface-2);
}

.btn--icon {
  width: var(--tap);
  min-width: var(--tap);
  padding: 0;
  font-size: var(--fs-400);
  background: var(--surface-2);
}

.btn--block { display: flex; width: 100%; }

/* 6. Cards & leaderboards — the frosted-glass panels ------------------------ */

.card {
  background: var(--glass);
  border: 2px solid var(--glass-edge);
  border-top: 5px solid var(--line-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: var(--sp-4);
}

.card__title {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  font-family: var(--display);
  font-size: var(--fs-400);
  font-weight: 900;
  font-style: italic;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--accent);
  /* the tint strip ends on a slant, like an MK8D name plate */
  background: linear-gradient(102deg,
    rgb(var(--accent-rgb) / 0.1) 0 86%, transparent 86.5%);
  border-bottom: 2px solid var(--line);
}

.card__body { padding: var(--sp-3); }

.card--pilotes {
  --accent: var(--red);
  --accent-rgb: var(--red-rgb);
  border-top-color: rgb(var(--red-rgb));
}

.card--pronos {
  --accent: var(--violet);
  --accent-rgb: var(--violet-rgb);
  border-top-color: rgb(var(--violet-rgb));
}

.lb {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 6px;
  font-variant-numeric: tabular-nums;
}

.lb th {
  padding: 0 6px var(--sp-1);
  font-size: var(--fs-100);
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink-3);
  text-align: right;
  white-space: nowrap;
}

.lb th:first-child,
.lb th.lb__th--name { text-align: left; }

/* only the (long, French) name header may wrap — never the numeric ones */
.lb th.lb__th--name { white-space: normal; overflow-wrap: anywhere; }

.lb td {
  padding: 6px;
  background: var(--surface-2);
  border-top: 2px solid transparent;
  border-bottom: 2px solid transparent;
}

.lb td:first-child { border-radius: var(--r-md) 0 0 var(--r-md); border-left: 4px solid transparent; }

.lb td:last-child { border-radius: 0 var(--r-md) var(--r-md) 0; }

.lb__rank {
  width: 26px;
  text-align: center;
  font-family: var(--display);
  font-size: var(--fs-300);
  font-weight: 900;
  font-style: italic;
  color: var(--ink-3);
}

/* podium: gold, silver, bronze — the numbers grow like MK position badges.
   Keyed off [data-rank] (app.js), NOT row position: ties share a rank, so at
   0-0-0-0-0-0 all six rows read "1" and must all be gold. */
.lb__row[data-rank="1"] .lb__rank,
.lb__row[data-rank="2"] .lb__rank,
.lb__row[data-rank="3"] .lb__rank { font-size: var(--fs-500); }

.lb__row[data-rank="1"] .lb__rank { color: var(--gold); }
.lb__row[data-rank="2"] .lb__rank { color: var(--silver); }
.lb__row[data-rank="3"] .lb__rank { color: var(--bronze); }

.lb__name {
  width: 99%;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb__pts {
  text-align: right;
  font-size: var(--fs-400);
  font-weight: 800;
  white-space: nowrap;
}

.lb__stat {
  text-align: right;
  font-size: var(--fs-200);
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
}

/* the yellow cursor: your row, in either championship */
.lb__row--me td {
  background: rgb(var(--sel-rgb) / 0.18);
  border-top-color: rgb(var(--sel-rgb) / 0.55);
  border-bottom-color: rgb(var(--sel-rgb) / 0.55);
}

.lb__row--me td:first-child { border-left-color: var(--sel); }
.lb__row--me .lb__name { font-weight: 800; }

/* 7. Badges & pills -------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px var(--sp-2);
  border-radius: var(--r-sm);
  border: 2px solid transparent;
  font-family: var(--display);
  font-size: var(--fs-100);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1.4;
}

.badge--upcoming {
  color: var(--ink-2);
  background: var(--surface-2);
  border-color: var(--line-strong);
  border-style: dashed;
}

.badge--locked {
  color: var(--amber);
  background: rgb(var(--amber-rgb) / var(--tint-strong));
  border-color: rgb(var(--amber-rgb) / 0.55);
}

.badge--finished,
.badge--ok {
  color: var(--green);
  background: rgb(var(--green-rgb) / var(--tint-strong));
  border-color: rgb(var(--green-rgb) / 0.5);
}

.badge--info {
  color: var(--violet);
  background: rgb(var(--violet-rgb) / var(--tint));
  border-color: rgb(var(--violet-rgb) / 0.4);
}

.badge--miss {
  color: var(--red);
  background: rgb(var(--red-rgb) / var(--tint));
  border-color: rgb(var(--red-rgb) / 0.45);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px var(--sp-3) 4px var(--sp-2);
  border-radius: var(--r-pill);
  border: 2px solid var(--line);
  background: var(--surface-2);
  font-size: var(--fs-200);
  font-weight: 700;
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgb(var(--pc, var(--ink-rgb)));
  flex: none;
}

.pill--me {
  border-color: rgb(var(--sel-rgb) / 0.9);
  background: var(--surface);
  box-shadow: 0 0 0 2px rgb(var(--sel-rgb) / 0.25);
}

.pill[data-player-id="1"] { --pc: var(--p1-rgb); }
.pill[data-player-id="2"] { --pc: var(--p2-rgb); }
.pill[data-player-id="3"] { --pc: var(--p3-rgb); }
.pill[data-player-id="4"] { --pc: var(--p4-rgb); }
.pill[data-player-id="5"] { --pc: var(--p5-rgb); }
.pill[data-player-id="6"] { --pc: var(--p6-rgb); }

/* 8. Banner, match list, match detail, duels ------------------------------- */

/* the CTA banner is a full MK8D menu bar: hexagon, gradient, chevron */
.banner {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  min-height: var(--tap);
  padding: var(--sp-3) var(--sp-5);
  margin-bottom: var(--sp-4);
  clip-path: var(--hex);
  background: var(--glass);
  color: var(--ink);
  font-size: var(--fs-300);
  font-weight: 800;
  text-align: left;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.08s ease;
}

.banner::after {
  content: "›";
  margin-left: auto;
  font-size: var(--fs-500);
  line-height: 1;
  opacity: 0.6;
}

.banner:active { transform: translateY(2px); filter: brightness(0.94); }

.banner:focus-visible { clip-path: none; }

/* "something to do" = the yellow selected bar */
.banner--warn {
  color: var(--sel-ink);
  background: var(--sel-grad);
}

.matchrow {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--sp-1) var(--sp-3);
  width: 100%;
  min-height: 64px;
  padding: var(--sp-3);
  margin-bottom: var(--sp-2);
  border-radius: var(--r-md);
  border: 2px solid var(--glass-edge);
  background: var(--glass);
  text-align: left;
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.15s ease;
}

.matchrow:active { transform: scale(0.985); border-color: var(--line-strong); }

.matchrow__players {
  font-size: var(--fs-300);
  font-weight: 700;
  line-height: 1.35;
}

.matchrow .badge { justify-self: end; }

.matchrow__rel {
  grid-column: 1 / -1;
  font-size: var(--fs-200);
  font-weight: 600;
  color: var(--ink-2);
}

.duels {
  display: grid;
  gap: 6px;
  margin: var(--sp-3) 0;
}

.duel {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  border-left: 4px solid;
  font-size: var(--fs-300);
}

/* holds a full sentence ("Guillaume devant Anaëlle"), not just "A / B" */
.duel__pair {
  flex: 1;
  min-width: 0;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

/* ✓ / ✗ never rely on colour alone: solid filled disc vs hollow dashed ring */
.duel__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: var(--fs-200);
  font-weight: 800;
  line-height: 1;
  flex: none;
}

.duel--ok {
  border-left-color: var(--green);
  background: rgb(var(--green-rgb) / var(--tint));
}

.duel--ok .duel__mark {
  background: var(--green);
  color: var(--on-solid);
  border: 2px solid var(--green);
}

.duel--ko {
  border-left-color: var(--red);
  border-left-style: dashed;
  background: rgb(var(--red-rgb) / calc(var(--tint) * 0.6));
  color: var(--ink-2);
}

.duel--ko .duel__mark {
  background: transparent;
  color: var(--red);
  border: 2px dashed var(--red);
}

.score {
  font-family: var(--display);
  font-size: var(--fs-500);
  font-weight: 900;
  font-style: italic;
  font-variant-numeric: tabular-nums;
}

.score small {
  display: block;
  font-family: var(--font);
  font-size: var(--fs-200);
  font-weight: 600;
  font-style: normal;
  letter-spacing: 0;
  color: var(--ink-2);
}

/* 9. Ranker — the ↑/↓ ordering list, shared by pronos and admin results ----- */

.ranker {
  display: grid;
  gap: var(--sp-2);
  margin: var(--sp-3) 0;
  counter-reset: none;
}

.ranker__item {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: var(--sp-3);
  min-height: 56px;
  padding: var(--sp-2);
  border-radius: var(--r-md);
  border: 2px solid var(--line);
  background: var(--surface);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.ranker__pos {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgb(var(--ink-rgb) / var(--tint));
  font-family: var(--display);
  font-size: var(--fs-300);
  font-weight: 900;
  font-style: italic;
  font-variant-numeric: tabular-nums;
}

/* P1 wears the coin */
.ranker__item:first-child { border-color: rgb(var(--sel-rgb) / 0.7); }

.ranker__item:first-child .ranker__pos {
  background: var(--coin);
  color: var(--sel-ink);
  box-shadow: inset 0 0 0 2px rgb(63 47 0 / 0.25);
}

.ranker__name {
  font-size: var(--fs-400);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranker__ctrl { display: flex; gap: 6px; }

/* 9b. Additive wrappers emitted by app.js ---------------------------------- */

/* the two revealed pronos of a locked/finished match */
.mk-bets {
  display: grid;
  gap: var(--sp-3);
  margin: var(--sp-3) 0;
}

/* these cards are pronos by definition, even though app.js emits a plain .card */
.mk-bets > .card {
  margin-bottom: 0;
  --accent: var(--violet);
  --accent-rgb: var(--violet-rgb);
  border-top-color: rgb(var(--violet-rgb));
}

/* an inline, wrapping row of .pill / .badge */
.mk-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  margin: var(--sp-2) 0;
}

/* read-only counterpart of .ranker: a 1→4 ranking made of pills */
.mk-orderlist {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin: var(--sp-3) 0;
  counter-reset: mko;
}

.mk-orderlist > li {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  counter-increment: mko;
}

.mk-orderlist > li::before {
  content: counter(mko);
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgb(var(--accent-rgb) / var(--tint));
  color: var(--accent);
  font-family: var(--display);
  font-size: var(--fs-100);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 24px;
  text-align: center;
}

.mk-orderlist > li:first-child::before {
  background: var(--coin);
  color: var(--sel-ink);
}

/* admin: the result .ranker plus its buttons */
.mk-resultform { display: grid; gap: var(--sp-2); }

.mk-resultform .ranker { margin: 0 0 var(--sp-1); }

/* 10. Admin ---------------------------------------------------------------- */

/* #admin-login is itself a .card — only lay out its body */
#admin-login .card__body { display: grid; gap: var(--sp-3); }

#admin-password {
  width: 100%;
  min-height: var(--tap);
  padding: 0 var(--sp-3);
  border-radius: var(--r-md);
  border: 2px solid var(--line-strong);
  background: var(--surface-2);
  font-size: var(--fs-400);
}

#admin-password:focus { outline: 3px solid var(--focus); outline-offset: 1px; }

#admin-panel .card__body { display: grid; gap: var(--sp-2); }

/* 11. Identity gate — the character select --------------------------------- */

.identity-gate {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  /* `safe` matters: this box scrolls, and plain `center` puts the overflow
     above the scroll origin where scrollTop can't reach it — in landscape or
     at a large default font size the title and the first row of .idbtn would
     be unreachable. `safe center` degrades to flex-start once it overflows.
     The unprefixed `center` first is the fallback for engines without it. */
  justify-content: center;
  justify-content: safe center;
  gap: var(--sp-3);
  overflow-y: auto;
  padding: calc(var(--sp-6) + env(safe-area-inset-top)) var(--sp-4)
           calc(var(--sp-6) + env(safe-area-inset-bottom));
  background: var(--bg);
  background-image: var(--bgfx);
  background-size: 180px 180px, auto;
  text-align: center;
}

.identity-gate h1,
.identity-gate h2 {
  font-family: var(--display);
  font-size: var(--fs-700);
  font-weight: 900;
  font-style: italic;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  line-height: 1.1;
  color: #ffffff;
  text-shadow: 0 2px 4px rgb(3 40 80 / 0.45);
  margin-bottom: 0;
}

.identity-gate p {
  font-size: var(--fs-300);
  color: rgb(255 255 255 / 0.92);
  text-shadow: 0 1px 2px rgb(3 40 80 / 0.4);
}

.identity-gate__grid,
#identity-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-3);
  margin-top: var(--sp-3);
}

#identity-gate-foot {
  font-size: var(--fs-200);
  color: rgb(255 255 255 / 0.75);
  margin-top: var(--sp-2);
}

#identity-gate-foot:empty { display: none; }

/* the gate and the modal own the viewport while they are open */
body:has(.identity-gate:not([hidden])),
body:has(.modal-backdrop:not([hidden])) { overflow: hidden; }

/* glass character plates, tinted per player */
.idbtn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 92px;
  padding: var(--sp-3);
  border-radius: var(--r-lg);
  border: 2px solid rgb(var(--pc, var(--ink-rgb)) / 0.55);
  border-top: 6px solid rgb(var(--pc, var(--ink-rgb)));
  background-color: var(--glass);
  background-image: linear-gradient(rgb(var(--pc, var(--ink-rgb)) / 0.16),
                                    rgb(var(--pc, var(--ink-rgb)) / 0.16));
  font-family: var(--display);
  font-size: var(--fs-500);
  font-weight: 900;
  font-style: italic;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 4px 0 rgb(var(--pc, var(--ink-rgb)) / 0.45);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.idbtn:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 rgb(var(--pc, var(--ink-rgb)) / 0.45);
}

.idbtn[data-player-id="1"] { --pc: var(--p1-rgb); }
.idbtn[data-player-id="2"] { --pc: var(--p2-rgb); }
.idbtn[data-player-id="3"] { --pc: var(--p3-rgb); }
.idbtn[data-player-id="4"] { --pc: var(--p4-rgb); }
.idbtn[data-player-id="5"] { --pc: var(--p5-rgb); }
.idbtn[data-player-id="6"] { --pc: var(--p6-rgb); }

/* 12. Toasts, modal, offline banner ---------------------------------------- */

.toasts {
  position: fixed;
  left: var(--sp-4);
  right: var(--sp-4);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--sp-3));
  z-index: 80;
  display: flex;
  flex-direction: column-reverse;
  gap: var(--sp-2);
  pointer-events: none;
}

/* lift the stack when the offline strip is showing */
body:has(.offline-banner:not([hidden])) .toasts { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 62px); }

.toast {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--ink);
  color: var(--on-solid);
  font-size: var(--fs-300);
  font-weight: 700;
  box-shadow: 0 12px 28px -14px rgb(0 0 0 / 0.7);
  animation: toast-in 0.16s ease-out both;
}

.toast--error { background: var(--red); color: var(--on-solid); }
.toast--ok { background: var(--green); color: var(--on-solid); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: var(--scrim);
  animation: fade-in 0.14s ease-out both;
}

@keyframes fade-in { from { opacity: 0; } }

.modal {
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  padding: var(--sp-5) var(--sp-4);
  padding-bottom: calc(var(--sp-5) + env(safe-area-inset-bottom));
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  border-top: 5px solid var(--sel);
  background: var(--surface);
  animation: sheet-up 0.2s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

@keyframes sheet-up { from { transform: translateY(16px); } }

.modal h2,
.modal h3 {
  font-family: var(--display);
  font-size: var(--fs-500);
  font-weight: 900;
  font-style: italic;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  margin-bottom: var(--sp-2);
}

.modal p { color: var(--ink-2); margin-bottom: var(--sp-4); }

.modal .btn { margin-top: var(--sp-2); }

.mk-modal-body { color: var(--ink-2); }
.mk-modal-body > * + * { margin-top: var(--sp-3); }
.mk-modal-body p { margin-bottom: 0; }
.mk-modal-body strong { color: var(--ink); }

.mk-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-5);
}

.mk-modal-actions > .btn { flex: 1 1 42%; margin-top: 0; }

/* "Annuler" sits next to a confirm button — it needs an edge to be tappable */
.mk-modal-actions > .btn--ghost {
  padding: 0 var(--sp-4);
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink);
  box-shadow: 0 3px 0 var(--edge);
}

.mk-modal-actions > .btn--ghost:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 var(--edge);
  background: var(--surface-2);
}

.offline-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  z-index: 46;
  padding: var(--sp-2) var(--sp-4);
  background: var(--sel-grad);
  color: var(--sel-ink);
  font-size: var(--fs-200);
  font-weight: 700;
  text-align: center;
}

/* 13. Règles — long-form French documentation ------------------------------ */

/* long-form text gets its own glass panel — never raw on the blue sky */
.rules-content {
  font-size: var(--fs-400);
  line-height: 1.65;
  color: var(--ink);
  overflow-wrap: break-word;
  background: var(--glass);
  border: 2px solid var(--glass-edge);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
}

.rules-content > * + * { margin-top: var(--sp-4); }

.rules-content h2 {
  font-family: var(--display);
  font-size: var(--fs-600);
  font-weight: 900;
  font-style: italic;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  line-height: 1.15;
  margin-top: var(--sp-6);
}

.rules-content > h2:first-child { margin-top: 0; }

/* two-tone rail = the two competitions */
.rules-content h2::after {
  content: "";
  display: block;
  width: 56px;
  height: 4px;
  margin-top: var(--sp-2);
  border-radius: 2px;
  background: linear-gradient(90deg, rgb(var(--red-rgb)) 0 50%, rgb(var(--violet-rgb)) 50% 100%);
}

.rules-content h3 {
  font-family: var(--display);
  font-size: var(--fs-500);
  font-weight: 900;
  font-style: italic;
  letter-spacing: 0.01em;
  margin-top: var(--sp-5);
}

.rules-content p { max-width: 68ch; }

.rules-content ul,
.rules-content ol {
  display: grid;
  gap: var(--sp-2);
  padding-left: var(--sp-1);
  max-width: 68ch;
}

.rules-content li { position: relative; padding-left: var(--sp-5); }

/* item-box bullets: the rotated square */
.rules-content ul > li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 0.58em;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: rgb(var(--violet-rgb));
  transform: rotate(45deg);
}

.rules-content ol { counter-reset: rl; }

.rules-content ol > li { counter-increment: rl; }

.rules-content ol > li::before {
  content: counter(rl);
  position: absolute;
  left: 0;
  top: 0.15em;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgb(var(--violet-rgb) / var(--tint-strong));
  color: var(--violet);
  font-family: var(--display);
  font-size: var(--fs-100);
  font-weight: 900;
  line-height: 20px;
  text-align: center;
}

.rules-content li > ul,
.rules-content li > ol { margin-top: var(--sp-2); }

.rules-content strong { font-weight: 800; }
.rules-content em { font-style: italic; color: var(--ink-2); }

.rules-content a { color: var(--violet); text-underline-offset: 3px; }

.rules-content code {
  padding: 2px 6px;
  border-radius: 6px;
  background: rgb(var(--ink-rgb) / var(--tint));
  font-family: var(--mono);
  font-size: 0.875em;
}

/* tables must survive a 320px phone with no wrapper element available */
.rules-content table {
  display: block;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-collapse: separate;
  border-spacing: 0;
  border: 2px solid var(--line);
  border-radius: var(--r-md);
  font-size: var(--fs-300);
  font-variant-numeric: tabular-nums;
}

.rules-content th,
.rules-content td {
  padding: var(--sp-2) var(--sp-3);
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.rules-content th {
  background: var(--surface-2);
  font-size: var(--fs-100);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.rules-content tbody tr:last-child td { border-bottom: 0; }
.rules-content tbody tr:nth-child(even) td { background: rgb(var(--ink-rgb) / 0.03); }

.rules-content blockquote {
  padding: var(--sp-3) var(--sp-4);
  border-left: 5px solid rgb(var(--violet-rgb));
  border-radius: 0 var(--r-md) var(--r-md) 0;
  background: var(--surface-2);
  color: var(--ink-2);
}

/* the checkered start line again, as a section divider */
.rules-content hr {
  height: 8px;
  border: 0;
  margin: var(--sp-6) 0;
  border-radius: 2px;
  background-image:
    repeating-conic-gradient(var(--checker-a) 0% 25%, var(--checker-b) 0% 50%);
  background-size: 16px 16px;
  opacity: 0.85;
}

.rules-content details {
  border: 2px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
}

.rules-content summary {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: var(--tap);
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--fs-300);
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.rules-content summary::-webkit-details-marker { display: none; }

.rules-content summary::before {
  content: "›";
  font-size: var(--fs-500);
  line-height: 1;
  color: var(--violet);
  transition: transform 0.15s ease;
}

.rules-content details[open] summary::before { transform: rotate(90deg); }

.rules-content details[open] summary { border-bottom: 2px solid var(--line); }

.rules-content details > *:not(summary) { margin: var(--sp-3) var(--sp-4); }

/* helper blocks the rules fragment may use */
.rules-content .rl-callout {
  padding: var(--sp-3) var(--sp-4);
  border: 2px solid rgb(var(--amber-rgb) / 0.5);
  border-left-width: 5px;
  border-radius: var(--r-md);
  background: rgb(var(--amber-rgb) / var(--tint));
  font-size: var(--fs-300);
}

.rules-content .rl-example {
  padding: var(--sp-4);
  border: 2px dashed var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.rules-content .rl-example > * + * { margin-top: var(--sp-3); }
.rules-content .rl-callout > * + * { margin-top: var(--sp-2); }

/* 14. Wide screens --------------------------------------------------------- */

@media (min-width: 640px) {
  :root {
    --fs-400: 1.0625rem;
    --fs-600: 2rem;
    --fs-700: 2.75rem;
  }

  .topbar {
    padding-left: var(--sp-5);
    padding-right: var(--sp-5);
  }

  #app {
    max-width: 720px;
    margin: 0 auto;
    padding: var(--sp-5) var(--sp-5) 0;
    padding-bottom: calc(var(--tabbar-h) + var(--sp-6));
  }

  /* the two leaderboards sit side by side — equal weight, literally */
  #screen-accueil {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-4);
    align-items: start;
  }

  #screen-accueil > * { grid-column: 1 / -1; }
  #screen-accueil > .card { margin-bottom: 0; }
  #screen-accueil > .card--pilotes { grid-column: 1; }
  #screen-accueil > .card--pronos { grid-column: 2; }

  .card__body { padding: var(--sp-4); }

  .tabbar {
    max-width: 720px;
    margin: 0 auto;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
  }

  .identity-gate__grid,
  #identity-grid {
    grid-template-columns: repeat(3, 1fr);
    max-width: 720px;
    margin: 0 auto;
    width: 100%;
  }

  /* the two revealed pronos, side by side */
  .mk-bets {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  .modal-backdrop { align-items: center; }

  .modal {
    border-radius: var(--r-lg);
    padding-bottom: var(--sp-5);
  }

  .toasts {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(480px, calc(100% - 32px));
  }

  .rules-content { font-size: 1.125rem; padding: var(--sp-5); }
}

/* 15. Reduced motion ------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  .btn:active,
  .banner:active,
  .idbtn:active,
  .matchrow:active,
  .chip:active { transform: none; }
}
