/* L'apparence de l'application : couleurs, tailles, espacements. */

/* Les couleurs sont définies une seule fois ici, puis réutilisées partout avec var(--nom). */
:root {
  --vert: #1e6b45;
  --fond: #f3f5f2;
  --carte: #ffffff;
  --texte: #1f2a24;
  --discret: #66736b;
  --bordure: #dfe5e0;
  --rouge: #b3261e;
  --equipe-a: #2a78d6;
  --equipe-b: #d9691e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, "Segoe UI", sans-serif;
  background: var(--fond);
  color: var(--texte);
}

/* --- En-tête et menu --- */

header {
  background: var(--vert);
  color: white;
  padding: 12px 16px 0;
  text-align: center;
}

header h1 {
  margin: 0 0 8px;
  font-size: 1.5rem;
}

nav {
  display: flex;
  justify-content: center;
  gap: 4px;
}

nav a {
  color: white;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 8px 8px 0 0;
  opacity: 0.85;
}

nav a.actif {
  background: var(--fond);
  color: var(--vert);
  font-weight: 600;
  opacity: 1;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}

h2 {
  font-size: 1.15rem;
  margin: 20px 0 10px;
}

h3 {
  font-size: 1rem;
  margin: 16px 0 6px;
}

/* --- Cartes --- */

