/* ============================================================
   TOURNOI DE GESTION — design system Capio
   Charte : bleu Capio #123A66, bleu nuit #0A1E38, orange #F07D00
   (accent seulement, jamais en texte sur fond clair), crème
   #F5F1DE, police Jost. Règle 60-30-10. Mobile-first.
   Un « skin » de sujet peut surcharger les variables --skin-*.
   ============================================================ */

@font-face {
  font-family: 'Jost';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/jost-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122;
}
@font-face {
  font-family: 'Jost';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/jost-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C0;
}

:root {
  /* Jetons Capio */
  --bleu-capio: #123A66;
  --bleu-nuit: #0A1E38;
  --orange-capio: #F07D00;
  --orange-fonce: #D95F00;
  --creme: #F5F1DE;
  --blanc: #FFFFFF;
  --gris-ardoise: #5C6B7A;
  --gris-fond: #EEF1F4;
  --bleu-clair: #DCE7F2;
  --succes: #2E8B57;
  --succes-fond: #E6F3EC;
  --erreur: #C0392B;
  --erreur-fond: #F9E9E7;
  --alerte: #E9A400;
  --alerte-fond: #FCF3DC;
  --info: #2E7FB8;
  --info-fond: #E5F0F8;
  --texte: #1A1A1A;
  --bord: #DDE3E9;
  --ombre: 0 2px 10px rgba(10, 30, 56, .08);
  --radius-bouton: 8px;
  --radius-carte: 12px;

  /* Variables de skin (surchargées par css/skins/<sujet>.css) */
  --skin-header-bg: linear-gradient(120deg, var(--bleu-nuit), var(--bleu-capio));
  --skin-page-bg: var(--creme);
  --skin-page-texture: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Jost', 'Segoe UI', Arial, sans-serif;
  background: var(--skin-page-bg);
  background-image: var(--skin-page-texture);
  color: var(--texte);
  font-size: 16px;
  line-height: 1.5;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; color: var(--bleu-capio); }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 {
  font-size: 1.2rem; font-weight: 700;
  padding-bottom: 4px;
  border-bottom: 2px solid var(--orange-capio);
  display: flex; align-items: center; gap: 8px;
}
h3 { font-size: 1.02rem; font-weight: 600; color: var(--bleu-nuit); }
p { margin: .4em 0; }
a { color: var(--info); }

.wrap { max-width: 1150px; margin: 0 auto; padding: 12px; }
.wrap-narrow { max-width: 660px; margin: 0 auto; padding: 16px; }

