

:root {
  --carte-l: 66px;
  --carte-h: 92px;
  --tapis: #0f3d2a;
  --tapis-bord: #1b5a3f;
  --or: #f2c14e;
  --carte-rouge: #c62828;
  --carte-noir: #15171c;
}

@media (max-width: 899px) { :root { --carte-l: 58px; --carte-h: 81px; } }
@media (max-width: 600px) { :root { --carte-l: 46px; --carte-h: 64px; } }
@media (max-height: 480px) and (orientation: landscape) { :root { --carte-l: 40px; --carte-h: 56px; } }

[hidden] { display: none !important; }


body.page-partie #app { max-width: 920px; padding: 16px 16px 12px; }

body.page-partie #app .jeu-banner { margin: -16px -16px 12px; }

.titre-page-jeu {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--texte-doux);
  margin: 4px 0 12px;
}


body.en-partie .titre-page-jeu,
body.en-partie footer,
body.en-partie .bandeau-infos-wrap,
body.en-partie .bloc-jeux-une-wrap { display: none !important; }

.ecran-jeu { display: flex; flex-direction: column; gap: 8px; }

.barre-partie {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.86rem;
}

.barre-scores { display: flex; align-items: baseline; gap: 10px; font-weight: 700; white-space: nowrap; }
.barre-scores b { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.score-nous b { color: #6ee7b7; }
.score-eux b { color: #f1f5f9; }
.score-but { color: var(--texte-faible); font-weight: 600; font-size: 0.78rem; }

.barre-contrat { flex: 1; min-width: 0; text-align: center; color: var(--texte); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barre-contrat .enseigne { font-size: 1.05rem; }
.rouge { color: #ff6b6b; }
.noir { color: #e8edf3; }

.barre-outils { display: flex; gap: 6px; }
.btn-outil {
  min-width: 44px; min-height: 36px; padding: 0 10px;
  font: inherit; font-size: 0.8rem; font-weight: 700;
  color: var(--texte); background: transparent; border: 1px solid var(--line-forte); border-radius: 6px; cursor: pointer;
}
.btn-outil:hover { border-color: var(--color-light); }
.btn-outil[aria-expanded="true"] { background: var(--surface-1); border-color: var(--color-light); }

.bandeau-message {
  min-height: 34px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(110, 231, 183, 0.08);
  border: 1px solid rgba(110, 231, 183, 0.18);
  color: #a7f3d0;
  font-size: 0.9rem; font-weight: 600;
}
.bandeau-message.erreur { background: rgba(248, 113, 113, 0.1); border-color: rgba(248, 113, 113, 0.4); color: #fecaca; }
.bandeau-message.a-moi { background: rgba(242, 193, 78, 0.12); border-color: rgba(242, 193, 78, 0.45); color: #fde9b0; }
.bandeau-message .btn { padding: 6px 12px; font-size: 0.8rem; }


.carte {
  position: relative;
  width: var(--carte-l);
  height: var(--carte-h);
  flex-shrink: 0;
  border-radius: calc(var(--carte-l) * 0.09);
  background: #fdfdfb;
  border: 1px solid rgba(0, 0, 0, 0.28);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.carte[role="button"] { cursor: pointer; transition: transform 0.12s; }
@media (hover: hover) {
  .carte[role="button"]:hover:not(.non-jouable) { transform: translateY(-10px); }
}
.carte[role="button"]:focus { outline: none; }
.carte[role="button"]:focus-visible { outline: 3px solid var(--or); outline-offset: 2px; transform: translateY(-10px); }


.carte.est-atout::after {
  content: '';
  position: absolute; left: 0; right: 0; top: 0; height: 4px;
  background: var(--or);
}


.carte.non-jouable { filter: brightness(0.55) saturate(0.6); cursor: not-allowed; }
.carte.conseillee { box-shadow: 0 0 0 3px #38bdf8, 0 0 14px rgba(56, 189, 248, 0.7); transform: translateY(-10px); }

.dos {
  width: calc(var(--carte-l) * 0.5);
  height: calc(var(--carte-h) * 0.5);
  border-radius: 3px;
  background: repeating-linear-gradient(45deg, #1d6b4a 0 3px, #145238 3px 6px);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
}


.table-belote {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr) minmax(0, 1fr);
  grid-template-areas:
    "o n e"
    "o c e"
    "o s e";
  gap: 6px 8px;
  justify-items: center;
  align-items: center;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 12px 10px;
  border-radius: 26px;
  background: radial-gradient(ellipse at center, #17573c 0%, var(--tapis) 78%);
  border: 2px solid var(--tapis-bord);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.4);
}

.tb-place { display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; max-width: 100%; }
.tb-pos-s { grid-area: s; flex-direction: column-reverse; }
.tb-pos-n { grid-area: n; }
.tb-pos-e { grid-area: e; flex-direction: row-reverse; }
.tb-pos-o { grid-area: o; flex-direction: row; }

.tb-etiquette {
  position: relative;
  max-width: 100%;
  padding: 3px 9px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.14);
  text-align: center;
  line-height: 1.25;
}
.tb-pos-e .tb-etiquette, .tb-pos-o .tb-etiquette { max-width: calc(100% - var(--carte-l) - 5px); }

.tb-nom { display: block; font-size: 0.8rem; font-weight: 700; color: #ecfdf5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-partenaire .tb-nom { color: #6ee7b7; }
.tb-infos { display: block; font-size: 0.7rem; color: #a7b5ae; }
.tb-infos:empty { display: none; }
.tb-badge { display: inline-block; margin: 1px 2px 0; padding: 0 5px; border-radius: 6px; font-size: 0.66rem; font-weight: 800; background: var(--or); color: #1b1503; }
.tb-badge.tb-donneur { background: transparent; border: 1px solid rgba(255, 255, 255, 0.45); color: #e5e7eb; }
.tb-badge.tb-absent { background: #64748b; color: #fff; }

.tb-actif .tb-etiquette { border-color: var(--or); box-shadow: 0 0 0 2px rgba(242, 193, 78, 0.35); }
.tb-gagnant .tb-etiquette { border-color: var(--or); background: rgba(242, 193, 78, 0.18); }


.tb-bulle {
  position: absolute; left: 50%; bottom: calc(100% + 4px); transform: translateX(-50%);
  z-index: 3; white-space: nowrap;
  padding: 3px 9px; border-radius: 10px;
  background: #fdfdfb; color: #15171c; font-size: 0.76rem; font-weight: 800;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.tb-pos-n .tb-bulle { bottom: auto; top: 50%; left: calc(100% + 6px); transform: translateY(-50%); }
.tb-pos-s .tb-bulle { bottom: calc(100% + 4px); }

.tb-emplacement {
  position: relative;
  width: var(--carte-l);
  height: var(--carte-h);
  flex-shrink: 0;
  border-radius: calc(var(--carte-l) * 0.09);
  border: 1.5px dashed rgba(255, 255, 255, 0.14);
}
.tb-emplacement.tb-occupe { border-color: transparent; }

.ecran-jeu[data-vue="encheres"] .tb-emplacement { display: none; }
.ecran-jeu[data-vue="encheres"] .table-belote { gap: 12px 8px; padding-top: 16px; padding-bottom: 16px; }
.tb-emplacement .carte { position: absolute; inset: 0; animation: tb-pose 0.22s ease-out; }
.tb-gagnant .tb-emplacement .carte { box-shadow: 0 0 0 3px var(--or), 0 0 16px rgba(242, 193, 78, 0.7); }
.tb-pos-s .tb-emplacement .carte { --tb-depart: translateY(26px); }
.tb-pos-n .tb-emplacement .carte { --tb-depart: translateY(-26px); }
.tb-pos-o .tb-emplacement .carte { --tb-depart: translateX(-26px); }
.tb-pos-e .tb-emplacement .carte { --tb-depart: translateX(26px); }
@keyframes tb-pose {
  from { opacity: 0; transform: var(--tb-depart, none) scale(0.92); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) { .tb-emplacement .carte { animation: none; } }


.tb-centre {
  grid-area: c;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: calc(var(--carte-h) * 0.62);
  min-width: 0; max-width: 100%;
  text-align: center;
}
.tb-centre .carte { width: calc(var(--carte-l) * 0.8); height: calc(var(--carte-h) * 0.8); }
.tb-centre-ligne { font-size: 0.8rem; font-weight: 800; color: #fde9b0; line-height: 1.25; }
.tb-centre-detail { font-size: 0.7rem; font-weight: 600; color: #d1fae5; line-height: 1.25; }

@media (max-width: 600px) {
  
  .barre-contrat { display: none; }
  
  .barre-partie { justify-content: space-between; flex-wrap: wrap; row-gap: 4px; padding: 6px 8px; }
  .barre-outils { margin-left: auto; }
  .btn-outil { padding: 0 8px; white-space: nowrap; }
  .table-belote { padding: 8px 4px; border-radius: 18px; gap: 4px 2px; }
  .tb-etiquette { padding: 2px 6px; }
  .tb-nom { font-size: 0.74rem; }
  .tb-infos { font-size: 0.66rem; }
  .tb-pos-e, .tb-pos-o { flex-direction: column; }
  .tb-pos-e .tb-etiquette, .tb-pos-o .tb-etiquette { max-width: 100%; }
}


.zone-decision {
  max-width: 600px; width: 100%;
  margin: 0 auto;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line-forte);
  text-align: center;
}

.ecran-jeu[data-phase="fin_donne"] .table-belote,
.ecran-jeu[data-phase="termine"] .table-belote { display: none; }
.decision-titre { font-size: 0.92rem; font-weight: 700; color: #f1f5f9; margin-bottom: 8px; }
.decision-texte { font-size: 0.82rem; color: var(--texte-doux); margin-bottom: 8px; line-height: 1.4; }
.decision-boutons { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.decision-boutons .btn { min-height: 44px; }

.btn-couleur {
  min-width: 52px; min-height: 44px; padding: 4px 10px;
  font: inherit; font-size: 1.35rem; font-weight: 700; line-height: 1;
  background: #fdfdfb; border: 2px solid transparent; border-radius: 8px; cursor: pointer;
}
.btn-couleur.rouge { color: var(--carte-rouge); }
.btn-couleur.noir { color: var(--carte-noir); }
.btn-couleur.texte { font-size: 0.8rem; color: var(--carte-noir); }
.btn-couleur[aria-pressed="true"] { border-color: var(--or); box-shadow: 0 0 0 2px rgba(242, 193, 78, 0.5); }
.btn-couleur:focus-visible, .btn-points:focus-visible { outline: 3px solid var(--or); outline-offset: 2px; }

.btn-points {
  min-width: 48px; min-height: 40px; padding: 4px 8px;
  font: inherit; font-size: 0.9rem; font-weight: 700;
  color: var(--texte); background: transparent; border: 1px solid var(--line-forte); border-radius: 8px; cursor: pointer;
}
.btn-points[aria-pressed="true"] { background: var(--color-btn1); border-color: var(--color-btn1); color: #fff; }
.encheres-rangee { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-bottom: 8px; }
.btn-coinche { background: #b45309; border-color: #b45309; }
.btn-coinche:hover:not(:disabled) { background: #c2620e; }


.decompte { width: 100%; border-collapse: collapse; margin: 4px 0 8px; font-size: 0.86rem; }
.decompte th, .decompte td { padding: 5px 8px; border-bottom: 1px solid var(--line); }
.decompte th { font-weight: 600; color: var(--texte-doux); text-align: left; }
.decompte td { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.decompte thead th { text-align: right; color: var(--texte); }
.decompte thead th:first-child { text-align: left; }
.decompte .total th, .decompte .total td { border-top: 2px solid var(--line-forte); border-bottom: none; font-size: 0.98rem; color: #f1f5f9; }
.decompte .nous { color: #6ee7b7; }
.decompte-phrase { font-size: 0.95rem; font-weight: 700; margin-bottom: 6px; }
.decompte-phrase.bon { color: #6ee7b7; }
.decompte-phrase.mauvais { color: #fca5a5; }
.decompte-note { font-size: 0.78rem; color: var(--texte-doux); margin: 0 0 8px; }


.zone-main {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  justify-content: center;
  padding: 10px 6px max(8px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, var(--surface-1) 18%);
}
.main-cartes { display: flex; justify-content: center; flex-wrap: nowrap; max-width: 100%; min-height: var(--carte-h); }
.main-cartes .carte { box-shadow: -2px 0 5px rgba(0, 0, 0, 0.3); }
.main-cartes .carte.entre { animation: main-entre 0.3s ease-out; }
@keyframes main-entre { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }


.panneau-pli, .zone-aides {
  max-width: 600px; width: 100%;
  margin: 0 auto;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  text-align: center;
}
.panneau-titre { font-size: 0.86rem; font-weight: 700; color: #f1f5f9; margin-bottom: 8px; }
.pli-a-plat { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.pli-a-plat li { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.pli-a-plat .carte { width: calc(var(--carte-l) * 0.8); height: calc(var(--carte-h) * 0.8); }
.pli-a-plat-nom { font-size: 0.7rem; color: var(--texte-doux); max-width: 84px; overflow-wrap: anywhere; }
.pli-gagnant .carte { box-shadow: 0 0 0 2px var(--or); }
.pli-gagnant .pli-a-plat-nom { color: #fde9b0; font-weight: 700; }

.aides-boutons { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 8px; }
.aides-conseil { font-size: 0.86rem; color: #bae6fd; margin-bottom: 8px; line-height: 1.4; min-height: 0; }
.aides-conseil:empty { display: none; }
.tombees { display: grid; grid-template-columns: auto 1fr; gap: 4px 8px; align-items: center; text-align: left; font-size: 0.82rem; }
.tombees-couleur { font-size: 1.1rem; font-weight: 700; }
.tombees-rangs { display: flex; flex-wrap: wrap; gap: 4px; }
.tombee { min-width: 26px; padding: 1px 4px; border-radius: 4px; text-align: center; font-weight: 700; background: var(--surface-1); border: 1px solid var(--line); color: var(--texte); }
.tombee.sortie { opacity: 0.32; text-decoration: line-through; }
.tombee.a-moi { border-color: #6ee7b7; color: #6ee7b7; }
.tombees-legende { font-size: 0.72rem; color: var(--texte-faible); margin-top: 6px; }


.overlay .overlay-box { position: relative; max-width: 520px; width: 100%; max-height: calc(100dvh - 90px); overflow-y: auto; }
.overlay-fermer {
  position: absolute; top: 6px; right: 6px;
  width: 44px; height: 44px;
  font-size: 1.5rem; line-height: 1; color: var(--texte-doux);
  background: transparent; border: none; cursor: pointer; border-radius: 6px;
}
.overlay-fermer:hover { color: #fff; background: var(--surface-2); }
.fin-titre { font-family: var(--font-display); font-size: 1.5rem; margin: 6px 40px 10px; }
.fin-titre.victoire { color: #6ee7b7; }
.fin-titre.defaite { color: #fca5a5; }
.fin-score { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; margin-bottom: 8px; }
.fin-resume { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; font-size: 0.84rem; color: var(--texte-doux); margin-bottom: 10px; }
.fin-resume b { color: var(--texte); }
.fin-rang { font-size: 0.92rem; font-weight: 700; color: #fde9b0; margin: 8px 0; min-height: 0; }
.fin-rang:empty { display: none; }
.fin-lien { display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px; color: var(--color-light); font-weight: 700; font-size: 0.88rem; text-decoration: none; }
.fin-lien:hover { text-decoration: underline; }
.fin-donnes { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 0.8rem; }
.fin-donnes th, .fin-donnes td { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
.fin-donnes th:first-child, .fin-donnes td:first-child { text-align: left; }
.fin-donnes th { color: var(--texte-doux); font-weight: 600; }
.fin-details summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; justify-content: center; font-size: 0.86rem; font-weight: 700; color: var(--color-light); }
.fin-compte { margin: 10px 0; padding: 10px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); font-size: 0.86rem; }
.fin-compte p { margin-bottom: 8px; }
.overlay-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 12px; }



@media (max-width: 600px), (max-height: 700px) {
  body.en-partie { padding-top: 50px; }
  body.en-partie #app { padding-top: 8px; }
  body.en-partie .jeu-banner { display: none; }
  .tb-centre-ligne .enseigne { font-size: 1.15rem; }
  
  .ecran-jeu[data-vue="encheres"] .tb-emplacement { display: none; }
  .ecran-jeu[data-vue="encheres"] .table-belote { gap: 10px 8px; }
  .zone-decision { padding: 8px 10px; }
  .decision-titre { font-size: 0.86rem; margin-bottom: 6px; }
}


@media (max-height: 480px) and (orientation: landscape) {
  body.en-partie { padding: 46px 4px 0; }
  body.en-partie #app { padding: 4px 8px; }
  .ecran-jeu { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); grid-auto-rows: min-content; gap: 6px 8px; align-items: start; }
  .table-belote { grid-column: 1; grid-row: 1 / span 8; padding: 6px; gap: 2px 4px; }
  .barre-partie, .bandeau-message, .zone-decision, .panneau-pli, .zone-aides, .zone-main { grid-column: 2; }
  .barre-partie { flex-wrap: wrap; row-gap: 4px; }
  .barre-contrat { order: 3; flex-basis: 100%; }
  .zone-main { position: static; padding: 4px 0; background: none; }
  .bandeau-message { min-height: 28px; padding: 4px 8px; font-size: 0.82rem; }
  .tb-centre { min-height: 20px; }
  .tb-etiquette { padding: 1px 6px; }
  .ecran-jeu[data-phase="fin_donne"] .zone-decision,
  .ecran-jeu[data-phase="termine"] .zone-decision { grid-column: 1; grid-row: 1 / span 8; }
}
