:root {
  --felt: #1f6b45;
  --felt-dark: #134a2f;
  --felt-light: #2a8457;
  --ink: #f4f1e8;
  --ink-soft: #c9dccf;
  --gold: #e9c46a;
  --us: #6cb4ff;
  --them: #ff9f6b;
  --card: #fffdf7;
  --card-edge: #d8d2c2;
  --red: #c8102e;
  --black: #1b1b1b;
  --panel: rgba(8, 30, 19, 0.72);
  --shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  --card-w: 86px;
  --card-h: 124px;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  background: radial-gradient(ellipse at center, var(--felt-light) 0%, var(--felt) 45%, var(--felt-dark) 100%) fixed;
  background-color: var(--felt);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  cursor: pointer;
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  background: var(--gold);
  color: #2b2105;
  font-weight: 600;
  transition: transform 0.08s ease, filter 0.15s ease;
}
button:hover:not(:disabled) { filter: brightness(1.08); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.4; cursor: default; }
button.ghost { background: transparent; color: var(--ink); border: 1px solid rgba(255, 255, 255, 0.3); }
button.secondary { background: rgba(255, 255, 255, 0.14); color: var(--ink); }
button.danger { background: #e76f51; color: #fff; }

/* ------------------------------------------------------------ Barre du haut */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
}
.brand { font-weight: 800; font-size: 20px; letter-spacing: 0.5px; }
.brand-suit { color: var(--gold); }
.scoreboard { display: flex; align-items: center; gap: 14px; }
.team { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.team span { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--ink-soft); }
.team b { font-size: 24px; font-variant-numeric: tabular-nums; }
.team.us b { color: var(--us); }
.team.them b { color: var(--them); }
.target { color: var(--ink-soft); font-size: 13px; }

/* ------------------------------------------------------------ Table */

