/*
 * CashKash — style sobre et épuré.
 * Fond clair, une seule couleur d'accent (vert), tapis vert pour le poker,
 * échiquier beige et brun. Polices du système, aucune ressource externe.
 * CSP stricte : aucun style en ligne, les valeurs dynamiques passent par le CSSOM.
 */

:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #f0efea;
  --text: #1c1c1e;
  --muted: #6b6b70;
  --line: #e2e0d9;
  --accent: #1f6f4a;
  --accent-soft: #e7f1ec;
  --accent-ink: #ffffff;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #1f7a3d;
  --gold: #f2c94c;
  --felt: #1f6b47;
  --felt-dark: #154d33;
  --rail: #5b3d28;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 2px 8px rgba(0, 0, 0, 0.04);
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --accent-hover: #185b3c;
  --shadow-2: 0 2px 4px rgba(0, 0, 0, 0.06), 0 8px 20px rgba(0, 0, 0, 0.08);
  --shadow-3: 0 6px 16px rgba(0, 0, 0, 0.12), 0 18px 40px rgba(0, 0, 0, 0.12);

  /* Système de mouvement : une seule signature partout (durées et courbes). */
  --dur-press: 80ms; /* appui */
  --dur-fast: 140ms; /* survol, focus, petits éléments */
  --dur-base: 220ms; /* panneaux, onglets, notices, bulles */
  --dur-move: 280ms; /* pièces, cartes, jetons misés */
  --dur-slow: 460ms; /* pot vers le gagnant, bandeaux, compteurs */
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1); /* entrées et déplacements */
  --ease-in: cubic-bezier(0.4, 0, 1, 1); /* sorties */
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1); /* retournements, allers-retours */
  --ease-pop: cubic-bezier(0.34, 1.3, 0.64, 1); /* très léger dépassement : badges, gains */
  --rise: 6px;
  color-scheme: light;
}

/* Mode sombre (Paramètres › Affichage ; data-ui posé sur <html> par js/ui/motion.js). Les cartes
   restent claires, la table et l'échiquier gardent leurs thèmes. */
