/* ==========================================================================
   Direction artistique — chargée après style.css, donc prioritaire.

   Même langage que corentinjgt.fr : fond sombre, grandes taches de couleur floues en
   dégradé, grain très fin par-dessus, titres en Syne, texte en DM Sans. L'accent est
   un violet qui glisse vers l'indigo ; le dégradé violet + grain est réservé à ce qui
   est actif (bouton principal, onglet actif, joueur qui joue…).

   Pensé d'abord pour le téléphone (c'est là que l'appli sert, à table) : styles de
   base = petit écran, puis élargissements à partir de 720px.

   Thème sombre par défaut ; thème clair via data-theme="light" (bouton dans la barre
   du haut, voir ui.js). style.css garde ses propres variables : on les redéfinit ici.
   ========================================================================== */

:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0b0a10;
  --surface-1: #15141c;
  --surface-2: #1c1b25;
  --glass: rgb(255 255 255 / 0.045);
  --glass-strong: rgb(255 255 255 / 0.08);
  --text-primary: #f5f4f8;
  --text-secondary: #b7b4c4;
  --text-muted: #85829a;
  --gridline: rgb(255 255 255 / 0.09);
  --baseline: rgb(255 255 255 / 0.16);
  --border: rgb(255 255 255 / 0.08);
  --success: #3ec27e;
  --danger: #ef5b5b;

  --violet: #8b6cff;
  --indigo: #5b5bf0;
  --violet-ink: #b8a6ff;
  --violet-soft: rgb(139 108 255 / 0.16);
  --violet-line: rgb(139 108 255 / 0.45);
  --blob-a: rgb(124 84 255 / 0.42);
  --blob-b: rgb(70 86 240 / 0.34);
  --blob-c: rgb(160 110 255 / 0.22);
  --grain-opacity: 0.075;
  --grain-blend: overlay;

  --board-dark: #1d1c24;
  --board-light: #e9e4d6;
  --board-ring-a: #c8463f;
  --board-ring-b: #2f8f5b;
  --board-wire: rgb(0 0 0 / 0.35);
  --board-rim: #0f0e14;
  --board-number: #f5f4f8;
  --heat: #ffcf33;

  --shadow-1: 0 1px 0 rgb(255 255 255 / 0.04) inset, 0 8px 24px -14px rgb(0 0 0 / 0.6);
  --shadow-2: 0 1px 0 rgb(255 255 255 / 0.06) inset, 0 20px 44px -18px rgb(0 0 0 / 0.75);
  --shadow-violet: 0 10px 26px -10px rgb(124 84 255 / 0.75);
}

:root[data-theme="light"] {
  color-scheme: light;
  --page: #f6f5f9;
  --surface-1: #ffffff;
  --surface-2: #f4f3f8;
  --glass: rgb(255 255 255 / 0.7);
  --glass-strong: rgb(255 255 255 / 0.9);
  --text-primary: #14121c;
  --text-secondary: #4d4a5c;
  --text-muted: #7c7990;
  --gridline: rgb(20 18 30 / 0.09);
  --baseline: rgb(20 18 30 / 0.18);
  --border: rgb(20 18 30 / 0.08);
  --success: #18834f;
  --danger: #d23f3f;

  --violet: #6b46e8;
  --indigo: #4a48d6;
  --violet-ink: #5a36d6;
  --violet-soft: rgb(107 70 232 / 0.1);
  --violet-line: rgb(107 70 232 / 0.35);
  --blob-a: rgb(124 84 255 / 0.22);
  --blob-b: rgb(70 86 240 / 0.16);
  --blob-c: rgb(160 110 255 / 0.12);
  --grain-opacity: 0.045;
  --grain-blend: multiply;

  --board-dark: #24222c;
  --board-light: #efe9da;
  --board-rim: #1a1820;

  --shadow-1: 0 1px 2px rgb(20 18 30 / 0.05), 0 6px 18px -10px rgb(20 18 30 / 0.18);
  --shadow-2: 0 2px 6px rgb(20 18 30 / 0.06), 0 18px 36px -16px rgb(20 18 30 / 0.24);
  --shadow-violet: 0 10px 22px -10px rgb(107 70 232 / 0.6);
}

:root {
  --violet-gradient: linear-gradient(135deg, var(--violet), var(--indigo));
  /* Grain fin (même filtre que le portfolio, tuile serrée = petits grains). */
  --grain-img: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.25' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23g)'/%3E%3C/svg%3E");
  /* Grain transparent pour les surfaces violettes : points clairs à faible opacité,
     le dégradé reste bien saturé dessous. */
  --grain-light: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.6' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.6 -0.3'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23g)'/%3E%3C/svg%3E");
  --violet-fill: var(--grain-light) 0 0 / 80px 80px, var(--violet-gradient);
  --f-num: 'DM Sans', system-ui, sans-serif;
  --f-display: 'Syne', system-ui, sans-serif;
  --f-body: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius-s: 10px;
  --radius-m: 14px;
  --radius-l: 18px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: linear(0, 0.21 6%, 0.65 15%, 0.96 25%, 1.08 34%, 1.1 40%, 1.05 52%, 0.99 64%, 1);
  --bottom-nav-h: 0px;
  --gutter: 16px;
  accent-color: var(--violet);
  interpolate-size: allow-keywords;
  scrollbar-color: var(--violet-line) transparent;
  scrollbar-width: thin;
  -webkit-text-size-adjust: 100%;
}
@media (min-width: 720px) { :root { --gutter: 28px; } }

/* ---------- Base ---------- */
html, body { background: var(--page); font-family: var(--f-body); font-weight: 450; }
body { -webkit-font-smoothing: antialiased; position: relative; overflow-x: hidden; }
button, input, select, textarea { font-family: inherit; }
h1, h2, h3, .brand-word, .display { font-family: var(--f-display); letter-spacing: -0.01em; }
h1 { font-size: clamp(1.55rem, 6vw, 2.4rem); font-weight: 800; line-height: 1.05; margin: 0 0 4px; text-wrap: balance; }
h2 { font-size: 1.12rem; font-weight: 700; margin: 0 0 12px; text-wrap: balance; }
h3 { font-size: 0.98rem; font-weight: 700; margin: 0 0 10px; }
p, .subtitle { text-wrap: pretty; }
.subtitle { color: var(--text-muted); font-size: 0.88rem; font-weight: 500; margin: 0 0 16px; }
::selection { background: var(--violet-soft); }
:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; border-radius: 6px; }