/* ---------- En-tête ---------- */
header.app {
  background: var(--skin-header-bg);
  color: #fff;
  padding: 10px 16px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 2px 10px rgba(10, 30, 56, .35);
}
header.app .inner {
  max-width: 1150px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
header.app .mascotte { width: 40px; height: 40px; border-radius: 8px; flex: 0 0 auto; }
header.app .titre { font-weight: 700; font-size: 1.06rem; }
header.app .sous { opacity: .85; font-size: .8rem; }
header.app .spacer { flex: 1; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 999px; padding: 4px 12px;
  font-size: .85rem; font-weight: 600; white-space: nowrap;
}

/* ---------- Cartes ---------- */
.card {
  background: var(--blanc);
  border: 1px solid var(--bord);
  border-top: 3px solid var(--orange-capio);
  border-radius: var(--radius-carte);
  box-shadow: var(--ombre);
  padding: 16px;
  margin: 12px 0;
}
.card.sobre { border-top: 1px solid var(--bord); }
.muted { color: var(--gris-ardoise); font-size: .86rem; }
.small { font-size: .86rem; }
.center { text-align: center; }

/* ---------- Onglets ---------- */
.tabs {
  display: flex; gap: 2px; margin: 12px 0 0;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  border-bottom: 2px solid var(--bord);
}
.tabs button {
  appearance: none; border: none; background: none;
  padding: 10px 14px; font-size: .95rem; font-weight: 600;
  color: var(--gris-ardoise); cursor: pointer; white-space: nowrap;
  border-bottom: 3px solid transparent; margin-bottom: -2px;
  font-family: inherit;
}
.tabs button.actif { color: var(--bleu-capio); border-bottom-color: var(--orange-capio); }
.tab-page { display: none; }
.tab-page.actif { display: block; }

/* ---------- Boutons (charte : CTA orange, texte bleu nuit gras) ---------- */
.btn {
  appearance: none; border: none; cursor: pointer;
  font-family: inherit; font-size: 1rem; font-weight: 700;
  padding: 12px 20px; border-radius: var(--radius-bouton);
  background: var(--orange-capio); color: var(--bleu-nuit);
  box-shadow: 0 2px 6px rgba(240, 125, 0, .3);
  transition: background .15s, transform .05s;
  min-height: 48px;
}
.btn:hover { background: var(--orange-fonce); }
.btn:active { transform: scale(.98); }
.btn:disabled { background: #CBD3DA; color: #7B8794; box-shadow: none; cursor: not-allowed; }
.btn.secondaire {
  background: transparent; color: var(--bleu-capio);
  border: 1.5px solid var(--bleu-capio); box-shadow: none;
}
.btn.secondaire:hover { background: var(--bleu-clair); }
.btn.danger { background: var(--erreur); color: #fff; box-shadow: 0 2px 6px rgba(192, 57, 43, .3); }
.btn.danger:hover { background: #A93226; }
.btn.vert { background: var(--succes); color: #fff; box-shadow: 0 2px 6px rgba(46, 139, 87, .3); }
.btn.vert:hover { background: #257048; }
.btn.large { width: 100%; padding: 14px; font-size: 1.08rem; }
.btn.mini { padding: 6px 12px; font-size: .85rem; min-height: 36px; border-radius: 7px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 700;
}
.badge.vert { background: var(--succes-fond); color: var(--succes); }
.badge.rouge { background: var(--erreur-fond); color: var(--erreur); }
.badge.ambre { background: var(--alerte-fond); color: #8A6200; }
.badge.bleu { background: var(--bleu-clair); color: var(--bleu-capio); }
.badge.gris { background: var(--gris-fond); color: var(--gris-ardoise); }

/* ---------- Formulaires ---------- */
label.champ { display: block; margin: 12px 0 4px; font-weight: 600; font-size: .92rem; color: var(--bleu-nuit); }
.hint { font-size: .8rem; color: var(--gris-ardoise); margin: 2px 0 0; }
input[type=text], input[type=number], input[type=password], select, textarea {
  width: 100%; padding: 11px 12px; font-size: 1.02rem;
  border: 1.5px solid var(--bord); border-radius: var(--radius-bouton);
  background: var(--blanc); color: var(--texte); font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--bleu-capio); }
input.invalide { border-color: var(--erreur); background: var(--erreur-fond); }
input:disabled, select:disabled { background: var(--gris-fond); color: var(--gris-ardoise); }

.saisie { display: flex; align-items: stretch; gap: 6px; }
.saisie input { text-align: center; font-weight: 700; }
.saisie .pas {
  flex: 0 0 46px; border: 1.5px solid var(--bord); border-radius: var(--radius-bouton);
  background: var(--blanc); font-size: 1.2rem; font-weight: 700; color: var(--bleu-capio);
  cursor: pointer; font-family: inherit; min-height: 48px;
}
.saisie .pas:active { background: var(--bleu-clair); }
.saisie .pas:disabled { color: #AAB4BE; cursor: not-allowed; }

/* Sélecteur segmenté (config animateur : Équipe / Professeur / Non utilisé) */
.seg { display: inline-flex; border: 1.5px solid var(--bord); border-radius: 8px; overflow: hidden; }
.seg button {
  appearance: none; border: none; background: var(--blanc); cursor: pointer;
  padding: 6px 10px; font-family: inherit; font-size: .8rem; font-weight: 600;
  color: var(--gris-ardoise); border-right: 1px solid var(--bord);
}
.seg button:last-child { border-right: none; }
.seg button.actif { background: var(--bleu-capio); color: #fff; }
.seg button.actif.off { background: var(--gris-ardoise); }

/* Curseur de difficulté */
input[type=range] { width: 100%; accent-color: var(--orange-capio); height: 34px; }

/* Interrupteur simple (rendus visibles/masqués) */
.coche { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: .92rem; }
.coche input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--bleu-capio); flex: 0 0 auto; }

/* ---------- Tableaux ---------- */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.donnees { border-collapse: collapse; width: 100%; font-size: .92rem; }
table.donnees th, table.donnees td {
  padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--bord);
  white-space: nowrap;
}
table.donnees th {
  background: var(--gris-fond); font-size: .76rem; text-transform: uppercase;
  letter-spacing: .04em; color: var(--gris-ardoise);
}
table.donnees td:first-child, table.donnees th:first-child { text-align: left; white-space: normal; }
table.donnees tr.total td { font-weight: 800; border-top: 2px solid var(--bleu-capio); background: var(--bleu-clair); }
table.donnees tr.sous-total td { font-weight: 700; background: var(--gris-fond); }
table.donnees tr.section td {
  font-weight: 700; color: var(--bleu-capio); background: var(--creme);
  text-transform: uppercase; font-size: .78rem; letter-spacing: .04em;
}
.pos { color: var(--succes); font-weight: 700; }
.neg { color: var(--erreur); font-weight: 700; }

/* États financiers multi-tours : 1re colonne libellés, tours en colonnes */
table.fin { border-collapse: collapse; width: 100%; font-size: .9rem; }
table.fin th, table.fin td { padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--bord); }
table.fin th:first-child, table.fin td:first-child { text-align: left; white-space: normal; }
table.fin th { background: var(--bleu-capio); color: #fff; font-size: .8rem; }
table.fin tr.solde td { font-weight: 800; background: var(--bleu-clair); }
table.fin tr.grand-total td { font-weight: 800; background: var(--creme); border-top: 2px solid var(--bleu-capio); }

/* ---------- Chrono ---------- */
.chrono { font-variant-numeric: tabular-nums; font-weight: 800; letter-spacing: .02em; }
.chrono.grand { font-size: 2rem; }

/* ---------- Bandeaux ---------- */
.bandeau {
  border-radius: 10px; padding: 12px 14px; margin: 10px 0;
  font-weight: 600; font-size: .95rem;
  display: flex; gap: 10px; align-items: flex-start;
}
.bandeau.info { background: var(--info-fond); color: var(--info); }
.bandeau.ok { background: var(--succes-fond); color: var(--succes); }
.bandeau.alerte { background: var(--alerte-fond); color: #8A6200; }
.bandeau.erreur { background: var(--erreur-fond); color: var(--erreur); }

#hors-ligne {
  position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%);
  background: var(--erreur); color: #fff; padding: 10px 18px;
  border-radius: 999px; font-weight: 700; box-shadow: 0 4px 14px rgba(0,0,0,.3);
  display: none; z-index: 100; font-size: .9rem; white-space: nowrap;
}

/* ---------- Grilles ---------- */
.grille-2 { display: grid; grid-template-columns: 1fr; gap: 12px; }
.grille-3 { display: grid; grid-template-columns: 1fr; gap: 12px; }
.grille-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 700px) {
  .grille-2 { grid-template-columns: 1fr 1fr; }
  .grille-3 { grid-template-columns: 1fr 1fr 1fr; }
  .grille-stats { grid-template-columns: repeat(4, 1fr); }
  h1 { font-size: 1.7rem; }
}
.stat {
  background: var(--blanc); border: 1px solid var(--bord); border-radius: var(--radius-carte);
  padding: 12px; text-align: center;
}
.stat .valeur { font-size: 1.3rem; font-weight: 800; color: var(--bleu-capio); }
.stat .legende { font-size: .76rem; color: var(--gris-ardoise); margin-top: 2px; }

/* Récap budget mobile-first : cartes empilées, PAS de scroll horizontal */
.recap-lignes { display: flex; flex-direction: column; gap: 4px; }
.recap-ligne {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  padding: 7px 4px; border-bottom: 1px dashed var(--bord); font-size: .94rem;
}
.recap-ligne .lib { color: var(--texte); }
.recap-ligne .val { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.recap-ligne.total { border-bottom: none; border-top: 2px solid var(--bleu-capio); font-weight: 800; }

/* Jauge (heures d'atelier) */
.jauge { height: 14px; background: var(--gris-fond); border-radius: 7px; overflow: hidden; margin: 6px 0 2px; }
.jauge > div { height: 100%; background: var(--succes); border-radius: 7px; transition: width .3s, background .3s; }
.jauge.pleine > div { background: var(--alerte); }
.jauge.depasse > div { background: var(--erreur); }

/* ---------- Barres CSS ---------- */
.barre-ligne { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.barre-ligne .nom { flex: 0 0 110px; font-size: .85rem; text-align: right; }
.barre-ligne .barre { flex: 1; height: 20px; background: var(--gris-fond); border-radius: 6px; overflow: hidden; }
.barre-ligne .barre > div { height: 100%; background: var(--orange-capio); border-radius: 6px; min-width: 2px; transition: width .6s ease; }
.barre-ligne .val { flex: 0 0 76px; font-size: .85rem; font-weight: 700; }

/* ============================================================
   ÉCRAN DE SYNTHÈSE (projection) — même présentation que les
   consoles, avec des tailles adaptées à la lecture de loin.
   ============================================================ */
.chrono-carte {
  max-width: 860px;
  margin: 16px auto 12px;
  text-align: center;
  padding: 22px 20px 14px;
}
.badge-tour {
  display: inline-block; background: var(--orange-capio); color: var(--bleu-nuit);
  font-weight: 800; border-radius: 999px; padding: 6px 22px;
  font-size: clamp(1rem, 2.4vw, 1.5rem); letter-spacing: .03em;
}
.chrono-hero {
  font-variant-numeric: tabular-nums;
  font-size: clamp(4rem, 15vw, 11rem); font-weight: 900; line-height: 1.08;
  color: var(--bleu-capio);
}
.chrono-hero.urgent { color: var(--erreur); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.titre-section {
  text-align: center; border-bottom: none; justify-content: center;
  font-size: clamp(1.1rem, 2.4vw, 1.6rem); margin: 18px 0 8px;
}
table.ecran-table { font-size: clamp(.95rem, 1.8vw, 1.25rem); }
table.ecran-table td { padding: 9px 12px; }

/* Palmarès */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 14px; margin: 26px auto 10px; max-width: 900px; padding: 0 10px; }
.podium .marche { flex: 1; text-align: center; border-radius: 14px 14px 0 0; padding: 14px 6px; animation: monte .9s ease both; }
.podium .m1 { background: linear-gradient(180deg, #FFD54F, #B8860B); height: 220px; animation-delay: .9s; }
.podium .m2 { background: linear-gradient(180deg, #CFD8DC, #78909C); height: 160px; animation-delay: .5s; }
.podium .m3 { background: linear-gradient(180deg, #D7A06B, #8D5524); height: 120px; animation-delay: .1s; }
@keyframes monte { from { transform: translateY(60px); opacity: 0; } to { transform: none; opacity: 1; } }
.podium .medaille { font-size: clamp(1.6rem, 4vw, 3rem); }
.podium .nom { font-weight: 900; font-size: clamp(.95rem, 2.4vw, 1.5rem); color: var(--bleu-nuit); }
.podium .score { font-weight: 700; font-size: clamp(.8rem, 1.8vw, 1.1rem); color: var(--bleu-nuit); opacity: .8; }
.classement-final { max-width: 760px; margin: 4px auto 10px; }
.classement-final .ligne {
  display: flex; align-items: center; gap: 12px;
  background: var(--blanc); border: 1px solid var(--bord);
  border-left: 4px solid var(--orange-capio);
  border-radius: 10px; padding: 10px 16px; margin: 8px 0;
  font-size: clamp(.95rem, 2vw, 1.3rem);
  animation: apparait .5s ease both;
}
@keyframes apparait { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }
.classement-final .rang { font-weight: 900; color: var(--bleu-capio); flex: 0 0 2.2em; }
.classement-final .nom { flex: 1; font-weight: 700; }
.classement-final .val { font-variant-numeric: tabular-nums; font-weight: 800; }

/* ---------- QR codes ---------- */
.qr-grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.qr-carte { text-align: center; border: 2px dashed var(--bord); border-radius: var(--radius-carte); padding: 14px; background: var(--blanc); }
.qr-carte img { width: 180px; height: 180px; }
.qr-carte .lien { font-size: .72rem; word-break: break-all; color: var(--gris-ardoise); }
@media print {
  header.app, .tabs, .btn, #hors-ligne, .no-print { display: none !important; }
  body { background: #fff !important; background-image: none !important; }
  .card { box-shadow: none; break-inside: avoid; page-break-inside: avoid; }
  .grille-2 { grid-template-columns: 1fr 1fr; }
  .grille-stats { grid-template-columns: repeat(4, 1fr); }
}

/* ---------- Aide en jeu (onglet Aide : sujet + manuels) ---------- */
details.aide-bloc {
  background: var(--blanc);
  border: 1px solid var(--bord);
  border-radius: var(--radius-carte);
  box-shadow: var(--ombre);
  margin: 12px 0;
  overflow: hidden;
}
details.aide-bloc > summary {
  cursor: pointer; list-style: none;
  padding: 14px 16px;
  font-weight: 700; font-size: 1.02rem; color: var(--bleu-capio);
  user-select: none;
}
details.aide-bloc > summary::-webkit-details-marker { display: none; }
details.aide-bloc > summary::before {
  content: '▸'; display: inline-block; margin-right: 8px;
  color: var(--orange-capio); transition: transform .15s;
}
details.aide-bloc[open] > summary::before { transform: rotate(90deg); }
details.aide-bloc > .aide-corps { padding: 0 16px 14px; }
details.aide-bloc details.aide-bloc {
  box-shadow: none; border-radius: 10px; margin: 8px 0;
}
details.aide-bloc details.aide-bloc > summary { padding: 11px 13px; font-size: .96rem; }
details.aide-bloc details.aide-bloc > .aide-corps { padding: 0 13px 11px; }
.aide-illu {
  display: block; max-width: 300px; width: 100%;
  margin: 4px auto 12px; border-radius: 14px;
  border: 1px solid var(--bord);
}
.aide-h3 {
  font-size: 1rem; font-weight: 700; color: var(--bleu-nuit);
  margin: 14px 0 6px;
}
.aide-corps ul { padding-left: 20px; margin: 6px 0; }
.aide-corps ul li { margin: 4px 0; }
.aide-etapes { padding-left: 22px; margin: 6px 0; }
.aide-etapes li { margin: 5px 0; }
.aide-etapes li::marker { font-weight: 700; color: var(--orange-capio); }
.aide-checklist { list-style: none; padding-left: 4px; margin: 6px 0; }
.aide-checklist li { margin: 5px 0; }
.aide-checklist li::before { content: '☐  '; color: var(--bleu-capio); font-weight: 700; }
.aide-corps table.donnees td { white-space: normal; text-align: left; }

/* La barre d'onglets défile latéralement si besoin, sans afficher
   d'ascenseur (le débordement de 2 px des boutons créait un faux
   mini-ascenseur vertical sous Windows) */
.tabs { scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
