/* style.css : gros, lisible, contrasté. Pensé pour un téléphone en plein soleil.
   Texte de 18 px minimum, boutons de 52 px minimum. */

:root {
  color-scheme: light;
  --fond: #f4eee2; /* sable */
  --surface: #ffffff;
  --texte: #1c1712;
  --doux: #574d42;
  --bord: #d8ccb8;
  --bleu: #1d4ed8;
  --bleu-fonce: #1e3a8a;
  --bleu-clair: #e3ebff;
  --vert: #166534;
  --vert-vif: #15803d;
  --vert-clair: #dcfce7;
  --orange-fonce: #7c2d12;
  --orange: #ea580c;
  --orange-clair: #ffedd5;
  --rouge: #b91c1c;
  --rouge-clair: #fee2e2;
  --jaune: #fde047;
  --focus: #f59e0b;
  --rayon: 14px;
  --ombre: 0 1px 2px rgb(60 40 10 / 0.08), 0 3px 10px rgb(60 40 10 / 0.07);
}

* {
  box-sizing: border-box;
}

html {
  font-size: 20px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', 'Noto Sans Thai', sans-serif;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
h3 {
  line-height: 1.2;
  margin: 0;
}

h2 {
  font-size: 1.35rem;
}

p {
  margin: 0;
}

a {
  color: var(--bleu-fonce);
}

:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

main {
  max-width: 780px;
  margin: 0 auto;
  padding: 18px 16px 48px;
}

.pile > * + * {
  margin-top: 14px;
}

.centre {
  text-align: center;
}

.chargement {
  padding: 40vh 16px 0;
  text-align: center;
  color: var(--doux);
}

/* ————— En-tête ————— */

.entete {
  background: var(--bleu-fonce);
  color: #fff;
  padding: 10px 16px 16px;
}

.entete > * {
  max-width: 780px;
  margin-left: auto;
  margin-right: auto;
}

.entete .barre {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.entete h1 {
  font-size: 1.5rem;
  margin-top: 12px;
}

.entete .sous-titre {
  margin-top: 4px;
  opacity: 0.9;
}

.nav {
  display: inline-flex;
  align-items: center;
  min-height: 52px;
  padding: 8px 16px;
  border: 2px solid rgb(255 255 255 / 0.55);
  border-radius: 12px;
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}

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

.entete.accueil {
  padding: 22px 16px;
}

.marque {
  display: flex;
  align-items: center;
  gap: 16px;
}

.marque img {
  border-radius: 16px;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.25);
  flex: none;
}

.marque h1 {
  margin: 0;
  font-size: 1.6rem;
}

.marque p {
  opacity: 0.9;
}

.date-du-jour {
  font-weight: 700;
  color: var(--doux);
}

.pied {
  text-align: center;
  padding-top: 18px;
}

.pied a {
  display: inline-block;
  padding: 12px;
  color: var(--doux);
}

/* ————— Boutons ————— */

.bouton {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 60px;
  padding: 12px 20px;
  border: 2px solid var(--bleu);
  border-radius: var(--rayon);
  background: var(--surface);
  color: var(--bleu-fonce);
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}

.bouton:active {
  transform: translateY(1px);
}

.bouton:disabled {
  border-color: var(--bord);
  background: #ece5d8;
  color: var(--doux);
  cursor: not-allowed;
}

.bouton.principal {
  background: var(--bleu);
  color: #fff;
}

.bouton.principal:disabled {
  background: #c9c0b1;
  border-color: #c9c0b1;
  color: #3d342b;
}

.bouton.vert {
  background: var(--vert-vif);
  border-color: var(--vert-vif);
  color: #fff;
}

.bouton.danger {
  border-color: var(--rouge);
  color: var(--rouge);
}

.bouton.danger.plein {
  background: var(--rouge);
  color: #fff;
}

.bouton.grand {
  min-height: 80px;
  flex-direction: column;
  gap: 2px;
  font-size: 1.2rem;
}

.bouton small {
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0.92;
}

.bouton.compact {
  width: auto;
  min-height: 52px;
  padding: 8px 14px;
  font-size: 0.95rem;
  flex: none;
}

.lien {
  display: inline;
  min-height: 48px;
  padding: 10px 4px;
  border: none;
  background: none;
  color: var(--bleu);
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.lien.rouge {
  color: var(--rouge);
}

.rangee-boutons,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.rangee-boutons > *,
.actions > * {
  flex: 1 1 140px;
}

.avec {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

/* ————— Messages ————— */

.info {
  background: var(--surface);
  border-left: 6px solid var(--bleu);
  border-radius: 10px;
  padding: 12px 16px;
}

.alerte {
  background: var(--orange-clair);
  border-left: 6px solid var(--orange);
  border-radius: 10px;
  padding: 12px 16px;
  color: var(--orange-fonce);
  font-weight: 700;
}

.erreur {
  color: var(--rouge);
  font-weight: 700;
}

.erreur:empty {
  display: none;
}

.aide {
  color: var(--doux);
  font-size: 0.9rem;
}

.etape {
  color: var(--doux);
  font-weight: 700;
}

.compte {
  color: var(--doux);
  font-weight: 700;
}

.avancement {
  text-align: center;
  font-weight: 700;
  color: var(--doux);
  font-size: 1.1rem;
}

.avancement.fini {
  color: var(--vert);
}

#message {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 50;
  max-width: calc(100% - 32px);
  padding: 12px 22px;
  border-radius: 999px;
  background: #14532d;
  color: #fff;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.25);
  transform: translate(-50%, 200%);
  transition: transform 0.25s ease;
  pointer-events: none;
}

#message:not(.visible) {
  visibility: hidden;
}

#message.visible {
  transform: translate(-50%, 0);
}

