/*
 * Backgammon : pages de jeu. Le socle (police, #app, boutons, barre du haut,
 * encart de classement) vient de jeu.css partagé, chargé avant. Ici : l'écran
 * de réglages, le salon, la table en pleine fenêtre, l'écran de fin, le défi
 * du jour et le tutoriel.
 */

#app { max-width: 800px; }
.top-bar h1 { font-size: 1.35rem; }
[hidden] { display: none !important; }

/* ============================== RÉGLAGES ============================== */

.reglages { text-align: left; }
.reglage { margin-bottom: 18px; }
.reglage-titre { font-size: 0.82rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--texte-doux); margin-bottom: 8px; }
.reglage-aide { font-size: 0.86rem; line-height: 1.5; color: var(--texte-doux); margin-top: 8px; }
.intro-mode { margin: 0 0 10px; font-size: 0.95rem; color: var(--texte); }
.liste-aides { margin: 0 0 20px 20px; font-size: 0.9rem; line-height: 1.6; color: var(--texte-doux); }
.liste-aides strong { color: var(--texte); }

.choix { display: flex; flex-wrap: wrap; gap: 8px; }
.choix button {
  flex: 1 1 120px;
  min-height: 46px;
  padding: 10px 12px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--texte);
  background: var(--surface-2);
  border: 1px solid var(--line-forte);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.choix button:hover { border-color: var(--color-light); }