.carte {
  display: block;
  background: var(--carte);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

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

a.resume {
  color: inherit;
  text-decoration: none;
}

a.resume:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* --- Lignes et colonnes --- */

/* Une ligne : les éléments sont côte à côte ; celui marqué "grand" prend la place restante. */
.ligne,
.ligne-equipe {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ligne-equipe {
  padding: 6px 0;
}

.ligne-equipe.score .total {
  font-size: 1.6rem;
}

/* --- Saisie d'une donne : des touches à la place des listes --- */

.touches {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.touches.deux {
  grid-template-columns: 1fr 1fr;
}

.touches.trois {
  grid-template-columns: repeat(3, 1fr);
}

.ligne .touches {
  grid-template-columns: 1fr 1fr;
  flex: 2;
  margin-bottom: 0;
}

button.touche {
  background: white;
  color: var(--texte);
  border: 2px solid var(--bordure);
  padding: 14px 2px;
  font-size: 0.95rem;
  font-weight: 600;
}

button.touche.choisie {
  background: var(--vert);
  border-color: var(--vert);
  color: white;
}

.symbole-touche {
  font-size: 3rem;
  line-height: 1;
}

.rouge {
  color: #c62828;
}

/* Le rappel de l'atout pendant la donne. */
.rappel {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 8px;
}

.symbole {
  font-size: 6rem;
  line-height: 1;
  font-weight: 700;
}

/* "SA" et "TA" sont plus larges qu'un symbole de couleur. */
.symbole.lettres {
  font-size: 4rem;
}

input.points {
  font-size: 1.3rem;
  font-weight: 600;
  text-align: center;
}

.grand {
  flex: 1;
  min-width: 0;
}

.deux-colonnes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: end;
}

/* --- Formulaires --- */

.champ {
  display: block;
  margin-bottom: 10px;
}

.champ > span {
  display: block;
  font-size: 0.85rem;
  color: var(--discret);
  margin-bottom: 4px;
}

.case {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 12px;
}

input,
select,
button,
.bouton {
  font: inherit;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #c3cbc5;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  background: white;
  color: var(--texte);
}

input[type="checkbox"] {
  width: 20px;
  height: 20px;
}

input:disabled {
  background: var(--fond);
  color: var(--discret);
}

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

button,
.bouton {
  background: var(--vert);
  border-color: var(--vert);
  color: white;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

button.secondaire {
  background: white;
  color: var(--vert);
}

button.danger {
  background: white;
  border-color: var(--rouge);
  color: var(--rouge);
}

button.petit {
  padding: 6px 10px;
  font-size: 0.9em;
}

.large {
  display: block;
  width: 100%;
}

.apercu {
  background: var(--fond);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 4px 0 12px;
}

/* --- Listes et tableaux --- */

.liste {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
}

.liste li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid var(--bordure);
  overflow-wrap: anywhere;
}

.defilant {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 8px 6px;
  text-align: left;
  border-top: 1px solid var(--bordure);
  vertical-align: top;
}

th {
  border-top: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--discret);
}

.nombre {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

td.actions {
  white-space: nowrap;
  text-align: right;
}

td.actions button + button {
  margin-left: 4px;
}

tr.en-correction {
  background: #fff6dd;
}

/* --- Petits éléments --- */

.pastille {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  flex: none;
}

.equipe-a {
  background: var(--equipe-a);
}

.equipe-b {
  background: var(--equipe-b);
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e0efe6;
  color: var(--vert);
  margin-left: 6px;
}

.badge.echec {
  background: #f9e0de;
  color: var(--rouge);
}

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

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

.tuiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.tuile {
  background: var(--carte);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.tuile strong {
  display: block;
  font-size: 1.8rem;
}

.tuile span {
  color: var(--discret);
  font-size: 0.9rem;
}

/* --- Graphiques --- */

.graphique {
  position: relative;
}

.zone-graphique svg {
  display: block;
  touch-action: pan-y;
}

.legende {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-size: 0.9rem;
  margin-bottom: 6px;
}

.grille {
  stroke: var(--bordure);
  stroke-width: 1;
}

.axe {
  stroke: #9aa69f;
  stroke-width: 1;
}

.repere {
  stroke: #9aa69f;
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.graduation {
  fill: var(--discret);
  font-size: 12px;
}

.bulle {
  position: absolute;
  top: 8px;
  background: var(--carte);
  border: 1px solid var(--bordure);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.9rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  pointer-events: none;
  white-space: nowrap;
}

/* --- Page d'accueil : le choix du jeu --- */

a.jeu {
  display: flex;
  align-items: center;
  gap: 16px;
  color: inherit;
  text-decoration: none;
  font-size: 1.1rem;
}

a.jeu:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

a.jeu .grand span {
  display: block;
}

.symbole-jeu {
  width: 64px;
  text-align: center;
  font-size: 2.2rem;
  line-height: 1;
  flex: none;
}

/* --- Yam's : les dés --- */

/* Un dé : un carré découpé en 9 emplacements, dont certains portent un point. */
.de {
  display: inline-grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 48px;
  height: 48px;
  padding: 6px;
  gap: 2px;
  background: white;
  border: 2px solid var(--texte);
  border-radius: 10px;
  vertical-align: middle;
}

.de .point {
  background: var(--texte);
  border-radius: 50%;
}

.de.vide {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-style: dashed;
  border-color: #c3cbc5;
  color: #c3cbc5;
  font-weight: 700;
}

.des {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 8px;
}

.des.faces {
  margin: 12px 0 0;
}

.des.faces .de {
  width: 40px;
  height: 40px;
  padding: 5px;
}

/* Le bouton qui entoure un dé : sans décor, pour ne voir que le dé. */
button.bouton-de {
  background: none;
  border: none;
  padding: 2px;
  color: var(--texte);
  display: flex;
  flex-direction: column;
  align-items: center;
}

button.bouton-de:disabled {
  cursor: default;
}

.des.faces button.bouton-de:disabled {
  opacity: 0.35;
}

.etiquette-de {
  font-size: 0.75rem;
  height: 1em;
  color: var(--vert);
  font-weight: 600;
}

button.bouton-de.garde .de {
  border-color: var(--vert);
  background: #e0efe6;
  box-shadow: 0 0 0 2px var(--vert);
}

/* Petite secousse des dés qui viennent d'être lancés. */
@keyframes secousse {
  0% { transform: rotate(-25deg) scale(0.8); }
  60% { transform: rotate(12deg) scale(1.08); }
  100% { transform: none; }
}

button.bouton-de.roule .de {
  animation: secousse 0.35s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  button.bouton-de.roule .de {
    animation: none;
  }
}

/* --- Yam's : la feuille de score --- */

.feuille-yams th,
.feuille-yams td {
  padding: 5px 6px;
  vertical-align: middle;
}

.feuille-yams tbody th {
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--texte);
  white-space: nowrap;
  /* La première colonne reste visible quand on fait défiler la feuille. */
  position: sticky;
  left: 0;
  background: var(--carte);
}

.feuille-yams thead th {
  max-width: 5.5em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feuille-yams thead th.courant {
  color: var(--vert);
  border-bottom: 3px solid var(--vert);
}

.feuille-yams td {
  min-width: 3em;
  height: 2.4em;
}

.feuille-yams .ligne-total th,
.feuille-yams .ligne-total td {
  background: var(--fond);
  font-weight: 600;
}

.feuille-yams .ligne-total.final td {
  font-size: 1.15rem;
}

.feuille-yams td.dernier {
  font-weight: 700;
  color: var(--vert);
}

/* Une case libre où le joueur peut inscrire ses dés. */
button.possible {
  min-width: 2.6em;
  padding: 3px 6px;
  background: white;
  color: var(--vert);
  border: 2px solid var(--vert);
  font-weight: 600;
}

button.possible.zero {
  color: var(--discret);
  border-color: #c3cbc5;
  font-weight: 400;
}

button:disabled {
  cursor: default;
}

button.large:disabled {
  opacity: 0.45;
}