:root {
  --fond: #eaf0f4; --carte: #fff; --encre: #12243a; --doux: #566779; --trait: #cfdae3;
  --rouge: #c8142c; --bleu: #1d5fae; --bleu-pale: #dde9f6; --sur-rouge: #fff;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    --fond: #0c141d; --carte: #15212e; --encre: #e8eff5; --doux: #95a6b6; --trait: #283a4b;
    --rouge: #ff5064; --bleu: #6fb0ff; --bleu-pale: #183250; --sur-rouge: #1a0307;
    color-scheme: dark;
  }
}
:root[data-theme=dark] {
  --fond: #0c141d; --carte: #15212e; --encre: #e8eff5; --doux: #95a6b6; --trait: #283a4b;
  --rouge: #ff5064; --bleu: #6fb0ff; --bleu-pale: #183250; --sur-rouge: #1a0307;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; height: 100vh; height: 100dvh; background: var(--fond); color: var(--encre); font: 400 16px/1.5 Barlow, system-ui, sans-serif; display: flex; flex-direction: column; overflow: hidden; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--bleu); outline-offset: 2px; }
h1, h2, .marque, .gros, .btn, #temps, .num { font-family: "Barlow Condensed", "Arial Narrow", sans-serif; }

.haut { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 20px; border-bottom: 3px solid var(--rouge); background: var(--carte); }
.marque { color: inherit; font-weight: 700; font-size: 26px; text-decoration: none; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.rond { width: 24px; height: 24px; border: 3px solid var(--bleu); border-radius: 50%; position: relative; }
.rond::after { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--rouge); }
.haut-actions { display: flex; gap: 8px; }

.btn { border: 1.5px solid var(--trait); background: var(--carte); color: var(--encre); border-radius: 8px; padding: 8px 16px; min-height: 44px; font-weight: 600; font-size: 18px; line-height: 1.2; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; }
.btn:hover { border-color: var(--bleu); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.plein { background: var(--rouge); border-color: var(--rouge); color: var(--sur-rouge); }
.btn.icone { width: 44px; padding: 0; }

.page { flex: 1; min-height: 0; display: grid; grid-template-columns: 372px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.liste { border-right: 1px solid var(--trait); overflow-y: auto; background: var(--carte); }
.recherche { position: sticky; top: 0; background: var(--carte); padding: 16px 16px 12px; border-bottom: 1px solid var(--trait); z-index: 1; }
#q { width: 100%; min-height: 44px; padding: 8px 12px; border: 1.5px solid var(--trait); border-radius: 8px; background: var(--fond); }
.groupes, .presets { display: flex; flex-wrap: wrap; gap: 6px; }
#filtres { margin-top: 10px; }
.puce { border: 1.5px solid var(--trait); background: none; border-radius: 99px; padding: 4px 12px; min-height: 36px; font-size: 14px; font-weight: 500; cursor: pointer; }
.puce[aria-pressed=true] { background: var(--encre); border-color: var(--encre); color: var(--carte); }
#cats { list-style: none; margin: 0; padding: 8px 0 16px; }
#cats a { color: inherit; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 7px 16px; text-decoration: none; font-weight: 500; border-left: 4px solid transparent; }
#cats a:hover { background: var(--fond); }
#cats a[aria-current=page] { background: var(--bleu-pale); border-left-color: var(--bleu); }
#cats small { color: var(--doux); font-size: 13px; font-weight: 400; }
.vide { padding: 16px; color: var(--doux); margin: 0; }

main { overflow-y: auto; padding: 32px clamp(16px, 4vw, 56px) 48px; outline: none; }
main > * { max-width: 820px; }
.retour { display: none; }
h1 { font-size: clamp(34px, 5vw, 52px); line-height: 1.05; margin: 0 0 8px; font-weight: 700; text-wrap: balance; }
.desc { font-size: 18px; margin: 0 0 6px; max-width: 62ch; }
.aussi { color: var(--doux); font-size: 14px; margin: 0 0 4px; }
.outil { background: var(--carte); border: 1px solid var(--trait); border-radius: 12px; padding: 20px; margin-top: 24px; }
.outil h2 { font-size: 22px; font-weight: 600; margin: 0 0 14px; }
.outil .groupes { margin-bottom: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

.tableau { border: 2px solid var(--bleu); border-radius: 10px; min-height: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px 18px; background: var(--fond); }
.gros { font-size: clamp(30px, 5.4vw, 50px); line-height: 1.12; font-weight: 700; text-wrap: balance; overflow-wrap: anywhere; }
.gros.long { font-size: clamp(25px, 3.6vw, 36px); font-weight: 600; }
.gros.lettre { font-size: 120px; line-height: 1; }
.indice { color: var(--doux); font-size: 17px; margin-top: 8px; text-wrap: balance; }
.tableau.alerte { background: var(--rouge); border-color: var(--rouge); color: var(--sur-rouge); }

.lignes { list-style: none; margin: 0; padding: 0; }
.lignes li { display: grid; grid-template-columns: 150px 1fr 44px; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--trait); }
.lignes li:first-child { border-top: 0; }
.lignes .nom { color: var(--doux); font-size: 15px; }
.lignes .val { font-size: 20px; font-weight: 600; line-height: 1.25; }
.lignes .val small { display: block; font-size: 15px; font-weight: 400; color: var(--doux); }
.relance { width: 44px; height: 44px; border: 0; background: none; border-radius: 8px; font-size: 22px; cursor: pointer; color: var(--bleu); }
.relance:hover { background: var(--fond); }
.cache .val, .cache.tableau > * { filter: blur(12px); user-select: none; }

.serie { margin: 16px 0 0; padding-left: 28px; columns: 2; column-gap: 40px; }
.serie li { padding: 3px 0; break-inside: avoid; }
.serie li::marker { color: var(--doux); }

.etapes { list-style: none; margin: 0; padding: 0; }
.etapes li { display: flex; gap: 14px; align-items: baseline; padding: 9px 12px; border-left: 4px solid var(--trait); }
.etapes .num { min-width: 84px; flex: none; color: var(--doux); font-size: 17px; font-weight: 600; }
.etapes small { color: var(--doux); display: block; font-weight: 400; }
.etapes li.ici { border-left-color: var(--rouge); background: var(--fond); font-weight: 600; font-size: 19px; }
.etapes li.fait { opacity: .5; }
.etapes .fin { margin-left: auto; }

.alphabet { display: grid; grid-template-columns: repeat(13, 1fr); gap: 4px; margin-top: 16px; }
.alphabet button { min-height: 44px; border: 1.5px solid var(--trait); border-radius: 6px; background: none; cursor: pointer; font-weight: 600; padding: 0; }
.alphabet .fait { opacity: .35; }
.alphabet .ici { background: var(--rouge); border-color: var(--rouge); color: var(--sur-rouge); }

.carre { display: grid; grid-template-columns: 1fr 1.1fr 1fr; grid-template-areas: ". n ." "o c e" "s s s"; gap: 10px; align-items: center; }
.carre > div { border: 1.5px solid var(--trait); border-radius: 10px; padding: 12px; text-align: center; min-height: 88px; display: flex; flex-direction: column; justify-content: center; font-weight: 500; overflow-wrap: anywhere; }
.carre small { color: var(--doux); font-weight: 400; }
.carre .n { grid-area: n; }
.carre .e { grid-area: e; }
.carre .o { grid-area: o; }
.carre .s { grid-area: s; border: 3px solid var(--rouge); font-size: 24px; font-weight: 600; line-height: 1.25; }
.carre .s small { font-size: 14px; }
.carre .c { grid-area: c; border-style: dashed; color: var(--doux); }

.patinoire { display: grid; border: 3px solid var(--encre); border-radius: 36px; overflow: hidden; grid-template-columns: repeat(var(--col), 1fr); gap: 2px; background: var(--rouge); }
.patinoire button { min-height: 120px; background: var(--fond); border: 0; font-size: 20px; font-weight: 600; cursor: pointer; padding: 12px; overflow-wrap: anywhere; }
.patinoire button:hover { background: var(--bleu-pale); }

.chrono { display: flex; align-items: center; gap: 10px; padding: 8px 20px; background: var(--carte); border-top: 1px solid var(--trait); }
#temps { font-size: 36px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 92px; line-height: 1; }
.chrono.fini #temps { color: var(--rouge); }
.presets { flex: 1; }

.lignes .duo { display: flex; }
.lignes li:has(.duo) { grid-template-columns: 150px 1fr 88px; }
.lignes .garde { background: var(--bleu-pale); }

.icone-cat { --ton: 215; flex: none; display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; font-size: 19px; line-height: 1; background: hsl(var(--ton) 85% 88%); font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif; transition: transform .15s; }
.icone-cat.libre { --ton: 48; }
.icone-cat.style { --ton: 285; }
.icone-cat.contrainte { --ton: 350; }
.icone-cat.structure { --ton: 205; }
.icone-cat.expression { --ton: 150; }
.icone-cat.concept { --ton: 25; }
h1 { display: flex; align-items: center; gap: 16px; }
h1 .icone-cat { width: 68px; height: 68px; border-radius: 18px; font-size: 38px; }
#cats .titre { flex: 1; }
#cats a:hover .icone-cat { transform: rotate(-8deg) scale(1.12); }
@media (prefers-color-scheme: dark) { :root:not([data-theme=light]) .icone-cat { background: hsl(var(--ton) 40% 26%); } }
:root[data-theme=dark] .icone-cat { background: hsl(var(--ton) 40% 26%); }

@media (max-width: 820px) {
  .page { grid-template-columns: minmax(0, 1fr); }
  body:not(.ouvert) main { display: none; }
  body.ouvert .liste { display: none; }
  .liste { border-right: 0; }
  .retour { display: inline-block; margin: 0 0 8px; padding: 8px 0; color: var(--bleu); font-weight: 500; text-decoration: none; }
  main { padding-top: 10px; padding-bottom: 24px; }
  .haut { padding: 8px 16px; }
  .marque { font-size: 23px; }
  .outil { padding: 16px; margin-top: 16px; }
  .lignes li { grid-template-columns: 1fr 44px; gap: 0 8px; }
  .lignes .nom { grid-column: 1; grid-row: 1; }
  .lignes .val { grid-column: 1; grid-row: 2; }
  .relance, .lignes .duo { grid-column: 2; grid-row: 1 / 3; }
  .lignes li:has(.duo) { grid-template-columns: 1fr 88px; }
  h1 { gap: 12px; }
  h1 .icone-cat { width: 52px; height: 52px; border-radius: 14px; font-size: 29px; }
  .serie { columns: 1; }
  .alphabet { grid-template-columns: repeat(7, 1fr); }
  .carre { gap: 6px; }
  .carre > div { padding: 8px; font-size: 14px; line-height: 1.3; }
  .carre .s { font-size: 19px; }
  .patinoire button { min-height: 92px; font-size: 16px; padding: 6px; }
  .chrono { padding: 8px 16px; gap: 8px; flex-wrap: wrap; }
  .chrono .presets { order: 3; flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .presets .puce { flex: none; }
  #temps { flex: 1; }
  .etapes .num { min-width: 70px; }
}
@media (prefers-reduced-motion: no-preference) {
  .tableau .gros { animation: arrive .18s ease-out; }
  @keyframes arrive { from { transform: translateY(6px); opacity: .2; } }
}
.sous { color: var(--doux); margin: 22px 0 8px; font-weight: 500; }
.outil .groupes:last-child { margin-bottom: 0; }

#joueurs { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-weight: 600; font-size: 15px; }
#joueurs .groupes { flex-wrap: nowrap; gap: 3px; }
#joueurs .puce { min-width: 36px; padding: 4px 8px; }
#joueurs .puce[aria-pressed=true] { background: var(--bleu); border-color: var(--bleu); }
#caches { margin: 10px 0 0; font-size: 14px; color: var(--doux); }
.aussi.trop { color: var(--rouge); font-weight: 600; }
#cats small { font-variant-numeric: tabular-nums; }
