/*
 * Feuille de style.
 *
 * HIERARCHIE. Une donne de bridge se lit en trois temps : quel est le contrat, où en sont les
 * levées, qu'est-ce que je peux jouer. La première version reléguait le contrat dans un coin du
 * bandeau, ce qui obligeait à le chercher à chaque coup. Il occupe maintenant le haut de l'écran,
 * en grand, avec la jauge des levées juste dessous.
 *
 * Conçue pour le téléphone d'abord (brief §9). Le public visé est celui des clubs, souvent d'un
 * âge où le confort de lecture n'est pas un détail : les cartes sont des pastilles larges, jamais
 * des cartes miniatures qui se chevauchent, et chaque couleur occupe sa ligne. On tape une carte,
 * on ne la vise pas.
 */
:root {
  --tapis: #0d5233;
  --tapis-clair: #17724a;
  --tapis-sombre: #073821;
  --fond: #f4f2ec;
  --panneau: #ffffff;
  --encre: #191817;
  --menu: #6e6862;
  --rouge: #b3261e;
  --or: #c08a1e;
  --or-clair: #f0d99b;
  --trait: #e0dbd1;
  --ombre: 0 1px 3px rgba(25, 24, 23, 0.08), 0 6px 18px rgba(25, 24, 23, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 17px; line-height: 1.4;
  color: var(--encre); background: var(--fond);
  -webkit-text-size-adjust: 100%;
}

/* ------------------------------------------------------------------ en-tête */

.entete {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  padding: 0.5rem 0.9rem;
  background: var(--tapis-sombre); color: #fff;
}
.titre-site {
  font-size: 0.63rem; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--or-clair); font-weight: 700; white-space: nowrap;
}
.entete-donne { font-size: 0.72rem; color: #9ccfb4; text-align: right; }

main { padding: 0.7rem; max-width: 720px; margin: 0 auto; }

/* ------------------------------------------------------------------ état de la donne */

.etat {
  background: var(--panneau); border-radius: 14px; box-shadow: var(--ombre);
  padding: 0.55rem 0.9rem 0.65rem; text-align: center; margin-bottom: 0.6rem;
}
.etat-phase {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.16em;
  color: var(--menu); font-weight: 700;
}
.etat-contrat {
  font-size: 2.2rem; font-weight: 800; line-height: 1.05; letter-spacing: -0.02em;
  margin: 0.1rem 0 0.1rem;
}
.etat-contrat .rouge { color: var(--rouge); }
.etat-contrat .contre { font-size: 1.4rem; color: var(--rouge); vertical-align: 0.35em; margin-left: 0.15rem; }
.etat-contrat.attente { font-size: 1.5rem; color: var(--menu); font-weight: 700; }
.etat-detail { font-size: 0.86rem; color: var(--menu); }
.etat-detail strong { color: var(--encre); }

/* La jauge des levées : une case par levée demandée, remplie à mesure. Les cases rouges sont les
   levées déjà concédées au delà de ce que le contrat autorise, donc la chute en cours. */
.jauge { display: flex; gap: 3px; justify-content: center; margin-top: 0.55rem; }
.jauge span { flex: 1; max-width: 24px; height: 9px; border-radius: 3px; background: var(--trait); }
.jauge span.faite { background: var(--tapis); }
.jauge span.perdue { background: var(--rouge); }

/* ------------------------------------------------------------------ panneaux */

.panneau {
  background: var(--panneau); border-radius: 14px; box-shadow: var(--ombre);
  padding: 0.7rem 0.8rem; margin-bottom: 0.7rem;
}

/* ------------------------------------------------------------------ sièges et cartes */

.siege { margin-bottom: 0.5rem; }
.siege-nom {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--menu); font-weight: 700; margin-bottom: 0.3rem;
}
.siege-menu { text-transform: none; letter-spacing: 0; font-weight: 400; }
.siege.actif .siege-nom { color: var(--tapis); }
.siege.actif .siege-nom::before {
  content: "▸ "; color: var(--or); font-size: 1.1em;
}

.couleur { display: flex; align-items: center; gap: 0.25rem; margin-bottom: 0.28rem; flex-wrap: wrap; }
.enseigne { width: 1.35rem; font-size: 1.25rem; text-align: center; flex: none; line-height: 1; color: var(--encre); }
.enseigne.rouge { color: var(--rouge); }
.vide { color: var(--menu); font-size: 0.85rem; font-style: italic; }