/* ---------- Fond : taches dégradées floues + grain fin (comme le portfolio) ---------- */
html::before {
  content: '';
  position: fixed;
  inset: -10vmax;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(38vmax 34vmax at 12% 8%, var(--blob-a), transparent 70%),
    radial-gradient(34vmax 30vmax at 92% 30%, var(--blob-b), transparent 70%),
    radial-gradient(30vmax 26vmax at 40% 92%, var(--blob-c), transparent 70%);
  filter: blur(18px);
  animation: blob-drift 24s ease-in-out infinite alternate;
}
@keyframes blob-drift {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(2vmax, -2vmax, 0) scale(1.05); }
  100% { transform: translate3d(-2vmax, 1.5vmax, 0) scale(0.98); }
}
body { background: transparent; }
body::before {
  content: '';
  position: fixed;
  inset: -20%;
  z-index: 9999;
  pointer-events: none;
  opacity: var(--grain-opacity);
  mix-blend-mode: var(--grain-blend);
  background-image: var(--grain-img);
  background-size: 110px 110px;
  animation: grain-shift 0.9s steps(1) infinite;
}
@keyframes grain-shift {
  0% { transform: translate(0, 0); } 20% { transform: translate(-3%, 2%); } 40% { transform: translate(2%, -3%); }
  60% { transform: translate(-2%, -2%); } 80% { transform: translate(3%, 3%); } 100% { transform: translate(0, 0); }
}

/* ---------- Transitions entre pages ---------- */
@view-transition { navigation: auto; }
.topbar { view-transition-name: topbar; }
main.container { view-transition-name: page; }
::view-transition-old(page) { animation: 120ms ease both vt-out; }
::view-transition-new(page) { animation: 240ms var(--ease-out) both vt-in; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Barre du haut ----------
   Le flou est sur un pseudo-élément : un backdrop-filter sur .topbar en ferait le bloc
   conteneur de la nav en position fixed (barre d'onglets du bas sur téléphone). */
.topbar {
  background: transparent;
  border-bottom: none;
  padding: calc(8px + env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) 8px max(var(--gutter), env(safe-area-inset-left));
  isolation: isolate;
}
.topbar::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: color-mix(in srgb, var(--page) 70%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}
.brand-logo { height: 26px; transition: transform 0.4s var(--ease-spring); }
:root:not([data-theme="light"]) .brand-logo { filter: invert(1); }
@media (min-width: 720px) { .brand-logo { height: 32px; } }
.topbar-right { gap: 6px; flex-shrink: 0; }
.topbar { gap: 10px; }
.brand { flex-shrink: 0; }

.topbar nav { gap: 2px; padding: 4px; border-radius: 999px; background: var(--glass); border: 1px solid var(--border); }
.topbar nav a { border-radius: 999px; margin: 0; color: var(--text-secondary); font-weight: 600; transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease; }
.topbar nav a:hover { color: var(--text-primary); background: var(--glass-strong); }
.topbar nav a.active { background: var(--violet-fill); color: white; box-shadow: var(--shadow-violet); }
.topbar nav a:active { transform: scale(0.95); }

.icon-btn { background: var(--glass); border: 1px solid var(--border); color: var(--text-primary); transition: transform 0.12s ease, background 0.2s ease; }
.icon-btn:hover { background: var(--glass-strong); }
.theme-toggle svg { display: block; }

/* Fine barre de progression de défilement sous la barre du haut. */
@supports (animation-timeline: scroll()) {
  .topbar::after {
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: -1px;
    height: 2px;
    background: var(--violet-gradient);
    transform-origin: 0 50%;
    animation: scroll-progress linear both;
    animation-timeline: scroll(root);
  }
}
@keyframes scroll-progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ---------- Mise en page ---------- */
.container { padding: 18px var(--gutter) 64px; max-width: 1240px; animation: none; }
@media (min-width: 720px) { .container { padding-top: 32px; } }
.section { margin-bottom: 28px; }
@media (min-width: 720px) { .section { margin-bottom: 40px; } }

.card {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-1);
  padding: 16px;
}
@media (min-width: 720px) { .card { padding: 22px; } }
.card-help { color: var(--text-muted); font-size: 0.82rem; margin: -4px 0 12px; }

.empty-state { border-color: var(--border); color: var(--text-muted); background: var(--glass); padding: 28px 16px; }

/* ---------- Boutons ---------- */
.btn {
  font-weight: 700;
  border-radius: var(--radius-m);
  padding: 12px 18px;
  transition: transform 0.25s var(--ease-spring), box-shadow 0.2s ease, filter 0.2s ease, background 0.2s ease;
}
.btn:not(.secondary):not(.ghost):not(.danger) { background: var(--violet-fill); color: white; box-shadow: var(--shadow-violet), inset 0 1px 0 rgb(255 255 255 / 0.18); }
@media (hover: hover) {
  .btn:not(:disabled):hover { transform: translateY(-1px); }
  .btn:not(.secondary):not(.ghost):not(.danger):not(:disabled):hover { filter: brightness(1.1); }
}
.btn:not(:disabled):active { transform: scale(0.96); }
.btn.secondary { background: var(--glass-strong); color: var(--text-primary); border: 1px solid var(--border); }
.btn.ghost { color: var(--text-secondary); box-shadow: inset 0 0 0 1px var(--border); }
.btn.danger { background: var(--danger); color: white; }
.btn.small { padding: 8px 12px; font-size: 0.84rem; }
.show-more-btn { width: 100%; margin-top: 10px; }

/* ---------- Champs ---------- */
input[type="text"], input[type="number"], input[type="password"], select, textarea {
  background: var(--glass);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  font-size: 1rem; /* 16px : évite le zoom automatique d'iOS sur les champs */
  transition: border-color 0.15s ease, box-shadow 0.2s ease;
}
input::placeholder { color: var(--text-muted); }
input[type="text"]:focus, input[type="number"]:focus, input[type="password"]:focus, select:focus, textarea:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 4px var(--violet-soft);
}

/* ---------- Accueil : jeux en petites tuiles sur téléphone ---------- */
#games-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 14px !important; }
@media (min-width: 560px) { #games-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 900px) { #games-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; } }
.game-card {
  position: relative;
  overflow: hidden;
  background: var(--glass);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
  border-radius: var(--radius-l);
  padding: 12px 8px 10px;
  gap: 8px;
  align-items: center;
  text-align: center;
  transition: transform 0.35s var(--ease-spring), border-color 0.2s ease, box-shadow 0.25s ease;
}
.game-card .emoji { width: 44px; height: 44px; border-radius: 14px; font-size: 1.5rem; }
.game-card .emoji svg { width: 24px; height: 24px; }
.game-card .name { font-family: var(--f-display); font-size: 0.78rem; font-weight: 700; line-height: 1.15; letter-spacing: 0; }
.game-card .tagline { display: none; }
@media (min-width: 720px) {
  .game-card { padding: 18px 12px 14px; }
  .game-card .emoji { width: 54px; height: 54px; }
  .game-card .name { font-size: 0.92rem; }
}
.game-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent, var(--violet)) 55%, transparent); box-shadow: var(--shadow-2); }
.game-card > .emoji { transition: transform 0.45s var(--ease-spring); }
.game-card:hover > .emoji { transform: rotate(-6deg) scale(1.08); }
.game-card-badge { font-size: 0.62rem; }