:root[data-ui='dark'] {
  --bg: #15171a;
  --surface: #1e2124;
  --surface-2: #282b30;
  --text: #ececeb;
  --muted: #9b9da3;
  --line: #33363c;
  --accent: #2f9a68;
  --accent-hover: #37b079;
  --accent-soft: #17332a;
  --accent-ink: #ffffff;
  --danger: #f2706a;
  --danger-soft: #3a1f1f;
  --ok: #4cc77d;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 2px 4px rgba(0, 0, 0, 0.4), 0 8px 20px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}
:root[data-ui='dark'] .btn:hover:not(:disabled) {
  border-color: #4a4e55;
}
:root[data-ui='dark'] .chess-clock.is-running {
  background: #ececeb;
  color: #15171a;
}
:root[data-ui='dark'] .skeleton {
  background-image: linear-gradient(90deg, var(--surface-2) 0%, #33373c 50%, var(--surface-2) 100%);
}
:root[data-ui='dark'] .dbutton {
  color: #15171a;
}

@keyframes ck-fade-in {
  from {
    opacity: 0;
  }
}
@keyframes ck-rise-in {
  from {
    opacity: 0;
    transform: translateY(var(--rise));
  }
}
@keyframes ck-pop-in {
  from {
    opacity: 0;
    transform: scale(0.85);
  }
}
@keyframes ck-shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}

/* Réglage « Animations de l'interface : selon le système » (Paramètres › Affichage) : l'interface
   hors jeu suit alors la demande de réduire les mouvements. Par défaut, elle anime. */
@media (prefers-reduced-motion: reduce) {
  :root[data-motion='system'] {
    --dur-fast: 1ms;
    --dur-base: 1ms;
    --dur-move: 1ms;
    --dur-slow: 1ms;
    --rise: 0px;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
}

h1,
h2,
h3 {
  line-height: 1.25;
  margin: 0 0 10px;
}
h2 {
  font-size: 18px;
}
p {
  margin: 0 0 10px;
}
a {
  color: var(--accent);
}
button,
input,
select {
  font: inherit;
  color: inherit;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Mise en page ---------- */

.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
}

.app--wide {
  max-width: 1440px;
}

main {
  flex: 1;
  padding: 18px 0 26px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 22px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.brand {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}

.brand span {
  color: var(--accent);
}

.nav {
  display: flex;
  gap: 4px;
}

.nav a {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.nav a:hover {
  background: var(--surface-2);
}
.nav a[aria-current='page'] {
  background: var(--accent-soft);
  color: var(--accent);
}

.wallets {
  display: flex;
  gap: 20px;
  margin-left: auto;
}
.wallet {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.wallet-amount {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.wallet-label {
  font-size: 12px;
  color: var(--muted);
}

.user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-name {
  font-weight: 600;
}

.footer {
  padding: 16px 0 24px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.footer-links {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 14px;
}
.footer-links a {
  color: var(--muted);
}
.footer-links a:hover {
  color: var(--accent);
}
.footer-age {
  margin-top: 4px;
  font-size: 12px;
}
.footer-sound {
  margin: 6px 0 0;
}
/* Choix de la langue (ajouté au pied de page par js/core/i18n.js) */
.lang-picker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}
.lang-picker select {
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

/* Dans les Paramètres (catégorie Affichage), le choix de langue suit le style des autres réglages. */
.settings-row .lang-picker {
  margin-top: 0;
  font-size: inherit;
}
.settings-row .lang-picker select {
  padding: 6px 8px;
}

/* Page 404 */
.not-found {
  text-align: center;
}
.not-found-code {
  margin: 0;
  font-size: 64px;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
}
.not-found-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

/* Pages d'information (mentions légales, CGU, confidentialité, signalement) */
.legal {
  display: grid;
  gap: 20px;
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
}
.legal-doc h2 {
  font-size: 18px;
  margin: 22px 0 6px;
}
.legal-doc p,
.legal-doc li {
  line-height: 1.6;
  max-width: 72ch;
}
.legal-doc ul {
  padding-left: 20px;
  display: grid;
  gap: 4px;
}
.legal-note {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 14px;
}
.legal-table-wrap {
  overflow-x: auto;
}
.legal-table td,
.legal-table th {
  text-align: left !important;
  vertical-align: top;
}

.page-title {
  font-size: 25px;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.page-lead {
  color: var(--muted);
  font-size: 15.5px;
  max-width: 62ch;
}
.hint {
  color: var(--muted);
  font-size: 14px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

/* ---------- Éléments de formulaire ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

.btn:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: #d3d0c6;
}
.btn:active:not(:disabled) {
  transform: scale(0.98);
  transition-duration: var(--dur-press);
}
.btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}
.btn--primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 2px 8px rgba(31, 111, 74, 0.25);
}
.btn--danger {
  background: var(--surface);
  border-color: var(--danger);
  color: var(--danger);
}
.btn--danger:hover:not(:disabled) {
  background: var(--danger);
  color: #fff;
}
.danger-zone {
  border-color: var(--danger-soft);
}
.danger-zone h3 {
  color: var(--danger);
}
/* Case à cocher avec son texte (inscription, signalement) */
.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 14px;
  line-height: 1.45;
  margin: 4px 0 12px;
  cursor: pointer;
}
.check input {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  flex: none;
}
.report-form {
  display: grid;
  gap: 4px;
  margin-top: 12px;
}
.report-text {
  min-height: 120px;
  resize: vertical;
  font: inherit;
}
.btn--small {
  padding: 5px 10px;
  font-size: 13px;
}
.btn--block {
  width: 100%;
}

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}
.input--small {
  width: auto;
  padding: 5px 9px;
  font-size: 14px;
}

input[type='range'] {
  width: 100%;
  accent-color: var(--accent);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.field label,
.field-label {
  font-weight: 600;
  font-size: 14px;
}

.notice {
  padding: 10px 14px;
  margin: 0 0 14px;
  border-radius: 8px;
  background: var(--accent-soft);
  font-size: 15px;
}

.notice--error {
  background: var(--danger-soft);
  color: var(--danger);
}
.notice--ok {
  background: var(--accent-soft);
  color: var(--ok);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.tab {
  padding: 9px 14px;
  margin-bottom: -1px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}

.tab:hover {
  color: var(--text);
}
.tab[aria-selected='true'] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.choices {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.choice {
  position: relative;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.choice:hover:not(:disabled) {
  border-color: var(--accent);
}
.choice[aria-pressed='true'],
.choice[aria-checked='true'] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.choice:disabled {
  opacity: 0.45;
  cursor: default;
}

.choice-badge {
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--gold);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.badge {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
}

.badge--reflet {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Pastille d'un joueur : photo de profil (recadrée en rond) ou initiale (session.face). */
.face {
  overflow: hidden;
}
.face img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.face.has-photo {
  background: var(--surface-2);
}

.face--small,
.face--large {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.face--small {
  width: 30px;
  height: 30px;
  font-size: 14px;
}
.face--large {
  width: 96px;
  height: 96px;
  font-size: 40px;
  box-shadow: 0 0 0 1px var(--line);
}

.user-me {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
}
.user-me:hover .user-name {
  text-decoration: underline;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.profile-photo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 20px;
  margin-bottom: 14px;
}
.profile-photo-actions {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 220px;
}
.profile-photo-actions .hint {
  width: 100%;
  margin: 0;
}
#photo-file:focus-visible + label {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.big-number {
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ---------- Accueil ---------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 40px;
  align-items: start;
  padding-top: 24px;
}

.perks {
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
}

.perks li {
  position: relative;
  padding: 6px 0 6px 28px;
}

.perks li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 700;
}

.auth-links {
  margin-top: 12px;
  text-align: center;
}
#resend-box {
  margin-top: 12px;
  text-align: center;
}

.hub {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.game-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.game-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s;
}

.game-card:hover {
  border-color: var(--accent);
}
.game-card .btn {
  margin-top: auto;
}
.game-icon {
  font-size: 34px;
  line-height: 1;
  color: var(--accent);
}

.history {
  margin: 0;
  padding: 0;
  list-style: none;
}

.history li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.history li:last-child {
  border-bottom: 0;
}
.history-game {
  width: 20px;
  color: var(--muted);
  text-align: center;
}
.history-label {
  flex: 1;
  min-width: 0;
}
.history-label time {
  color: var(--muted);
}
.history-delta {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.history-delta.plus {
  color: var(--ok);
}
.history-delta.minus {
  color: var(--danger);
}

/* ---------- Salon du poker ---------- */

.lobby {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.lobby .tabs {
  margin-bottom: 0;
}

.lobby-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.level-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}

.level-card:hover {
  border-color: var(--accent);
}
.level-card[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.level-card.is-short {
  opacity: 0.5;
}
.level-blinds {
  font-size: 16px;
}

.buyin {
  margin: 4px 0 14px;
}
.buyin-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.buyin-head strong {
  font-variant-numeric: tabular-nums;
}

.room-list,
.tour-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.room-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.room-item:last-child {
  border-bottom: 0;
}
.public-list {
  margin-top: 16px;
}
.public-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.public-names {
  color: var(--muted);
  font-size: 13px;
}

.tour-item {
  padding: 12px 14px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tour-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
}
.tour-time {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}
.tour-name {
  font-weight: 600;
}
.tour-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.tour-badge {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}
.tour-code {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

/* Lien « Tournois » parmi les onglets de mode (page à part), lien de retour au tournoi */
.tab--link {
  text-decoration: none;
  color: var(--muted);
}
.tab--link:hover {
  color: var(--accent);
}
.tour-back {
  display: block;
  text-decoration: none;
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
}
.tour-back:hover {
  text-decoration: underline;
}

/* ---------- Tournois d'échecs (tournois-echecs.html) ---------- */
.ctour-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.ctour-layout {
  display: grid;
  grid-template-columns: minmax(300px, 400px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.ctour-side {
  display: grid;
  gap: 4px;
}
.ctour-item.is-current {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}
.ctour-formats {
  display: grid;
  gap: 8px;
}
.ctour-format {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
}
.ctour-format:hover {
  border-color: var(--accent);
}
.ctour-format[aria-checked='true'] {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.ctour-format .hint {
  font-size: 13px;
}
.ctour-controls .choice {
  min-width: 64px;
}
.ctour-detail {
  display: grid;
  gap: 12px;
  min-width: 0;
}
.ctour-detail h3 {
  margin: 6px 0 0;
  font-size: 15px;
}
.ctour-detail-head h2 {
  margin-bottom: 2px;
  font-size: 22px;
}
.ctour-player {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left !important;
}
.ctour-table td:nth-child(2),
.ctour-table th:nth-child(2) {
  text-align: left;
}
.ctour-score {
  font-weight: 800;
}
.ctour-live {
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}
.ctour-history {
  white-space: nowrap;
}
.ctour-res {
  display: inline-block;
  min-width: 20px;
  margin-left: 2px;
  padding: 0 3px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}
.ctour-res--V,
.ctour-res--Vp {
  background: var(--accent-soft);
  color: var(--ok);
}
.ctour-res--Vp {
  box-shadow: inset 0 0 0 1px var(--ok);
}
.ctour-res--N,
.ctour-res--E {
  background: var(--surface-2);
  color: var(--muted);
}
.ctour-res--D {
  background: var(--danger-soft);
  color: var(--danger);
}
.ctour-bracket {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.ctour-round {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  gap: 10px;
  min-width: 170px;
}
.ctour-round h4 {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--muted);
  text-transform: capitalize;
}
.ctour-match {
  display: grid;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}
.ctour-match.is-live {
  border-color: var(--accent);
}
.ctour-slot {
  padding: 5px 10px;
  font-size: 13px;
}
.ctour-slot + .ctour-slot {
  border-top: 1px solid var(--line);
}
.ctour-slot.is-winner {
  font-weight: 800;
  color: var(--accent);
}
.ctour-slot.is-empty {
  color: var(--muted);
  font-style: italic;
}
.ctour-note {
  padding: 2px 10px 5px;
  font-size: 11px;
}
.ctour-games {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 3px;
  font-size: 14px;
}
.ctour-games li.is-you {
  color: var(--accent);
  font-weight: 600;
}
@media (max-width: 900px) {
  .ctour-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Créer un tournoi / rejoindre avec un code */
.tour-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0 16px;
}
.tour-create {
  flex: 1 1 360px;
}
.tour-create > summary {
  list-style: none;
  display: inline-flex;
}
.tour-create > summary::-webkit-details-marker {
  display: none;
}
.tour-create[open] > summary {
  margin-bottom: 12px;
}
.tour-form {
  display: grid;
  gap: 2px;
  max-width: 560px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.tour-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.tour-join {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.tour-join .input {
  width: 110px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.tag-ok {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--ok);
  font-size: 13px;
  font-weight: 600;
}

.queue-box {
  margin-top: 12px;
}
.code-input {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-weight: 600;
}

.blink {
  animation: blink 1.4s ease-in-out infinite;
}
@keyframes blink {
  50% {
    opacity: 0.45;
  }
}

/* ---------- Cartes à jouer (js/ui/card-face.js) ----------
   Tout est en unités de la carte (cqw) : la même carte sert de 20 à 120 px de large. */

.pcard {
  --w: var(--pcard-w, 56px);
  --suit: #15121c;
  position: relative;
  flex: none;
  width: var(--w);
  aspect-ratio: 5 / 7;
  border-radius: max(3px, min(8px, calc(var(--w) * 0.1)));
  background: #fdfcf8;
  color: var(--suit);
  border: 1px solid rgba(0, 0, 0, 0.35);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  line-height: 1;
  container-type: inline-size;
  overflow: hidden;
  transition:
    translate 0.2s,
    filter 0.2s,
    box-shadow 0.2s;
}

.pcard.is-red {
  --suit: #c8182a;
}
.cards-4c .pcard.suit-d {
  --suit: #1b5fd6;
}
.cards-4c .pcard.suit-c {
  --suit: #138a3c;
}

.pc-index {
  position: absolute;
  width: 26cqw;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pc-tl {
  left: 3cqw;
  top: 4cqw;
}
.pc-br {
  right: 3cqw;
  bottom: 4cqw;
  rotate: 180deg;
}

.pc-rank {
  font-weight: 700;
  font-size: 36cqw;
  letter-spacing: -0.04em;
  line-height: 0.9;
}

.pc-rank.is-ten {
  font-size: 29cqw;
  letter-spacing: -0.12em;
  text-indent: -0.12em;
}
.pc-suit {
  width: 20cqw;
  height: 20cqw;
  margin-top: 2cqw;
  fill: currentColor;
}

.pc-pips {
  position: absolute;
  left: 38cqw;
  right: 38cqw;
  top: 22cqw;
  bottom: 22cqw;
}

.pc-pip {
  position: absolute;
  left: calc(var(--x) * 100%);
  top: calc(var(--y) * 100%);
  width: 16cqw;
  height: 16cqw;
  translate: -50% -50%;
  fill: currentColor;
}

.pc-pip.is-down {
  rotate: 180deg;
}
.pc-ace {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46cqw;
  height: 46cqw;
  translate: -50% -50%;
  fill: currentColor;
}

.pc-figure {
  position: absolute;
  left: 30cqw;
  right: 30cqw;
  top: 9cqw;
  bottom: 9cqw;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4cqw;
  border: max(1px, 1.6cqw) solid currentColor;
  border-radius: 5cqw;
  background: #f5f2ea;
}

.pc-crown {
  width: 30cqw;
  height: 9cqw;
  background: currentColor;
  -webkit-mask: var(--crown) center / contain no-repeat;
  mask: var(--crown) center / contain no-repeat;
}

.pc-figure-letter {
  font-weight: 700;
  font-size: 32cqw;
  line-height: 0.9;
}
.pc-figure-suit {
  width: 20cqw;
  height: 20cqw;
  fill: currentColor;
}
.pc-figure--J {
  --crown: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 26 7'%3E%3Cpath d='M1 7h24L22 2l-3 3-6-5-6 5-3-3z'/%3E%3C/svg%3E");
}
.pc-figure--Q {
  --crown: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 26 7'%3E%3Cpath d='M1 7h24l-2-6-4 3-3-4-3 4-3-4-3 4-4-3z'/%3E%3C/svg%3E");
}
.pc-figure--K {
  --crown: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 26 7'%3E%3Cpath d='M1 7h24V1l-4 3-4-4-4 4-4-4-4 4-4-3z'/%3E%3C/svg%3E");
}

.pcard--back {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #2b4f7e;
  background-image: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.1) 0 2px, transparent 2px 6px);
}

.pcard--back::before {
  content: '';
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: max(2px, calc(var(--w) * 0.07));
}

.pcard-mark {
  position: relative;
  color: #fff;
  font-weight: 800;
  font-size: calc(var(--w) * 0.24);
}
.pcard.is-hidden {
  visibility: hidden;
}
.pcard.is-made {
  box-shadow: 0 0 0 2px var(--gold);
}
.pcard.is-win {
  translate: 0 -8%;
  box-shadow:
    0 0 0 2px var(--gold),
    0 4px 10px rgba(0, 0, 0, 0.35);
}
.pcard.is-dim {
  filter: brightness(0.6) saturate(0.6);
}

/* ---------- Table de poker ---------- */

.table-page {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 16px;
}

.table-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}
.table-title {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}
.table-prefs {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.stage {
  --pcard-w: clamp(36px, 4.4vw, 64px);
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 1;
  min-height: 360px;
  max-height: calc(100dvh - 220px);
  user-select: none;
}

.felt {
  position: absolute;
  inset: 9% 7%;
  border: 12px solid var(--rail);
  border-radius: 999px;
  background: radial-gradient(ellipse at center, var(--felt) 0%, var(--felt-dark) 100%);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.08),
    0 6px 20px rgba(0, 0, 0, 0.18);
}

.table-center {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  translate: -50% -50%;
}

.pboard {
  display: flex;
  gap: 6px;
}

.pslot {
  width: var(--pcard-w);
  aspect-ratio: 5 / 7;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  border-radius: 6px;
}

.pslot:has(.pcard) {
  border-color: transparent;
}
.pslot .pcard {
  --w: var(--pcard-w);
}

.ppot {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 12px 3px 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  opacity: 0;
  transition: opacity 0.2s;
}

.ppot.is-shown {
  opacity: 1;
}

.showdown-plate {
  display: none;
  align-items: baseline;
  gap: 8px;
  padding: 4px 14px;
  border-radius: 999px;
  background: var(--surface);
  font-size: 14px;
  box-shadow: var(--shadow);
}

.showdown-plate.is-shown {
  display: flex;
}
.showdown-plate.is-you {
  box-shadow: 0 0 0 2px var(--gold);
}
.showdown-hand {
  color: var(--muted);
}

.seats-layer,
.bets-layer,
.fly-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.seats-layer {
  z-index: 3;
}
.bets-layer {
  z-index: 4;
}
.fly-layer {
  z-index: 5;
  overflow: visible;
}

.fly-layer > * {
  position: absolute;
  left: 0;
  top: 0;
}
.fly-layer .pcard {
  --w: calc(var(--pcard-w) * 0.75);
}

.pseat {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: max-content;
  max-width: 170px;
  translate: -50% -50%;
  transition: opacity 0.2s;
}

/* En haut : la plaque au-dessus, les cartes vers le tapis. En bas (vous) : la place remonte dans la table. */
.pseat[data-side='top'] {
  flex-direction: column-reverse;
  translate: -50% -24px;
}
.pseat[data-side='bottom'] {
  translate: -50% calc(-100% + 24px);
}

.pseat-cards {
  display: flex;
  gap: 3px;
  min-height: calc(var(--pcard-w) * 0.7 * 1.4);
}
.pseat-cards .pcard {
  --w: calc(var(--pcard-w) * 0.7);
}
.pseat.is-you .pseat-cards {
  min-height: calc(var(--pcard-w) * 1.4);
}
.pseat.is-you .pseat-cards .pcard {
  --w: var(--pcard-w);
}

.pseat-plate {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 4px 14px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.pseat-badge {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 700;
}

.pseat.is-you .pseat-badge {
  background: var(--accent);
  color: var(--accent-ink);
}
.pseat.is-empty .pseat-badge {
  display: none;
}

.pseat-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}
.pseat-name {
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pseat-stack {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* Étiquette (dernière action) et gain : sous la plaque (au-dessus pour les places du haut),
   en position absolue pour ne jamais décaler la place. */
.pseat-tag,
.pseat-win {
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  translate: -50% 0;
  z-index: 1;
  white-space: nowrap;
  pointer-events: none;
}
.pseat[data-side='top'] .pseat-tag,
.pseat[data-side='top'] .pseat-win {
  top: auto;
  bottom: calc(100% + 4px);
}

.pseat-tag {
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 12px;
  animation: ck-fade-in var(--dur-fast) var(--ease-out);
}

.pseat-win {
  padding: 1px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: var(--gold);
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  animation: ck-win-in 420ms var(--ease-pop);
}
.pseat-win:empty {
  display: none;
}
.pseat-plate:has(.pseat-win:not(:empty)) .pseat-tag {
  display: none;
}
@keyframes ck-win-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.9);
  }
}

/* Barre de temps de parole : collée sous la plaque, animée par transform. */
.pseat-timer {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: -2px;
  display: none;
  height: 3px;
  overflow: hidden;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.15);
}

.pseat-timer.is-on {
  display: none;
} /* remplacée par l'anneau autour de la pastille */

/* Anneau du temps de parole, posé sur la pastille (même centre, un peu plus grand). */
.pseat-ring {
  position: absolute;
  left: 1px;
  top: 50%;
  width: 34px;
  height: 34px;
  translate: 0 -50%;
  rotate: -90deg;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out);
}
.pseat-ring.is-on {
  opacity: 1;
}
.pseat-ring circle {
  fill: none;
  stroke-width: 3;
}
.pseat-ring-track {
  stroke: rgba(0, 0, 0, 0.08);
}
.pseat-ring-arc {
  stroke: var(--gold);
  stroke-dasharray: 100;
  stroke-dashoffset: 0;
  stroke-linecap: round;
}
.pseat.is-empty .pseat-ring {
  display: none;
}
.pseat-timer span {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--gold);
  transform-origin: left center;
}

.pseat-plate {
  transition:
    border-color var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out);
}
.pseat.is-turn .pseat-plate {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(242, 201, 76, 0.45);
}
.pseat.is-winner .pseat-plate {
  border-color: var(--ok);
  animation: ck-halo 700ms var(--ease-out);
}
@keyframes ck-halo {
  0% {
    box-shadow: 0 0 0 0 rgba(31, 122, 61, 0.55);
  }
  60% {
    box-shadow: 0 0 0 7px rgba(31, 122, 61, 0.18);
  }
  100% {
    box-shadow: var(--shadow);
  }
}
.pseat.is-folded,
.pseat.is-out {
  opacity: 0.5;
}
.pseat.is-away .pseat-name {
  font-style: italic;
}
.pseat.is-empty {
  opacity: 0.55;
}
.pseat.is-empty .pseat-plate {
  padding: 4px 14px;
  border-style: dashed;
  box-shadow: none;
}

.hand-hint {
  display: none;
  flex-direction: column;
  align-items: center;
  padding: 3px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 12px;
  line-height: 1.3;
  text-align: center;
}

.hand-hint.is-shown {
  display: flex;
}
.hand-hint.is-strong {
  background: var(--accent);
}
.hand-hint-draw:empty {
  display: none;
}

.pbet {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px 2px 2px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  translate: -50% -50%;
  opacity: 0;
  transition: opacity 0.2s;
}

.pbet.is-shown {
  opacity: 1;
}

.chip {
  display: inline-block;
  flex: none;
  width: 16px;
  height: 16px;
  border: 3px dotted rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  background: #c8352e;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.chip--w {
  background: #e9e7e1;
  border-color: #8a8a8a;
}
.chip--r {
  background: #c8352e;
}
.chip--g {
  background: #2f8a4e;
}
.chip--k {
  background: #222;
  border-color: var(--gold);
}

.dbutton {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(0, 0, 0, 0.3);
  border-radius: 50%;
  background: #fff;
  font-size: 11px;
  font-weight: 800;
  translate: -50% -50%;
  opacity: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  /* Le bouton glisse d'une place à l'autre au lieu de sauter. */
  transition:
    left var(--dur-slow) var(--ease-out),
    top var(--dur-slow) var(--ease-out),
    opacity var(--dur-base) var(--ease-out);
}

.dbutton.is-shown {
  opacity: 1;
}

/* Sous la table : état, actions, journal et chat. */
/* Chat et onglets à gauche, toujours visibles (pas besoin de faire défiler pour écrire) ; table et actions à droite. */
.table-layout {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.table-area {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.table-layout > .side-box,
.chess-layout > .chess-box {
  position: sticky;
  top: 12px;
}

/* Échecs : l'encadré ne dépasse jamais la hauteur de l'échiquier (bandeau du haut → bandeau du bas,
   --board-h posé par echecs.js) ; c'est l'intérieur de l'onglet qui défile. */
.chess-layout > .chess-box {
  display: flex;
  flex-direction: column;
  height: var(--board-h, 640px);
  min-height: 0;
}
@media (max-width: 1180px) {
  .chess-layout > .chess-box {
    height: auto;
    max-height: var(--board-h, 640px);
  }
}
.chess-box > .side-pane:not([hidden]) {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
}
#cside-chat {
  overflow: hidden;
}
#chess-chat:not([hidden]) {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}
.chess-box .chat--bare {
  flex: 1;
  min-height: 0;
}
.chess-box .chat--bare .chat-body {
  flex: 1;
  min-height: 0;
}
.chess-box .chat--bare .chat-log {
  flex: 1;
  height: auto;
  min-height: 80px;
}

.table-main {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.status {
  min-height: 1.5em;
  margin: 0;
  font-weight: 600;
}
.status.is-you {
  color: var(--accent);
}
.status.is-urgent {
  color: var(--danger);
}
.status.is-thinking {
  color: var(--muted);
  font-weight: 500;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.betting {
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: opacity var(--dur-base) var(--ease-out);
}
/* Pas votre tour : boutons visibles et lisibles mais inactifs (avant : 0,6 × 0,5 = presque invisibles). */
.betting:not(.is-active) {
  opacity: 0.85;
}
.betting:not(.is-active) .btn:disabled {
  opacity: 0.55;
}

.raise-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.raise-row input[type='range'] {
  flex: 1;
  min-width: 140px;
  width: auto;
}
.raise-row output {
  min-width: 72px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.presets {
  display: flex;
  gap: 4px;
}

.action-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.action-row .btn {
  padding: 11px 10px;
}

.show-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
/* Cash game, tapis vide : recaver ou quitter */
.busted-box {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
}
.busted-text {
  display: grid;
  gap: 2px;
}
.busted-text strong {
  font-size: 16px;
}
.busted-amount {
  display: flex;
  align-items: center;
  gap: 12px;
}
.busted-amount input[type='range'] {
  flex: 1;
  accent-color: var(--accent);
}
.busted-amount output {
  min-width: 110px;
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.busted-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.busted-actions .btn {
  flex: 1;
  min-width: 140px;
}
.show-question {
  font-weight: 600;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.table-actions #btn-leave {
  margin-left: auto;
}
.rebuy {
  display: flex;
  gap: 6px;
}

.tour-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.tour-stat {
  display: flex;
  flex-direction: column;
}

.ranking {
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.ranking li {
  display: flex;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.rank-place {
  width: 36px;
  font-weight: 700;
}
.rank-prize {
  margin-left: auto;
  color: var(--ok);
  font-weight: 600;
}

.log summary {
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}

.log ol {
  max-height: 240px;
  margin: 8px 0 0;
  padding-left: 22px;
  overflow: auto;
  color: var(--muted);
  font-size: 13px;
}

.log .kind-result {
  color: var(--text);
  font-weight: 600;
}

/* ---------- Chat (js/ui/chat-box.js) ---------- */

.chat {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.chat-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.chat.is-closed .chat-head {
  border-bottom: 0;
}
.chat.is-closed .chat-body {
  display: none;
}

.chat-unread {
  padding: 0 7px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px;
}

.chat-unread:empty {
  display: none;
}

.chat-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px 12px;
}
.chat-body.is-disabled {
  opacity: 0.6;
}

.chat-log {
  height: 220px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  font-size: 14px;
}

.chat-msg {
  padding: 2px 0;
  overflow-wrap: anywhere;
}
.chat-from {
  margin-right: 6px;
  padding: 0;
  border: 0;
  background: none;
  font-weight: 700;
}
button.chat-from {
  cursor: pointer;
}
.chat-msg.is-you .chat-from {
  color: var(--accent);
}
.chat-msg.kind-system {
  color: var(--muted);
  font-style: italic;
}
.chat-msg.kind-bot .chat-from {
  color: var(--muted);
}
/* « Signaler » : discret, visible au survol du message ou au clavier (toujours visible au toucher). */
.chat-report {
  margin-left: 6px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 11px;
  opacity: 0;
  transition: opacity 140ms ease;
  cursor: pointer;
}
.chat-msg:hover .chat-report,
.chat-report:focus-visible,
.chat-report:disabled {
  opacity: 1;
}
.chat-report:hover {
  color: var(--danger);
  text-decoration: underline;
}
@media (hover: none) {
  .chat-report {
    opacity: 0.7;
  }
}
.chat-empty {
  color: var(--muted);
}

.chat-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.chat-chip {
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 12px;
  cursor: pointer;
}

.chat-chip:hover:not(:disabled) {
  border-color: var(--accent);
}
.chat-form {
  display: flex;
  gap: 6px;
}
.chat-input {
  flex: 1;
  min-width: 0;
}
.chat-error {
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}
.chat-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}
.chat-error:empty,
.chat-note:empty {
  display: none;
}

/* ---------- Échecs ---------- */

.chess-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 360px;
  gap: 20px;
  align-items: start;
}

.board-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 580px;
  margin: 0 auto;
}

.player-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.player-strip.is-turn {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}
.who {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}
.who > span {
  color: var(--muted);
  font-size: 13px;
}
.who-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 10px;
}

.captured {
  display: flex;
  align-items: center;
}
.captured-piece {
  width: 18px;
  height: 18px;
  margin-right: -4px;
}
.captured-piece svg {
  display: block;
  width: 100%;
  height: 100%;
}
.captured-adv {
  margin-left: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.chess-clock {
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--surface-2);
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.chess-clock,
.player-strip {
  transition:
    background-color var(--dur-base) var(--ease-out),
    color var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out);
}
.chess-clock.is-running {
  background: var(--text);
  color: #fff;
}
.chess-board.is-mate {
  filter: saturate(0.9);
  transition: filter var(--dur-slow) var(--ease-out);
}
.chess-clock.is-low {
  color: var(--danger);
}
.chess-clock.is-running.is-low {
  background: var(--danger);
  color: #fff;
}

.chess-board {
  --sq-light: #f0d9b5;
  --sq-dark: #b58863;
  --board-frame: #6b4a2f;
  --sq-coord: #5b3d22;
  --sq-mark: #f6e05e;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  /* Rangées fixes : une case au contenu plus grand (roi maté renversé) ne doit jamais étirer sa rangée. */
  grid-template-rows: repeat(8, minmax(0, 1fr));
  aspect-ratio: 1;
  overflow: hidden;
  border: 8px solid var(--board-frame);
  border-radius: 6px;
  transition: filter 0.3s;
}

.sq {
  position: relative;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
  padding: 7%;
  border: 0;
  background: var(--sq-dark);
  cursor: pointer;
}

.sq.light {
  background: var(--sq-light);
}

.sq.last::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--sq-mark);
  opacity: 0.45;
}

.sq.selected {
  box-shadow: inset 0 0 0 3px var(--accent);
}
.sq.check {
  background: radial-gradient(circle, #e5484d 0%, rgba(229, 72, 77, 0.4) 55%, transparent 75%), var(--sq-dark);
}
.sq.light.check {
  background: radial-gradient(circle, #e5484d 0%, rgba(229, 72, 77, 0.4) 55%, transparent 75%), var(--sq-light);
}
.sq.premove::before {
  content: '';
  position: absolute;
  inset: 0;
  background: #4c7bd9;
  opacity: 0.4;
}
.sq.mated .piece {
  rotate: 90deg;
} /* la bascule elle-même est animée par echecs.js, une fois */
.sq .piece.is-moving {
  z-index: 5;
}
.sq .piece.piece-ghost {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
.sq.target::after {
  animation: ck-fade-in 120ms var(--ease-out);
}
.sq.mate-winner {
  box-shadow: inset 0 0 0 3px var(--gold);
}

.sq.target::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.22);
  translate: -50% -50%;
}

.sq.target.capture::after {
  width: 92%;
  height: 92%;
  background: none;
  border: 4px solid rgba(0, 0, 0, 0.22);
}

.sq .piece {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
}
.sq .piece svg {
  display: block;
  width: 100%;
  height: 100%;
}

.sq .coord {
  position: absolute;
  z-index: 1;
  color: var(--sq-coord);
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  pointer-events: none;
}

.sq.light .coord {
  color: var(--sq-dark);
}
.sq:not(.light) .coord {
  color: var(--sq-light);
}
.sq .coord.file {
  right: 3px;
  bottom: 2px;
}
.sq .coord.rank {
  left: 3px;
  top: 2px;
}

.chess-board.locked .sq {
  cursor: default;
}

/* Glisser-déposer : la pièce suit le pointeur, la case d'origine s'estompe, la case survolée s'entoure. */
.chess-board {
  user-select: none;
  -webkit-user-select: none;
}
.chess-board:not(.locked),
.chess-board.is-premove {
  touch-action: none;
} /* au doigt, glisser une pièce ne fait pas défiler la page */
.chess-board:not(.locked) .sq .piece,
.chess-board.is-premove .sq .piece {
  cursor: grab;
}
.chess-board.is-dragging,
.chess-board.is-dragging .sq {
  cursor: grabbing;
}
.sq.drag-source .piece {
  opacity: 0.3;
}
.sq.drag-over {
  box-shadow: inset 0 0 0 4px var(--accent);
}
.sq.drag-over.target::after {
  background: rgba(31, 111, 74, 0.55);
}

.drag-ghost {
  position: fixed;
  z-index: 60;
  padding: 0.4%;
  translate: -50% -55%;
  scale: 1.12;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.35));
  pointer-events: none;
}

.drag-ghost svg {
  display: block;
  width: 100%;
  height: 100%;
}
.chess-board.is-premove {
  filter: saturate(0.85);
}

.review-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
}
.review-label {
  min-width: 150px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.review-bar.is-reviewing .review-label {
  color: var(--accent);
  font-weight: 600;
}

.promo {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 6;
  display: flex;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
  translate: -50% -50%;
}

.promo .btn {
  width: 60px;
  height: 60px;
  padding: 6px;
}
.promo .btn svg {
  width: 100%;
  height: 100%;
}

.mate-banner {
  position: absolute;
  left: 50%;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 28px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  translate: -50% -50%;
  transition: opacity 0.5s;
}

.mate-banner strong {
  font-size: 22px;
}
.mate-banner.is-win strong {
  color: var(--accent);
}
.mate-banner.is-leaving {
  opacity: 0;
}

.chess-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}
.chess-side .tabs {
  margin-bottom: 0;
}

.level-choices {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.level-choice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}

.level-choice:hover {
  border-color: var(--accent);
}
.level-choice[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.level-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}
.level-text > span {
  color: var(--muted);
  font-size: 13px;
}
.level-meta {
  font-size: 12px;
}

.form-chips {
  display: flex;
  gap: 3px;
  margin-top: 3px;
}

.form-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: var(--surface-2);
  font-size: 11px;
  font-weight: 700;
}

.form-chip--V {
  background: var(--accent-soft);
  color: var(--ok);
}
.form-chip--D {
  background: var(--danger-soft);
  color: var(--danger);
}

.stake-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Choix de la cadence : Récent, Bullet, Blitz, Rapide (et Sans pendule contre un bot). */
#bot-times,
#online-times {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tc-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.tc-head {
  font-size: 13px;
  font-weight: 700;
}
.tc-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.tc-choice {
  padding: 8px 6px;
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.tc-choice[aria-pressed='true'] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.stake-line {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}

.stake-line strong {
  font-variant-numeric: tabular-nums;
}
#play .status,
#online-play .status {
  margin: 12px 0;
}

.moves {
  display: grid;
  grid-template-columns: 40px 1fr 1fr;
  max-height: 220px;
  margin: 0 0 12px;
  padding: 0;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  list-style: none;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.moves li {
  padding: 3px 8px;
}
.moves li:nth-child(6n + 1),
.moves li:nth-child(6n + 2),
.moves li:nth-child(6n + 3) {
  background: var(--surface-2);
}
.moves .num {
  color: var(--muted);
}
.moves .move {
  cursor: pointer;
}
.moves .move:hover {
  color: var(--accent);
}
.moves .move.is-current {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.takeback-box,
.draw-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}
.takeback-note {
  margin: 0;
  font-size: 14px;
}
.takeback-note:empty {
  display: none;
}
.takeback-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.takeback-actions .btn {
  flex: 1;
}
.takeback-box.is-asked .takeback-note {
  color: var(--accent);
  font-weight: 600;
}
/* Réponse à une demande de reprise : acceptée (vert), refusée (rouge), simple information ou attente (gris). */
.takeback-note[data-kind='ok'] {
  color: var(--accent);
  font-weight: 600;
}
.takeback-note[data-kind='no'] {
  color: var(--danger);
  font-weight: 600;
}
.takeback-note[data-kind='info'],
.takeback-note[data-kind='wait'] {
  color: var(--muted);
}
.draw-box:empty {
  display: none;
}
.draw-offer {
  margin: 0;
  font-weight: 600;
}
#play > .btn,
#online-play > .btn {
  margin-top: 4px;
}

.ranking-box {
  margin-top: 18px;
}
.ranking-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  margin-bottom: 6px;
}
.ranking-me {
  font-size: 14px;
}
.ranking-list {
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
  font-size: 14px;
}

.ranking-list li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto 60px;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
}

.ranking-list li.is-you {
  color: var(--accent);
  font-weight: 600;
}
.ranking-rank {
  color: var(--muted);
}
.ranking-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ranking-record {
  color: var(--muted);
  font-size: 12px;
}
.ranking-points {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.ranking-list li.ranking-empty {
  display: block;
  color: var(--muted);
}

.private-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.join-row {
  display: flex;
  gap: 6px;
}
.join-row .input {
  flex: 1;
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

.private-code {
  margin: 8px 0;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

#online-wait .btn,
#setup .btn + div {
  margin-top: 8px;
}

/* ---------- Thèmes de cartes (js/core/themes.js, attribut data-cards) ---------- */

.pc-big {
  display: none;
  fill: currentColor;
}

/* Moderne : grand symbole au centre, coins plus gros, dos sarcelle à motif rond. */
[data-cards='moderne'] .pcard {
  --suit: #0f172a;
  background: #f8fafc;
  border-color: #cbd5e1;
  border-radius: max(4px, calc(var(--w) * 0.14));
}
[data-cards='moderne'] .pcard.is-red {
  --suit: #e11d48;
}
[data-cards='moderne'] .pc-pips,
[data-cards='moderne'] .pc-figure,
[data-cards='moderne'] .pc-br {
  display: none;
}
[data-cards='moderne'] .pc-rank {
  font-size: 40cqw;
  font-weight: 800;
}
[data-cards='moderne'] .pc-big {
  display: block;
  position: absolute;
  left: 56%;
  top: 58%;
  width: 54cqw;
  height: 54cqw;
  translate: -50% -50%;
}
[data-cards='moderne'] .pcard--back {
  background-color: #0f766e;
  background-image:
    radial-gradient(circle at 50% 50%, transparent 0 20%, rgba(255, 255, 255, 0.85) 21% 25%, transparent 26%),
    repeating-radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.14) 0 2px, transparent 2px 7px);
}
[data-cards='moderne'] .pcard--back::before {
  border-color: rgba(255, 255, 255, 0.35);
}
[data-cards='moderne'] .pcard-mark {
  display: none;
}

/* Ivoire : papier crème, chiffres à empattements, filet intérieur, dos bordeaux en losanges. */
[data-cards='ivoire'] .pcard {
  --suit: #2b1d14;
  background: #f3e7cf;
  border-color: #8b6f47;
}
[data-cards='ivoire'] .pcard.is-red {
  --suit: #9b1c1c;
}
[data-cards='ivoire'] .pcard:not(.pcard--back)::after {
  content: '';
  position: absolute;
  inset: 3cqw;
  border: max(1px, 1cqw) solid rgba(139, 111, 71, 0.45);
  border-radius: 5cqw;
  pointer-events: none;
}
[data-cards='ivoire'] .pc-rank,
[data-cards='ivoire'] .pc-figure-letter {
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: 700;
  letter-spacing: 0;
}
[data-cards='ivoire'] .pc-figure {
  background: #eadbb8;
}
[data-cards='ivoire'] .pcard--back {
  background-color: #7a1f2b;
  background-image:
    linear-gradient(
      45deg,
      rgba(232, 199, 143, 0.22) 25%,
      transparent 25%,
      transparent 75%,
      rgba(232, 199, 143, 0.22) 75%
    ),
    linear-gradient(
      45deg,
      rgba(232, 199, 143, 0.22) 25%,
      transparent 25%,
      transparent 75%,
      rgba(232, 199, 143, 0.22) 75%
    );
  background-position:
    0 0,
    5px 5px;
  background-size: 10px 10px;
}
[data-cards='ivoire'] .pcard--back::before {
  border: 3px double #e8c78f;
}
[data-cards='ivoire'] .pcard-mark {
  color: #e8c78f;
  font-family: Georgia, serif;
}

/* Nuit : face sombre, couleurs vives, dos noir quadrillé d'or. */
[data-cards='nuit'] .pcard {
  --suit: #e5e7eb;
  background: #1f1f26;
  border-color: #3f3f46;
}
[data-cards='nuit'] .pcard.is-red {
  --suit: #ff6b81;
}
[data-cards='nuit'] .pc-figure {
  background: #2a2a33;
}
[data-cards='nuit'] .pcard--back {
  background-color: #111;
  background-image:
    repeating-linear-gradient(0deg, transparent 0 6px, rgba(212, 175, 55, 0.18) 6px 7px),
    repeating-linear-gradient(90deg, transparent 0 6px, rgba(212, 175, 55, 0.18) 6px 7px);
}
[data-cards='nuit'] .pcard--back::before {
  border-color: #d4af37;
}
[data-cards='nuit'] .pcard-mark {
  color: #d4af37;
}

/* Gros chiffres : chiffre géant, fond teinté par couleur (toujours 4 couleurs), dos orange à pois. */
[data-cards='geant'] .pcard {
  border-color: rgba(0, 0, 0, 0.25);
}
[data-cards='geant'] .pcard.suit-s {
  --suit: #111827;
  background: #eef2f6;
}
[data-cards='geant'] .pcard.suit-h {
  --suit: #dc2626;
  background: #ffe4e6;
}
[data-cards='geant'] .pcard.suit-d {
  --suit: #1d4ed8;
  background: #e0ecff;
}
[data-cards='geant'] .pcard.suit-c {
  --suit: #15803d;
  background: #dcfce7;
}
[data-cards='geant'] .pc-pips,
[data-cards='geant'] .pc-figure,
[data-cards='geant'] .pc-br,
[data-cards='geant'] .pc-tl .pc-suit {
  display: none;
}
[data-cards='geant'] .pc-tl {
  left: 6cqw;
  top: 3cqw;
  width: auto;
  align-items: flex-start;
}
[data-cards='geant'] .pc-rank {
  font-size: 64cqw;
  font-weight: 800;
}
[data-cards='geant'] .pc-rank.is-ten {
  font-size: 50cqw;
}
[data-cards='geant'] .pc-big {
  display: block;
  position: absolute;
  right: 6cqw;
  bottom: 6cqw;
  width: 46cqw;
  height: 46cqw;
}
[data-cards='geant'] .pcard--back {
  background-color: #e8710a;
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.4) 0 2px, transparent 2.5px);
  background-size: 9px 9px;
}

/* Jeu à 4 couleurs : après les thèmes, pour passer devant eux. */
.cards-4c [data-cards='moderne'] .pcard.suit-d,
.cards-4c [data-cards='ivoire'] .pcard.suit-d {
  --suit: #1b5fd6;
}
.cards-4c [data-cards='moderne'] .pcard.suit-c,
.cards-4c [data-cards='ivoire'] .pcard.suit-c {
  --suit: #138a3c;
}
.cards-4c [data-cards='nuit'] .pcard.suit-d {
  --suit: #60a5fa;
}
.cards-4c [data-cards='nuit'] .pcard.suit-c {
  --suit: #4ade80;
}

/* ---------- Table et fond (variables posées par js/ui/settings.js) ---------- */

.stage {
  border-radius: 16px;
  background: var(--backdrop-image, none), var(--backdrop-color, transparent);
}

:root[data-backdrop='clair'] .stage {
  background: transparent;
}

/* ---------- Choix des thèmes (js/ui/settings.js) ---------- */

.theme-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 8px;
}

.theme-picker--compact {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.theme-option {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s;
}

.theme-option:hover {
  border-color: var(--accent);
}
.theme-option[aria-checked='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.theme-picker--compact .theme-option {
  padding: 5px;
  gap: 4px;
}
.theme-name {
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.theme-picker--compact .theme-name {
  font-size: 12px;
  text-align: center;
}
.theme-detail {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.tp-chess {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
  max-width: 96px;
  overflow: hidden;
  border: 4px solid var(--board-frame);
  border-radius: 4px;
}

.theme-picker--compact .tp-chess {
  max-width: none;
  border-width: 3px;
}
.tp-sq {
  display: block;
  aspect-ratio: 1;
  padding: 8%;
  background: var(--sq-dark);
}
.tp-sq.light {
  background: var(--sq-light);
}
.tp-sq svg {
  display: block;
  width: 100%;
  height: 100%;
}

.tp-cards {
  display: flex;
  gap: 4px;
}
.tp-cards .pcard {
  --w: 36px;
}

.tp-table {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  background: var(--backdrop-image), var(--backdrop-color);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.tp-felt {
  position: absolute;
  inset: 16% 12%;
  border: 5px solid var(--rail);
  border-radius: 999px;
  background: radial-gradient(ellipse at center, var(--felt), var(--felt-dark));
}

/* Sous l'échiquier et à la table : choix rapide, lien vers tous les paramètres. */
.board-themes {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.board-themes-head,
.look-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.look-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.look-panel h3 {
  margin: 0 0 6px;
  font-size: 15px;
}
.look-panel .theme-picker {
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
}

/* ---------- Page Paramètres ---------- */

.settings {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 900px;
}
.settings h2 {
  margin-bottom: 4px;
}
.settings h3 {
  margin: 18px 0 8px;
  font-size: 15px;
}
.settings .panel > .hint:first-of-type {
  margin-bottom: 14px;
}
.settings-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.settings-row:first-of-type {
  border-top: 0;
}
.settings-row p {
  margin: 0;
}
.pseudo-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.pseudo-form .input {
  flex: 1;
  min-width: 180px;
  width: auto;
}

.preview-stage {
  --pcard-w: 44px;
  position: relative;
  aspect-ratio: 5 / 2;
  max-width: 520px;
  margin-bottom: 4px;
  border-radius: 14px;
  background: var(--backdrop-image), var(--backdrop-color);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.preview-stage .felt {
  inset: 10% 8%;
  border-width: 8px;
}
.preview-stage .table-center {
  flex-direction: row;
  gap: 6px;
}

/* Catégories : menu à gauche, contenu à droite (menu en haut sur téléphone). */
.settings {
  max-width: 1040px;
}
.settings-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.settings-nav {
  position: sticky;
  top: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-cat {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  color: var(--text);
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.settings-cat:hover {
  background: var(--surface-2);
}
.settings-cat[aria-selected='true'] {
  border-color: var(--line);
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow);
}
.settings-cat span {
  width: 22px;
  text-align: center;
}
.settings-pane {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.settings-pane.panel {
  gap: 0;
}
.settings-pane > .panel h3:first-child {
  margin-top: 0;
}
.settings-form {
  max-width: 420px;
}
.volume-row {
  justify-content: flex-start;
  gap: 14px;
}
.volume-row label {
  font-weight: 600;
}
.volume-row input[type='range'] {
  flex: 1;
  max-width: 320px;
}
.volume-row output {
  min-width: 48px;
  font-variant-numeric: tabular-nums;
}
.settings-form .btn {
  margin-top: 2px;
}

@media (max-width: 760px) {
  .settings-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  /* Téléphone : les 9 catégories en grille régulière de 3 × 3, l'icône au-dessus du nom. */
  .settings-nav {
    position: static;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
  .settings-cat {
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    padding: 8px 4px;
    font-size: 13px;
    line-height: 1.2;
    text-align: center;
  }
  /* Choix des thèmes : 3 par ligne, aperçus à la largeur de leur carte. */
  .theme-picker {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
  .theme-option {
    padding: 6px;
  }
  .tp-chess {
    max-width: none;
  }
  .theme-name {
    font-size: 13px;
  }
}

/* ---------- Aide : classement des mains ---------- */

.help {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.help summary {
  padding: 12px 16px;
  font-weight: 600;
  cursor: pointer;
}
.help-body {
  padding: 0 16px 14px;
}
.hand-ranks {
  margin: 0;
  padding: 0;
  list-style: none;
}
.hand-ranks li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
}
.hand-rank-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 160px;
  line-height: 1.3;
}
.hand-rank-text span {
  color: var(--muted);
  font-size: 13px;
}
.hand-rank-cards {
  display: flex;
  gap: 3px;
}
.hand-rank-cards .pcard {
  --w: 30px;
}
.hand-rank-cards .pcard.is-dim {
  filter: opacity(0.35);
}

/* ---------- Partie rapide ---------- */

.quick-play {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-color: var(--accent);
  background: var(--accent-soft);
}

.quick-play p {
  margin: 0;
}
.game-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

/* ---------- Encadré à onglets : chat, suivi, historique, tournoi (poker) ; chat, coups, parties (échecs) ---------- */

.side-box {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.side-tabs {
  gap: 0;
  margin-bottom: 10px;
}
.side-tabs .tab {
  flex: 1;
  padding: 8px 6px;
  white-space: nowrap;
}

.tab-badge {
  display: inline-block;
  min-width: 18px;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}

.side-pane {
  min-width: 0;
}
.side-pane.panel {
  max-height: 560px;
  padding: 14px;
  overflow-y: auto;
}
.side-pane h3 {
  margin: 14px 0 6px;
  font-size: 15px;
}
.side-pane h3:first-child {
  margin-top: 0;
}
.chat--bare .chat-log {
  height: 300px;
}
.side-pane .tour-stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.side-pane .tour-stat:last-child {
  grid-column: 1 / -1;
}

.suivi-me {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.suivi-me .tour-stat {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.stats-table th {
  padding: 4px 6px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-weight: 600;
  text-align: left;
}
.stats-table td {
  padding: 5px 6px;
  border-bottom: 1px solid var(--line);
}
.stats-table th:not(:first-child),
.stats-table td:not(:first-child) {
  text-align: right;
}
.stats-table tr.is-you td {
  color: var(--accent);
  font-weight: 600;
}
.stats-table tr.is-current td {
  background: var(--accent-soft);
  font-weight: 700;
}
.stats-table tr.is-past td {
  color: var(--muted);
}
.plus {
  color: var(--ok);
}
.minus {
  color: var(--danger);
}

.log-list {
  max-height: 180px;
  margin: 0;
  padding-left: 20px;
  overflow: auto;
  color: var(--muted);
  font-size: 13px;
}
.log-list .kind-result {
  color: var(--text);
  font-weight: 600;
}

.hand-history {
  margin: 0;
  padding: 0;
  list-style: none;
}
.hand-history > li {
  border-top: 1px solid var(--line);
}
.hh summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  padding: 8px 0;
  font-size: 13px;
  cursor: pointer;
}
.hh-num {
  color: var(--muted);
  font-weight: 600;
}
.hh-what {
  flex: 1;
  min-width: 0;
}
.hh-net {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.hh-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 0 10px;
}
.hh-board {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.hh-players {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.hh-players li {
  display: grid;
  grid-template-columns: minmax(70px, auto) auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.hh-players li.is-you .hh-name {
  color: var(--accent);
  font-weight: 600;
}
.hh-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hh-hidden {
  font-size: 12px;
}
.mini-cards {
  display: inline-flex;
  gap: 2px;
}
.mini-cards .pcard {
  --w: 24px;
}
.rank-stack {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.ranking li.is-you {
  color: var(--accent);
  font-weight: 600;
}
#tour-back {
  align-self: flex-start;
}

/* Échecs : coups en direct et parties passées. */
.move-totals {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.move-totals .tour-stat {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.move-times td,
.move-times th {
  text-align: left !important;
}
.move-times .mt-num {
  width: 36px;
  color: var(--muted);
}
.mt-san {
  margin-right: 6px;
}
.mt-time {
  color: var(--muted);
  font-size: 12px;
}
.move-times td.is-last .mt-san {
  color: var(--accent);
}
.mt-live {
  color: var(--accent);
  font-weight: 600;
  animation: blink 1.4s ease-in-out infinite;
}
.game-history {
  margin: 0;
  padding: 0;
  list-style: none;
}
.gh-item {
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.gh-item:first-child {
  border-top: 0;
}
.gh-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  font-size: 14px;
}
.gh-detail {
  margin: 4px 0 0;
  font-size: 12px;
}
.chess-box .side-tabs .tab {
  font-size: 14px;
}
/* Modes de jeu (en ligne, bot, tournois) : trois colonnes égales, jamais un onglet seul sur une seconde ligne. */
.chess-modes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.chess-modes .tab {
  padding: 9px 6px;
  text-align: center;
  line-height: 1.25;
}

/* ---------- Piles de jetons sur la table ---------- */

.pseat-plate {
  position: relative;
}

/* À gauche de la plaque (vers le centre pour les places de droite et du bas), à droite pour les places de gauche. */
.pseat-chips {
  position: absolute;
  right: calc(100% + 6px);
  bottom: 2px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  pointer-events: none;
}

.pseat[data-side='left'] .pseat-chips,
.pseat[data-side='top'][data-half='left'] .pseat-chips {
  right: auto;
  left: calc(100% + 6px);
}
/* Téléphone : piles plus étroites (2 colonnes au plus), elles ne mordent plus sur les cartes voisines. */
@media (max-width: 520px) {
  .pseat-chips .stack-col:nth-child(n + 3) {
    display: none;
  }
  .pseat-chips {
    gap: 1px;
  }
  .pseat[data-side='left'] .pseat-chips,
  .pseat[data-side='top'][data-half='left'] .pseat-chips {
    left: calc(100% + 3px);
  }
  .pseat-chips {
    right: calc(100% + 3px);
  }
}
.pseat-chips:empty {
  display: none;
}
.stack-col {
  position: relative;
  width: 16px;
  height: calc(10px + 11 * 3px);
}

.stack-chip {
  position: absolute;
  left: 0;
  bottom: calc(var(--k) * 3px);
  width: 16px;
  height: 6px;
  border: 1px solid rgba(0, 0, 0, 0.45);
  border-radius: 50%;
  background: #c8352e;
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.55);
}

.stack-chip.chip--w {
  background: #ece9e1;
  box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, 0.18);
}
.stack-chip.chip--r {
  background: #c8352e;
}
.stack-chip.chip--g {
  background: #2f8a4e;
}
.stack-chip.chip--k {
  background: #1f1f22;
  box-shadow: inset 0 0 0 1.5px var(--gold);
}

/* ---------- Emotes ---------- */

.emote-bar {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
.emote-bar-label {
  margin-right: 2px;
  color: var(--muted);
  font-size: 13px;
}

.emote-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition:
    transform 0.1s,
    border-color 0.15s;
}

.emote-btn:hover:not(:disabled) {
  border-color: var(--accent);
  transform: scale(1.1);
}
.emote-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.emote-wait {
  min-width: 28px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.emote-bar.is-disabled .emote-wait {
  display: none;
}

.emote-bubble {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 4px);
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  font-size: 28px;
  line-height: 1;
  translate: -50% 0;
  animation: emote-pop 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.4);
  transition:
    opacity 0.4s,
    translate 0.4s;
  pointer-events: none;
}

.emote-bubble.is-leaving {
  opacity: 0;
  translate: -50% -12px;
}
@keyframes emote-pop {
  from {
    transform: scale(0.3);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
.player-strip {
  position: relative;
}
.player-strip .emote-bubble {
  left: auto;
  right: 12px;
  bottom: calc(100% - 10px);
  translate: 0 0;
}
.player-strip .emote-bubble.is-leaving {
  translate: 0 -12px;
}

/* ---------- Lobby d'un tournoi (salon) et de la table ---------- */

.tour-lobby {
  margin-top: 10px;
  border-top: 1px dashed var(--line);
}
.tour-lobby summary {
  padding: 8px 0 0;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.tour-lobby-body {
  padding-top: 10px;
}
.tour-lobby-body h3 {
  margin: 14px 0 6px;
  font-size: 14px;
}
.tour-lobby-body .tour-stats {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.tour-lobby-body .blind-table {
  max-width: 420px;
}
.tour-players {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.tour-players li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
}
.tour-players li.is-you {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.tour-players li.hint {
  padding: 0;
  border: 0;
}
.tour-players .face--small,
.ranking .face--small {
  width: 22px;
  height: 22px;
  font-size: 11px;
}
.ranking li {
  align-items: center;
}

/* ---------- Boutique de jetons (maquette) ---------- */

.shop {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.shop-warning {
  margin: 0;
}

.pack-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pack {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
}
.pack--best {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.pack-flag {
  position: absolute;
  top: -10px;
  padding: 1px 10px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 700;
}
.pack-chips {
  font-size: 28px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.pack-bonus {
  color: var(--ok);
  font-size: 13px;
  font-weight: 600;
}
.pack-price {
  margin: 8px 0;
  font-size: 20px;
}

/* ---------- Échecs : après la partie (revanche, bilan) et bilan de partie ---------- */

.after-game {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: -4px 0 14px;
}
.after-game .takeback-note {
  width: 100%;
}
.after-game-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.gh-review {
  margin-left: auto;
}

.bilan-head {
  margin-bottom: 8px;
  font-size: 15px;
}
.bilan-progress {
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--surface-2);
}
.bilan-progress span {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 0.2s;
}
.bilan-acc {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.bilan-player {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
}
.bilan-player--b {
  background: #2a2a2e;
  color: #fff;
}
.bilan-player--b .hint {
  color: #c9c9cf;
}
.bilan-pct {
  font-size: 24px;
  font-variant-numeric: tabular-nums;
}
.bilan-graph {
  display: block;
  width: 100%;
  height: 70px;
  margin-bottom: 10px;
  border-radius: 6px;
  background: #2a2a2e;
}
.bilan-graph-white {
  fill: #f4f4f0;
}
.bilan-graph-mid {
  stroke: var(--gold);
  stroke-width: 0.8;
  stroke-dasharray: 3 3;
}
.bilan-graph-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
}
.bilan-counts {
  margin-bottom: 4px;
}
.bilan-moves {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
}

.bilan-move {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 26px auto 52px;
  align-items: center;
  gap: 6px;
  padding: 3px 4px;
  border-radius: 4px;
}

.bilan-move.is-clickable {
  cursor: pointer;
}
.bilan-move.is-clickable:hover {
  background: var(--surface-2);
}
.bilan-num {
  color: var(--muted);
}
.bilan-cat {
  font-size: 12px;
}
.bilan-eval {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.bilan-best {
  grid-column: 2 / -1;
  font-size: 12px;
}
/* Explication du coach sous un coup */
.bilan-why {
  grid-column: 2 / -1;
  margin: 2px 0 4px;
  padding: 6px 9px;
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  background: var(--accent-soft);
  font-size: 12.5px;
  line-height: 1.45;
}
.bilan-why--erreur,
.bilan-why--gaffe {
  border-left-color: var(--danger);
  background: var(--danger-soft);
}
.bilan-why--imprecision {
  border-left-color: #e8a10a;
  background: rgba(232, 161, 10, 0.1);
}

/* Panneau du coach (bilan) */
.coach-toggle {
  justify-self: start;
  margin: 4px 0;
}
.coach-panel {
  display: grid;
  gap: 8px;
  margin: 6px 0 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--accent-soft), var(--surface) 70%);
  animation: ck-rise-in var(--dur-base) var(--ease-out);
}
.coach-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}
.coach-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 17px;
}
.coach-side {
  margin-left: auto;
}
.coach-side .choice {
  font-size: 12px;
  padding: 4px 10px;
}
.coach-verdict {
  margin: 0;
  font-weight: 700;
}
.coach-phases {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.coach-phase {
  display: grid;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.coach-phase strong {
  font-variant-numeric: tabular-nums;
}
.coach-phase.is-good strong {
  color: var(--ok);
}
.coach-phase.is-weak strong {
  color: var(--danger);
}
.coach-phase.is-empty {
  opacity: 0.6;
}
.coach-panel h4 {
  margin: 4px 0 0;
  font-size: 13px;
}
.coach-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 4px;
  font-size: 13px;
  line-height: 1.45;
}
.coach-list--good li::marker {
  color: var(--ok);
}
.coach-moments {
  list-style: none;
  padding-left: 0;
}
.coach-moments li.is-clickable {
  cursor: pointer;
  border-radius: 6px;
  padding: 2px 4px;
}
.coach-moments li.is-clickable:hover {
  background: var(--surface-2);
}

/* Coach en direct (onglet « Coach » de la page Échecs) : fil des avis et des réponses, questions */
.chess-box > .coach-live:not([hidden]) {
  gap: 8px;
  padding: 12px;
  overflow: hidden;
}
.coach-live-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}
.coach-live-head .coach-avatar {
  width: 26px;
  height: 26px;
  font-size: 15px;
}
.coach-state {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11.5px;
}
.coach-state[data-state='on'] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.coach-state[data-state='pause'] {
  background: rgba(232, 161, 10, 0.14);
  color: #a86e00;
}
:root[data-ui='dark'] .coach-state[data-state='pause'] {
  color: #f0b84a;
}
.coach-settings-link {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}
.coach-settings-link:hover {
  color: var(--accent);
}
.coach-feed {
  flex: 1;
  min-height: 120px;
  margin: 0;
  padding: 2px 2px 2px 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}
.coach-msg {
  max-width: 92%;
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  animation: ck-rise-in var(--dur-base) var(--ease-out);
}
.coach-msg p {
  margin: 2px 0 0;
}
.coach-msg--coach {
  align-self: flex-start;
  border: 1px solid var(--line);
  border-top-left-radius: 3px;
  background: var(--surface);
}
.coach-msg--you {
  align-self: flex-end;
  border-top-right-radius: 3px;
  background: var(--accent);
  color: var(--accent-ink);
}
.coach-msg--move {
  align-self: stretch;
  max-width: none;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
}
.coach-msg--move[data-cat='imprecision'] {
  border-left-color: #e8a10a;
  background: rgba(232, 161, 10, 0.1);
}
.coach-msg--move[data-cat='erreur'],
.coach-msg--move[data-cat='gaffe'] {
  border-left-color: var(--danger);
  background: var(--danger-soft);
}
.coach-msg.is-typing {
  color: var(--muted);
  letter-spacing: 2px;
}
.coach-msg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.coach-move {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.coach-badge {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.coach-badge--meilleur,
.coach-badge--excellent {
  color: var(--ok);
}
.coach-badge--imprecision {
  color: #a86e00;
}
:root[data-ui='dark'] .coach-badge--imprecision {
  color: #f0b84a;
}
.coach-badge--erreur,
.coach-badge--gaffe {
  color: var(--danger);
}
.coach-quick .chat-chip {
  font-size: 11.5px;
}

/* Conseil du coach pendant la partie */
.coach-hint {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}
.coach-hint-note {
  margin: 0;
  padding: 8px 10px;
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  background: var(--accent-soft);
  font-size: 13.5px;
  line-height: 1.45;
  animation: ck-rise-in var(--dur-base) var(--ease-out);
}
.sq.hint-from {
  box-shadow: inset 0 0 0 4px rgba(31, 111, 74, 0.85);
}
.sq.hint-threat {
  box-shadow: inset 0 0 0 4px rgba(229, 72, 77, 0.85);
}
.sq.hint-from::after,
.sq.hint-threat::after {
  content: '';
  position: absolute;
  inset: 0;
  animation: ck-hint-pulse 1.2s var(--ease-in-out) 2;
  pointer-events: none;
}
.sq.hint-from::after {
  background: rgba(31, 111, 74, 0.18);
}
.sq.hint-threat::after {
  background: rgba(229, 72, 77, 0.16);
}
@keyframes ck-hint-pulse {
  50% {
    opacity: 0.2;
  }
}

.cat-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 18px;
  padding: 0 3px;
  border-radius: 9px;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.cat-meilleur {
  background: #2f8a4e;
}
.cat-excellent {
  background: #4aa36b;
}
.cat-bon {
  background: #8aa79a;
}
.cat-imprecision {
  background: #e3a008;
}
.cat-erreur {
  background: #e8710a;
}
.cat-gaffe {
  background: #c8352e;
}
.cat-row-gaffe {
  background: rgba(200, 53, 46, 0.07);
}
.cat-row-erreur {
  background: rgba(232, 113, 10, 0.07);
}

/* ---------- Petits écrans ---------- */

/* Écran moyen : l'échiquier et les réglages côte à côte, le chat et les onglets dessous, sur toute la largeur. */
@media (max-width: 1180px) {
  .chess-layout {
    grid-template-columns: minmax(0, 1fr) 340px;
  }
  .chess-layout > .chess-box {
    position: static;
    order: 3;
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  .hero,
  .chess-layout,
  .table-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .table-layout > .side-box {
    position: static;
    order: 2;
  }
  .hero {
    gap: 24px;
    padding-top: 0;
  }
  .stage {
    aspect-ratio: 4 / 3;
    min-height: 320px;
  }
  .felt {
    inset: 10% 4%;
    border-width: 8px;
  }
}

@media (max-width: 640px) {
  /* En-tête compact (2 lignes au lieu de 4) : marque, soldes et pastille ; navigation dessous. */
  .topbar {
    gap: 8px;
    padding: 10px 0;
    min-height: 0;
  }
  .brand {
    font-size: 17px;
  }
  .wallets {
    order: 2;
    gap: 8px;
    margin-left: auto;
  }
  .wallet-amount {
    font-size: 13px;
  }
  /* Libellés remplacés par un symbole pour tenir sur une ligne (le détail reste lu par les lecteurs d'écran). */
  .wallet-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  #wallet-poker::before {
    content: '♠ ';
    color: var(--muted);
  }
  #wallet-chess::before {
    content: '♞ ';
    color: var(--muted);
  }
  .user {
    order: 3;
    gap: 6px;
  }
  .user-name {
    display: none;
  }
  .user .btn {
    padding: 4px 8px;
    font-size: 12px;
  }
  .nav {
    order: 4;
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .nav a {
    padding: 5px 10px;
    font-size: 14px;
    white-space: nowrap;
  }
  main {
    padding-top: 14px;
  }
  .game-cards,
  .lobby-split {
    grid-template-columns: minmax(0, 1fr);
  }
  .page-title {
    font-size: 24px;
  }
  .panel {
    padding: 16px;
  }
  .stage {
    --pcard-w: clamp(30px, 9vw, 44px);
    aspect-ratio: 4 / 5;
    min-height: 300px;
  }
  .felt {
    inset: 8% 8%;
    border-radius: 160px;
  }
  .pseat {
    max-width: 116px;
  }
  .pseat-plate {
    gap: 6px;
    padding-right: 10px;
  }
  /* La pastille reste (photo ou initiale), en plus petit. */
  .pseat-badge {
    width: 22px;
    height: 22px;
    font-size: 11px;
  }
  .pseat-ring {
    width: 28px;
    height: 28px;
  }
  /* Vos cartes, plus grandes sur téléphone. */
  .pseat.is-you .pseat-cards {
    min-height: calc(var(--pcard-w) * 1.25 * 1.4);
  }
  .pseat.is-you .pseat-cards .pcard {
    --w: calc(var(--pcard-w) * 1.25);
  }
  .action-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .table-prefs {
    margin-left: 0;
  }
  /* À votre tour : les boutons de mise se fixent en bas de l'écran, plus besoin de faire défiler. */
  .betting.is-active {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: var(--surface);
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.12);
    animation: ck-sheet-in var(--dur-base) var(--ease-out);
  }
  .table-page:has(.betting.is-active) {
    padding-bottom: 170px;
  }
}
@keyframes ck-sheet-in {
  from {
    transform: translateY(100%);
  }
}

/* ---------- Cadre immersif de la table de poker ----------
   La partie est posée dans un cadre : une salle éclairée par une lampe au-dessus de la table
   (halo chaud, coins assombris), une table à rebord de cuir matelassé et cerclé de bois, une ligne
   de mise, le logo gravé dans le feutre et le plateau du croupier. Les couleurs suivent les thèmes
   (--felt, --felt-dark, --rail, --backdrop-*). */
.stage {
  isolation: isolate;
  border-radius: 22px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    0 18px 48px rgba(20, 16, 10, 0.22);
}
:root[data-backdrop='clair'] .stage {
  background: radial-gradient(ellipse at 50% 28%, #fffdf7 0%, #efe8d9 62%, #e2d8c4 100%);
}
/* Lumière de la lampe et coins dans l'ombre */
.stage::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 60% 52% at 50% 44%, rgba(255, 236, 190, 0.22), transparent 70%),
    radial-gradient(ellipse at 50% 50%, transparent 58%, rgba(0, 0, 0, 0.32) 100%);
}
/* Cadre intérieur fin, comme une vitrine */
.stage::after {
  content: '';
  position: absolute;
  inset: 8px;
  z-index: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  pointer-events: none;
}
.stage > .felt {
  z-index: 1;
}

/* La table : feutre + rebord de cuir (dégradé de la couleur du thème) + cerclage de bois */
.felt {
  border: 16px solid transparent;
  background:
    radial-gradient(
        ellipse at 50% 40%,
        color-mix(in srgb, var(--felt) 88%, white) 0%,
        var(--felt) 45%,
        var(--felt-dark) 100%
      )
      padding-box,
    linear-gradient(
        180deg,
        color-mix(in srgb, var(--rail) 75%, white) 0%,
        var(--rail) 38%,
        color-mix(in srgb, var(--rail) 70%, black) 100%
      )
      border-box;
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--rail) 45%, black),
    0 0 0 5px rgba(255, 255, 255, 0.07),
    0 22px 40px rgba(0, 0, 0, 0.35),
    inset 0 0 50px rgba(0, 0, 0, 0.35),
    inset 0 2px 0 rgba(255, 255, 255, 0.12);
}
/* Texture très fine du feutre */
.felt::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: repeating-radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 3px);
  pointer-events: none;
}
/* Coutures du rebord de cuir */
.felt::after {
  content: '';
  position: absolute;
  inset: -9px;
  border: 1.5px dashed rgba(255, 255, 255, 0.22);
  border-radius: inherit;
  pointer-events: none;
}
.felt-decor {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}
/* Ligne de mise : un anneau discret où l'on pose les jetons */
.felt-line {
  position: absolute;
  inset: 11% 9%;
  border: 2px solid rgba(255, 255, 255, 0.09);
  border-radius: 999px;
}
/* Logo gravé dans le feutre, sous le tableau */
.felt-logo {
  position: absolute;
  left: 50%;
  top: 31%;
  translate: -50% -50%;
  color: rgba(255, 255, 255, 0.09);
  font-size: clamp(18px, 3.4vw, 40px);
  font-weight: 900;
  letter-spacing: 0.04em;
  text-shadow:
    0 1px 0 rgba(0, 0, 0, 0.25),
    0 -1px 0 rgba(255, 255, 255, 0.06);
  white-space: nowrap;
  user-select: none;
}
.felt-logo b {
  font-weight: 900;
  color: rgba(255, 255, 255, 0.13);
}
/* Plateau du croupier, en haut de la table : rangées de jetons */
.felt-tray {
  position: absolute;
  left: 50%;
  top: -2px;
  width: clamp(70px, 14%, 150px);
  height: clamp(12px, 2.4vw, 20px);
  translate: -50% 0;
  border-radius: 0 0 10px 10px;
  background:
    linear-gradient(90deg, #c8352e 0 20%, #e9e7e1 20% 40%, #2f8a4e 40% 60%, #222 60% 80%, #c8352e 80% 100%) center 55% /
      86% 45% no-repeat,
    linear-gradient(180deg, color-mix(in srgb, var(--rail) 60%, black), color-mix(in srgb, var(--rail) 85%, black));
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.5),
    0 1px 0 rgba(255, 255, 255, 0.08);
}
/* Les cartes du tableau reposent dans des emplacements gravés */
.pslot {
  background: rgba(0, 0, 0, 0.08);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.25);
}
.pslot:has(.pcard) {
  background: none;
  box-shadow: none;
}

@media (max-width: 900px) {
  .felt {
    border-width: 10px;
  }
  .felt::after {
    inset: -6px;
  }
  .stage {
    border-radius: 16px;
  }
}

/* ---------- Échecs : titre du panneau et carte de fin de partie ---------- */
.chess-side-title {
  margin: 0 0 4px;
  font-size: 20px;
}
.board-wrap {
  position: relative;
}
.game-end {
  position: absolute;
  left: 50%;
  top: 46%;
  z-index: 20;
  display: grid;
  justify-items: center;
  gap: 8px;
  width: min(360px, 88%);
  padding: 18px 18px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: var(--shadow-3);
  text-align: center;
  translate: -50% -50%;
  animation: ck-end-in 260ms var(--ease-pop);
}
@keyframes ck-end-in {
  from {
    opacity: 0;
    scale: 0.94;
  }
}
.game-end-title {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -0.01em;
}
.game-end[data-result='won'] .game-end-title {
  color: var(--ok);
}
.game-end[data-result='lost'] .game-end-title {
  color: var(--danger);
}
.game-end-detail {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}
.game-end-actions {
  display: grid;
  gap: 8px;
  width: 100%;
}
.game-end-actions .btn {
  width: 100%;
}
.game-end-online .after-game-actions {
  display: grid;
  gap: 8px;
}
.game-end-online .takeback-note:empty {
  display: none;
}
.game-end-close {
  font-size: 13px;
  color: var(--muted);
}

/* ---------- Paramètres › Historique ---------- */
.hist-tabs {
  margin-bottom: 12px;
}
.hist-totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.hist-total {
  display: grid;
  gap: 1px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.hist-total strong {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}
.hist-total .hint {
  font-size: 12px;
}
.hist-total.is-good strong,
.hist-money.is-good {
  color: var(--ok);
}
.hist-total.is-bad strong,
.hist-money.is-bad {
  color: var(--danger);
}
.hist-filter {
  margin-bottom: 10px;
}
.hist-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}
.hist-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color var(--dur-fast) var(--ease-out);
}
.hist-item:hover {
  border-color: #d3d0c6;
}
.hist-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  min-width: 0;
}
.hist-tag {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}
.hist-side {
  display: flex;
  align-items: center;
  gap: 10px;
}
.hist-money {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.hist-detail {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 13px;
}

/* ---------- Commandes de mise : gros boutons, mises préréglées ---------- */
.presets {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}
.preset {
  display: grid;
  justify-items: center;
  gap: 1px;
  padding: 7px 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-weight: 700;
  font-size: 14px;
  line-height: 1.15;
  cursor: pointer;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}
.preset small {
  min-height: 1.1em;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.preset:hover:not(:disabled) {
  border-color: var(--accent);
}
.preset:active:not(:disabled) {
  transform: scale(0.97);
}
.preset[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.preset[aria-pressed='true'] small {
  color: var(--accent);
}
.preset:disabled {
  opacity: 0.4;
  cursor: default;
}
.raise-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.raise-row input[type='range'] {
  flex: 1;
  min-width: 120px;
  height: 28px;
}
.raise-step {
  width: 38px;
  height: 38px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}
.raise-input {
  width: 120px;
  padding: 8px 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
/* Les quatre actions : grandes, lisibles, l'action en gros et le montant en dessous */
.action-row {
  gap: 10px;
}
.action-row .action {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 2px;
  min-height: 62px;
  padding: 10px 8px;
  border-width: 2px;
  border-radius: 14px;
  font-size: 17px;
  line-height: 1.1;
}
.action-name {
  font-weight: 800;
}
.action-amount {
  font-size: 13px;
  font-weight: 700;
  opacity: 0.85;
  font-variant-numeric: tabular-nums;
}
.action--fold {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--line));
  color: var(--danger);
}
.action--fold:hover:not(:disabled) {
  background: var(--danger-soft);
}
.action--raise {
  border-color: var(--accent);
  color: var(--accent);
}
.action--raise:hover:not(:disabled) {
  background: var(--accent-soft);
}
.action--allin {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}
.action--allin:hover:not(:disabled) {
  background: color-mix(in srgb, var(--text) 85%, var(--danger));
}
@media (max-width: 640px) {
  .presets {
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .preset {
    flex: 0 0 auto;
    min-width: 62px;
  }
  .raise-input {
    width: 92px;
  }
  .action-row .action {
    min-height: 54px;
    font-size: 16px;
  }
  .table-page:has(.betting.is-active) {
    padding-bottom: 240px;
  }
}

/* Mode immersion (plein écran) : la table occupe tout l'écran, le reste de la page s'efface. */
.table-page:fullscreen {
  padding: 12px 16px;
  overflow-y: auto;
  background: #14110c;
  color-scheme: dark;
}
.table-page:fullscreen .table-layout {
  grid-template-columns: 300px minmax(0, 1fr);
}
.table-page:fullscreen .stage {
  max-height: calc(100dvh - 210px);
}
/* Immersion sur un seul écran : en-tête, puis table et commandes dans la hauteur restante ; l'encadré
   (chat…) a la même hauteur et défile à l'intérieur ; l'aide des mains et l'apparence sont masquées. */
.table-page.is-immersive {
  height: 100dvh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  padding: 8px 14px;
}
.table-page.is-immersive .look-panel,
.table-page.is-immersive [data-help],
.table-page.is-immersive #tour-back {
  display: none !important;
}
.table-page.is-immersive .table-layout {
  height: 100%;
  min-height: 0;
  align-items: stretch;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 12px;
}
.table-page.is-immersive .table-layout > .side-box {
  position: static;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.table-page.is-immersive .side-box .side-pane {
  min-height: 0;
  overflow-y: auto;
}
.table-page.is-immersive .table-area {
  min-height: 0;
  height: 100%;
  gap: 6px;
}
.table-page.is-immersive .stage {
  flex: 1 1 0;
  min-height: 0;
  max-height: none;
  aspect-ratio: auto;
  height: auto;
}
.table-page.is-immersive .table-main {
  flex: none;
  gap: 6px;
}
.table-page.is-immersive .status {
  min-height: 0;
  font-size: 14px;
}
.table-page.is-immersive .action-row .action {
  min-height: 44px;
}
.table-page:fullscreen .table-head,
.table-page:fullscreen .table-main {
  color: #ece6d8;
}
.table-page:fullscreen .side-box {
  background: rgba(255, 255, 255, 0.04);
}

/* ---------- Icônes maison (js/ui/icons.js) ---------- */
.icon {
  display: inline-block;
  width: 1.15em;
  height: 1.15em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.2em;
  flex: none;
}
.icon-first path:last-child,
.icon-last path:last-child {
  fill: currentColor;
}
[data-icon] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.game-icon {
  color: var(--accent);
}
.game-icon .icon {
  width: 30px;
  height: 30px;
  stroke-width: 1.4;
}
.review-bar .btn [data-icon] {
  line-height: 0;
}

/* ---------- Finition : interactions, apparitions, chargement ---------- */

/* Survol, appui et focus : même rythme partout. */
.tab,
.choice,
.level-card,
.level-choice,
.settings-cat,
.nav a,
.chat-chip,
.theme-option,
.moves .move,
.link-btn,
.game-card {
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}
.choice:active:not(:disabled),
.level-card:active,
.level-choice:active,
.chat-chip:active:not(:disabled),
.theme-option:active,
.settings-cat:active {
  transform: scale(0.98);
  transition-duration: var(--dur-press);
}
.game-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
}

/* Les blocs qui apparaissent glissent légèrement au lieu de surgir (l'animation repart à chaque affichage). */
.notice:not([hidden]),
.side-pane:not([hidden]),
.lobby-pane:not([hidden]),
.settings-pane:not([hidden]),
#look-panel:not([hidden]),
.show-box:not([hidden]),
.busted-box:not([hidden]),
#promo:not([hidden]),
.after-game:not([hidden]),
.tour-lobby[open] > :not(summary),
.showdown-plate.is-shown,
.hand-hint.is-shown {
  animation: ck-rise-in var(--dur-base) var(--ease-out);
}
.chat-msg.is-new {
  animation: ck-rise-in 160ms var(--ease-out);
}
.chat-unread:not([hidden]),
.tab-badge:not([hidden]) {
  animation: ck-pop-in var(--dur-base) var(--ease-pop);
}

/* En-tête : hauteur réservée avant l'arrivée du profil (plus de saut de toute la page). */
.topbar {
  min-height: 64px;
}
@media (max-width: 640px) {
  .topbar {
    min-height: 92px;
  }
}
.topbar-skeleton {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
}
.topbar-skeleton .skeleton {
  height: 14px;
}

/* Chargement : barres grises avec un reflet qui passe (pas de reflet si les animations sont réduites). */
.skeleton {
  display: block;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2) 0%, #f8f7f3 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: ck-shimmer 1.2s linear infinite;
}
.skeleton-line {
  height: 14px;
  margin: 10px 0;
}
.skeleton-line:nth-child(2n) {
  width: 82%;
}
.skeleton-line:nth-child(3n) {
  width: 64%;
}
.hub-skeleton {
  display: grid;
  gap: 16px;
}
.skeleton-title {
  width: 260px;
  max-width: 70%;
  height: 30px;
}
#main:has(#guest:not([hidden])) .hub-skeleton,
#main:has(#hub:not([hidden])) .hub-skeleton {
  display: none;
}
#hub:not([hidden]),
#guest:not([hidden]) {
  animation: ck-fade-in var(--dur-base) var(--ease-out);
}
.hub-skeleton .panel {
  min-height: 150px;
}

/* Soldes et montants : une teinte brève quand ils changent (js/ui/motion.js). */
.is-up {
  animation: ck-tint-up 900ms var(--ease-out);
}
.is-down {
  animation: ck-tint-down 900ms var(--ease-out);
}
@keyframes ck-tint-up {
  0%,
  30% {
    color: var(--ok);
  }
}
@keyframes ck-tint-down {
  0%,
  30% {
    color: var(--danger);
  }
}
.ppot.is-bump {
  animation: ck-bump 220ms var(--ease-pop);
}
@keyframes ck-bump {
  50% {
    scale: 1.06;
  }
}

/* Notifications brèves (ck.ui.motion.toast) */
.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 60;
  display: grid;
  gap: 8px;
  justify-items: center;
  translate: -50% 0;
  pointer-events: none;
}
.toast {
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-3);
  animation: ck-rise-in var(--dur-base) var(--ease-out);
}
.toast--ok {
  background: var(--accent);
  color: var(--accent-ink);
}
.toast--error {
  background: var(--danger);
  color: #fff;
}
.toast.is-leaving {
  opacity: 0;
  transform: translateY(6px);
  transition:
    opacity 160ms var(--ease-in),
    transform 160ms var(--ease-in);
}
@media (max-width: 640px) {
  .table-page:has(.betting.is-active) ~ .toasts,
  body:has(.betting.is-active) .toasts {
    bottom: 190px;
  }
}

/* Fond vert de la table : anneau de focus clair, visible. */
.stage :focus-visible {
  outline-color: #fff;
}

@media (prefers-reduced-motion: reduce) {
  .blink {
    animation: none;
  }
  :root[data-motion='system'] .mt-live,
  :root[data-motion='system'] .skeleton {
    animation: none;
  }
}

/* ---------- Page Classement (classement.html, js/pages/classement.js) ---------- */
:root {
  --silver: #b8bec8;
  --bronze: #c98a55;
  --gold-ink: #8a6a12;
}
:root[data-ui='dark'] {
  --gold-ink: #f2c94c;
}

.rank-page {
  display: grid;
  gap: 18px;
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
}
.rank-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px 20px;
}
.rank-hero .page-title {
  font-size: 34px;
}
.rank-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.rank-updated {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* Point « en direct » qui pulse doucement. */
.live-dot {
  position: relative;
  display: inline-block;
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
}
.live-dot::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--ok);
  animation: ck-live 1.8s var(--ease-out) infinite;
}
@keyframes ck-live {
  from {
    opacity: 0.6;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(2.6);
  }
}

/* Onglets : deux familles (Poker, Échecs), votre place dans chaque classement. */
.rank-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
}
.rank-tab-group {
  display: grid;
  gap: 6px;
}
.rank-tab-group-name {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.rank-tab-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.rank-tab {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 8px;
  min-width: 132px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    translate var(--dur-fast) var(--ease-out);
}
.rank-tab .icon {
  grid-row: span 2;
  width: 20px;
  height: 20px;
  color: var(--muted);
}
.rank-tab-name {
  font-weight: 700;
  font-size: 15px;
}
.rank-tab-me {
  color: var(--muted);
  font-size: 12px;
}
.rank-tab:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
  box-shadow: var(--shadow);
  translate: 0 -1px;
}
.rank-tab:active {
  translate: 0 0;
}
.rank-tab[aria-selected='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.rank-tab[aria-selected='true'] .icon,
.rank-tab[aria-selected='true'] .rank-tab-name {
  color: var(--accent);
}

.rank-board {
  display: grid;
  gap: 18px;
}

/* Votre place : rang, photo, points, écart au joueur suivant. */
.rank-me {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 14px 24px;
  padding: 18px 22px;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  background: linear-gradient(120deg, var(--surface) 0%, var(--surface) 55%, var(--accent-soft) 100%);
  box-shadow: var(--shadow-2);
}
.rank-me.is-first {
  background: linear-gradient(
    120deg,
    var(--surface) 0%,
    var(--surface) 50%,
    color-mix(in srgb, var(--gold) 28%, var(--surface)) 100%
  );
  border-color: color-mix(in srgb, var(--gold) 55%, var(--line));
}
.rank-me-pos {
  display: grid;
  justify-items: center;
  min-width: 76px;
}
.rank-me-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.rank-me-rank {
  font-size: 38px;
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.rank-me.is-first .rank-me-rank {
  color: var(--gold-ink);
}
.rank-me-who {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.rank-me-info {
  display: grid;
  min-width: 0;
}
.rank-me-name {
  font-size: 17px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rank-me-points {
  color: var(--muted);
  font-size: 14px;
}
.rank-me-value {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.rank-me-goal {
  display: grid;
  gap: 8px;
  justify-items: start;
}
.rank-me-text {
  font-size: 15px;
}
.rank-me-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--line) inset;
}
.rank-me-fill {
  display: block;
  height: 100%;
  width: var(--fill, 0%);
  border-radius: inherit;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 70%, var(--surface)), var(--accent));
  transition: width 900ms var(--ease-out);
}
.rank-me.is-first .rank-me-fill {
  background: linear-gradient(90deg, color-mix(in srgb, var(--gold) 70%, var(--surface)), var(--gold));
}

.face--medium {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 22px;
  font-weight: 700;
  box-shadow:
    0 0 0 2px var(--surface),
    0 0 0 3px var(--line);
}
.face--podium {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 32px;
  font-weight: 700;
}

/* Podium : 2e, 1er (au milieu, plus haut), 3e. */
.podium {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  gap: 14px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}
.podium[data-count='1'] {
  grid-template-columns: minmax(0, 320px);
  justify-content: center;
}
.podium[data-count='2'] {
  grid-template-columns: repeat(2, minmax(0, 300px));
  justify-content: center;
}
.podium-step {
  --medal: var(--silver);
  position: relative;
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 22px 12px 0;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  overflow: hidden;
  background: linear-gradient(180deg, color-mix(in srgb, var(--medal) 16%, var(--surface)) 0%, var(--surface) 62%);
  box-shadow: var(--shadow-2);
  transition:
    translate var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out);
}
.podium-step:hover {
  translate: 0 -3px;
  box-shadow: var(--shadow-3);
}
.podium-step--1 {
  --medal: var(--gold);
  padding-top: 34px;
  border-color: color-mix(in srgb, var(--gold) 55%, var(--line));
}
.podium-step--3 {
  --medal: var(--bronze);
}
.podium-step.is-you {
  box-shadow:
    0 0 0 2px var(--accent),
    var(--shadow-2);
}
.podium-avatar {
  position: relative;
  margin-bottom: 6px;
}
.podium-avatar .face--podium {
  box-shadow:
    0 0 0 3px var(--surface),
    0 0 0 6px var(--medal);
}
.podium-step--1 .face--podium {
  width: 92px;
  height: 92px;
  font-size: 38px;
}
.podium-medal {
  position: absolute;
  right: -4px;
  bottom: -4px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--medal);
  color: #1c1c1e;
  font-size: 14px;
  font-weight: 800;
  box-shadow:
    0 0 0 3px var(--surface),
    var(--shadow);
}
.podium-crown {
  position: absolute;
  left: 50%;
  top: -24px;
  translate: -50% 0;
  color: var(--gold);
  animation: ck-crown 3.2s var(--ease-in-out) infinite;
}
.podium-crown .icon {
  width: 28px;
  height: 28px;
  fill: color-mix(in srgb, var(--gold) 45%, transparent);
  stroke-width: 1.4;
}
@keyframes ck-crown {
  0%,
  100% {
    translate: -50% 0;
    rotate: -4deg;
  }
  50% {
    translate: -50% -3px;
    rotate: 4deg;
  }
}
.podium-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 17px;
}
.podium-step--1 .podium-name {
  font-size: 19px;
}
.podium-points {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.podium-step--1 .podium-points {
  font-size: 26px;
}
.podium-unit {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.podium-sub {
  color: var(--muted);
  font-size: 13px;
}
.podium-plinth {
  align-self: stretch;
  height: 18px;
  margin: 10px -12px 0;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--medal) 55%, var(--surface)),
    color-mix(in srgb, var(--medal) 30%, var(--surface))
  );
}
.podium-step--1 .podium-plinth {
  height: 40px;
}
.podium-step--2 .podium-plinth {
  height: 26px;
}
.podium-step .rank-you {
  margin-top: 2px;
}

/* Suite du classement. */
.rank-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.rank-row {
  display: grid;
  grid-template-columns: 34px 30px auto minmax(0, 1fr) auto minmax(92px, auto);
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition:
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
}
.rank-row:hover {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
  box-shadow: var(--shadow);
}
.rank-row.is-you {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.rank-row .face--small {
  width: 36px;
  height: 36px;
  font-size: 16px;
}
.rank-pos {
  color: var(--muted);
  font-size: 17px;
  font-weight: 800;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.rank-who {
  display: grid;
  min-width: 0;
}
.rank-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.rank-pseudo {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}
.rank-sub {
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rank-stats {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.rank-score {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 6px;
}
.rank-points {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}
.rank-gap {
  text-align: center;
  color: var(--muted);
  letter-spacing: 0.3em;
}
.rank-you {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.rank-live {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--ok);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.rank-live .live-dot {
  width: 6px;
  height: 6px;
}
.rank-delta {
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  animation: none;
}
.rank-delta.is-up {
  background: color-mix(in srgb, var(--ok) 14%, transparent);
  color: var(--ok);
}
.rank-delta.is-down {
  background: var(--danger-soft);
  color: var(--danger);
}
.rank-move {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 20px;
  font-size: 12px;
  font-weight: 700;
}
.rank-move .icon {
  width: 14px;
  height: 14px;
}
.rank-move.is-up {
  color: var(--ok);
  animation: ck-pop-in var(--dur-base) var(--ease-pop);
}
.rank-move.is-down {
  color: var(--danger);
  animation: ck-pop-in var(--dur-base) var(--ease-pop);
}

/* Apparition en cascade à l'ouverture d'un classement. */
.rank-enter {
  animation: ck-rise-in var(--dur-slow) var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 40ms);
}

.rank-empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 34px 20px;
  border: 1px dashed var(--line);
  border-radius: calc(var(--radius) + 4px);
  background: var(--surface);
  text-align: center;
}
.rank-empty > .icon {
  width: 40px;
  height: 40px;
  color: var(--gold);
}
.rank-empty strong {
  font-size: 18px;
}

.rank-rules {
  display: grid;
  gap: 10px;
}
.rank-rules h2 {
  font-size: 18px;
}
.rank-rules p {
  max-width: 75ch;
  line-height: 1.55;
}
.rank-ladder {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.rank-ladder li {
  display: grid;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.rank-ladder li.is-you {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.rank-ladder .hint {
  font-size: 12px;
}

/* Lien vers la page Classement depuis le classement des échecs. */
.ranking-more {
  display: inline-block;
  margin-top: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}

@media (max-width: 760px) {
  .rank-hero .page-title {
    font-size: 28px;
  }
  /* Téléphone : les 4 onglets en grille 2 × 2 (le pique et le cavalier disent le jeu). */
  .rank-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .rank-tab-group,
  .rank-tab-row {
    display: contents;
  }
  .rank-tab-group-name {
    display: none;
  }
  .rank-tab {
    min-width: 0;
    padding: 8px 10px;
  }
  .rank-tab-name {
    font-size: 14px;
  }
  .rank-me {
    grid-template-columns: auto minmax(0, 1fr);
    padding: 14px 16px;
  }
  .rank-me-goal {
    grid-column: 1 / -1;
  }
  .podium {
    gap: 8px;
  }
  .podium-step {
    padding: 18px 6px 0;
  }
  .podium-step--1 {
    padding-top: 28px;
  }
  .face--podium {
    width: 56px;
    height: 56px;
    font-size: 24px;
  }
  .podium-step--1 .face--podium {
    width: 68px;
    height: 68px;
    font-size: 28px;
  }
  .podium-name {
    font-size: 14px;
  }
  .podium-step--1 .podium-name {
    font-size: 15px;
  }
  .podium-points,
  .podium-step--1 .podium-points {
    font-size: 17px;
  }
  .podium-sub {
    font-size: 11px;
  }
  .podium-plinth {
    margin: 8px -6px 0;
  }
  .rank-row {
    grid-template-columns: 26px 22px auto minmax(0, 1fr) auto;
    gap: 8px;
    padding: 8px 10px;
  }
  .rank-stats {
    display: none;
  }
  .rank-row .face--small {
    width: 30px;
    height: 30px;
  }
}

/* ---------- Amis (amis.html, js/pages/amis.js) et invitations sur toutes les pages ---------- */
.nav a {
  position: relative;
}
.nav-badge {
  position: absolute;
  top: -2px;
  right: -4px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--bg);
  animation: ck-pop-in var(--dur-base) var(--ease-pop);
}
.btn--danger-soft {
  color: var(--danger);
}
.btn--danger-soft:hover:not(:disabled) {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.friends-page {
  display: grid;
  gap: 14px;
  max-width: 1040px;
  width: 100%;
  margin: 0 auto;
}
.friends-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 14px;
  align-items: start;
}
.friends-main,
.friends-side {
  display: grid;
  gap: 14px;
}
.friends-side {
  position: sticky;
  top: 12px;
}
.friends-block {
  display: grid;
  gap: 10px;
  padding: 16px;
}
.friends-block h2 {
  font-size: 16px;
}
.friends-block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.friends-count {
  color: var(--muted);
  font-weight: 600;
}
.friends-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.friend-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition:
    border-color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out);
}
.friend-row:hover {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
}
.friend-row.is-open {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface));
}
.friend-row--compact {
  padding: 6px 8px;
  gap: 8px;
}
.friend-face {
  position: relative;
  display: inline-flex;
}
.friend-row--compact .face--small {
  width: 28px;
  height: 28px;
  font-size: 13px;
}
.presence {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--surface);
  background: var(--line);
}
.presence--online {
  background: var(--ok);
}
.presence--chess,
.presence--poker {
  background: var(--gold);
}
.friend-who {
  display: grid;
  min-width: 0;
}
.friend-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.friend-status {
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.friend-status--online {
  color: var(--ok);
}
.friend-status--chess,
.friend-status--poker {
  color: color-mix(in srgb, var(--gold) 55%, var(--text));
}
.friend-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}
.friend-actions .btn .icon {
  width: 15px;
  height: 15px;
}
.friend-more {
  min-width: 34px;
  letter-spacing: 0.08em;
}
.friend-tag {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.invite-form {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  animation: ck-rise-in var(--dur-base) var(--ease-out);
}
.invite-buyin {
  width: 110px;
}
.friends-empty {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 18px 10px;
  text-align: center;
}
.friends-empty .icon {
  width: 30px;
  height: 30px;
  color: var(--muted);
}
.friends-note {
  padding: 0 4px;
  font-size: 13px;
}
.friends-search .input {
  width: 100%;
}

/* Invitations reçues : cartes en bas à droite de toutes les pages. */
.invite-tray {
  position: fixed;
  right: 16px;
  top: calc(76px + env(safe-area-inset-top));
  z-index: 55;
  display: grid;
  gap: 8px;
  width: min(360px, calc(100vw - 32px));
}
.invite-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px 10px;
  padding: 10px 12px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-3);
  animation: ck-rise-in var(--dur-base) var(--ease-out);
}
.invite-text {
  display: grid;
  min-width: 0;
  font-size: 14px;
}
.invite-text .hint {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.invite-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

/* Défier un ami (échecs) et inviter à la table (poker). */
.friend-pick {
  display: flex;
  gap: 6px;
}
.friend-pick select {
  flex: 1;
  min-width: 0;
}
.table-invite {
  position: relative;
}
.table-invite-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 30;
  width: 260px;
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-3);
  animation: ck-rise-in var(--dur-base) var(--ease-out);
}
.table-invite-pop .friends-list {
  max-height: 240px;
  overflow-y: auto;
}

/* Classement : filtre « Mes amis » et étiquette. */
.rank-filter {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}
.rank-filter button {
  padding: 4px 12px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.rank-filter button[aria-pressed='true'] {
  background: var(--accent);
  color: var(--accent-ink);
}
.rank-friend {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

/* Chat : menu d'un pseudo (ajouter en ami, ignorer, bloquer). */
.chat-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 2px 0 4px;
}
.chat-menu .btn {
  padding: 2px 8px;
  font-size: 12px;
}

@media (max-width: 900px) {
  .friends-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .friends-side {
    position: static;
    order: -1;
  }
}
@media (max-width: 560px) {
  .friend-row {
    grid-template-columns: auto minmax(0, 1fr);
  }
  .friend-row > .friend-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}
.rank-hero-side {
  display: grid;
  justify-items: end;
  gap: 6px;
}

/* ---------- Thèmes du site (Paramètres › Thème du site ; data-site posé sur <html> par js/ui/motion.js) ----------
   Clair et Sombre sont définis en tête de feuille (:root et [data-ui='dark']). Les autres thèmes
   redéfinissent les mêmes variables ; data-ui vaut 'dark' pour Nuit bleue et Contraste élevé. */
:root[data-site='nuit'] {
  --bg: #0f1626;
  --surface: #17213a;
  --surface-2: #1f2b47;
  --text: #e6ebf5;
  --muted: #93a1bd;
  --line: #2a3a5e;
  --accent: #4c8dff;
  --accent-hover: #6aa1ff;
  --accent-soft: #1b2c4f;
  --accent-ink: #ffffff;
  --danger: #ff7a73;
  --danger-soft: #3a1f26;
  --ok: #4cc77d;
  --gold: #f2c94c;
}
:root[data-site='papier'] {
  --bg: #f3ead8;
  --surface: #fbf5e9;
  --surface-2: #efe4cf;
  --text: #3a2e22;
  --muted: #7b6a54;
  --line: #e0d2b6;
  --accent: #8a5a2b;
  --accent-hover: #74491f;
  --accent-soft: #f0e0c6;
  --accent-ink: #ffffff;
  --danger: #a3301c;
  --danger-soft: #f8e1d6;
  --ok: #4f7a2a;
  --gold: #c99a2e;
  --shadow: 0 1px 2px rgba(80, 55, 20, 0.08), 0 2px 8px rgba(80, 55, 20, 0.06);
  --shadow-2: 0 2px 4px rgba(80, 55, 20, 0.08), 0 8px 20px rgba(80, 55, 20, 0.08);
}
:root[data-site='contraste'] {
  --bg: #000000;
  --surface: #0b0b0b;
  --surface-2: #1a1a1a;
  --text: #ffffff;
  --muted: #dedede;
  --line: #ffffff;
  --accent: #ffd400;
  --accent-hover: #ffe34d;
  --accent-soft: #2b2500;
  --accent-ink: #000000;
  --danger: #ff6b6b;
  --danger-soft: #330d0d;
  --ok: #5cff8f;
  --gold: #ffd400;
  --shadow: none;
  --shadow-2: none;
  --shadow-3: 0 0 0 2px #ffffff;
}
:root[data-site='contraste'] a {
  text-decoration: underline;
}
:root[data-site='contraste'] :focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
:root[data-site='contraste'] .btn--primary {
  color: #000;
}
:root[data-site='contraste'] .hint,
:root[data-site='contraste'] .page-lead {
  color: #e8e8e8;
}

/* Aperçus des thèmes (couleurs fixes : chaque carte montre SON thème, quel que soit le thème actif). */
.site-themes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin: 6px 0 12px;
}
.site-theme {
  display: grid;
  gap: 2px;
  padding: 0 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    translate var(--dur-fast) var(--ease-out);
}
.site-theme:hover {
  translate: 0 -2px;
  box-shadow: var(--shadow-2);
}
.site-theme[aria-checked='true'] {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}
.site-theme-name {
  padding: 6px 10px 0;
  font-weight: 700;
}
.site-theme-sub {
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
}
.site-theme-preview {
  --p-bg: #f6f5f1;
  --p-surface: #fff;
  --p-line: #e2e0d9;
  --p-text: #1c1c1e;
  --p-muted: #6b6b70;
  --p-accent: #1f6f4a;
  --p-ink: #fff;
  display: grid;
  gap: 6px;
  padding: 10px;
  background: var(--p-bg);
  border-bottom: 1px solid var(--line);
}
.site-theme-preview[data-preview='dark'] {
  --p-bg: #15171a;
  --p-surface: #1e2124;
  --p-line: #33363c;
  --p-text: #ececeb;
  --p-muted: #9b9da3;
  --p-accent: #2f9a68;
}
.site-theme-preview[data-preview='nuit'] {
  --p-bg: #0f1626;
  --p-surface: #17213a;
  --p-line: #2a3a5e;
  --p-text: #e6ebf5;
  --p-muted: #93a1bd;
  --p-accent: #4c8dff;
}
.site-theme-preview[data-preview='papier'] {
  --p-bg: #f3ead8;
  --p-surface: #fbf5e9;
  --p-line: #e0d2b6;
  --p-text: #3a2e22;
  --p-muted: #7b6a54;
  --p-accent: #8a5a2b;
}
.site-theme-preview[data-preview='contraste'] {
  --p-bg: #000;
  --p-surface: #0b0b0b;
  --p-line: #fff;
  --p-text: #fff;
  --p-muted: #dedede;
  --p-accent: #ffd400;
  --p-ink: #000;
}
.stp-bar {
  font-size: 12px;
  color: var(--p-text);
}
.stp-bar b {
  font-weight: 800;
}
.stp-bar i {
  font-style: normal;
  font-weight: 800;
  color: var(--p-accent);
}
.stp-panel {
  display: grid;
  gap: 5px;
  padding: 8px;
  border: 1px solid var(--p-line);
  border-radius: 6px;
  background: var(--p-surface);
}
.stp-line {
  height: 5px;
  width: 75%;
  border-radius: 3px;
  background: var(--p-text);
}
.stp-line--short {
  width: 45%;
  background: var(--p-muted);
  opacity: 0.6;
}
.stp-btn {
  height: 12px;
  border-radius: 4px;
  background: var(--p-accent);
}

/* FAQ (Paramètres › FAQ) */
.faq {
  display: grid;
  gap: 6px;
  margin: 8px 0 12px;
}
.faq-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.faq-item summary {
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.faq-item summary::-webkit-details-marker {
  display: none;
}
.faq-item summary::after {
  content: '+';
  color: var(--muted);
  font-weight: 700;
  transition: rotate var(--dur-base) var(--ease-out);
}
.faq-item[open] summary::after {
  rotate: 45deg;
}
.faq-item[open] {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}
.faq-item p {
  padding: 0 14px 12px;
  color: var(--text);
  line-height: 1.55;
  animation: ck-rise-in var(--dur-base) var(--ease-out);
}
#block-form {
  margin: 10px 0;
}

/* ===== Espace d'administration (admin.html) ===== */
.admin-page {
  display: grid;
  gap: 12px;
}
.admin-count {
  display: inline-block;
  min-width: 18px;
  padding: 0 6px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
}
.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.admin-stat p {
  margin: 0;
}
.admin-stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
}
.admin-stat-label {
  font-weight: 600;
}
.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.admin-toolbar .input {
  flex: 1 1 220px;
}
.admin-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.admin-report.is-done {
  opacity: 0.7;
}
.admin-report p {
  margin: 0 0 6px;
}
.admin-quote {
  margin: 6px 0;
  padding: 6px 10px;
  border-left: 3px solid var(--line);
  color: var(--muted);
  white-space: pre-wrap;
}
.admin-details {
  white-space: pre-wrap;
}
.admin-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.admin-actions .input {
  flex: 1 1 200px;
}
.admin-actions .notice {
  flex-basis: 100%;
  margin: 0;
}
.admin-users {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 12px;
  align-items: start;
}
.admin-user-row {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.admin-user-row:hover {
  border-color: var(--accent);
}
.admin-user-name {
  font-weight: 600;
}
.admin-user-row .hint {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-face {
  width: 32px;
  height: 32px;
  flex: none;
}
.admin-face--big {
  width: 56px;
  height: 56px;
}
.admin-user-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.admin-badge-ban {
  background: var(--danger-soft);
  color: var(--danger);
}
.admin-dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 12px;
  margin: 12px 0;
}
.admin-dl dt {
  color: var(--muted);
}
.admin-dl dd {
  margin: 0;
}
@media (max-width: 760px) {
  .admin-users {
    grid-template-columns: 1fr;
  }
}

/* ===================================================================================
   Mise en page adaptative : du téléphone de 320 px à l'écran de 2560 px et plus.
   Points de rupture : 380 (petit téléphone), 640 (téléphone), 900 (tablette), 1180 (portable),
   1600 et 2000 (grands écrans). Hauteur : paysage de téléphone (max-height 500 px).
   =================================================================================== */

/* Les mots longs (allemand, néerlandais, russe…) se coupent au lieu de déborder. */
body {
  overflow-wrap: break-word;
}
h1,
h2,
h3 {
  hyphens: auto;
}

/* En-tête du bureau sur UNE ligne : la navigation prend la place restante et défile si elle manque d'espace. */
@media (min-width: 1180px) {
  .topbar {
    flex-wrap: nowrap;
  }
  .nav {
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar {
    display: none;
  }
  .nav a {
    flex: none;
    padding: 6px 10px;
    white-space: nowrap;
  }
  .wallets {
    flex: none;
  }
  .user {
    flex: none;
  }
  .user-name {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* Tablette et petit portable : marque, soldes et compte sur la 1re ligne, navigation entière dessous. */
@media (min-width: 641px) and (max-width: 1179px) {
  .topbar {
    row-gap: 6px;
  }
  .brand {
    order: 1;
  }
  .wallets {
    order: 2;
    margin-left: auto;
  }
  .user {
    order: 3;
  }
  .nav {
    order: 4;
    flex-basis: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .nav a {
    flex: none;
    white-space: nowrap;
  }
}

/* Grands écrans : plus de largeur utile (le texte courant garde des lignes lisibles). */
@media (min-width: 1600px) {
  .app {
    max-width: 1320px;
  }
  .app--wide {
    max-width: 1640px;
  }
  .chess-layout {
    grid-template-columns: 340px minmax(0, 1fr) 380px;
  }
  .table-layout {
    grid-template-columns: 360px minmax(0, 1fr);
  }
}
@media (min-width: 2000px) {
  .app {
    max-width: 1480px;
  }
  .app--wide {
    max-width: 1880px;
  }
  .chess-layout {
    grid-template-columns: 380px minmax(0, 1fr) 420px;
  }
  .table-layout {
    grid-template-columns: 400px minmax(0, 1fr);
  }
}

/* Échiquier : aussi grand que possible, sans jamais dépasser la hauteur de l'écran
   (bandeaux des joueurs et en-tête compris). */
.board-wrap {
  max-width: max(280px, min(580px, calc(100dvh - 230px)));
}
@media (min-width: 1600px) {
  .board-wrap {
    max-width: max(280px, min(760px, calc(100dvh - 230px)));
  }
}
@media (min-width: 2000px) {
  .board-wrap {
    max-width: max(280px, min(920px, calc(100dvh - 230px)));
  }
}
@media (max-width: 900px) {
  .board-wrap {
    max-width: min(100%, max(280px, calc(100dvh - 200px)));
  }
}

/* Onglets : une seule ligne qui défile sur téléphone, au lieu de s'empiler sur trois lignes. */
@media (max-width: 640px) {
  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
  }
  .tabs::-webkit-scrollbar {
    display: none;
  }
  .tab {
    flex: none;
    white-space: nowrap;
  }
}

/* Petits téléphones (320–380 px) : marges et panneaux resserrés. */
@media (max-width: 380px) {
  .app {
    padding: 0 10px;
  }
  .panel {
    padding: 12px 12px;
  }
  .page-title {
    font-size: 22px;
  }
  .btn {
    padding-left: 12px;
    padding-right: 12px;
  }
}

/* Téléphone en paysage : peu de hauteur, on resserre l'en-tête et les marges verticales. */
@media (max-height: 500px) and (orientation: landscape) {
  .topbar {
    min-height: 0;
    padding: 4px 0;
  }
  main {
    padding: 8px 0 16px;
  }
  .stage {
    min-height: 240px;
    max-height: calc(100dvh - 120px);
  }
}

/* Petits écrans : la barre de revue des coups et les onglets du panneau d'échecs tiennent dans la largeur. */
@media (max-width: 420px) {
  .review-label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .review-bar .btn--small {
    flex: none;
    padding-left: 8px;
    padding-right: 8px;
  }
  .chess-side .tabs .tab {
    padding-left: 4px;
    padding-right: 4px;
    white-space: normal;
    line-height: 1.2;
    font-size: 13px;
  }
}
/* Une grille de page ne s'élargit jamais pour suivre une rangée d'onglets qui défile. */
.admin-page {
  grid-template-columns: minmax(0, 1fr);
}
/* Catégories des Paramètres sur téléphone : un nom long (russe, allemand) passe à la ligne au lieu d'être coupé. */
@media (max-width: 640px) {
  .settings-cat {
    min-width: 0;
    overflow-wrap: anywhere;
    hyphens: auto;
    line-height: 1.2;
  }
}

/* Champ mot de passe avec bouton « afficher / masquer » (js/ui/password-toggle.js). */
.password-field {
  position: relative;
  display: block;
}
.password-field > .input {
  width: 100%;
  padding-right: 44px;
}
.password-toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--muted);
  cursor: pointer;
  transform: translateY(-50%);
}
.password-toggle:hover {
  background: var(--surface-2);
  color: var(--text);
}
.password-toggle[aria-pressed='true'] {
  color: var(--accent);
}
.password-toggle .icon {
  width: 20px;
  height: 20px;
}