#message.attente {
  background: #9a3412;
}

/* ————— Formulaires ————— */

.champ {
  display: block;
}

.etiquette,
legend {
  display: block;
  margin-bottom: 6px;
  font-weight: 800;
  font-size: 1.05rem;
}

.facultatif {
  font-weight: 500;
  color: var(--doux);
}

input[type='text'],
input:not([type]),
input[type='search'],
input[type='number'],
input[type='date'] {
  width: 100%;
  min-height: 58px;
  padding: 10px 14px;
  border: 2px solid var(--bord);
  border-radius: 12px;
  background: var(--surface);
  color: var(--texte);
  font: inherit;
  font-size: 1.1rem;
}

input:focus {
  border-color: var(--bleu);
  outline: none;
  box-shadow: 0 0 0 3px var(--bleu-clair);
}

.champ .aide {
  display: block;
  margin-top: 6px;
}

.champ-date {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  font-weight: 700;
}

.champ-date input {
  width: auto;
  flex: 1 1 200px;
}

.groupe {
  margin: 0;
  padding: 0;
  border: none;
}

.groupe {
  margin-top: 24px;
}

.choix.ligne .option span {
  gap: 10px;
  padding: 10px 12px;
  white-space: nowrap;
}

.groupe .aide {
  margin-top: 8px;
}

.choix {
  display: grid;
  gap: 10px;
}