.carte {
  min-width: 2.4rem; min-height: 3rem;
  padding: 0.25rem 0.35rem;
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  font-weight: 700; font-variant-numeric: tabular-nums;
  background: #fff; color: var(--encre);
  border: 1px solid var(--trait); border-radius: 7px;
  box-shadow: 0 1px 2px rgba(25, 24, 23, 0.14);
  cursor: default; transition: transform 0.12s, box-shadow 0.12s;
}
.carte .rang { font-size: 1.15rem; line-height: 1; }
.carte .sym { font-size: 0.85rem; line-height: 1; opacity: 0.75; }
.carte.rouge { color: var(--rouge); }
.carte.jouable {
  cursor: pointer; border-color: var(--tapis); background: #fbfdfb;
  box-shadow: 0 0 0 2px rgba(13, 82, 51, 0.18), 0 2px 5px rgba(25, 24, 23, 0.14);
}
.carte.jouable:hover { transform: translateY(-4px); }
.carte.jouable:active { transform: translateY(-1px); }
.carte.interdite { opacity: 0.28; }

/* Pendant les enchères, la main se lit et ne se clique pas : rangs alignés, quatre lignes fines,
   ce qui laisse la place à la boîte à enchères sans recouvrir la main. */
.jeu-lecture .couleur { margin-bottom: 0.1rem; }
.jeu-lecture .rangs {
  font-size: 1.2rem; font-weight: 700; letter-spacing: 0.12em;
  font-variant-numeric: tabular-nums;
}
.jeu-lecture .rangs.rouge { color: var(--rouge); }

/* Le mort est plus compact : on le lit, on n'y cherche pas ses propres cartes. */
.jeu-compact .carte { min-width: 2.05rem; min-height: 2.5rem; }
.jeu-compact .carte .rang { font-size: 1rem; }
.jeu-compact .carte .sym { font-size: 0.72rem; }

/* ------------------------------------------------------------------ tapis */

.tapis {
  background: radial-gradient(ellipse at 50% 40%, var(--tapis-clair), var(--tapis) 72%);
  border-radius: 18px; padding: 0.5rem; margin: 0.5rem 0;
  box-shadow: inset 0 0 34px rgba(0, 0, 0, 0.30);
}
.pli {
  position: relative;
  display: grid; gap: 0.2rem;
  grid-template-areas: ". nord ." "ouest centre est" ". sud .";
  grid-template-columns: 1fr auto 1fr;
  min-height: 8.2rem; align-items: center; justify-items: center;
}
.place-nord { grid-area: nord; } .place-sud { grid-area: sud; }
.place-est { grid-area: est; } .place-ouest { grid-area: ouest; }
.tapis-centre {
  grid-area: centre; color: rgba(255, 255, 255, 0.5);
  font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.12em; text-align: center;
  min-width: 3.4rem;
}
.place { min-height: 3rem; display: flex; align-items: center; }
.place .carte { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45); border-color: transparent; }
.place.gagnante .carte { outline: 2px solid var(--or); outline-offset: 2px; }

.dernier { text-align: center; margin: 0.15rem 0 0; min-height: 1rem; color: var(--menu); font-size: 0.78rem; }
.dernier .gagne { color: var(--or); font-weight: 700; }

.tour {
  text-align: center; margin: 0.5rem 0 0.6rem; min-height: 1.4rem;
  font-size: 1rem; color: var(--menu);
}
.tour.attente { color: var(--tapis); font-weight: 700; }

/* ------------------------------------------------------------------ feuille d'enchères */