.choix button[aria-pressed="true"] { background: color-mix(in srgb, var(--color-btn1) 34%, var(--surface-2)); border-color: var(--color-light); color: #fff; }
.choix button:focus-visible, .btn:focus-visible, .tb-icone:focus-visible { outline: 2px solid var(--color-light); outline-offset: 2px; }

.note-classement { font-size: 0.86rem; line-height: 1.5; color: var(--texte-doux); margin: 4px 0 14px; text-align: center; }
.bilan { margin: 0 0 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); font-size: 0.88rem; line-height: 1.6; text-align: center; }
.message-reglages { min-height: 1.4em; margin-bottom: 12px; text-align: center; font-size: 0.92rem; color: #e9c58f; }
.action { text-align: center; margin: 6px 0 18px; }
.btn-grand { min-height: 50px; padding: 14px 34px; font-size: 1.02rem; }
.btn-discret { background: transparent; border-color: transparent; color: var(--texte-doux); }
.btn-discret:hover:not(:disabled) { color: var(--texte); border-color: var(--line-forte); }
.btn[aria-pressed="true"] { border-color: var(--color-light); color: #fff; }
.liens-modes { text-align: center; font-size: 0.88rem; line-height: 2; }
.liens-modes a { color: var(--texte-doux); text-decoration: none; }
.liens-modes a:hover { color: var(--color-light); text-decoration: underline; }

/* ============================== SALON DU DUEL ============================== */

.salon-bloc { margin-bottom: 22px; padding: 18px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); text-align: left; }
.salon-titre { font-family: var(--font-display); font-size: 1.12rem; color: #f0f3f6; margin-bottom: 14px; }
.salon-code { display: flex; gap: 10px; flex-wrap: wrap; }
.salon-code input {
  flex: 1 1 140px; min-height: 48px; padding: 8px 14px;
  font: inherit; font-size: 1.3rem; font-weight: 800; letter-spacing: 0.35em; text-align: center; text-transform: uppercase;
  color: var(--texte); background: var(--surface-0); border: 1px solid var(--line-forte); border-radius: 8px;
}
.salon-code input:focus { outline: 2px solid var(--color-light); outline-offset: 1px; }
.salon-code .btn { min-height: 48px; }
.code-affiche { font-size: 2.6rem; font-weight: 800; letter-spacing: 0.3em; text-indent: 0.3em; color: var(--color-light); margin: 12px 0 6px; }
.salon-format { color: var(--texte-doux); font-size: 0.9rem; margin-bottom: 14px; }
.salon-explication { font-size: 0.92rem; line-height: 1.6; color: var(--texte-doux); margin: 10px auto; max-width: 520px; }
.salon-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 10px 0; }

/* ============================== TABLE EN PLEINE FENÊTRE ============================== */

body.en-partie { overflow: hidden; }
/* Pendant la partie, rien d'autre que la table : ni barre de compte, ni blocs latéraux. */
body.en-partie .auth-nav, body.en-partie .bandeau-infos-wrap, body.en-partie .bloc-jeux-une-wrap { display: none !important; }

.zone-table {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  background: #120e0a;
  color: var(--texte);
}

.tb-haut {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px;
  padding-top: calc(6px + env(safe-area-inset-top));
  background: var(--surface-1);
  border-bottom: 1px solid var(--line);
}
.tb-icone {
  flex: none;
  min-width: 44px; min-height: 44px;
  font: inherit; font-size: 1.05rem; font-weight: 700;
  color: var(--texte-doux);
  background: transparent; border: 1px solid transparent; border-radius: 8px; cursor: pointer;
}
.tb-icone:hover { color: var(--texte); border-color: var(--line-forte); }
.tb-icone[aria-pressed="true"] { color: var(--color-light); }
#tb-numeros { font-size: 0.78rem; letter-spacing: 0.02em; }
.tb-outils { display: flex; flex: none; }

.tb-joueur {
  display: flex; align-items: center; gap: 6px;
  min-width: 0;
  padding: 5px 10px;
  border: 1px solid transparent; border-radius: 999px;
  font-size: 0.86rem;
}
.tb-joueur.actif { border-color: var(--color-light); background: color-mix(in srgb, var(--color-btn1) 22%, transparent); }
.tb-pion { flex: none; width: 14px; height: 14px; border-radius: 50%; }
.tb-pion.clair { background: #f2e6cf; box-shadow: inset 0 0 0 1.5px #b9a67b; }
.tb-pion.fonce { background: #2b2b30; box-shadow: inset 0 0 0 1.5px #8a8a96; }
.tb-nom { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 16ch; }
.tb-points { font-weight: 800; font-size: 1.05rem; color: var(--color-light); }
.tb-points:empty { display: none; }
.tb-pips { color: var(--texte-doux); font-size: 0.78rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tb-centre { flex: 1 1 0; min-width: 0; text-align: center; }
.tb-format { display: block; font-size: 0.76rem; color: var(--texte-doux); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-minuteur { height: 5px; margin: 4px auto 0; max-width: 220px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.tb-minuteur span { display: block; height: 100%; width: 100%; background: var(--color-light); transition: width 0.25s linear; }
.tb-minuteur.presse span { background: #d07070; }

.tb-alerte {
  position: absolute; z-index: 5;
  top: calc(64px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  width: min(560px, 92vw);
  padding: 10px 14px;
  font-size: 0.9rem; line-height: 1.45; text-align: center;
  color: #1c1305; background: #e9c58f; border-radius: 8px;
}

/* min-* à 0 et débordement coupé : le canvas garde sa taille précédente le temps d'un
   redimensionnement, il ne doit pas empêcher sa zone de rétrécir. */
.tb-milieu { flex: 1 1 0; min-width: 0; min-height: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; padding: 6px; }
.tb-milieu canvas { display: block; border-radius: 8px; touch-action: none; cursor: pointer; }
.tb-milieu canvas:focus-visible { outline: 2px solid var(--color-light); outline-offset: 2px; }

.tb-bas {
  padding: 8px 10px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: var(--surface-1);
  border-top: 1px solid var(--line);
}
.tb-message { min-height: 2.7em; margin-bottom: 8px; font-size: 0.93rem; line-height: 1.35; text-align: center; display: flex; align-items: center; justify-content: center; }
.tb-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.tb-actions .btn { min-height: 46px; padding: 10px 18px; }
.tb-actions .btn-primary { min-width: 150px; }

/* Téléphone tenu à l'horizontale : les commandes passent sur le côté, le plateau prend toute la hauteur. */
@media (orientation: landscape) and (max-height: 540px) {
  .zone-table { display: grid; grid-template-columns: minmax(176px, 25vw) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .zone-table .tb-haut { grid-column: 1; grid-row: 1; flex-wrap: wrap; border-bottom: 0; border-right: 1px solid var(--line); padding-left: calc(8px + env(safe-area-inset-left)); }
  .zone-table .tb-bas { grid-column: 1; grid-row: 2; overflow-y: auto; border-top: 0; border-right: 1px solid var(--line); padding-left: calc(10px + env(safe-area-inset-left)); }
  .zone-table .tb-milieu { grid-column: 2; grid-row: 1 / span 2; padding: 4px; padding-right: calc(4px + env(safe-area-inset-right)); }
  .zone-table .tb-centre { flex-basis: 100%; order: 5; }
  .zone-table .tb-joueur { flex: 1 1 100%; order: 3; }
  .zone-table .tb-outils { order: 2; margin-left: auto; }
  .zone-table .tb-icone { min-width: 40px; min-height: 40px; }
  .zone-table .tb-message { min-height: 0; font-size: 0.84rem; }
  .zone-table .tb-actions .btn { flex: 1 1 100%; min-width: 0; min-height: 42px; padding: 8px 10px; font-size: 0.84rem; }
  .zone-table .defi-suite { grid-column: 1; }
  .tb-alerte { top: 8px; left: auto; right: 8px; transform: none; width: min(420px, 60vw); }
}
@media (max-width: 520px) {
  .tb-nom { max-width: 9ch; }
  .tb-joueur { padding: 4px 7px; gap: 4px; font-size: 0.8rem; }
  .tb-icone { min-width: 40px; }
  #tb-plein-ecran { display: none; }
}

/* ============================== COMPTE À REBOURS, FIN ============================== */

.compte-a-rebours { position: fixed; inset: 0; z-index: 2100; display: flex; align-items: center; justify-content: center; background: rgba(8, 6, 4, 0.82); }
.compte-a-rebours span { font-family: var(--font-display); font-size: 6rem; font-weight: 700; color: var(--color-light); }

.fin-partie {
  position: fixed; z-index: 2200;
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(440px, 94vw); max-height: 92vh; overflow-y: auto;
  padding: 26px 22px 20px;
  text-align: center;
  background: var(--surface-1);
  border: 1px solid var(--line-forte);
  border-radius: 12px;
}
.fin-partie h2 { font-family: var(--font-display); font-size: 1.6rem; color: #f0f3f6; margin-bottom: 8px; }
.fin-fermer {
  position: absolute; top: 4px; right: 4px;
  width: 44px; height: 44px;
  font-size: 1.6rem; line-height: 1; color: var(--texte-doux);
  background: none; border: 0; border-radius: 8px; cursor: pointer;
}
.fin-fermer:hover { color: #fff; }
.fin-message { font-size: 0.98rem; line-height: 1.5; margin-bottom: 10px; }
.fin-details { list-style: none; margin: 0 0 12px; padding: 0; font-size: 0.86rem; line-height: 1.6; color: var(--texte-doux); }
.fin-elo { font-size: 1.2rem; font-weight: 800; color: var(--color-light); margin-bottom: 8px; }
.fin-statut { min-height: 1.3em; font-size: 0.86rem; color: var(--texte-doux); margin-bottom: 8px; }
.fin-lien-classement { display: inline-block; margin-bottom: 12px; padding: 8px 4px; font-size: 0.9rem; font-weight: 700; color: var(--color-light); text-decoration: none; }
.fin-lien-classement:hover { text-decoration: underline; }
.fin-compte { margin: 6px 0 14px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); font-size: 0.88rem; line-height: 1.5; }
.fin-compte-btns, .fin-boutons { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 10px; }
.fin-boutons .btn, .fin-compte-btns .btn { min-height: 44px; }

/* ============================== DÉFI DU JOUR ============================== */

.page-defi #app { max-width: 800px; }
#app p a:not([class]), .defi-compte a:not([class]) { color: var(--color-light); }
.defi-date { color: var(--texte-doux); margin: 6px 0 16px; }
.etat-defi { min-height: 1.4em; margin: 12px 0; font-size: 0.95rem; line-height: 1.5; color: #e9c58f; }
.etat-defi:empty { display: none; }
.defi-avertissement { margin-top: 10px; font-size: 0.84rem; color: var(--texte-doux); }

.defi-suite {
  display: flex; gap: 6px; align-items: center;
  padding: 7px 10px;
  overflow-x: auto;
  background: var(--surface-0);
  border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
}
.defi-de {
  flex: none;
  padding: 5px 9px;
  font-size: 0.86rem; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--texte-doux);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.defi-de.double { color: #e9c58f; }
.defi-de.courant { color: #1c1305; background: var(--color-light); border-color: var(--color-light); font-size: 1rem; }

/* ============================== TUTORIEL ============================== */

.tuto-intro { font-size: 0.96rem; line-height: 1.6; color: var(--texte-doux); margin-bottom: 14px; }
.tuto-sommaire { font-family: var(--font-display); font-size: 1.1rem; color: #f0f3f6; margin: 22px 0 10px; text-align: left; }
.tuto-etapes { margin: 0 0 18px; padding-left: 22px; text-align: left; font-size: 0.88rem; line-height: 1.5; color: var(--texte-faible); }
.tuto-etapes li { margin-bottom: 4px; }
.tuto-etapes li strong { color: var(--texte-doux); }
.tuto-etapes li.courant, .tuto-etapes li.courant strong { color: var(--texte); }
.tuto-etapes li.fait strong { color: #64ab7c; }
.tuto-etapes li.fait strong::after { content: ' ✓'; }
.tuto-zone { padding: 16px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.tuto-numero { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-light); margin-bottom: 4px; }
.tuto-zone h2, .tuto-fin h2 { font-family: var(--font-display); font-size: 1.3rem; color: #f0f3f6; margin-bottom: 8px; }
.tuto-texte { font-size: 0.95rem; line-height: 1.6; text-align: left; margin-bottom: 12px; }
.tuto-plateau { display: flex; justify-content: center; }
.tuto-plateau canvas { display: block; border-radius: 8px; touch-action: manipulation; cursor: pointer; }
.tuto-retour { min-height: 4.5em; margin: 10px 0 4px; font-size: 0.93rem; line-height: 1.5; }
.tuto-retour.reussi { color: #7fc796; }
.tuto-retour.rate { color: #e9a08f; }
.tuto-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 10px 0; }
.tuto-actions .btn { min-height: 46px; }
.tuto-fin { padding: 22px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); line-height: 1.6; }
.tuto-fin a:not(.btn) { color: var(--color-light); }
