/* FAP FAP en ligne — feuille de style. */
body { margin: 0; }
[hidden] { display: none !important; }
img { max-width: 100%; }
/* Mise en page : une table de jeu tenue dans un écran de téléphone —
   adversaires en haut, tapis au centre, main du joueur en bas. */
:root {
  --night: #0b1f24;
  --panel: #102c32;
  --felt: #17505a;
  --felt-deep: #0f353c;
  --ivory: #f7f0df;
  --ivory-shade: #e3d8bd;
  --ink: #17181c;
  --rouge: #c3352b;
  --back: #7b2230;
  --gold: #f3b63f;
  --gold-ink: #33240a;
  --text: #ecf3f0;
  --muted: #a3bbb8;
  --line: rgba(236, 243, 240, .16);
  --danger: #ff9a8b;
  --ok: #86dbab;
  --font-display: 'Bricolage Grotesque', 'Trebuchet MS', system-ui, sans-serif;
  --font-body: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--night);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

#app {
  max-width: 540px;
  min-height: 100%;
  margin: 0 auto;
  padding-inline: 16px;
  padding-block: 14px 18px;
  display: flex;
  flex-direction: column;
}
.screen { display: flex; flex-direction: column; gap: 16px; flex: 1; min-width: 0; }

/* ---------- éléments communs ---------- */
.wordmark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 28px;
  line-height: 1;
  letter-spacing: -.02em;
  margin: 0;
}
.wordmark span { color: var(--gold); }
.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
}
.pill {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.pill b { font-family: var(--font-display); font-weight: 700; font-size: 16px; color: var(--gold); }
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 12px;
  padding: 11px 16px;
  font-weight: 600;
  min-height: 44px;
}
.btn:hover { border-color: var(--muted); }
a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; color: var(--text); }
a.btn.btn-primary { color: var(--gold-ink); }
.btn-primary { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.btn-primary:hover { border-color: var(--ivory); }
.btn-ghost { border-color: transparent; color: var(--muted); padding-inline: 8px; }
.btn-ghost:hover { color: var(--text); border-color: transparent; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.error { color: var(--danger); font-size: 13px; margin: 0; }

/* ---------- accueil ---------- */
.lobby-head { display: flex; flex-direction: column; gap: 10px; }
.lobby-head .title-block { display: flex; flex-direction: column; gap: 4px; }
/* Première ligne : retour à gauche, solde à droite. */
.lobby-head .top-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; min-height: 40px; }
.lobby-head .top-row > .pill { margin-left: auto; }
.lobby-head .wordmark { font-size: 24px; }
.btn-back { min-height: 40px; padding: 8px 12px; color: var(--muted); font-size: 14px; }
.btn-back:hover { color: var(--text); }
.form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.form h2, .rules summary {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  margin: 0;
  text-wrap: balance;
}
.field { display: flex; flex-direction: column; gap: 8px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > legend, .field > label.label {
  font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 0;
}
.field > legend { margin-bottom: 8px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.seg label { position: relative; }
.seg input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.seg span {
  display: block; text-align: center; padding: 10px 0; border: 1px solid var(--line); border-radius: 12px;
  font-family: var(--font-display); font-weight: 700; font-size: 18px;
}
.seg input:checked + span { background: var(--felt); border-color: var(--gold); color: var(--gold); }
.seg input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }
.stake-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
#stake {
  width: 120px; background: var(--night); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
  font-family: var(--font-display); font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums;
}
.chip {
  appearance: none; background: transparent; border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.chip:hover { border-color: var(--muted); }
.opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.opt {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 8px; align-items: center; align-content: start;
  padding: 10px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer;
}
.opt:has(input:checked) { border-color: var(--gold); }
.opt strong { font-weight: 600; font-size: 14px; line-height: 1.2; overflow-wrap: anywhere; }
.opt small { grid-column: 1 / -1; color: var(--muted); font-size: 12px; line-height: 1.35; }
.opt input {
  grid-column: 2; grid-row: 1; appearance: none; width: 44px; height: 26px; margin: 0;
  border-radius: 999px; background: var(--night); border: 1px solid var(--line); position: relative; cursor: pointer;
  transition: background .15s;
}
.opt input::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--muted); transition: transform .15s, background .15s;
}
.opt input:checked { background: var(--felt); border-color: var(--gold); }
.opt input:checked::after { transform: translateX(18px); background: var(--gold); }
.sit { display: flex; flex-direction: column; gap: 8px; }
.rules { border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px; }
.rules summary { cursor: pointer; font-size: 17px; }
.rules ul { margin: 12px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; color: var(--muted); max-width: 62ch; }
.rules ul b { color: var(--text); font-weight: 600; }
.deck { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; margin-top: 14px; align-items: center; }
.deck .suit { font-size: 18px; line-height: 1; }
.deck .ranks { display: flex; flex-wrap: wrap; gap: 4px; }
.deck .ranks span {
  min-width: 24px; padding: 2px 0; text-align: center; border-radius: 5px; background: var(--ivory); color: var(--ink);
  font-family: var(--font-display); font-weight: 700; font-size: 12px;
}
.deck .ranks span.red { color: var(--rouge); }
.deck .ranks span.out { background: transparent; color: var(--muted); border: 1px dashed var(--line); text-decoration: line-through; }
.foot { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }

/* ---------- table ---------- */
#table { gap: 12px; }
.bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.bar .pli { font-family: var(--font-display); font-weight: 700; font-size: 17px; white-space: nowrap; }
.bar .pill { justify-self: end; }
.bar .btn-ghost { justify-self: start; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags span { font-size: 12px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.seats { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.seat {
  border: 1px solid var(--line); border-radius: 14px; padding: 9px 10px; min-width: 0;
  display: flex; flex-direction: column; gap: 5px;
}
.seat.is-turn { border-color: var(--gold); background: var(--panel); }
.seat.is-bank { opacity: .55; }
.seat .who { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; min-width: 0; }
.seat .who b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat .who span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.seat .backs { display: flex; gap: 3px; min-height: 22px; }
.seat .backs i {
  width: 15px; height: 22px; border-radius: 3px; border: 1px solid var(--ivory-shade);
  background: repeating-linear-gradient(45deg, var(--gold) 0 1px, transparent 1px 5px), var(--back);
}
.seat .state { font-size: 12px; color: var(--muted); min-height: 17px; }
.seat.is-turn .state { color: var(--gold); }

.felt {
  flex: 1; min-height: 200px; position: relative; border-radius: 22px;
  background: radial-gradient(ellipse at 50% 35%, var(--felt), var(--felt-deep) 78%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 18px 12px;
}
.felt::before {
  content: ''; position: absolute; inset: 7px; border-radius: 16px; border: 1px dashed rgba(243, 182, 63, .32); pointer-events: none;
}
.trick { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.slot { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 64px; }
.slot .name { font-size: 12px; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot.win .name { color: var(--gold); font-weight: 700; }
.slot .empty { width: 100%; aspect-ratio: 5 / 7; border-radius: 9px; border: 1px dashed var(--line); }
.status { text-align: center; margin: 0; font-weight: 600; text-wrap: balance; max-width: 34ch; position: relative; }
.event { text-align: center; margin: 0; font-size: 13px; color: var(--muted); min-height: 19px; position: relative; text-wrap: balance; }

.card {
  appearance: none; display: block; position: relative; width: 100%; aspect-ratio: 5 / 7; padding: 0;
  border-radius: 9px; border: 1px solid var(--ivory-shade); background: var(--ivory); color: var(--ink);
  font-family: var(--font-display); box-shadow: 0 2px 0 rgba(0, 0, 0, .28);
}
.card.red { color: var(--rouge); }
.card .rk { position: absolute; top: 5px; left: 7px; font-weight: 800; font-size: 19px; line-height: 1; letter-spacing: -.03em; }
.card .st { position: absolute; inset: 0; display: grid; place-items: center; font-size: 30px; line-height: 1; padding-top: 14px; }
.slot.win .card { outline: 3px solid var(--gold); outline-offset: 2px; }
.slot .card { animation: drop .22s ease-out; }
@keyframes drop { from { transform: translateY(-10px); opacity: 0; } to { transform: none; opacity: 1; } }

.mine { display: flex; flex-direction: column; gap: 10px; }
.mine-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.mine-head b { font-weight: 600; }
.mine-head span { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.timer { height: 5px; border-radius: 999px; background: var(--panel); overflow: hidden; }
.timer i { display: block; height: 100%; width: 0; background: var(--gold); border-radius: 999px; }
.hand { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; min-height: 60px; }
.hand .card { transition: transform .12s; }
.hand .card.can { cursor: pointer; }
.hand .card.can:hover { transform: translateY(-6px); }
.hand .card.no { opacity: .4; cursor: not-allowed; }
.hand .card.wait { cursor: default; }
.hand-note { grid-column: 1 / -1; align-self: center; text-align: center; color: var(--muted); margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions .btn { flex: 1; }

/* ---------- feuilles (fin de partie, déclaration, départ) ---------- */
#sheet {
  position: fixed; inset: 0; z-index: 10; background: rgba(5, 14, 16, .72);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}
.sheet-card {
  width: 100%; max-width: 508px; max-height: 100%; overflow-y: auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: 20px; padding: 20px 18px; display: flex; flex-direction: column; gap: 14px;
}
.sheet-card h2 { font-family: var(--font-display); font-weight: 800; font-size: 21px; line-height: 1.1; margin: 0; text-wrap: balance; }
.sheet-card p { margin: 0; }
.sheet-card .lead { color: var(--muted); }
.badge { align-self: flex-start; background: var(--gold); color: var(--gold-ink); font-weight: 700; font-size: 12px; padding: 4px 10px; border-radius: 999px; }
.mini { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
.mini .who { flex-basis: 100%; font-size: 13px; color: var(--muted); }
.mini .card { width: 38px; box-shadow: none; }
.mini .card .rk { font-size: 13px; top: 3px; left: 4px; }
.mini .card .st { font-size: 17px; padding-top: 10px; }
.pay { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.pay th { text-align: left; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: 0 0 6px; }
.pay td { padding: 8px 0; border-top: 1px solid var(--line); }
.pay th:not(:first-child), .pay td:not(:first-child) { text-align: right; }
.pay .plus { color: var(--ok); font-weight: 700; }
.pay .minus { color: var(--danger); font-weight: 700; }
.sheet-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sheet-actions .btn { flex: 1; }

#toast {
  position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 20;
  background: var(--ivory); color: var(--ink); font-weight: 600; padding: 10px 16px; border-radius: 12px;
  max-width: calc(100% - 32px); text-align: center; box-shadow: 0 6px 24px rgba(0, 0, 0, .4);
}

@media (min-width: 480px) {
  .slot { width: 76px; }
  .card .rk { font-size: 22px; }
  .card .st { font-size: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- version en ligne : connexion, salon, salle d'attente ---------- */
.auth { max-width: 420px; width: 100%; margin: 6vh auto 0; display: flex; flex-direction: column; gap: 18px; }
.auth .lede { color: var(--muted); margin: 0; max-width: 46ch; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tabs button {
  appearance: none; background: transparent; border: 1px solid var(--line); border-radius: 12px; padding: 10px 8px;
  font-weight: 600; color: var(--muted); min-height: 44px;
}
.tabs button[aria-selected="true"] { background: var(--felt); border-color: var(--gold); color: var(--gold); }
.offer { border: 1px solid var(--gold); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.offer[hidden] { display: none; }
.offer p { margin: 0; overflow-wrap: anywhere; }
.text-input {
  width: 100%; background: var(--night); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-height: 46px;
}
.lobby-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.section-title { font-family: var(--font-display); font-weight: 700; font-size: 16px; margin: 0; }
.block { display: flex; flex-direction: column; gap: 12px; }
.tables { display: flex; flex-direction: column; gap: 10px; list-style: none; margin: 0; padding: 0; }
.tables li {
  border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center;
}
.tables .t-head { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.tables .t-head b { font-family: var(--font-display); letter-spacing: .06em; color: var(--gold); }
.tables .t-who { grid-column: 1 / -1; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.tables .tags { grid-column: 1 / -1; }
.empty-note { border: 1px dashed var(--line); border-radius: 16px; padding: 16px; color: var(--muted); margin: 0; }
.join-row { display: flex; gap: 8px; }
.join-row .text-input { flex: 1; min-width: 0; text-transform: uppercase; letter-spacing: .12em; font-family: var(--font-display); font-weight: 700; }
.banner {
  border: 1px solid var(--gold); border-radius: 14px; padding: 12px 14px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
}
.banner p { margin: 0; flex: 1; min-width: 180px; }
#offline {
  position: fixed; top: env(safe-area-inset-top, 0px); left: 0; right: 0; z-index: 30; text-align: center; padding: 8px 16px;
  background: var(--gold); color: var(--gold-ink); font-weight: 700; font-size: 13px;
}
.roster { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.roster li {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; min-width: 0;
}
.roster li.free { border-style: dashed; color: var(--muted); }
.roster .r-name { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.roster .r-name small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.roster .r-state { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.roster .r-state.on { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.code { font-family: var(--font-display); font-weight: 800; font-size: 34px; letter-spacing: .14em; color: var(--gold); margin: 0; position: relative; }
.wait-note { text-align: center; margin: 0; color: var(--muted); max-width: 36ch; position: relative; text-wrap: balance; }
.seat .who b.off { color: var(--muted); }
.slot .card.still { animation: none; }

/* ---------- cartes déjà jouées : un joueur par ligne, un pli par colonne ---------- */
.played-box { position: relative; border: 1px solid var(--line); border-radius: 14px; padding: 6px 10px; }
.sheet-card .played-box { background: var(--night); }
.played { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 0 2px; font-variant-numeric: tabular-nums; }
.played caption { caption-side: top; text-align: left; font-size: 12px; color: var(--muted); }
.played thead th, .played thead td { padding: 0; font-size: 11px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.played thead th { width: 40px; text-align: center; }
.played thead td { text-align: left; }
.played thead td span { display: none; }
.played tbody th { padding: 0 8px 0 0; text-align: left; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.played tbody td { padding: 0; text-align: center; }
.pc {
  display: inline-flex; align-items: center; justify-content: center; gap: 1px; width: 36px; height: 24px; vertical-align: middle;
  border-radius: 6px; border: 1px solid var(--ivory-shade); background: var(--ivory); color: var(--ink);
  font-family: var(--font-display); font-weight: 800; font-size: 13px; line-height: 1; letter-spacing: -.03em;
}
.pc.red { color: var(--rouge); }
.pc.win { outline: 2px solid var(--gold); outline-offset: -1px; border-color: var(--gold); }
.pc-none { color: var(--muted); }

/* La main reste accrochée en bas : on peut toujours jouer sans faire défiler. */
.mine {
  position: sticky; bottom: 0; z-index: 2; background: var(--night);
  padding-block: 4px 10px; margin-block: -4px -10px;
}
/* Même principe pour les feuilles : les boutons restent atteignables si la feuille dépasse l'écran. */
.sheet-card .sheet-actions {
  position: sticky; bottom: 0; background: var(--panel);
  padding-top: 10px; margin-top: -10px; box-shadow: 0 20px 0 var(--panel);
}
/* Taille des cartes calculée sur la hauteur de l'écran, pour que le tapis, les cartes
   jouées et la main tiennent ensemble sans défiler, sur téléphone comme sur ordinateur.
   --fixed = hauteur de tout ce qui n'est pas une carte ; --rows = nombre de joueurs. */
#table {
  --rows: 4;
  --fixed: calc(508px + var(--rows) * 26px);
  --budget: calc(100vh - var(--fixed));
  --hand-w: clamp(44px, calc(var(--budget) * .4), 101px);
  --slot-w: min(clamp(38px, calc(var(--budget) * .3), 76px), 19vw);
}
@supports (height: 1dvh) {
  #table { --budget: calc(100dvh - var(--fixed)); }
}
.hand { grid-template-columns: repeat(5, minmax(0, var(--hand-w))); }
.hand .card .rk { font-size: clamp(15px, calc(var(--hand-w) * .31), 22px); }
.hand .card .st { font-size: clamp(24px, calc(var(--hand-w) * .5), 36px); }
.slot { width: var(--slot-w); }
.slot .card .rk { font-size: max(13px, calc(var(--slot-w) * .3)); top: 4px; left: 5px; }
.slot .card .st { font-size: calc(var(--slot-w) * .47); padding-top: calc(var(--slot-w) * .22); }

/* Écran peu haut (téléphone, ordinateur portable) : la table se resserre. */
@media (max-height: 900px) {
  #app { padding-block: 8px 10px; }
  #table { gap: 8px; --fixed: calc(424px + var(--rows) * 26px); }
  .tags.one-line { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tags.one-line::-webkit-scrollbar { display: none; }
  .tags.one-line.more {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent);
  }
  .mine { gap: 8px; }
  .felt { min-height: 0; gap: 8px; padding: 12px 10px; }
  .status { max-width: none; }
  .slot { gap: 4px; }
  #table > .played-box { padding: 4px 10px; }
  #table > .played-box caption {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
  #table > .played-box thead td span { display: inline; }
}

/* ---------- choix du jeu ---------- */
.games { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.game-card {
  appearance: none; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 18px 16px; display: flex; flex-direction: column; gap: 8px; min-width: 0;
}
.game-card:hover { border-color: var(--gold); }
.game-card .wordmark { font-size: 22px; }
.game-card .game-sub { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--gold); }
.game-card .game-text { color: var(--muted); }
.seg.two { grid-template-columns: repeat(2, 1fr); }
.seg:has(#seat-5:not([hidden])) { grid-template-columns: repeat(4, 1fr); }

/* ---------- table de 21 : le sol, les cartes posées, puis la main ---------- */
#table.t21 {
  --fixed: 490px;
  --slot-w: min(clamp(34px, calc(var(--budget) * .21), 68px), calc((100vw - 104px) / 6));
  --hand-w: clamp(44px, calc(var(--budget) * .28), 92px);
}
.t21 .felt { gap: 8px; justify-content: flex-start; }
.row-label { position: relative; margin: 0; font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.t21 .trick { gap: 8px; }
.t21 .slot { gap: 3px; }
.t21 .slot .name.bust { color: var(--danger); }
.t21 .slot .name.good { color: var(--gold); font-weight: 700; }
.t21 .slot button.card { cursor: pointer; }
.t21 .slot button.card:hover { transform: translateY(-4px); }
.t21 .slot .took { min-height: 24px; display: flex; align-items: center; }
.t21 .hand { grid-template-columns: repeat(4, minmax(0, var(--hand-w))); }
.hand .plus-sign { align-self: center; justify-self: center; color: var(--muted); font-family: var(--font-display); font-weight: 800; font-size: 22px; }
.sum21 { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; position: relative; }
.sum21 th { text-align: left; font-weight: 600; font-size: 13px; padding: 4px 8px 4px 0; overflow-wrap: anywhere; }
.sum21 td { padding: 4px 0; white-space: nowrap; }
.sum21 td.cards { display: flex; gap: 3px; }
.sum21 td.tot { text-align: right; font-family: var(--font-display); font-weight: 800; font-size: 16px; padding-inline: 8px; }
.sum21 td.note { text-align: right; font-size: 12px; color: var(--muted); }
.sum21 tr.win th, .sum21 tr.win td.tot { color: var(--gold); }
.sum21 tr.bust td.tot { color: var(--danger); }
.sum-box { position: relative; width: 100%; max-width: 380px; border: 1px solid var(--line); border-radius: 14px; padding: 6px 10px; background: rgba(11, 31, 36, .55); }
.sheet-card .sum-box { max-width: none; background: var(--night); }
.sum-box summary { cursor: pointer; font-size: 13px; color: var(--muted); padding: 4px 0; }
@media (max-height: 900px) {
  .t21 .felt { gap: 5px; padding: 10px 8px; }
  .t21 .slot .took { min-height: 20px; }
  .t21 .seat { padding: 6px 9px; gap: 3px; }
}
.t21 .felt:has(.sum-box) { justify-content: center; gap: 12px; }
.seats.tight .seat .who { flex-direction: column; align-items: flex-start; gap: 0; }
.seats.tight .seat .who b { max-width: 100%; }
.seats.tight .seat { padding-inline: 7px; }
.seats.tight .seat .backs i { width: 13px; height: 19px; }
/* 21 : cartes du sol cochées, cartes prises */
.t21 .slot button.card.on { outline: 3px solid var(--gold); outline-offset: 2px; transform: translateY(-5px); }
.t21 .slot button.card.no { opacity: .4; cursor: not-allowed; }
.t21 .slot button.card.no:hover { transform: none; }
.t21 .slot .took { flex-wrap: wrap; justify-content: center; gap: 2px; }
.t21 .slot .took .pc { width: 25px; height: 19px; font-size: 11px; border-radius: 5px; }
.t21 .slot .took small { font-size: 11px; color: var(--muted); }
.hand .got { display: flex; flex-wrap: wrap; gap: 4px; align-self: center; grid-column: 4; min-width: 0; }
.hand .got .pc { width: 44px; height: 30px; font-size: 16px; }
.t21 .hand { grid-template-columns: minmax(0, var(--hand-w)) minmax(0, var(--hand-w)) auto minmax(0, 1fr); }
.t21 .hand .card { width: var(--hand-w); }
.hand .pick-go { grid-column: 3 / -1; align-self: center; justify-self: stretch; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 8px; min-width: 0; text-align: center; line-height: 1.2; }
.hand .pick-go small { font-weight: 600; font-size: 12px; opacity: .8; }
.banner.refill { border-color: var(--line); background: var(--panel); }
.banner.refill p { color: var(--muted); }
.form-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.form-head h2 { margin: 0; }
#open-create { align-self: stretch; }

/* ---------- tournois ---------- */
.tables li.tour .t-head small { display: block; font-weight: 400; color: var(--muted); font-size: 13px; }
.tables li.tour.mine { border-color: var(--gold); }
.sum21 caption { caption-side: top; text-align: left; font-size: 12px; color: var(--muted); padding-bottom: 2px; }
.sum21.wins th { width: 100%; }
.sum21.wins td.note { padding-left: 4px; }

/* ---------- argent réel ---------- */
.pill-btn { appearance: none; -webkit-appearance: none; background: transparent; cursor: pointer; font: inherit; color: inherit; border-color: var(--gold); }
.pill-btn:hover { background: var(--panel); }
.w-balance { display: flex; flex-direction: column; gap: 2px; }
.w-balance b { font-family: var(--font-display); font-weight: 800; font-size: 30px; color: var(--gold); font-variant-numeric: tabular-nums; }
.w-balance small { color: var(--muted); font-size: 13px; min-height: 18px; }
.w-form { display: flex; flex-direction: column; gap: 12px; }
.w-title { font-family: var(--font-display); font-weight: 700; font-size: 17px; margin: 4px 0 0; }
.txs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.txs li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.txs li:first-child { border-top: 0; }
.txs .tx-what { font-weight: 600; overflow-wrap: anywhere; }
.txs .tx-what small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.txs .tx-amount { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.txs .tx-amount.plus { color: var(--ok); }
.txs .tx-amount.minus { color: var(--danger); }
.txs .btn { grid-column: 1 / -1; min-height: 40px; padding: 8px 12px; }

/* ---------- contrôles de saisie, compte, code de validation ---------- */
.field-error { color: var(--danger); font-size: 13px; margin: 0; }
.field-error:empty { display: none; }
.text-input.bad, #stake.bad, #join-code.bad { border-color: var(--danger); }
.text-input.good { border-color: var(--ok); }
.pass-row { display: flex; gap: 8px; align-items: stretch; }
.pass-row .text-input { flex: 1; min-width: 0; }
.pass-row .btn { flex: none; min-width: 92px; }
.code-input { font-family: var(--font-display); font-weight: 700; font-size: 24px; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
.code-input::placeholder { letter-spacing: .3em; opacity: .35; }
.acc-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.acc-rows li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.acc-rows li:first-child { border-top: 0; }
.acc-rows .acc-what { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.acc-rows .acc-what small { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.state { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
.state.ok { color: var(--ok); border-color: var(--ok); }
.state.todo { color: var(--gold); border-color: var(--gold); }
.acc-box { border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.acc-box.now { border-color: var(--gold); }
.acc-box h3, .acc-title { font-family: var(--font-display); font-weight: 700; font-size: 17px; margin: 0; }
.acc-form { display: flex; flex-direction: column; gap: 12px; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.row-btns .btn { flex: 1; }
.note-test { border: 1px dashed var(--line); border-radius: 12px; padding: 10px 12px; color: var(--muted); font-size: 13px; }
#auth-form .btn-ghost { align-self: center; }
/* Accueil : entrée vers les jetons virtuels, puis liens du compte en pied d'écran. */
.go-tokens {
  appearance: none; text-align: left; background: transparent; border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; color: var(--text);
}
.go-tokens[hidden] { display: none; }
.go-tokens:hover { border-color: var(--muted); }
.go-tokens > span:first-child { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.go-tokens small { color: var(--muted); font-size: 13px; }
.go-tokens .go-arrow { color: var(--muted); font-size: 22px; line-height: 1; }
.foot-links { display: flex; justify-content: center; gap: 4px 16px; flex-wrap: wrap; margin-top: auto; padding-top: 8px; }
.foot-links .btn-ghost { min-height: 40px; padding: 8px 10px; font-size: 14px; }
.acc-next { display: block; color: var(--gold); font-size: 13px; }

/* Garam Tia : numéro d'ordre des cartes au sol. La première à prendre est mise en avant. */
.t21 .slot .ord { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-family: var(--font-display); font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.t21 .slot.next .ord { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
@media (max-height: 900px) { .t21 .slot .ord { min-width: 19px; height: 19px; font-size: 12px; } }

/* ---------- déconnexion automatique ---------- */
#idle-warn {
  position: fixed; top: env(safe-area-inset-top, 0px); left: 0; right: 0; z-index: 31; padding: 10px 16px;
  background: var(--gold); color: var(--gold-ink); font-weight: 600; font-size: 14px;
  display: flex; align-items: center; justify-content: center; gap: 10px 14px; flex-wrap: wrap; text-align: center;
}
#idle-warn .btn { background: var(--gold-ink); color: var(--ivory); border-color: var(--gold-ink); min-height: 38px; padding: 6px 14px; }
.notice { border: 1px solid var(--gold); border-radius: 12px; padding: 10px 12px; margin: 0; color: var(--text); font-size: 14px; }
/* Le numéro est posé sur le coin de la carte : la table ne s'allonge pas. */
.t21 .slot { position: relative; }
/* En haut à droite : le chiffre de la carte, en haut à gauche, reste lisible même sur une petite carte. */
.t21 .slot .ord { position: absolute; top: -8px; right: -7px; z-index: 2; background: var(--panel); box-shadow: 0 1px 3px rgba(0, 0, 0, .35); }
.t21 .trick:has(.ord) { margin-top: 6px; }
.t21 .slot.next .ord { background: var(--gold); }
/* Une place étroite (table de 5 sur petit téléphone) ne déborde plus quand son texte d'état est long. */
.seat { min-width: 0; }
.seat .state { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seats.tight .seat .state { font-size: 11px; }