.table {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr minmax(240px, 2.2fr) 1fr;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    ". north ."
    "west center east"
    ". south .";
  gap: 8px;
  padding: 12px 16px 0;
  max-width: 1000px;
  width: 100%;
  margin: 0 auto;
}
.seat { position: relative; align-self: center; justify-self: center; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.seat-north { grid-area: north; }
.seat-west { grid-area: west; }
.seat-east { grid-area: east; }
.seat-south { grid-area: south; min-height: 34px; }

.name {
  background: rgba(0, 0, 0, 0.28);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  border: 2px solid transparent;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.name:empty { visibility: hidden; }
.name .tag {font-size: 11px; font-weight: 700; margin-left: 6px; padding: 1px 6px; border-radius: 6px; vertical-align: 1px; }
.name .tag.dealer { background: rgba(255, 255, 255, 0.85); color: #222; }
.name .tag.taker { background: var(--gold); color: #2b2105; }
.tag.bot { background: rgba(255, 255, 255, 0.18); color: var(--ink); font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 6px; margin-left: 6px; }
.tag.away { background: #e76f51; color: #fff; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 6px; margin-left: 6px; }
.tag.dealer { background: rgba(255, 255, 255, 0.85); color: #222; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 6px; }
.seat.away .backs { opacity: 0.5; }
.seat.us .name { color: var(--us); }
.seat.them .name { color: var(--them); }
.seat.active .name { border-color: var(--gold); box-shadow: 0 0 14px rgba(233, 196, 106, 0.7); }

.backs { display: flex; }
.backs .back {
  width: 26px;
  height: 38px;
  border-radius: 4px;
  margin-left: -14px;
  background:
    repeating-linear-gradient(45deg, #7a1f2b 0 4px, #962a38 4px 8px);
  border: 2px solid #f4f1e8;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
/* Jeu de cartes illustré : son propre dos remplace les rayures */
:root:not([data-deck="classique"]) .backs .back { background: center / 100% 100% no-repeat var(--deck-back); border: 0; }
.backs .back:first-child { margin-left: 0; }
.seat-west .backs, .seat-east .backs { flex-direction: column; }
.seat-west .backs .back, .seat-east .backs .back { margin-left: 0; margin-top: -26px; }
.seat-west .backs .back:first-child, .seat-east .backs .back:first-child { margin-top: 0; }

.bubble {
  position: absolute;
  z-index: 5;
  top: -6px;
  left: 50%;
  transform: translate(-50%, -100%) scale(0.8);
  background: #fff;
  color: #222;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 12px;
  white-space: nowrap;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
}
.seat-north .bubble { top: auto; bottom: -8px; transform: translate(-50%, 100%) scale(0.8); }
.bubble.show { opacity: 1; transform: translate(-50%, -100%) scale(1); }
.seat-north .bubble.show { transform: translate(-50%, 100%) scale(1); }
.bubble.hot { background: var(--gold); }

/* ------------------------------------------------------------ Centre */

.center { grid-area: center; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
.contract {
  min-height: 30px;
  background: var(--panel);
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 14px;
  text-align: center;
}
.contract:empty { visibility: hidden; }
.contract .suit-big { font-size: 18px; vertical-align: -1px; }
.trick { position: relative; width: 290px; height: 290px; max-width: 100%; }
.slot { position: absolute; transition: transform 0.25s; }
.slot-0 { left: 50%; bottom: 0; transform: translateX(-50%); }
.slot-2 { left: 50%; top: 0; transform: translateX(-50%); }
.slot-3 { left: 0; top: 50%; transform: translateY(-50%); }
.slot-1 { right: 0; top: 50%; transform: translateY(-50%); }
.slot.win .card { box-shadow: 0 0 0 3px var(--gold), var(--shadow); }
.turned { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.turned .label { text-align: center; font-size: 12px; color: var(--ink-soft); margin-top: 4px; }


/* ------------------------------------------------------------ Cartes */

.card {
  position: relative;
  width: var(--card-w);
  height: var(--card-h);
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--card-edge);
  box-shadow: var(--shadow);
  font-weight: 700;
  user-select: none;
  flex-shrink: 0;
}
.card.red { color: var(--red); }
.card.black { color: var(--black); }
.card .corner { position: absolute; font-size: 17px; line-height: 1; text-align: center; }
.card .tl { top: 6px; left: 6px; }
.card .br { bottom: 6px; right: 6px; transform: rotate(180deg); }
.card .pip { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 46px; }
.card.trump::after {
  content: "atout";
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #8a6d1f;
  font-weight: 800;
  display: none;
}

/* ------------------------------------------------------------ Main du joueur */

.myhand {
  display: flex;
  justify-content: center;
  padding: 10px 16px 14px;
  min-height: calc(var(--card-h) + 34px);
}
.myhand .card { margin-left: -16px; transition: transform 0.12s ease, opacity 0.15s; }
.myhand .card:first-child { margin-left: 0; }
.myhand .card.trump::after { display: block; }
.myhand.playing .card.playable { cursor: pointer; }
.myhand.playing .card.playable:hover { transform: translateY(-14px); }
.myhand.playing .card:not(.playable) { opacity: 0.45; filter: grayscale(0.4); }
.myhand.waiting .card { opacity: 0.92; }

/* ------------------------------------------------------------ Enchères */

.bidbar {
  margin: 0 auto;
  max-width: 720px;
  width: calc(100% - 32px);
  background: var(--panel);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  box-shadow: var(--shadow);
}
.bidbar[hidden] { display: none; }
.bidbar .prompt { font-weight: 600; text-align: center; }
.bidbar .row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.bidbar .value { min-width: 54px; background: rgba(255, 255, 255, 0.12); color: var(--ink); }
.bidbar .value.selected { background: var(--gold); color: #2b2105; }
.bidbar .suit { font-size: 22px; min-width: 64px; background: var(--card); padding: 6px 14px; }
.bidbar .suit.red { color: var(--red); }
.bidbar .suit.black { color: var(--black); }

/* ------------------------------------------------------------ Bas de page */

.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  background: var(--panel);
  font-size: 14px;
  min-height: 46px;
}
.statusbar button { padding: 6px 12px; font-size: 13px; }
.statusbar #status { flex: 1; }
.timer { font-variant-numeric: tabular-nums; color: var(--ink-soft); font-weight: 700; }
.timer.urgent { color: #ffb4a2; }

/* ------------------------------------------------------------ Animations et notifications */

.fx { position: fixed; inset: 0; pointer-events: none; z-index: 15; }
.card.flying { position: fixed; margin: 0; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 70px;
  transform: translate(-50%, 20px);
  background: #fff;
  color: #222;
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-weight: 600;
  max-width: calc(100% - 32px);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 30;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ------------------------------------------------------------ Fenêtres */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 20;
}
.modal[hidden] { display: none; }
.modal-card {
  background: #0f3a25;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  padding: 22px;
  width: 100%;
  max-width: 460px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  animation: pop 0.2s ease-out;
}
@keyframes pop { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
.modal-card h2 { margin: 0 0 6px; font-size: 24px; }
.modal-card .sub { color: var(--ink-soft); margin: 0 0 18px; font-size: 14px; }
.modal-card .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }

.modal-card h3 { margin: 20px 0 8px; font-size: 15px; text-transform: uppercase; letter-spacing: 1px; color: var(--gold); }
.hint { color: var(--ink-soft); font-size: 13px; margin: 0 0 10px; }
.hint code, .invite code { background: rgba(0, 0, 0, 0.3); padding: 2px 6px; border-radius: 6px; }
button.small { padding: 5px 10px; font-size: 12px; }
input {
  font: inherit;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.25);
  color: var(--ink);
}
input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-soft); margin-bottom: 10px; }
.row-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.join { display: flex; gap: 8px; }
.join input { flex: 1; min-width: 0; text-transform: uppercase; letter-spacing: 4px; font-weight: 700; text-align: center; }

.code { color: var(--gold); letter-spacing: 4px; }
.invite { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.invite code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; padding: 6px 8px; }
.lobby-table {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-areas: ". n ." "w c e" ". s .";
  gap: 8px;
  align-items: center;
}
.lseat {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 8px;
  text-align: center;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 86px;
  justify-content: center;
}
.lseat.me { border-color: var(--gold); }
.lseat.team-a .lpos { color: var(--us); }
.lseat.team-b .lpos { color: var(--them); }
.lpos { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; font-weight: 700; }
.lwho { font-weight: 600; word-break: break-word; }
.lwho .free { color: var(--ink-soft); font-weight: 400; font-style: italic; }
.lact { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.lseat-0 { grid-area: s; }
.lseat-1 { grid-area: e; }
.lseat-2 { grid-area: n; }
.lseat-3 { grid-area: w; }
.formation { text-align: center; font-size: 13px; color: var(--ink-soft); margin: 12px 0 6px; }
.auto-choice { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; font-size: 13px; color: var(--ink-soft); }
.auto-choice select {
  font: inherit;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.25);
  color: var(--ink);
}
.auto { text-align: center; color: var(--gold); font-weight: 600; font-size: 14px; margin: 8px 0 0; min-height: 1.2em; font-variant-numeric: tabular-nums; }
.lcenter {grid-area: c; text-align: center; font-size: 22px; line-height: 1.3; color: rgba(255, 255, 255, 0.25); }

.modes { display: grid; gap: 10px; }
.mode {
  text-align: left;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 14px 16px;
  border-radius: 12px;
}
.mode:hover { border-color: var(--gold); }
.mode b { display: block; font-size: 17px; margin-bottom: 3px; }
.mode span { color: var(--ink-soft); font-size: 13px; font-weight: 400; }

.summary { width: 100%; border-collapse: collapse; font-size: 14px; }
.summary th, .summary td { padding: 7px 6px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); text-align: right; }
.summary th:first-child, .summary td:first-child { text-align: left; color: var(--ink-soft); font-weight: 400; }
.summary .us { color: var(--us); }
.summary .them { color: var(--them); }
.summary tr.total td { font-weight: 800; font-size: 16px; border-bottom: 0; }
.verdict { font-size: 15px; margin: 0 0 14px; padding: 10px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.08); }
.verdict.ok { border-left: 4px solid #52b788; }
.verdict.ko { border-left: 4px solid #e76f51; }
.verdict.eq { border-left: 4px solid var(--gold); }

.lasttrick { display: grid; grid-template-columns: repeat(4, auto); gap: 10px; justify-content: center; }
.lasttrick figure { margin: 0; text-align: center; font-size: 12px; color: var(--ink-soft); }
.lasttrick figure.win .card { box-shadow: 0 0 0 3px var(--gold), var(--shadow); }
.lasttrick figcaption { margin-top: 6px; }

/* ------------------------------------------------------------ Mobile */

@media (max-width: 640px) {
  :root { --card-w: 68px; --card-h: 98px; --radius: 8px; }
  .topbar { padding: 8px 12px; }
  .brand { font-size: 16px; }
  .team b { font-size: 20px; }
  .table { grid-template-columns: 56px 1fr 56px; padding: 8px 8px 0; gap: 4px; }
  .trick { width: 230px; height: 250px; }
  .name { font-size: 12px; padding: 3px 8px; }
  .seat-west .name, .seat-east .name { writing-mode: vertical-rl; transform: rotate(180deg); padding: 8px 3px; }
  .seat-east .name { transform: none; }
  .backs .back { width: 18px; height: 26px; }
  .seat-west .backs .back, .seat-east .backs .back { margin-top: -18px; }
  .card .corner { font-size: 15px; }
  .card .tl { top: 4px; left: 4px; }
  .card .br { bottom: 4px; right: 4px; }
  .card .pip { font-size: 34px; }
  .myhand { padding: 8px 8px 12px; }
  .myhand .card { margin-left: -27px; }
  .bidbar .suit { min-width: 52px; }
  .row-buttons { grid-template-columns: 1fr; }
  .lseat { min-height: 76px; padding: 6px 4px; font-size: 12px; }
}

/* ------------------------------------------------------------ Règles, chat, conseil, certification */

.settings { margin: 14px 0 4px; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 10px; padding: 8px 12px; }
.settings summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.settings[open] summary { margin-bottom: 10px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; font-size: 13px; }
.settings-grid label { display: flex; flex-direction: column; gap: 4px; color: var(--ink-soft); }
.settings-grid label.check { flex-direction: row; align-items: center; gap: 8px; grid-column: 1 / -1; color: var(--ink); }
.settings-grid select {
  font: inherit; padding: 6px 8px; border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.25); background: rgba(0, 0, 0, 0.25); color: var(--ink);
}
.settings-grid input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--gold); }
.rules-line { text-align: center; font-size: 13px; color: var(--ink-soft); margin: 12px 0 0; }

.bidbar .suit.nt { font-size: 15px; font-weight: 800; }

.cert { font-size: 12px; font-weight: 700; color: #b7e4c7; background: rgba(82, 183, 136, 0.15); border: 1px solid rgba(82, 183, 136, 0.4); padding: 3px 8px; border-radius: 999px; white-space: nowrap; cursor: help; }
.cert[hidden] { display: none; }
.cert-line { font-size: 14px; margin: 12px 0 4px; }
button.link { background: none; color: var(--gold); padding: 0; text-decoration: underline; font-weight: 600; }
.proof.ok { color: #b7e4c7; }
.proof.ko { color: #ffb4a2; font-weight: 700; }

.chatpop {
  position: fixed; right: 16px; bottom: 56px; z-index: 18;
  display: grid; grid-template-columns: repeat(3, auto); gap: 6px;
  background: #0f3a25; border: 1px solid rgba(255, 255, 255, 0.15); border-radius: 12px; padding: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45); max-width: calc(100% - 32px);
}
.chatpop[hidden] { display: none; }
.statusbar button[hidden] { display: none; }

.myhand .card.hinted { box-shadow: 0 0 0 3px #7ee0ff, 0 0 18px rgba(126, 224, 255, 0.8), var(--shadow); transform: translateY(-14px); }

@media (max-width: 640px) {
  .settings-grid { grid-template-columns: 1fr; }
  .chatpop { grid-template-columns: repeat(2, auto); left: 16px; right: 16px; }
  .cert { font-size: 0; padding: 3px 6px; }
  .cert::before { content: "🔒"; font-size: 12px; }
}
.install { margin-top: 14px; }
.install button { width: 100%; }

/* ------------------------------------------------------------ Rappel de l'atout */

.trump-badge {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); color: #222; border-radius: 10px; padding: 4px 10px 4px 12px;
  box-shadow: var(--shadow); font-weight: 700; white-space: nowrap;
}
.trump-badge[hidden] { display: none; }
.tb-label { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: #555; }
.tb-suit { font-size: 28px; line-height: 1; }
.tb-suit.red { color: var(--red); }
.tb-suit.black { color: var(--black); }
.tb-suit.nt { font-size: 16px; font-weight: 800; color: #2b2105; }
.trump-mark {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 230px; line-height: 1; color: rgba(255, 255, 255, 0.10);
  pointer-events: none; user-select: none;
}
.trump-mark.red { color: rgba(255, 110, 110, 0.16); }
.trump-mark.black { color: rgba(0, 0, 0, 0.22); }
.trump-mark.nt { font-size: 110px; font-weight: 800; }

@media (max-width: 640px) {
  body.has-trump .brand { display: none; }
  .trump-badge { padding: 3px 8px; gap: 6px; }
  .tb-label { font-size: 10px; }
  .tb-suit { font-size: 22px; }
  .trump-mark { font-size: 180px; }
  .trump-mark.nt { font-size: 80px; }
}

.music-settings { margin-top: 12px; align-items: end; }

/* Jeux de cartes illustrés (cartes/<jeu>/*.svg) et leur aperçu dans les options */
.card.img { background: none; border: 0; overflow: hidden; }
.card.img img { display: block; width: 100%; height: 100%; object-fit: fill; pointer-events: none; }
.deck-settings { margin-top: 12px; align-items: center; }
.deck-preview { display: flex; justify-content: center; }
.deck-preview .card { width: 52px; height: 73px; margin-left: -10px; font-size: 11px; }
.deck-preview .card:first-child { margin-left: 0; }
.deck-preview .card .corner { font-size: 11px; }
.deck-preview .card .pip { font-size: 26px; }
.volume { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-soft); }
.volume input { width: 100%; accent-color: var(--gold); }


/* ============================================================================================
   Charte Copains d'Atout (marque/charte.html, marque/couleurs.css) : couleurs, polices, plateau.
   Ce bloc vient en dernier et redéfinit l'apparence ; la structure reste celle du dessus.
   ============================================================================================ */

:root {
  --ca-nuit: #0b2a1e;
  --ca-fonce: #134a2f;
  --ca-tapis: #1f6b45;
  --ca-or: #e9c46a;
  --ca-or-fonce: #b8862b;
  --ca-or-texte: #8a6418;
  --ca-ivoire: #f7f2e6;
  --ca-carte: #fffdf7;
  --ca-carmin: #c8102e;
  --ca-encre: #1b1b1b;
  --ca-gris: #5b6159;
  --ca-titre: "Playfair Display", Georgia, "Times New Roman", serif;
  --ca-texte: "Lato", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ca-rayon: 14px;

  --felt: var(--ca-tapis);
  --felt-dark: var(--ca-nuit);
  --ink: var(--ca-ivoire);
  --ink-soft: #c9d8cc;
  --gold: var(--ca-or);
  --card: var(--ca-carte);
  --red: var(--ca-carmin);
  --panel: rgba(11, 42, 30, 0.82);

  /* Cartes au format 250 × 350 de la charte, à la taille de l'écran. */
  --card-h: clamp(112px, 18vh, 176px);
  --card-w: calc(var(--card-h) / 1.4);
  --radius: calc(var(--card-w) * 0.064);
}

body {
  font-family: var(--ca-texte);
  background: radial-gradient(ellipse at 50% 25%, #14402b 0%, var(--ca-nuit) 65%) fixed;
  background-color: var(--ca-nuit);
}

button { border-radius: var(--ca-rayon); font-family: var(--ca-texte); font-weight: 700; min-height: 44px; background: var(--ca-or); color: var(--ca-nuit); }
button.ghost { border-color: rgba(233, 196, 106, 0.45); color: var(--ca-ivoire); }
button.small { min-height: 32px; }

/* ------------------------------------------------------------ Barre du haut */

.topbar {
  background: linear-gradient(180deg, #0f3626, var(--ca-nuit));
  border-bottom: 1px solid rgba(233, 196, 106, 0.28);
  padding: 8px 18px;
}
.brand img { display: block; height: 40px; width: auto; }
.brand-icon { display: none !important; }
.team span { font-family: var(--ca-texte); font-weight: 700; }
.team b { font-family: var(--ca-titre); font-size: 28px; }
.team.us b { color: #8cc8ff; }
.team.them b { color: #ffb38a; }

/* ------------------------------------------------------------ Le plateau : tapis de feutre, filets dorés */

.table {
  position: relative;
  max-width: 1120px;
  width: calc(100% - 40px);
  margin: 12px auto 2px;
  padding: 14px 22px 8px;
  border-radius: 40px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .10 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    radial-gradient(ellipse at 50% 42%, #2d8f5d 0%, var(--ca-tapis) 42%, #17553a 78%, #113f2a 100%);
  box-shadow:
    inset 0 0 90px rgba(0, 0, 0, 0.45),
    0 0 0 9px #0d3121,
    0 0 0 10px rgba(233, 196, 106, 0.45),
    0 20px 46px rgba(0, 0, 0, 0.55);
}
.table::before {
  content: "";
  position: absolute;
  inset: 11px;
  border: 1px solid rgba(233, 196, 106, 0.38);
  border-radius: 31px;
  pointer-events: none;
}

.name {
  background: rgba(11, 42, 30, 0.72);
  border: 1px solid rgba(233, 196, 106, 0.22);
  font-family: var(--ca-texte);
  font-weight: 700;
  padding: 5px 14px;
}
.seat.active .name { border-color: var(--ca-or); box-shadow: 0 0 0 1px var(--ca-or), 0 0 16px rgba(233, 196, 106, 0.6); }
.backs .back { width: calc(var(--card-w) * 0.3); height: calc(var(--card-w) * 0.42); border-radius: 3px; margin-left: calc(var(--card-w) * -0.18); }
.seat-west .backs .back, .seat-east .backs .back { margin-left: 0; margin-top: calc(var(--card-w) * -0.3); }
.seat-west .backs .back:first-child, .seat-east .backs .back:first-child, .backs .back:first-child { margin-left: 0; margin-top: 0; }

.contract { background: rgba(11, 42, 30, 0.78); border: 1px solid rgba(233, 196, 106, 0.3); font-size: 15px; }

/* Zone du pli : cercle de jeu doré ; filigrane de l'atout, ou du logo avant les enchères */
.trick { width: calc(var(--card-w) * 3 + 30px); height: calc(var(--card-h) * 1.72 + 10px); max-width: 100%; } /* haut et bas se chevauchent un peu */
.trick::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(var(--card-h) * 1.95);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1px solid rgba(233, 196, 106, 0.24);
  background: radial-gradient(circle, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.08) 70%);
  pointer-events: none;
}
.trump-mark { font-size: calc(var(--card-h) * 1.45); font-family: var(--ca-titre); }
.trump-mark:empty { background: url(assets/logo/icone.svg) center / calc(var(--card-h) * 0.85) no-repeat; opacity: 0.13; }

.bubble { background: var(--ca-ivoire); color: var(--ca-encre); font-family: var(--ca-texte); border: 1px solid rgba(184, 134, 43, 0.4); }
.bubble.hot { background: var(--ca-or); color: var(--ca-nuit); }

/* ------------------------------------------------------------ Cartes */

.card { border-radius: var(--radius); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), 0 8px 18px rgba(0, 0, 0, 0.3); }
.card.img { border: 0; background: none; }
.card:not(.img) .corner { font-size: calc(var(--card-w) * 0.19); }
.card:not(.img) .pip { font-size: calc(var(--card-w) * 0.52); }
.myhand { min-height: calc(var(--card-h) + 30px); padding-top: 10px; padding-bottom: 10px; }
.myhand .card { margin-left: calc(var(--card-w) * -0.3); }
.myhand.playing .card.playable:hover { transform: translateY(-18px); }
/* Atouts de la main : liseré or et petite étiquette, visible même quand les cartes se chevauchent */
.myhand .card.trump { box-shadow: 0 0 0 2px var(--ca-or), 0 8px 18px rgba(0, 0, 0, 0.3); }
.myhand .card.trump::after {
  content: "atout";
  display: block;
  position: absolute;
  left: 6%;
  bottom: 4%;
  transform: none;
  background: var(--ca-or);
  color: var(--ca-nuit);
  font: 900 9px/1 var(--ca-texte);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 5px;
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

/* ------------------------------------------------------------ Barres d'action */

.bidbar { background: rgba(11, 42, 30, 0.92); border: 1px solid rgba(233, 196, 106, 0.3); border-radius: 18px; }
.bidbar .suit { background: var(--ca-carte); border-radius: 12px; }
.statusbar { background: var(--ca-nuit); border-top: 1px solid rgba(233, 196, 106, 0.22); }
.statusbar button { min-height: 36px; }
.trump-badge { background: var(--ca-carte); border: 1px solid rgba(184, 134, 43, 0.5); }
.tb-label { font-family: var(--ca-texte); font-weight: 900; color: var(--ca-or-texte); }

/* ------------------------------------------------------------ Fenêtres : ivoire, encre et or */

.modal { background: rgba(5, 22, 15, 0.62); backdrop-filter: blur(3px); }
.modal-card {
  --ink: var(--ca-encre);
  --ink-soft: var(--ca-gris);
  background: var(--ca-ivoire);
  color: var(--ca-encre);
  border: 1px solid rgba(184, 134, 43, 0.5);
  border-radius: 22px;
  box-shadow: 0 0 0 6px rgba(247, 242, 230, 0.06), 0 24px 60px rgba(0, 0, 0, 0.55);
}
.modal-card h2 { font-family: var(--ca-titre); color: var(--ca-fonce); font-size: 28px; }
.modal-card .brand-title { margin-bottom: 4px; }
.modal-card .brand-logo { display: block; height: 58px; width: auto; max-width: 100%; }
.modal-card h3 { color: var(--ca-or-texte); font-family: var(--ca-texte); font-weight: 900; }
.modal-card .sub, .modal-card .hint, .formation, .rules-line, .settings summary { color: var(--ca-gris); }
.modal-card button { background: var(--ca-fonce); color: var(--ca-ivoire); }
.modal-card button.secondary { background: transparent; color: var(--ca-fonce); border: 1.5px solid rgba(19, 74, 47, 0.35); }
.modal-card button.danger { background: var(--ca-carmin); color: #fff; }
.modal-card button.link { background: none; color: var(--ca-or-texte); border: 0; min-height: 0; }
.modal-card .mode { background: var(--ca-carte); color: var(--ca-encre); border: 1px solid #e3dccb; }
.modal-card .mode b { font-family: var(--ca-titre); color: var(--ca-fonce); font-size: 18px; }
.modal-card .mode span { color: var(--ca-gris); }
.modal-card .mode:hover { border-color: var(--ca-or-fonce); box-shadow: 0 4px 14px rgba(19, 74, 47, 0.12); }
.modal-card input, .modal-card select, .auto-choice select, .settings-grid select { background: #fff; color: var(--ca-encre); border: 1px solid #d8d2c2; }
.modal-card input:focus { outline-color: var(--ca-or-fonce); }
.settings { background: rgba(19, 74, 47, 0.04); border-color: rgba(19, 74, 47, 0.15); }
.settings-grid label { color: var(--ca-gris); }
.settings-grid label.check { color: var(--ca-encre); }
.settings-grid input[type="checkbox"], .volume input { accent-color: var(--ca-fonce); }
.summary th, .summary td { border-bottom-color: rgba(0, 0, 0, 0.08); }
.modal-card .us, .lseat.team-a .lpos { color: #1d5d9b; }
.modal-card .them, .lseat.team-b .lpos { color: #a4471c; }
.verdict { background: rgba(19, 74, 47, 0.06); }
.hint code, .invite code { background: rgba(0, 0, 0, 0.06); color: var(--ca-encre); }
.code { color: var(--ca-or-texte); font-family: var(--ca-titre); }
.lseat { background: var(--ca-carte); border-color: #e3dccb; }
.lseat.me { border-color: var(--ca-or-fonce); box-shadow: 0 0 0 1px var(--ca-or-fonce); }
.lwho .free { color: var(--ca-gris); }
.lcenter { color: rgba(19, 74, 47, 0.25); }
.modal-card .tag.bot { background: rgba(0, 0, 0, 0.07); color: var(--ca-encre); }
.auto { color: var(--ca-or-texte); }
.cert-line { color: var(--ca-fonce); }
.proof.ok { color: #2d6a4f; }
.proof.ko { color: var(--ca-carmin); }
.lasttrick figcaption { color: var(--ca-gris); }
.lasttrick figure.win .card { box-shadow: 0 0 0 3px var(--ca-or-fonce), 0 6px 14px rgba(0, 0, 0, 0.25); }

.chatpop { background: var(--ca-ivoire); border-color: rgba(184, 134, 43, 0.5); }
.chatpop button.secondary { background: var(--ca-carte); color: var(--ca-fonce); border: 1px solid #e3dccb; }

/* ------------------------------------------------------------ Téléphone */

@media (max-width: 640px) {
  :root {
    --card-w: min(80px, calc((100vw - 24px) / 4.6));
    --card-h: calc(var(--card-w) * 1.4);
  }
  .brand .brand-full { display: none; } /* « .brand img » l'affichait encore : il faut la même précision */
  .brand-icon { display: block !important; height: 34px !important; }
  .team b { font-size: 22px; }
  .table { width: calc(100% - 16px); margin: 10px auto 4px; padding: 12px 8px 8px; border-radius: 24px; box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.45), 0 0 0 5px #0d3121, 0 0 0 6px rgba(233, 196, 106, 0.4), 0 12px 26px rgba(0, 0, 0, 0.5); }
  .table::before { inset: 7px; border-radius: 18px; }
  .trick { width: calc(var(--card-w) * 3 + 16px); height: calc(var(--card-h) * 1.8 + 10px); }
  .myhand { padding: 12px 8px; }
  /* 8 cartes sur la largeur de l'écran */
  .myhand .card { margin-left: min(-8px, calc((100vw - 16px - var(--card-w)) / 7 - var(--card-w))); }
  .modal-card .brand-logo { height: 44px; }
  .statusbar { gap: 6px; padding: 6px 8px; }
  .statusbar #status { min-width: 0; font-size: 13px; line-height: 1.2; }
  .statusbar button { min-height: 36px; padding: 4px 10px; white-space: nowrap; }
  .statusbar .lbl { display: none; }
}

/* ------------------------------------------------------------ Mise en page stable
   Rien ne doit bouger pendant la partie : la barre d'enchères flotte au-dessus de la main
   (au lieu de s'insérer entre la table et la main), et la ligne d'état ne passe jamais à la ligne. */

.bidbar {
  position: fixed;
  z-index: 12;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--card-h) + 30px + 54px);
  margin: 0;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}
.statusbar { min-height: 50px; }
.statusbar #status { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 640px) {
  .bidbar { width: calc(100% - 16px); bottom: calc(var(--card-h) + 24px + 50px); }
}
/* La bulle du contrat garde toujours la même hauteur, quel que soit son texte. */
.contract { box-sizing: border-box; height: 34px; min-height: 34px; display: flex; align-items: center; justify-content: center; gap: 4px; white-space: nowrap; max-width: 100%; overflow: hidden; }
.contract .suit-big { line-height: 1; }

/* ------------------------------------------------------------ Comptes */

.account-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
  margin: 4px 0 6px; padding: 10px 12px; border-radius: 12px;
  background: rgba(19, 74, 47, 0.06); border: 1px solid rgba(19, 74, 47, 0.14); font-size: 14px;
}
.account-bar .hint { margin: 0; flex: 1 1 200px; }
.account-buttons { display: flex; gap: 6px; }
.auth-form { display: flex; flex-direction: column; gap: 4px; }
.auth-form input { width: 100%; box-sizing: border-box; }
.modal-card[data-screen="auth"] { max-width: 720px; }
/* Champs côte à côte quand la place le permet (3 à l'inscription, 2 à la connexion), un par ligne sur téléphone. */
.auth-form .fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0 16px; }
.modal-card[data-screen="auth"] .google-btn { display: flex; max-width: 340px; margin: 0 auto; }
.auth-form .actions { align-items: center; }
.auth-form .actions .back { margin-inline-end: auto; }
.check-line { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; margin: 6px 0; }
.check-line input { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--ca-fonce); flex-shrink: 0; }
.check-line a, .modal-card a { color: var(--ca-or-texte); }
.form-error { color: var(--ca-carmin); font-weight: 700; font-size: 14px; min-height: 1.2em; margin: 4px 0; }
.danger-zone summary { color: var(--ca-carmin); }
.danger-zone .field input { width: 100%; box-sizing: border-box; }

/* Les places des joueurs ne bougent pas quand leur main diminue ou qu'un badge (donneur, preneur) apparaît :
   chaque pile de dos a la taille d'une main de 8 cartes et reste calée en haut. */
.seat-west, .seat-east { align-self: center; justify-self: stretch; justify-content: flex-start; }
.seat-west .backs, .seat-east .backs { height: calc(var(--card-w) * 1.26); justify-content: flex-start; }
.seat-north .backs { width: calc(var(--card-w) * 1.14); height: calc(var(--card-w) * 0.42); justify-content: center; }
.seat-north { justify-self: center; }
/* Colonnes de la table indépendantes de la longueur des noms et des badges. */
@media (min-width: 641px) {
  .table { grid-template-columns: minmax(0, 1fr) minmax(240px, 2.2fr) minmax(0, 1fr); }
}
.seat-west .backs, .seat-east .backs { width: calc(var(--card-w) * 0.3); }

/* ------------------------------------------------------------ Langues */

.lang-picker { display: flex; justify-content: flex-end; align-items: center; gap: 6px; font-size: 14px; margin: -4px 0 6px; }
.lang-picker select { font: inherit; padding: 4px 8px; border-radius: 8px; border: 1px solid #d8d2c2; background: #fff; color: var(--ca-encre); }

/* Arabe : textes de droite à gauche, mais la table de jeu garde son orientation
   (Est à droite, Ouest à gauche), tout comme les cartes, la main et les scores. */
[dir="rtl"] body { font-family: var(--ca-texte), "Noto Sans Arabic", "Geeza Pro", "Segoe UI", Tahoma, sans-serif; }
[dir="rtl"] .table, [dir="rtl"] .trick, [dir="rtl"] .myhand, [dir="rtl"] .backs, [dir="rtl"] .scoreboard, [dir="rtl"] .lobby-table, [dir="rtl"] .lasttrick { direction: ltr; }
[dir="rtl"] .seat .name, [dir="rtl"] .contract, [dir="rtl"] .bubble, [dir="rtl"] .lseat { direction: rtl; unicode-bidi: plaintext; }
[dir="rtl"] .summary th, [dir="rtl"] .summary td { text-align: left; }
[dir="rtl"] .summary th:first-child, [dir="rtl"] .summary td:first-child { text-align: right; }
[dir="rtl"] .lang-picker { justify-content: flex-start; }

/* ------------------------------------------------------------ Compteur de la donne (coin du tapis, en surimpression) */

.live {
  position: absolute; top: 20px; left: 26px; z-index: 3; min-width: 150px;
  background: rgba(11, 42, 30, 0.8); border: 1px solid rgba(233, 196, 106, 0.35); border-radius: 12px;
  padding: 8px 12px; font-size: 13px; pointer-events: none; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}
.live[hidden] { display: none; }
.live-title { text-transform: uppercase; letter-spacing: 0.08em; font-size: 10px; font-weight: 900; color: var(--ca-or); margin-bottom: 4px; }
.live-row { display: flex; align-items: baseline; gap: 8px; position: relative; white-space: nowrap; }
.live-row span { min-width: 40px; color: var(--ink-soft); }
.live-row b { font-family: var(--ca-titre); font-size: 19px; font-variant-numeric: tabular-nums; }
.live-row.us b { color: #8cc8ff; }
.live-row.them b { color: #ffb38a; }
.live-row small { color: var(--ink-soft); font-size: 11px; }
.live-goal { margin-top: 5px; font-size: 12px; color: var(--ca-ivoire); max-width: 190px; }
.gain { position: absolute; right: -6px; transform: translateX(100%); font-weight: 900; color: var(--ca-or); font-size: 15px; }
[dir="rtl"] .live { direction: rtl; left: auto; right: 26px; }

@media (max-width: 640px) {
  /* Sur téléphone : coin bas gauche du tapis, pour ne pas cacher le partenaire. */
  .live { top: auto; bottom: 10px; left: 10px; min-width: 0; padding: 6px 8px; font-size: 11px; }
  .live-row b { font-size: 15px; }
  .live-row span { min-width: 30px; }
  .live-goal { font-size: 10px; max-width: 110px; }
  [dir="rtl"] .live { left: auto; right: 10px; }
}

/* Annonces à déclarer au premier pli */
.bidbar .annonce { background: rgba(255, 255, 255, 0.12); color: var(--ca-ivoire); border: 1px solid rgba(233, 196, 106, 0.45); }
.bidbar .annonce.selected { background: var(--ca-or); color: var(--ca-nuit); border-color: var(--ca-or); }

/* Signature de l'éditeur, en bas de l'accueil */
.editor { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 18px 0 0; font-size: 12px; color: var(--ca-gris); }
.editor img { height: 20px; width: 20px; border-radius: 5px; }
.editor a { color: var(--ca-gris); }

/* ------------------------------------------------------------ Connexion Google */

.google-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 44px; padding: 0 16px;
  border-radius: var(--ca-rayon); background: #fff; color: #1f1f1f; border: 1px solid #c7c7c7;
  font: 600 14px/1 var(--ca-texte); text-decoration: none; width: 100%; box-sizing: border-box;
}
.google-btn:hover { background: #f7f7f7; }
.account-bar .google-btn { flex-basis: 100%; }
.or { display: flex; align-items: center; gap: 10px; color: var(--ca-gris); font-size: 13px; margin: 12px 0 4px; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid rgba(0, 0, 0, 0.12); }
.hint svg, .summary svg { vertical-align: -3px; }

/* ------------------------------------------------------------ Inviter des amis (panneau de partage) */

.sharesheet { position: fixed; inset: 0; z-index: 40; background: rgba(5, 22, 15, 0.55); display: flex; align-items: flex-end; justify-content: center; padding: 16px; }
.sharesheet[hidden] { display: none; }
.sharebox { width: 100%; max-width: 460px; background: var(--ca-ivoire); color: var(--ca-encre); border-radius: 20px; padding: 18px; box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.45); border: 1px solid rgba(184, 134, 43, 0.5); }
.sharebox h3 { margin: 0 0 6px; font-family: var(--ca-titre); color: var(--ca-fonce); font-size: 22px; text-transform: none; letter-spacing: 0; }
.share-text { font-size: 13px; color: var(--ca-gris); margin: 0 0 12px; }
.share-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.share-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 72px; padding: 6px; border-radius: 12px; background: var(--ca-carte); border: 1px solid #e3dccb; color: var(--ca-fonce); font: 700 12px/1.2 var(--ca-texte); text-decoration: none; text-align: center; cursor: pointer; }
.share-item span { font-size: 24px; }
.share-item:hover { border-color: var(--ca-or-fonce); }
.sharebox .actions button { background: transparent; color: var(--ca-fonce); border: 1.5px solid rgba(19, 74, 47, 0.35); }
@media (max-width: 400px) { .share-grid { grid-template-columns: repeat(3, 1fr); } }
