/* Atout — le tarot a quatre.
   Le tapis est vert, les cartes sont claires, et rien d'autre ne bouge : tout ce
   qui se lit -- la main, le pli, le contrat -- doit se voir d'un coup d'oeil,
   sur un telephone comme sur un ecran. */

:root {
  --bg: #E6E7E1; --surface: #F6F6F1; --surface-2: #EDEDE6; --line: #CDCEC5;
  --texte: #171A20; --texte-2: #4E5663; --texte-doux: #7C8390;
  --accent: #1E5B45; --bon: #3B6A49; --mauvais: #A63C50;
  --tapis-a: #2A6B52; --tapis-b: #1E5B45; --tapis-trait: #14402F;
  --carte: #FBF7EE; --carte-bord: #C9BFA6; --carte-dos: #7A2E2E;
  --noir: #23262B; --rouge: #B0332A; --atout: #C2701A; --excuse: #6B4FA1;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ombre: 0 1px 2px rgba(20,24,30,.07), 0 10px 26px rgba(20,24,30,.09);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #13161B; --surface: #1B1F26; --surface-2: #232830; --line: #333A45;
  --texte: #E8E9E4; --texte-2: #A5ACB8; --texte-doux: #79808C;
  --accent: #6FBF9B; --bon: #83BA8E; --mauvais: #F4577A;
  --tapis-a: #1B4335; --tapis-b: #123025; --tapis-trait: #0B2019;
  --carte: #F3EEE2; --carte-bord: #8C816A; --carte-dos: #5A2222;
  --noir: #23262B; --rouge: #B0332A; --atout: #A85C12; --excuse: #57408A;
  --ombre: 0 1px 2px rgba(0,0,0,.45), 0 12px 30px rgba(0,0,0,.38);
} }
:root[data-theme="dark"] {
  --bg: #13161B; --surface: #1B1F26; --surface-2: #232830; --line: #333A45;
  --texte: #E8E9E4; --texte-2: #A5ACB8; --texte-doux: #79808C;
  --accent: #6FBF9B; --bon: #83BA8E; --mauvais: #F4577A;
  --tapis-a: #1B4335; --tapis-b: #123025; --tapis-trait: #0B2019;
  --carte: #F3EEE2; --carte-bord: #8C816A; --carte-dos: #5A2222;
  --noir: #23262B; --rouge: #B0332A; --atout: #A85C12; --excuse: #57408A;
  --ombre: 0 1px 2px rgba(0,0,0,.45), 0 12px 30px rgba(0,0,0,.38);
}

/* Ce qui ne suit pas le theme : une carte garde son papier clair dans le noir
   comme dans le clair, et l'or reste de l'or.  Le sceau des bouts est dessine
   ici plutot que charge : une image de plus a attendre pour une etoile de dix
   pixels serait un mauvais marche. */
:root {
  --or: #C08A20;
  --sceau: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23C8971F' d='M12 .8c1.2 6.6 4.4 9.8 11 11-6.6 1.2-9.8 4.4-11 11-1.2-6.6-4.4-9.8-11-11 6.6-1.2 9.8-4.4 11-11Z'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--texte);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  /* La main serre ses cartes pour tenir dans la largeur ; si le calcul se
     trompait d'un pixel, la page entiere se mettrait a glisser de cote. */
  overflow-x: hidden;
}
.ecran { min-height: 100dvh; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ─────────────────────────────── les boutons ─────────────────────────────── */
.btn {
  font: inherit; font-size: 15px; padding: 9px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--texte);
  cursor: pointer;
}
.btn:disabled { opacity: .38; cursor: default; }
@media (hover: hover) { .btn:hover:not(:disabled) { border-color: var(--accent); } }
.btn-primaire { background: var(--accent); border-color: var(--accent); color: #fff;
  font-weight: 650; }
.btn-mini { padding: 6px 10px; font-size: 13px; }
.btn-danger { color: var(--mauvais); }
.pousse { flex: 1; }

.segment { display: inline-flex; border: 1px solid var(--line); border-radius: 10px;
  overflow: hidden; background: var(--surface-2); }
.segment.large { display: flex; width: 100%; }
.segment button { flex: 1; border: 0; background: transparent; color: var(--texte-2);
  font: inherit; font-size: 14px; padding: 8px 10px; cursor: pointer; }
.segment button + button { border-left: 1px solid var(--line); }
.segment button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.langues button { font-size: 11px; letter-spacing: .08em; padding: 4px 9px; }