.feuille-entete, .feuille-ligne {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.25rem; text-align: center;
}
.feuille-entete {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--menu);
  font-weight: 700; padding-bottom: 0.3rem; border-bottom: 1px solid var(--trait); margin-bottom: 0.3rem;
}
.feuille-entete .moi { color: var(--tapis); }
.feuille-ligne span {
  font-size: 1.02rem; font-weight: 700; font-variant-numeric: tabular-nums;
  padding: 0.2rem 0; border-radius: 6px;
}
.feuille-ligne .rouge { color: var(--rouge); }
.feuille-ligne .passe { color: var(--menu); font-weight: 400; font-size: 0.9rem; }
.feuille-ligne .attente { color: var(--or); }
.feuille-ligne .mienne { background: #eef4f0; }

.explication {
  margin: 0.5rem 0 0; padding: 0.5rem 0.65rem;
  background: #f7f3e9; border-left: 3px solid var(--or);
  border-radius: 0 7px 7px 0; font-size: 0.87rem; color: #4c4640;
}
.explication:empty { display: none; }

/* ------------------------------------------------------------------ boîte à enchères */

.boite {
  position: sticky; bottom: 0; z-index: 10;
  background: var(--panneau); border-radius: 14px 14px 0 0;
  padding: 0.55rem; margin: 0.6rem -0.7rem 0;
  box-shadow: 0 -6px 20px rgba(25, 24, 23, 0.12);
}
.boite-grille { display: flex; flex-direction: column; gap: 0.3rem; }
.boite-paliers { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.25rem; }
.boite-couleurs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.25rem; }
.enchere.palier { font-size: 1.05rem; padding: 0.45rem 0; }
.enchere.palier.choisi { background: var(--tapis); color: #fff; border-color: var(--tapis); }
.enchere.denomination { font-size: 1.15rem; padding: 0.55rem 0; }
.boite-speciales { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.3rem; margin-top: 0.35rem; }

.enchere {
  padding: 0.42rem 0.1rem; font-size: 0.97rem; font-weight: 700;
  background: #fff; color: var(--encre);
  border: 1px solid var(--trait); border-radius: 7px; cursor: pointer;
  font-variant-numeric: tabular-nums; transition: background 0.1s, transform 0.1s;
}
.enchere .rouge { color: var(--rouge); }
.enchere:hover:not(:disabled) { background: #eef4f0; border-color: var(--tapis); }
.enchere:active:not(:disabled) { transform: translateY(1px); }
.enchere:disabled { opacity: 0.2; cursor: default; }
.enchere.speciale { padding: 0.55rem 0.2rem; font-size: 1rem; }
.enchere.passe { background: var(--tapis); color: #fff; border-color: var(--tapis); }
.enchere.passe:hover:not(:disabled) { background: var(--tapis-clair); }
.enchere.contre { color: var(--rouge); }

/* ------------------------------------------------------------------ bilan */

dialog {
  border: none; border-radius: 16px; padding: 1.3rem;
  max-width: 27rem; width: calc(100% - 1.6rem);
  box-shadow: 0 14px 50px rgba(0, 0, 0, 0.4); color: var(--encre);
}
dialog::backdrop { background: rgba(7, 56, 33, 0.6); }
dialog h2 { margin: 0 0 0.4rem; font-size: 1.45rem; letter-spacing: -0.01em; }
dialog p { margin: 0 0 0.6rem; font-size: 0.94rem; }
dialog dl { display: grid; grid-template-columns: 1fr auto; gap: 0.3rem 1rem; margin: 0.8rem 0; font-size: 0.93rem; }
dialog dt { color: var(--menu); }
dialog dd { margin: 0; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
dialog dd.gain { color: #15803d; }
dialog dd.perte { color: var(--rouge); }

.diagramme {
  background: #f7f3e9; border-radius: 8px; padding: 0.6rem;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 0.75rem; line-height: 1.6; margin-bottom: 0.9rem; overflow-x: auto; white-space: pre;
}
.diagramme .rouge { color: var(--rouge); }
.diagramme .position { color: var(--menu); font-weight: 700; }

.bouton {
  width: 100%; padding: 0.85rem; font-size: 1.02rem; font-weight: 700;
  color: #fff; background: var(--tapis); border: none; border-radius: 10px; cursor: pointer;
}
.bouton:hover { background: var(--tapis-clair); }

footer {
  padding: 1rem 0.9rem 2.2rem; text-align: center; max-width: 720px; margin: 0 auto;
  color: var(--menu); font-size: 0.78rem;
}

@media (min-width: 700px) {
  body { font-size: 18px; }
  .carte { min-width: 2.75rem; min-height: 3.35rem; }
  .carte .rang { font-size: 1.3rem; }
  .etat-contrat { font-size: 3rem; }
  .boite { position: static; margin: 0.7rem 0 0; border-radius: 14px; }
  .boite-grille { gap: 0.3rem; }
  .enchere { padding: 0.55rem 0.2rem; font-size: 1.05rem; }
}