.choix.ligne {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.choix.nombres {
  grid-template-columns: repeat(4, 1fr);
}

.option {
  position: relative;
  display: block;
}

.option input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.option span {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  height: 100%;
  padding: 10px 16px;
  border: 2px solid var(--bord);
  border-radius: var(--rayon);
  background: var(--surface);
  font-weight: 700;
  cursor: pointer;
}

.option span::before {
  content: '';
  flex: none;
  width: 28px;
  height: 28px;
  border: 3px solid #8a7e70;
  border-radius: 50%;
  background: var(--surface);
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  color: #fff;
}

.option small {
  font-weight: 500;
  color: var(--doux);
}

.option input:checked + span {
  border-color: var(--bleu);
  background: var(--bleu-clair);
  color: var(--bleu-fonce);
  box-shadow: inset 0 0 0 1px var(--bleu);
}

.option input:checked + span::before {
  content: '✓';
  border-color: var(--bleu);
  background: var(--bleu);
}

.option input:focus-visible + span {
  outline: 4px solid var(--focus);
  outline-offset: 2px;
}

.choix.nombres .option span {
  justify-content: center;
  font-size: 1.4rem;
}

.choix.nombres .option span::before {
  display: none;
}

.resume {
  margin-top: 26px;
  padding: 16px;
  border: 2px dashed var(--bleu);
  border-radius: var(--rayon);
  background: var(--surface);
}

.resume h3 {
  margin-bottom: 6px;
  font-size: 1.05rem;
  color: var(--bleu-fonce);
}

.resume .alerte {
  margin-top: 12px;
}

.recherche {
  display: flex;
  gap: 10px;
}

.recherche input {
  flex: 1;
  min-width: 0;
}

.recherche .bouton {
  width: auto;
  flex: none;
  min-height: 58px;
}

/* ————— Listes (membres, joueurs à cocher, anciens concours) ————— */

.liste {
  list-style: none;
  margin-left: 0;
  margin-right: 0;
  margin-bottom: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.ligne-membre {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 14px;
  min-height: 68px;
  padding: 10px 16px;
  border: 2px solid var(--bord);
  border-radius: var(--rayon);
  background: var(--surface);
  color: inherit;
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}

.ligne-membre .texte {
  flex: 1;
  min-width: 0;
}

.ligne-membre .nom {
  display: block;
  font-weight: 800;
  font-size: 1.15rem;
}

.ligne-membre .vrai-nom {
  display: block;
  color: var(--doux);
}

.ligne-membre .details {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.ligne-membre .fleche {
  color: var(--bleu);
  font-weight: 700;
  flex: none;
}

.pastille {
  display: inline-block;
  padding: 1px 10px;
  border-radius: 999px;
  background: #ece5d8;
  color: #3d342b;
  font-size: 0.9rem;
  font-weight: 700;
}

.pastille.fr {
  background: #dbe5ff;
  color: #1e3a8a;
}

.pastille.th {
  background: #ffe1e6;
  color: #9f1239;
}

.case {
  flex: none;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 3px solid #8a7e70;
  border-radius: 9px;
  background: var(--surface);
  color: #fff;
  font-size: 1.3rem;
  font-weight: 900;
}

.a-cocher[aria-pressed='true'] {
  border-color: var(--vert-vif);
  background: var(--vert-clair);
}

.a-cocher[aria-pressed='true'] .case {
  border-color: var(--vert-vif);
  background: var(--vert-vif);
}

.compteur {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 12px 16px;
  border-radius: 0 0 12px 12px;
  background: var(--bleu-fonce);
  color: #fff;
  box-shadow: var(--ombre);
}

.barre-bas {
  position: sticky;
  bottom: 0;
  z-index: 5;
  margin-left: -16px;
  margin-right: -16px;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, rgb(244 238 226 / 0), var(--fond) 22%);
}

.retires {
  margin-top: 30px;
}

.retires summary {
  min-height: 52px;
  padding: 12px 0;
  font-weight: 700;
  color: var(--doux);
  cursor: pointer;
}

.retires .ligne-membre {
  cursor: default;
}

/* ————— Matchs ————— */

.matchs {
  display: grid;
  gap: 14px;
}

@media (min-width: 720px) {
  .matchs {
    grid-template-columns: 1fr 1fr;
  }
}

.match {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px 16px;
  border: 2px solid var(--bord);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--ombre);
}

.match.termine {
  border-color: var(--vert-vif);
  background: #f2fbf4;
}

.match.repos {
  border-style: dashed;
  background: #fbf8f2;
}

.match .bouton {
  margin-top: 8px;
}

.terrain {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--doux);
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.terrain .fini {
  color: var(--vert);
}

.equipe {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 48px;
  font-size: 1.15rem;
  font-weight: 600;
}

.equipe .noms {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.equipe.gagnante {
  font-weight: 800;
}

.score {
  min-width: 2ch;
  font-size: 1.7rem;
  font-weight: 800;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--doux);
}

.equipe.gagnante .score {
  color: var(--vert);
}

.contre {
  color: var(--doux);
  font-size: 0.9rem;
  font-style: italic;
}

.plus {
  color: var(--doux);
  font-weight: 700;
}

.graine {
  margin-right: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  background: #ece5d8;
  color: #3d342b;
  font-size: 0.9rem;
  font-weight: 800;
}

.joueur {
  min-height: 48px;
  padding: 6px 12px;
  border: 2px dashed var(--bleu);
  border-radius: 10px;
  background: var(--surface);
  color: var(--bleu-fonce);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.joueur.choisi {
  border-style: solid;
  border-color: #a16207;
  background: var(--jaune);
  color: #000;
  box-shadow: 0 0 0 3px rgb(253 224 71 / 0.5);
}

.joueur.echange {
  animation: echange 1.4s ease-out;
}

@keyframes echange {
  from {
    background: #86efac;
  }
  to {
    background: var(--surface);
  }
}

.bandeau-echange {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--jaune);
  color: #000;
  font-weight: 600;
  box-shadow: 0 -4px 16px rgb(0 0 0 / 0.2);
}

main.avec-bandeau {
  padding-bottom: 140px;
}

.onglets {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 4px;
}

.onglets a {
  flex: none;
  display: inline-flex;
  align-items: center;
  min-height: 52px;
  padding: 8px 16px;
  border: 2px solid var(--bord);
  border-radius: 999px;
  background: var(--surface);
  color: var(--texte);
  font-weight: 700;
  text-decoration: none;
}

.onglets a[aria-current='page'] {
  border-color: var(--bleu-fonce);
  background: var(--bleu-fonce);
  color: #fff;
}

/* ————— Classement ————— */

.classement {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 2px solid var(--bord);
  border-radius: var(--rayon);
  background: var(--surface);
  overflow: hidden;
}

.classement th,
.classement td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--bord);
  text-align: left;
}