/* ─────────────────────────────── le réglage ──────────────────────────────── */
#ecran-config { display: grid; place-items: center; padding: 24px 16px; }
.boite { width: 100%; max-width: 440px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--ombre);
  overflow: hidden; }
.boite-tete { padding: 20px 20px 0; position: relative; }
.boite-tete .langues { position: absolute; top: 16px; right: 16px; }
.boite-tete h1 { margin: 0; font-size: 26px; letter-spacing: -.01em; }
.sous-titre { margin: 6px 0 0; font-size: 14px; color: var(--texte-2); }
.rappel { color: var(--texte-doux); font-size: 13px; }
.boite-corps { padding: 18px 20px; display: grid; gap: 16px; }
.champ label { display: block; font-size: 13px; color: var(--texte-2); margin-bottom: 6px; }
.libre { display: block; margin-top: 6px; font-size: 12.5px; color: var(--texte-doux);
  font-style: normal; }
.case { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.case em { color: var(--texte-doux); font-style: normal; font-size: 12.5px; }
.boite-pied { display: flex; gap: 8px; padding: 0 20px 20px; align-items: center; }

/* ──────────────────────────────── la table ───────────────────────────────── */
#ecran-jeu { display: flex; flex-direction: column; min-width: 0; }
#barre { display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line); background: var(--surface); min-width: 0; }
#phase-nom { font-size: 15px; }
.etiquette { font-size: 12.5px; color: var(--texte-doux); border: 1px solid var(--line);
  border-radius: 999px; padding: 2px 9px; }
.etiquette.attente { color: var(--accent); border-color: var(--accent); }

#tapis { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom)); min-width: 0; }
#table {
  position: relative; flex: 1 1 auto; min-height: 170px; border-radius: 16px;
  background: radial-gradient(120% 100% at 50% 0%, var(--tapis-a), var(--tapis-b));
  border: 1px solid var(--tapis-trait); box-shadow: inset 0 0 40px rgba(0,0,0,.25);
  padding: 10px; min-width: 0;
}
.siege { position: absolute; display: flex; flex-direction: column; align-items: center;
  gap: 4px; color: #EAF2ED; font-size: 12.5px; text-align: center; }
.siege .nom { font-weight: 600; letter-spacing: .02em; }
.siege .info { opacity: .72; font-size: 11.5px; }
.siege.a-lui .nom { color: #FFD98A; }
.siege.preneur .nom::after { content: " ★"; color: #FFD98A; }
.siege.haut { top: 10px; left: 50%; transform: translateX(-50%); }
.siege.bas { bottom: 10px; left: 50%; transform: translateX(-50%); }
.siege.gauche { left: 12px; top: 50%; transform: translateY(-50%); }
.siege.droite { right: 12px; top: 50%; transform: translateY(-50%); }
/* Le dos aussi vient du jeu de 1898 : le tartan rouge et vert de Grimaud.  Les
   mains des trois autres sont a l'echelle des cartes qu'on joue : on doit voir
   ce qu'il leur reste d'un coup d'oeil, pas deviner des timbres-poste. */
.dos { width: 34px; height: 60px; border-radius: 4px;
  background: url(../cartes/dos.webp) center / cover no-repeat, var(--carte-dos);
  border: 1px solid rgba(0,0,0,.35); box-shadow: 0 1px 2px rgba(0,0,0,.28); }
.dos-pile { display: flex; }
.dos-pile .dos + .dos { margin-left: -25px; }

/* le pli, au centre : chaque carte du côté de qui l'a jouée */
.pli { position: absolute; inset: 0; display: grid; place-items: center;
  pointer-events: none; }
.pli .pose { position: absolute; }
.pli .pose.p0 { bottom: 30%; }
.pli .pose.p1 { left: 26%; }
.pli .pose.p2 { top: 30%; }
.pli .pose.p3 { right: 26%; }
.pli .pose.gagne { filter: drop-shadow(0 0 0 2px #FFD98A); }
.pli .pose.gagne .carte { border-color: #FFD98A; box-shadow: 0 0 0 2px #FFD98A; }

/* ─────────────────────────────── les cartes ──────────────────────────────── */
/* L'index en haut a gauche, comme sur une vraie carte -- et pour la meme raison :
   c'est la seule partie qui reste visible quand les cartes se chevauchent dans la
   main.  Au centre du tapis, ou rien ne recouvre rien, on la recentre. */
/* Le visage des cartes est celui du jeu Grimaud de 1898, numerise par la BnF et
   tombe dans le domaine public : le tarot francais tel qu'il se joue, et non un
   dessin qui lui ressemble.  Le rapport 37/66 est celui du carton.
   L'image se pose PAR-DESSUS le fond dessine, qui reste dessous : si un fichier
   manquait, la carte se lirait encore. */
.carte {
  width: 44px; height: 78px; border-radius: 5px;
  background: var(--face) center / cover no-repeat, var(--carte);
  border: 1px solid var(--carte-bord); box-shadow: 0 1px 3px rgba(0,0,0,.25);
  font-weight: 650; user-select: none; flex: 0 0 auto; position: relative;
  font-family: inherit; color: var(--noir); cursor: default; overflow: hidden;
}
/* Sur le tapis, rien ne recouvre rien : la carte y est a sa taille, et le
   dessin de 1898 s'y regarde vraiment. */
.pli .carte { width: 62px; height: 110px; border-radius: 7px; }

/* Les vingt et un atouts sont vingt et une cartes qui ne different que par un
   chiffre : sans rien pour les tenir ensemble, un jeu de tarot ressemble a un
   tableau de nombres.  On leur donne donc un papier a eux -- parchemin raye
   fin, chiffre en serif -- et surtout un filet d'or au bord gauche, parce que c'est la seule part de la carte qui reste visible
   quand la main se serre : les atouts se voient alors comme la tranche doree
   d'un livre, d'un seul coup d'oeil et sans rien lire. */
.carte.atout {
  background: var(--face) center / cover no-repeat,
    linear-gradient(180deg, #FCF6E8, #F2E3C4);
  border-color: #D9BE88; border-left: 2px solid var(--or);
  box-shadow: 0 1px 3px rgba(0,0,0,.25), inset 0 0 0 1px rgba(255,255,255,.55);
}
.carte.excuse {
  background: var(--face) center / cover no-repeat,
    linear-gradient(180deg, #F6F1FD, #E2D8F4);
  border-color: #C7B8E5; border-left: 2px solid #8C74C4;
  box-shadow: 0 1px 3px rgba(0,0,0,.25), inset 0 0 0 1px rgba(255,255,255,.55);
}
/* Les trois bouts valent chacun quatre points et demi et decident a eux seuls
   du seuil a atteindre : un sceau, pas un point. */
.carte.bout::after { content: ""; position: absolute; bottom: 3px; right: 3px;
  width: 9px; height: 9px; background: var(--sceau) center / contain no-repeat; }

/* La main tient sur une ligne, toujours.  Dix-huit cartes ne rentrent pas cote
   a cote sur un telephone : elles se chevauchent, d'autant plus qu'elles sont
   nombreuses et l'ecran etroit.  Le recouvrement est calcule au rendu et pose
   ici, parce que le CSS ne sait pas compter ses enfants. */
.main { display: flex; justify-content: center; flex-wrap: wrap; gap: 0;
  padding: 8px 2px 4px; min-width: 0; max-width: 100%; }
.main .carte + .carte { margin-left: calc(2px - var(--chevauche, 0px)); }
.main .carte { z-index: 1; }
.main .carte:hover, .main .carte.choisie { z-index: 3; }
.main .carte { cursor: default; }
.main .carte.jouable { cursor: pointer; }
@media (hover: hover) {
  .main .carte.jouable:hover { transform: translateY(-6px); }
}
.main .carte { transition: transform .12s ease, opacity .12s ease; }
.main .carte.morte { opacity: .34; }
.main .carte.choisie { transform: translateY(-10px); box-shadow: 0 0 0 2px var(--accent); }

/* ────────────────────────── le bandeau d'action ──────────────────────────── */
/* ── LE DERNIER PLI ──────────────────────────────────────────────────────────
   Le pli se ramasse tout seul, donc il faut pouvoir le revoir : quatre cartes
   dans l'ordre ou elles sont tombees, la place de chacun au-dessus de la
   sienne, la maitresse encadree comme sur le tapis. */
.dernier { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 8px 12px; margin-bottom: 8px; }
.dernier[hidden] { display: none; }
.dernier .titre { font-size: 12px; color: var(--texte-doux);
  letter-spacing: .06em; text-transform: uppercase; }
.dernier .cartes { display: flex; gap: 8px; align-items: flex-end; }
.dernier .qui { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.dernier .qui em { font: 600 10.5px/1 system-ui, sans-serif; font-style: normal;
  color: var(--texte-doux); letter-spacing: .04em; }
.dernier .qui .carte { width: 30px; height: 53px; border-radius: 4px; }
.dernier .qui.gagne em { color: var(--accent); }
.dernier .qui.gagne .carte { border-color: #FFD98A; box-shadow: 0 0 0 2px #FFD98A; }
.dernier .nav { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.dernier .nav[hidden] { display: none; }
.dernier .nav .compte { font-size: 12.5px; color: var(--texte-doux);
  font-variant-numeric: tabular-nums; min-width: 4.2em; text-align: center; }

.action { background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  min-height: 52px; }
.action .quoi { font-size: 14px; }
.action .aide { font-size: 12.5px; color: var(--texte-doux); width: 100%; margin: 0; }
.action:empty { display: none; }

.annonce { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  background: rgba(10,20,16,.86); color: #EAF2ED; padding: 7px 14px;
  border-radius: 999px; font-size: 13.5px; pointer-events: none; }

/* ─────────────────────────────── la modale ───────────────────────────────── */
.modale { position: fixed; inset: 0; background: rgba(10,14,20,.55);
  display: grid; place-items: center; padding: 16px; z-index: 20; }
.modale-boite { width: 100%; max-width: 480px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--ombre);
  max-height: 88dvh; display: flex; flex-direction: column; }
.modale-tete { display: flex; align-items: center; gap: 10px; padding: 14px 16px 0; }
.modale-tete h2 { margin: 0; font-size: 18px; flex: 1; }
.modale-corps { padding: 12px 16px; overflow: auto; font-size: 14.5px; }
.modale-corps p { margin: 0 0 10px; }
.modale-corps h3 { margin: 14px 0 6px; font-size: 14px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--texte-2); }
.modale-pied { display: flex; gap: 8px; justify-content: flex-end; padding: 0 16px 16px; }
.verdict { font-size: 17px; font-weight: 650; }
.verdict.bon { color: var(--bon); } .verdict.mauvais { color: var(--mauvais); }
.compte { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px;
  font-size: 14px; margin: 10px 0; }
.compte b { font-weight: 600; color: var(--texte-2); }

/* ────────────────────────────── le téléphone ─────────────────────────────── */
@media (max-width: 620px) {
  #barre { gap: 8px; padding: 8px 10px; }
  #tapis { padding: 8px; gap: 8px; }
  #table { min-height: 200px; }
  .carte { width: 34px; height: 60px; }
  .pli .carte { width: 46px; height: 82px; }
  .dos { width: 26px; height: 46px; }
  .dos-pile .dos + .dos { margin-left: -19px; }
  .carte.bout::after { width: 8px; height: 8px; bottom: 2px; right: 2px; }
  .siege.gauche, .siege.droite { font-size: 11px; }
  /* La barre du haut tient sur une ligne : le contrat se laisse couper plutot
     que de renvoyer « Quitter » a la ligne suivante. */
  #barre { padding: 6px 8px; gap: 6px; }
  #phase-nom { font-size: 14px; }
  #barre .btn-mini { padding: 5px 8px; font-size: 12px; }
  #contrat-vu { max-width: 38vw; overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap; }
  /* Sur un telephone la barre ne tient pas tout : le choix de la langue est un
     reglage qu'on fait une fois, il reste sur l'ecran d'accueil.  Et rien n'y
     passe a la ligne -- une barre qui grandit quand l'ordinateur se met a
     reflechir ferait sauter toute la table d'un cran. */
  #barre .langues { display: none; }
  #barre { flex-wrap: nowrap; }
  #phase-nom, #barre .etiquette { min-width: 0; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap; }
  #barre .btn-mini { flex: 0 0 auto; }
  /* Cinq boutons d'enchere sur trois lignes mangeaient l'ecran : on les serre. */
  .action { padding: 8px; gap: 6px; }
  .action .btn { padding: 7px 10px; font-size: 13.5px; }
  .action .aide { font-size: 12px; }
}
@media (max-width: 400px) {
  .carte { width: 29px; height: 51px; }
  .carte.bout::after { width: 7px; height: 7px; bottom: 2px; right: 2px; }
}

/* Le bandeau de recherche d'une donne : quelques secondes, et la page le dit. */
.cherche {
  position: fixed; inset: 0; z-index: 40; display: flex;
  align-items: center; justify-content: center;
  background: #0b0f14cc; backdrop-filter: blur(2px);
}
.cherche-boite {
  background: var(--surface, #16202c); border-radius: 14px; padding: 22px 26px;
  text-align: center; max-width: 30rem; box-shadow: 0 18px 50px #0008;
}
.cherche-boite p { margin: 0; font-weight: 650; }
.cherche-vues { margin-top: 8px !important; font-weight: 400 !important;
  opacity: .7; font-variant-numeric: tabular-nums; }
.cherche-boite .btn { margin-top: 14px; }