.suggest-box { max-width: none; margin-top: 12px; padding: 0; }
.suggest-box-toggle { padding: 12px; color: var(--text-primary); }
.suggest-box-toggle strong { font-size: 0.88rem; }
.suggest-box-toggle span { font-size: 0.76rem; }

.home-columns { grid-template-columns: 1fr; gap: 24px; margin-top: 28px; }
@media (min-width: 900px) { .home-columns { grid-template-columns: 1fr 1fr; } }

.session-row {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 12px;
  gap: 10px;
  margin-bottom: 8px;
}
.session-row-finished { background: var(--glass) !important; border-left-width: 3px !important; }
.session-meta .game-name { font-family: var(--f-display); font-size: 0.92rem; }
.date-line { font-size: 0.76rem; }
.winner-line { font-size: 0.76rem; }

/* ---------- Puces, filtres, onglets ---------- */
.player-chip { background: var(--glass); border: 1px solid var(--border); color: var(--text-primary); font-weight: 600; transition: transform 0.25s var(--ease-spring), border-color 0.15s ease, background 0.15s ease; }
.player-chip:active { transform: scale(0.95); }
.player-chip:has(.player-chip-count) { padding-right: 6px; }
.player-chip-count { background: var(--violet-soft); color: var(--violet-ink); }


/* Stats : sur téléphone, le titre de chaque filtre passe au-dessus de son rail. */
@media (max-width: 719px) {
  .filter-row { flex-direction: column; align-items: stretch; gap: 6px; }
  .filter-row-label { flex: none; }
}
.filter-row:not(:last-child) { border-bottom-color: var(--border); }


.toggle-switch-track { background: var(--baseline); }
.toggle-switch input:checked + .toggle-switch-track { background: var(--violet-fill); }
.view-toggle { background: var(--glass); }
.view-toggle-btn.active, .toggle-btn.active { background: var(--glass-strong); color: var(--violet-ink); }
.sortable-th.sorted { color: var(--violet-ink); }
.resume-choice-option { background: var(--glass); border-color: var(--border); color: var(--text-primary); }
.resume-choice-option:hover { border-color: var(--violet-line); background: var(--violet-soft); }
.resume-choice-option.danger .resume-choice-title { color: var(--danger); }
a:not([class]) { color: var(--violet-ink); text-underline-offset: 3px; }

.same-players-tag { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; color: var(--violet-ink); background: var(--violet-soft); }