.classement tbody tr:last-child td {
  border-bottom: none;
}

.classement th {
  background: #f8f3ea;
  color: var(--doux);
  font-size: 0.9rem;
  line-height: 1.2;
}

.classement .nombre {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.classement .place {
  font-size: 1.2rem;
  font-weight: 800;
}

.classement td.nom {
  font-weight: 700;
}

.podium-1 td {
  background: #fff4c2;
}

.podium-2 td {
  background: #f1f1f1;
}

.podium-3 td {
  background: #fbe7d6;
}

.classement .rang {
  display: none;
}

@media (max-width: 640px) {
  .classement .large,
  .classement .col-place {
    display: none;
  }

  .classement .rang {
    display: inline-block;
    min-width: 1.7em;
    font-size: 1.2rem;
    font-weight: 800;
  }

  .classement th,
  .classement td {
    padding: 12px 6px;
  }

  .classement th {
    font-size: 0.8rem;
  }

  .classement .ligne-nom {
    display: flex;
    align-items: baseline;
    gap: 4px;
  }
}

.vainqueurs {
  padding: 22px 16px;
  border: 3px solid #ca8a04;
  border-radius: 18px;
  background: #fff4c2;
  text-align: center;
}

.vainqueurs .coupe {
  font-size: 3rem;
  line-height: 1;
}

.vainqueurs h2 {
  margin-top: 6px;
  color: #854d0e;
}

.vainqueurs .noms {
  margin-top: 6px;
  font-size: 1.5rem;
  font-weight: 800;
}

.ancienne-partie {
  border: 2px solid var(--bord);
  border-radius: var(--rayon);
  background: var(--surface);
}

.ancienne-partie summary {
  min-height: 56px;
  padding: 14px 16px;
  font-weight: 800;
  cursor: pointer;
}

.ancienne-partie ul {
  margin: 0;
  padding: 0 16px 14px 36px;
}

.ancienne-partie li + li {
  margin-top: 6px;
}

/* ————— Fenêtres (score, confirmation) ————— */

dialog {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: none;
  border-radius: 20px;
  background: var(--fond);
  color: var(--texte);
  box-shadow: 0 20px 60px rgb(0 0 0 / 0.35);
}

dialog::backdrop {
  background: rgb(20 15 10 / 0.6);
}

.fenetre {
  padding: 22px 18px;
}

.fenetre > * + * {
  margin-top: 16px;
}

.fenetre h2 {
  font-size: 1.4rem;
}

.grand-texte {
  font-size: 1.15rem;
  font-weight: 600;
}

.rappel {
  color: var(--vert);
}

.choix-equipe {
  min-height: 76px;
  font-size: 1.25rem;
}

.grille-points {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.point {
  min-height: 66px;
  border: 2px solid var(--bleu);
  border-radius: var(--rayon);
  background: var(--surface);
  color: var(--bleu-fonce);
  font: inherit;
  font-size: 1.6rem;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.point:active {
  background: var(--bleu);
  color: #fff;
}

/* ————— Écran du code ————— */

.ecran-code {
  max-width: 440px;
  padding-top: 12vh;
  text-align: center;
}

.ecran-code img {
  border-radius: 22px;
  box-shadow: var(--ombre);
}

.ecran-code .champ {
  text-align: left;
}

input.code {
  font-size: 1.8rem;
  letter-spacing: 0.3em;
  text-align: center;
}

/* ————— Impression ————— */

.titre-impression {
  display: none;
}

@media print {
  @page {
    margin: 14mm;
  }

  html {
    font-size: 15pt;
  }

  body {
    background: #fff;
  }

  .entete,
  .onglets,
  .actions,
  .bouton,
  .lien,
  .aide,
  [data-suite],
  .bandeau-echange,
  #message,
  dialog {
    display: none !important;
  }

  main {
    max-width: none;
    padding: 0;
  }

  .titre-impression {
    display: block;
    margin-bottom: 12pt;
    font-size: 20pt;
  }

  .matchs {
    grid-template-columns: 1fr 1fr;
  }

  .match {
    break-inside: avoid;
    border: 1.5pt solid #000;
    box-shadow: none;
    background: #fff;
  }

  .joueur {
    min-height: 0;
    padding: 0;
    border: none;
    background: none;
    color: #000;
  }

  .info,
  .alerte {
    border: 1pt solid #999;
    background: #fff;
    color: #000;
  }

  .classement {
    border: 1.5pt solid #000;
  }

  .podium td {
    background: #fff !important;
  }

  details {
    display: block;
  }

  details > * {
    display: block;
  }
}