/* ---------- Tuiles de stats ---------- */
.stat-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 720px) { .stat-tiles { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; } }
.stat-tile {
  background: var(--glass);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
  border-radius: var(--radius-m);
  padding: 12px;
  transition: transform 0.3s var(--ease-spring), border-color 0.2s ease;
}
.stat-tile.clickable:hover { transform: translateY(-2px); border-color: var(--violet-line); box-shadow: var(--shadow-1); }
.stat-tile .value { font-family: var(--f-num); font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-tile .label { font-size: 0.68rem; letter-spacing: 0.04em; color: var(--text-muted); }
.stat-tile .sub { font-size: 0.74rem; }
@media (min-width: 720px) { .stat-tile { padding: 16px; } .stat-tile .value { font-size: 1.5rem; } }

.stat-tile.clickable { border: 1px solid var(--border); box-shadow: var(--shadow-1); padding-right: 28px; }
.stat-tile.clickable:hover { transform: translateY(-2px); box-shadow: var(--shadow-1); }
.stat-tile.clickable:active { transform: scale(0.98); box-shadow: var(--shadow-1); }
.stat-tile.clickable::after { color: var(--violet-ink); font-weight: 600; }

/* Classements (fin de partie, pop-ups de classement) */
.recap-ranking { gap: 6px; }
.recap-row { background: var(--glass); border: 1px solid var(--border); padding: 9px 10px; border-radius: var(--radius-m); }
.recap-name { font-weight: 600; font-size: 0.92rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recap-total { font-weight: 600; font-size: 0.8rem; color: var(--text-secondary); text-align: right; line-height: 1.25; }
.darts-ranking { padding: 8px; }

/* ---------- Tableaux ---------- */
.score-table th, .score-table td { border-color: var(--border); }
.score-table thead th { color: var(--text-muted); font-weight: 600; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; }
.table-scroll { -webkit-overflow-scrolling: touch; }
.sticky-col { position: sticky; left: 0; z-index: 1; background: var(--surface-1); }
.sticky-col span { white-space: nowrap; }

/* ---------- Popups ---------- */
.modal-overlay, .admin-modal-overlay { background: rgb(5 4 10 / 0.6); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.modal-box, .admin-modal-box {
  position: relative;
  background: var(--surface-1);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -20px 50px -20px rgb(0 0 0 / 0.6);
}
@media (max-width: 639px) {
  .modal-box::before { content: ''; display: block; width: 36px; height: 4px; border-radius: 999px; background: var(--baseline); margin: -8px auto 12px; }
}
.modal-box.has-auto-close { padding-top: 22px; }
.modal-auto-close { position: absolute; top: 12px; right: 12px; z-index: 2; }
.modal-box.has-auto-close > :first-child > h2:first-child, .modal-box.has-auto-close > :first-child:is(h2) { padding-right: 40px; }
.ui-dialog-box { max-width: 420px; }
.ui-dialog h2 { margin: 0 0 8px; padding-right: 40px; }
.ui-dialog-message { color: var(--text-secondary); margin: 0 0 18px; line-height: 1.45; }
.ui-dialog input[type="text"] { margin-bottom: 16px; }
.ui-dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }
.ui-dialog-actions .btn { flex: 1; }
@media (min-width: 640px) { .ui-dialog-actions .btn { flex: 0 0 auto; min-width: 120px; } }

/* ---------- Écran de chargement ---------- */
.page-loader { background: var(--page); transition: opacity 0.4s ease, visibility 0.4s; }
.page-loader-inner { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.loader-mark { width: 78px; height: auto; overflow: visible; animation: loader-breathe 1.8s ease-in-out 1.05s infinite; }
.loader-mark path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: loader-draw 0.6s var(--ease-out) forwards; animation-delay: calc(var(--i) * 0.13s + 0.05s); }
.loader-word { font-family: var(--f-display); font-size: 1.2rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-primary); opacity: 0; animation: loader-word 0.5s var(--ease-out) 0.6s forwards; }
@keyframes loader-draw { to { stroke-dashoffset: 0; } }
@keyframes loader-word { from { opacity: 0; transform: translateY(6px); letter-spacing: 0.3em; } to { opacity: 1; transform: none; } }
@keyframes loader-breathe { 50% { transform: scale(1.05); } }
.page-loader-hide { opacity: 0; visibility: hidden; }
.page-loader-hide .page-loader-inner { transform: scale(1.15); transition: transform 0.45s var(--ease-out); }

/* ---------- Téléphone : navigation en barre d'onglets en bas ---------- */
@media (max-width: 719px) {
  body:not(:has(#game-page-root)) { --bottom-nav-h: calc(66px + env(safe-area-inset-bottom)); }
  body:not(:has(#game-page-root)) .topbar nav {
    position: fixed;
    left: 50%;
    translate: -50% 0;
    bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 50;
    width: min(340px, calc(100% - 28px));
    justify-content: space-between;
    padding: 5px;
    background: color-mix(in srgb, var(--surface-1) 78%, transparent);
    -webkit-backdrop-filter: blur(20px) saturate(1.5);
    backdrop-filter: blur(20px) saturate(1.5);
    box-shadow: var(--shadow-2);
  }
  body:not(:has(#game-page-root)) .topbar nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 4px 6px; font-size: 0.7rem; }
  body:not(:has(#game-page-root)) .topbar nav a::before {
    content: '';
    width: 21px;
    height: 21px;
    background: currentColor;
    -webkit-mask: var(--nav-icon) center / contain no-repeat;
    mask: var(--nav-icon) center / contain no-repeat;
  }
  .topbar nav a[data-nav="home"] { --nav-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 10.5 12 3l9 7.5V20a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z'/%3E%3C/svg%3E"); }
  .topbar nav a[data-nav="players"] { --nav-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='8' r='3.5'/%3E%3Cpath d='M2.5 20a6.5 6.5 0 0 1 13 0'/%3E%3Cpath d='M16 4.6a3.5 3.5 0 0 1 0 6.8M18 14a6.5 6.5 0 0 1 3.5 6'/%3E%3C/svg%3E"); }
  .topbar nav a[data-nav="stats"] { --nav-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 20V11M10 20V4M16 20v-7M22 20H2'/%3E%3C/svg%3E"); }
  body:not(:has(#game-page-root)) .container { padding-bottom: calc(var(--bottom-nav-h) + 32px); }
  /* Page de partie : pas de barre du bas (la saisie occupe le bas de l'écran) et pas
     la place pour le menu en haut à côté des boutons — le logo ramène à l'accueil. */
  body:has(#game-page-root) .topbar nav { display: none; }
}

/* ---------- Webapp installée ---------- */
@media (display-mode: standalone) {
  html, body { overscroll-behavior-y: none; }
  body { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
  input, textarea, [contenteditable] { -webkit-user-select: text; user-select: text; }
  .entry-bar { bottom: calc(16px + env(safe-area-inset-bottom)); }
}

/* ==========================================================================
   Mouvements fluides
   ========================================================================== */
/* Pastille qui glisse d'un bouton actif à l'autre (voir PillSlider dans ui.js) : le
   bouton actif perd son fond propre, c'est la pastille qui le dessine. */
.pill-ready { position: relative; isolation: isolate; }
.pill-indicator {
  position: absolute;
  z-index: 0;
  pointer-events: none;
  background: var(--violet-fill);
  box-shadow: var(--shadow-violet);
  transition: opacity 0.2s ease;
  will-change: left, width, transform;
}
.pill-ready > :not(.pill-indicator) { position: relative; z-index: 1; transition: color 0.3s ease, opacity 0.3s ease; }
.pill-ready > .active, .pill-ready > [aria-checked="true"], .pill-ready > .current {
  background: transparent !important;
  box-shadow: none !important;
  border-color: transparent !important;
  transform: none !important;
}
.view-toggle .pill-indicator { background: var(--glass-strong); box-shadow: var(--shadow-1); }
.darts-board .pill-indicator { border-radius: var(--radius-l); }
@media (max-width: 719px) {
  .darts-board.pill-ready { padding-top: 4px; }
}

/* Changement d'onglet : l'ancien contenu s'efface en glissant, le nouveau arrive du
   côté de l'onglet choisi (--panel-dir : 1 vers la droite, -1 vers la gauche). */
.admin-tab-panel, .game-tab-panel { animation: none; }
.panel-leave { animation: panel-leave 0.14s ease forwards !important; pointer-events: none; }
.panel-enter { animation: panel-enter 0.42s var(--ease-out) both !important; }
@keyframes panel-leave { to { opacity: 0; transform: translateX(calc(var(--panel-dir, 1) * -16px)); filter: blur(2px); } }
@keyframes panel-enter { from { opacity: 0; transform: translateX(calc(var(--panel-dir, 1) * 22px)); filter: blur(3px); } }

/* ---------- Rails de choix : la DA du sélecteur 301 / 501 / 701 partout ----------
   Un rail vitré, des options sans fond, et la pastille violette granuleuse qui glisse
   sous l'option choisie (PillSlider). Filtres des stats, onglets, mode des fléchettes,
   joueur de la carte de chaleur… tout fonctionne pareil. */
.segmented, .period-filter, .group-filter, .game-filter, .heat-picker, .game-tabs, .view-toggle, .admin-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-m);
  background: var(--glass);
  border: 1px solid var(--border);
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  margin-bottom: 0;
}
.segmented { width: auto; }
.period-filter::-webkit-scrollbar, .group-filter::-webkit-scrollbar, .game-filter::-webkit-scrollbar,
.heat-picker::-webkit-scrollbar, .game-tabs::-webkit-scrollbar, .admin-tabs::-webkit-scrollbar { display: none; }
.period-btn, .game-filter a, .heat-chip, .game-tab-btn, .view-toggle-btn, .admin-tab-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  border-radius: 10px;
  padding: 8px 12px;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.86rem;
  white-space: nowrap;
  box-shadow: none;
  cursor: pointer;
  transition: color 0.3s ease, transform 0.25s var(--ease-spring), background 0.2s ease;
}
.period-btn:hover, .game-filter a:hover, .heat-chip:hover, .game-tab-btn:hover, .view-toggle-btn:hover, .admin-tab-btn:hover { color: var(--text-primary); background: var(--glass); border-color: transparent; }
.period-btn:active, .game-filter a:active, .heat-chip:active, .game-tab-btn:active, .admin-tab-btn:active { transform: scale(0.95); }
.pill-ready > .active { color: white !important; }
.view-toggle .pill-indicator { background: var(--violet-fill); box-shadow: var(--shadow-violet); }
.view-toggle-btn { padding: 6px 10px; font-size: 0.76rem; }
.darts-mode-filter { margin-bottom: 16px; }
.game-tabs { margin-bottom: 14px; }
/* Onglets de saisie des scores : couleur du joueur (chaque onglet = un joueur). */
.score-modal-tabs .pill-indicator {
  background: color-mix(in srgb, var(--pill-color) 22%, transparent);
  box-shadow: inset 0 0 0 1.5px var(--pill-color);
}
.score-modal-tabs.pill-ready > .active { color: var(--text-primary) !important; }

/* ---------- Choix multiples (joueurs…) : chaque élément choisi se remplit de violet
   comme un liquide, depuis l'endroit touché (--tap-x / --tap-y, voir ui.js), et se
   vide de la même façon quand on le retire. */
.player-chip {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background: var(--glass);
  border: 1px solid var(--border);
  transition: color 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease, transform 0.25s var(--ease-spring);
}
.player-chip::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--violet-fill);
  clip-path: circle(0px at var(--tap-x, 50%) var(--tap-y, 50%));
  transition: clip-path 0.55s cubic-bezier(.3, .7, .2, 1);
}
.player-chip.selected { background: var(--glass); border-color: transparent; color: white; box-shadow: var(--shadow-violet); }
.player-chip.selected::before { clip-path: circle(160% at var(--tap-x, 50%) var(--tap-y, 50%)); }
.player-chip.selected .player-chip-count { background: rgb(255 255 255 / 0.2); color: white; }

/* Interrupteurs : ressort, et le rond s'allonge pendant l'appui (comme sur iPhone). */
.toggle-switch-track { transition: background 0.3s ease; }
.toggle-switch-thumb { transition: transform 0.45s var(--ease-spring), width 0.25s var(--ease-out), left 0.25s var(--ease-out); }
.toggle-switch:active .toggle-switch-thumb { width: 25px; }
.toggle-switch:active input:checked + .toggle-switch-track .toggle-switch-thumb { left: -3px; }

/* Graphiques qui se dessinent à leur apparition. */
.bar-mark { transform-box: fill-box; transform-origin: 50% 100%; animation: bar-grow 0.7s var(--ease-spring) both; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes bar-grow { from { transform: scaleY(0); } }
.line-mark { stroke-dasharray: 1; stroke-dashoffset: 1; animation: line-draw 1s var(--ease-out) forwards; }
@keyframes line-draw { to { stroke-dashoffset: 0; } }
.dot-mark { animation: fade-in 0.3s ease both; animation-delay: calc(var(--t, 0) * 0.8s + 0.1s); }
.donut-mark { animation: donut-in 0.8s var(--ease-out) both; }
@keyframes donut-in { from { stroke-width: 0; opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }
.dartboard { animation: board-in 0.55s var(--ease-spring) both; }
@keyframes board-in { from { opacity: 0; transform: scale(0.9) rotate(-8deg); } }
.heat-top-bar span { animation: bar-x 0.7s var(--ease-out) both; transform-origin: 0 50%; }
@keyframes bar-x { from { transform: scaleX(0); } }

/* Listes et cartes : apparition douce (y compris les 5 suivantes avec "Afficher plus"). */
.session-row, .recap-row { animation: item-in 0.45s var(--ease-out) both; }
@keyframes item-in { from { opacity: 0; transform: translateY(10px); } }
.player-chip.selected { animation: chip-pop 0.4s var(--ease-spring); }
@keyframes chip-pop { 40% { transform: scale(1.08); } }
.darts-hint { animation: fade-in 0.25s ease both; }
.admin-tab-panel.active { animation: panel-enter 0.42s var(--ease-out) both; }

/* Changement de thème : le nouveau thème se dévoile en cercle (voir ui.js). Pendant
   cette transition, toute la page est traitée d'un bloc. */
.theme-vt .topbar, .theme-vt main.container { view-transition-name: none !important; }
html.theme-vt::view-transition-old(root), html.theme-vt::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
html.theme-vt::view-transition-old(root) { z-index: 1; }
html.theme-vt::view-transition-new(root) { z-index: 2; }

/* Navigation : après la première page, plus d'écran de chargement qui recouvre tout.
   La barre du haut et le menu restent visibles (la pastille glisse vers la nouvelle
   page), seul le contenu apparaît en fondu dès que les données sont prêtes. */
html[data-loader="quiet"] .page-loader { display: none; }
html[data-loader="quiet"] body:not(.page-ready) main.container > * { opacity: 0; }
/* Opacité seule : un transform ici casserait les barres en position fixed (saisie). */
html[data-loader="quiet"] body.page-ready main.container > * { animation: fade-in 0.4s ease both; }
html[data-loader="quiet"] body.page-ready main.container > :nth-child(2) { animation-delay: 0.04s; }
html[data-loader="quiet"] body.page-ready main.container > :nth-child(3) { animation-delay: 0.08s; }
html[data-loader="quiet"] body.page-ready main.container > :nth-child(n+4) { animation-delay: 0.12s; }

/* Popups : montée en ressort plutôt qu'en ligne droite. */
.modal-box { transition: transform 0.42s var(--ease-spring) !important; }

/* ==========================================================================
   Nouvelle partie : réglages (fléchettes)
   ========================================================================== */
.segmented { display: flex; gap: 4px; padding: 4px; border-radius: var(--radius-m); background: var(--glass); border: 1px solid var(--border); }
.segmented-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 10px 6px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s var(--ease-spring);
}
.segmented-btn:active { transform: scale(0.95); }
.segmented-btn.active { background: var(--violet-fill); color: white; box-shadow: var(--shadow-violet); }
.setting-help { color: var(--text-muted); font-size: 0.84rem; line-height: 1.45; margin: 12px 0 4px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.setting-text { display: flex; flex-direction: column; gap: 2px; }
.setting-label { font-weight: 700; font-size: 0.9rem; }
.setting-sub { color: var(--text-muted); font-size: 0.78rem; }
.setting-block { display: flex; flex-direction: column; gap: 8px; padding: 12px 0; }
.killer-numbers { display: flex; flex-wrap: wrap; gap: 6px; }
.killer-number-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 6px 4px 4px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--border); color: var(--text-primary);
  font-weight: 600; cursor: pointer;
}
.killer-number-chip strong { font-family: var(--f-display); min-width: 28px; padding: 2px 8px; border-radius: 999px; background: var(--dot-color); color: white; text-align: center; }

/* ==========================================================================
   Partie de fléchettes (page-darts.js)
   ========================================================================== */
.darts-page { display: flex; flex-direction: column; gap: 12px; }
.darts-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.darts-head h1 { display: flex; align-items: center; gap: 8px; font-size: 1.35rem; }
.darts-rules { margin: 4px 0 0; color: var(--text-muted); font-size: 0.82rem; }

.darts-board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(118px, 1fr); gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--gutter)); padding: 4px var(--gutter); scroll-snap-type: x proximity; }
.darts-board::-webkit-scrollbar { display: none; }
.darts-player {
  scroll-snap-align: center;
  position: relative;
  padding: 10px 12px;
  border-radius: var(--radius-l);
  background: var(--glass);
  border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 4px;
  transition: transform 0.3s var(--ease-spring), background 0.3s ease, opacity 0.3s ease;
}
.darts-player.current { background: var(--violet-fill); border-color: transparent; box-shadow: var(--shadow-violet); color: white; transform: translateY(-2px); }
.darts-player.current .darts-sub, .darts-player.current .darts-name { color: rgb(255 255 255 / 0.85); }
.darts-player.out { opacity: 0.35; }
.darts-player-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.darts-player-top .player-avatar { width: 26px; height: 26px; line-height: 22px; font-size: 0.9rem; border-width: 2px; }
.darts-name { font-weight: 600; font-size: 0.82rem; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.darts-rem { font-family: var(--f-num); font-size: 2.2rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.darts-sub { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 0.74rem; color: var(--text-muted); min-height: 14px; }
.leg-dots { display: inline-flex; gap: 3px; }
.leg-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--baseline); }
.darts-player.current .leg-dot.on { background: white !important; }
.killer-num { font-family: var(--f-num); font-size: 1.9rem; font-weight: 800; line-height: 1; display: flex; align-items: center; gap: 6px; }
.killer-badge { display: inline-flex; padding: 4px; border-radius: 8px; background: var(--danger); color: white; }
.killer-lives { display: flex; gap: 4px; }
.life { width: 10px; height: 10px; border-radius: 50%; background: var(--baseline); }
.life.on { background: var(--danger); box-shadow: 0 0 8px rgb(239 91 91 / 0.6); }
.darts-player.current .life.on { background: white; box-shadow: none; }

.darts-turn { padding: 12px; border-radius: var(--radius-l); background: var(--glass); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.darts-turn-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.darts-turn-who { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.darts-turn-who .player-avatar { width: 22px; height: 22px; line-height: 18px; font-size: 0.8rem; border-width: 2px; }
.darts-turn-total { font-family: var(--f-num); font-weight: 800; font-size: 1.1rem; }
.darts-slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.darts-slot {
  height: 46px; border-radius: 12px; border: 1px dashed var(--baseline);
  display: grid; place-items: center;
  font-family: var(--f-num); font-weight: 800; font-size: 1.15rem;
  color: var(--text-primary);
}
.darts-slot.filled { border-style: solid; border-color: transparent; background: var(--glass-strong); animation: slot-pop 0.35s var(--ease-spring); }
.darts-slot.next { border-color: var(--violet); box-shadow: 0 0 0 3px var(--violet-soft); }
@keyframes slot-pop { from { transform: scale(0.8); opacity: 0; } }
.darts-hint { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 0.84rem; color: var(--text-muted); }
.darts-hint.bust { color: var(--danger); font-weight: 700; }
.darts-hint.out { color: var(--success); font-weight: 700; }
.hint-label { font-weight: 700; color: var(--text-secondary); text-transform: uppercase; font-size: 0.7rem; letter-spacing: 0.05em; }
.hint-dart { padding: 4px 9px; border-radius: 8px; background: var(--violet-soft); color: var(--violet-ink); font-weight: 700; font-family: var(--f-num); font-size: 0.86rem; }

.darts-keypad { display: flex; flex-direction: column; gap: 8px; }
.darts-mult { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.darts-mult-btn {
  padding: 11px 6px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--glass); color: var(--text-secondary); font-weight: 700; font-size: 0.9rem; cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.2s var(--ease-spring);
}
.darts-mult-btn:active { transform: scale(0.95); }
.darts-mult-btn.active { background: var(--violet-fill); color: white; border-color: transparent; box-shadow: var(--shadow-violet); }
.darts-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.darts-key {
  position: relative;
  height: 50px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--glass-strong); color: var(--text-primary);
  font-family: var(--f-num); font-weight: 700; font-size: 1.2rem;
  cursor: pointer; touch-action: manipulation;
  transition: transform 0.15s var(--ease-spring), background 0.15s ease;
}
.darts-key small { position: absolute; top: 4px; left: 6px; font-size: 0.62rem; color: var(--violet-ink); font-family: var(--f-body); font-weight: 800; }
.darts-key:active { transform: scale(0.92); background: var(--violet-soft); }
.darts-row { display: grid; grid-template-columns: 1.3fr 1fr 0.8fr; gap: 6px; }
.darts-key.wide { font-size: 0.95rem; }
.darts-key.muted { background: var(--glass); color: var(--text-secondary); }
.darts-validate { width: 100%; }
@media (min-width: 720px) {
  .darts-page { max-width: 720px; margin: 0 auto; }
  .darts-board { margin: 0; padding: 4px 0; }
  .darts-key { height: 58px; }
}

.darts-section > summary { cursor: pointer; font-family: var(--f-display); font-weight: 700; list-style: none; display: flex; align-items: center; justify-content: space-between; }
.darts-section > summary::after { content: '+'; color: var(--text-muted); font-size: 1.2rem; }
.darts-section[open] > summary::after { content: '−'; }
.darts-section[open] > summary { margin-bottom: 12px; }
.darts-stats-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.darts-stats-table th, .darts-stats-table td { padding: 8px 6px; border-bottom: 1px solid var(--border); text-align: center; white-space: nowrap; }
.darts-stats-table thead th { font-size: 0.74rem; color: var(--text-secondary); }
.darts-stats-table thead th .player-avatar { width: 22px; height: 22px; line-height: 18px; font-size: 0.75rem; border-width: 2px; display: block; margin: 0 auto 4px; }
.darts-stats-table tbody th { text-align: left; color: var(--text-muted); font-weight: 500; position: sticky; left: 0; background: var(--surface-1); }
.darts-stats-table td { font-variant-numeric: tabular-nums; font-weight: 600; }
.darts-history { display: flex; flex-direction: column; }
.hist-row { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.86rem; }
.hist-row .player-avatar { width: 22px; height: 22px; line-height: 18px; font-size: 0.75rem; border-width: 2px; }
.hist-darts { font-family: var(--f-num); font-weight: 600; color: var(--text-secondary); word-spacing: 4px; }
.hist-score { font-weight: 700; font-variant-numeric: tabular-nums; }
.hist-score.out { color: var(--success); }
.hist-bust { color: var(--danger); font-weight: 700; }
.muted-line { color: var(--text-muted); font-size: 0.86rem; margin: 0; }

.darts-finished { display: flex; flex-direction: column; gap: 12px; }
.darts-winner { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: var(--radius-l); background: var(--violet-fill); color: white; box-shadow: var(--shadow-violet); }
.darts-winner-label { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.8; font-weight: 700; }
.darts-winner-name { font-family: var(--f-display); font-size: 1.6rem; font-weight: 800; }
.darts-ranking { display: flex; flex-direction: column; gap: 2px; }
.darts-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* Cible "carte de chaleur" */
.heat-chip .player-avatar { width: 20px; height: 20px; line-height: 16px; font-size: 0.7rem; border-width: 2px; }
.heat-picker { margin-bottom: 10px; }
.heat-holder { display: grid; place-items: center; }
.dartboard { max-width: 100%; height: auto; filter: drop-shadow(0 12px 24px rgb(0 0 0 / 0.4)); }
.dartboard path, .dartboard circle { transition: fill 0.3s ease; }
.heat-layout { display: grid; gap: 16px; align-items: center; }
@media (min-width: 720px) { .heat-layout { grid-template-columns: 300px 1fr; } }
.heat-top { display: flex; flex-direction: column; gap: 6px; }
.heat-top-row { display: grid; grid-template-columns: 52px 1fr 36px; align-items: center; gap: 8px; font-size: 0.84rem; }
.heat-top-zone { font-family: var(--f-num); font-weight: 700; }
.heat-top-bar { height: 8px; border-radius: 999px; background: var(--glass-strong); overflow: hidden; }
.heat-top-bar span { display: block; height: 100%; background: var(--violet-gradient); border-radius: inherit; }
.heat-top-count { text-align: right; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.darts-table td.sorted-col { color: var(--violet-ink); font-weight: 700; }
.darts-table td, .darts-table th { white-space: nowrap; }
.darts-table tbody th { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.darts-table .player-avatar { width: 22px; height: 22px; line-height: 18px; font-size: 0.75rem; border-width: 2px; }

/* ==========================================================================
   Composants maison (voir ui.js)
   ========================================================================== */
.ui-select { position: relative; width: 100%; }
.ui-select-native { position: absolute !important; opacity: 0 !important; pointer-events: none !important; width: 1px !important; height: 1px !important; inset: 0; }
.ui-select-trigger {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 12px 11px 14px; border-radius: var(--radius-m);
  border: 1px solid var(--border); background: var(--glass); color: var(--text-primary);
  font: inherit; font-size: 0.95rem; font-weight: 600; text-align: left; cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.2s ease;
}
.ui-select-trigger:hover { border-color: var(--violet-line); }
.ui-select.open .ui-select-trigger, .ui-select-trigger:focus-visible { outline: none; border-color: var(--violet); box-shadow: 0 0 0 4px var(--violet-soft); }
.ui-select-trigger:disabled { opacity: 0.5; cursor: not-allowed; }
.ui-select-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-select-chevron {
  flex: none; width: 16px; height: 16px; background: var(--text-muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: transform 0.25s var(--ease-spring), background 0.2s ease;
}
.ui-select.open .ui-select-chevron { transform: rotate(180deg); background: var(--violet); }
.ui-select-menu {
  position: fixed; z-index: 1000; overflow-y: auto; padding: 6px;
  border-radius: var(--radius-m); border: 1px solid var(--border);
  background: var(--surface-2); box-shadow: var(--shadow-2);
  opacity: 0; transform: translateY(-4px) scale(0.98); transform-origin: top center;
  transition: opacity 0.14s ease, transform 0.2s var(--ease-out); scrollbar-width: thin;
}
.ui-select-menu.up { transform-origin: bottom center; transform: translateY(4px) scale(0.98); }
.ui-select-menu.show { opacity: 1; transform: none; }
.ui-select-option { padding: 10px 12px; border-radius: 10px; font-weight: 600; font-size: 0.92rem; cursor: pointer; white-space: nowrap; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.ui-select-option.active { background: var(--glass-strong); }
.ui-select-option.selected { color: var(--violet-ink); }
.ui-select-option.selected::after {
  content: ''; width: 14px; height: 14px; background: var(--violet);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5 10 17 19 7'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5 10 17 19 7'/%3E%3C/svg%3E") center / contain no-repeat;
}
.ui-select-option.disabled { opacity: 0.4; cursor: not-allowed; }

input[type="checkbox"]:not(.toggle-switch input):not(.setting-row input) {
  -webkit-appearance: none; appearance: none; flex: none;
  width: 20px !important; height: 20px; margin: 0 6px 0 0; border-radius: 6px;
  border: 1.5px solid var(--baseline); background: var(--glass);
  vertical-align: -4px; cursor: pointer; display: inline-grid; place-content: center;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.2s var(--ease-spring);
}
input[type="checkbox"]:not(.toggle-switch input):not(.setting-row input)::before {
  content: ''; width: 10px; height: 6px; border-left: 2.5px solid white; border-bottom: 2.5px solid white;
  transform: rotate(-45deg) scale(0); margin-top: -2px; transition: transform 0.2s var(--ease-spring);
}
input[type="checkbox"]:not(.toggle-switch input):not(.setting-row input):checked { background: var(--violet-fill); border-color: transparent; }
input[type="checkbox"]:not(.toggle-switch input):not(.setting-row input):checked::before { transform: rotate(-45deg) scale(1); }

.ui-color-picker { display: flex; flex-direction: column; gap: 14px; }
.ui-color-picker h2 { margin: 0; }
.ui-color-sv { position: relative; height: 180px; border-radius: var(--radius-m); background: linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, var(--hue, red)); touch-action: none; cursor: crosshair; }
.ui-color-hue { position: relative; height: 16px; border-radius: 999px; background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00); touch-action: none; cursor: ew-resize; }
.ui-color-sv-thumb, .ui-color-hue-thumb { position: absolute; width: 20px; height: 20px; border-radius: 50%; border: 3px solid white; box-shadow: 0 1px 4px rgb(0 0 0 / 0.4); transform: translate(-50%, -50%); pointer-events: none; }
.ui-color-hue-thumb { top: 50%; }
.ui-color-row { display: flex; gap: 10px; align-items: center; }
.ui-color-swatch { width: 44px; height: 44px; border-radius: var(--radius-s); flex: none; box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.1); }
.ui-color-hex { font-family: ui-monospace, SFMono-Regular, Menlo, monospace !important; text-transform: uppercase; }

@media (prefers-reduced-motion: reduce) {
  html::before, body::before { animation: none; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  @view-transition { navigation: none; }
}

/* ==========================================================================
   Cohérence : des carrés aux bords arrondis partout, comme le sélecteur 301/501/701
   (plus aucune forme en "gélule"). Petits éléments = petits arrondis.
   ========================================================================== */
.topbar nav { border-radius: var(--radius-m); }
.topbar nav a { border-radius: 10px; }
.player-chip, .heat-chip, .killer-number-chip, .player-detail-group-chip, .toast, .game-card-badge, .player-badge { border-radius: 10px; }
.player-chip-count, .same-players-tag, .tab-check, .order-badge, .killer-number-chip strong,
.rating-badge, .in-progress-tag, .multi-sitting-flag, .group-initials, .info-icon { border-radius: 7px; }
.player-dot, .player-avatar { border-radius: 30%; }
.rank-trend-dot, .recent-form-dot, .leg-dot, .life { border-radius: 3px; }
.rating-row-bar-track, .heat-top-bar, .heat-top-bar span, .ui-color-hue { border-radius: 5px; }
.toggle-switch-track { border-radius: 9px; }
.toggle-switch-thumb { border-radius: 7px; }
.ui-color-sv-thumb, .ui-color-hue-thumb { border-radius: 7px; }
.modal-box::before { border-radius: 2px; }

/* ---------- Accueil : tuiles des jeux en lignes équilibrées ----------
   --cols est calculé par layoutGamesGrid (page-home.js) selon la largeur et le nombre
   de jeux ; les tuiles d'une ligne incomplète s'élargissent pour la remplir. */
#games-grid {
  display: flex !important;
  flex-wrap: wrap;
  gap: var(--gap, 10px);
}
#games-grid > .game-card {
  flex: 1 1 calc((100% - (var(--cols, 3) - 1) * var(--gap, 10px)) / var(--cols, 3));
  min-width: 0;
}

/* ---------- Accueil : parties inactives (jamais terminées) ---------- */
.stale-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  margin-bottom: 10px;
  border-radius: var(--radius-m);
  background: var(--violet-soft);
  border: 1px solid var(--violet-line);
}
.stale-actions p { margin: 0; font-size: 0.84rem; color: var(--text-secondary); flex: 1 1 200px; }
.stale-tag {
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 7px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--violet-ink);
  background: var(--violet-soft);
}
.session-actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; flex-shrink: 0; }
.session-row-stale .avatar-stack { opacity: 0.75; }
@media (max-width: 560px) {
  .session-row:has(.session-actions .btn + .btn) { flex-wrap: wrap; }
  .session-row:has(.session-actions .btn + .btn) .session-actions { flex-direction: row; width: 100%; }
  .session-row:has(.session-actions .btn + .btn) .session-actions .btn { flex: 1; }
}

/* ---------- Fin de partie : gagnant ou perdant (jeux à mort subite) ---------- */
.recap-headline { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; margin-bottom: 18px; }
.recap-headline .player-avatar { margin-bottom: 6px; }
.recap-headline-label { font-size: 0.72rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--violet-ink); }
.recap-headline-name { font-family: var(--f-display); font-size: 1.2rem; font-weight: 800; }
.recap-headline-sub { font-size: 0.82rem; color: var(--text-muted); }
.recap-headline.loser .recap-headline-label { color: var(--danger); }
.loser-line { color: var(--danger); font-weight: 700; }

/* ---------- Logos de groupe : la vraie image (photo ou logo) ----------
   Fond clair derrière : un logo à fond transparent reste lisible, même en thème sombre. */
.group-logo, .group-logo-preview {
  display: inline-block;
  flex-shrink: 0;
  background-color: #f4f3f8;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  -webkit-mask: none;
  mask: none;
  border-radius: 7px;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.08);
}
.group-logo { width: 22px; height: 22px; vertical-align: -6px; }
.group-logo-preview { width: 30px; height: 30px; border-radius: 9px; }
.player-detail-group-chip .group-logo { width: 18px; height: 18px; vertical-align: -4px; }

/* ---------- Respiration : de l'air au-dessus des titres ---------- */
.admin-tabs { margin: 4px 0 26px; }
.game-tabs { margin-bottom: 18px; }
.filters-panel { margin-bottom: 26px; }
.darts-mode-filter { margin-bottom: 22px; }
.subtitle { margin-bottom: 20px; }
#games-grid { margin-top: 18px !important; }
.home-columns { margin-top: 36px; }
.section > h2:first-child, .section > h3:first-child { margin-top: 2px; }
.section > h2 { margin-bottom: 14px; }
.card > h2, .card > h3 { margin-bottom: 14px; }
.card-help { margin-top: -6px; margin-bottom: 14px; }
.admin-tab-panel > .section:first-child { margin-top: 4px; }
.stat-tiles + .section, .card + .section { margin-top: 8px; }
@media (min-width: 720px) {
  .admin-tabs { margin-bottom: 32px; }
  .section > h2 { margin-bottom: 16px; }
}

/* ---------- Curseur personnalisé (ordinateur, voir ui.js) ---------- */
html.custom-cursor, html.custom-cursor * { cursor: none !important; }
html.custom-cursor input[type="text"], html.custom-cursor input[type="number"], html.custom-cursor input[type="password"],
html.custom-cursor input:not([type]), html.custom-cursor textarea, html.custom-cursor [contenteditable="true"] { cursor: text !important; }
.cursor-blob, .cursor-dot {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10002;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
  will-change: transform;
}
.cursor-blob {
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border-radius: 50%;
  border: 1.5px solid var(--violet-ink);
  background: color-mix(in srgb, var(--violet) 10%, transparent);
  transition: opacity 0.25s ease, background 0.25s ease, border-color 0.25s ease;
}
.cursor-dot {
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: var(--violet-ink);
}
html.cursor-visible .cursor-blob, html.cursor-visible .cursor-dot { opacity: 1; }
html.cursor-hover .cursor-blob { background: color-mix(in srgb, var(--violet) 22%, transparent); border-color: transparent; }
html.cursor-hover .cursor-dot { opacity: 0; }
html.cursor-text .cursor-blob, html.cursor-text .cursor-dot { opacity: 0 !important; }
