#ddp-root {
  --felt: #1f6b45;
  --felt-dark: #154d31;
  --panel: #ffffff;
  --border: #dfe3e8;
  --text: #2b2f36;
  --muted: #6b7380;
  --accent: #f5b301;
  --red: #c62828;
  --shadow: 0 8px 24px rgba(20, 30, 40, 0.14);
  --cw: clamp(40px, 7.2vw, 82px);
  --ch: calc(var(--cw) * 1.4);
  /* Barre commune (css/games.css) aux couleurs du tapis */
  --mg-jeu-largeur: 1224px;
  --mgb-fond: radial-gradient(120% 160% at 0% 0%, rgba(245, 179, 1, 0.18), transparent 55%),
    linear-gradient(120deg, var(--felt-dark), var(--felt));
  --mgb-accent: var(--accent);
  --mgb-titre: linear-gradient(100deg, #ffffff, #ffe08a 50%, var(--accent));
  --mg-fs-fond: #f4f6f8;
  --mg-bulle-fond: var(--felt-dark);

  color: var(--text);
}

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

#ddp-root .layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

/* ---------- Table ---------- */
#ddp-root .table {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-areas:
    ".     north ."
    "west  trick east"
    "south south south";
  align-items: center;
  gap: 12px;
  padding: 16px;
  min-width: 0;
  background: radial-gradient(
    ellipse at center,
    var(--felt) 0%,
    var(--felt-dark) 100%
  );
  border: 6px solid #6d4c2f;
  border-radius: 24px;
  box-shadow:
    var(--shadow),
    inset 0 0 40px rgba(0, 0, 0, 0.35);
  color: #fff;
}

#ddp-root .seat-north {
  grid-area: north;
  justify-self: center;
}
#ddp-root .seat-west {
  grid-area: west;
  justify-self: start;
}
#ddp-root .seat-east {
  grid-area: east;
  justify-self: end;
}
#ddp-root .seat-south {
  grid-area: south;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

#ddp-root .seat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 12px;
  transition:
    background 0.2s,
    box-shadow 0.2s;
}
#ddp-root .seat.active {
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 0 2px var(--accent);
}
#ddp-root .seat-name {
  font-weight: 700;
  font-size: 0.95rem;
}
#ddp-root .seat-info {
  font-size: 0.8rem;
  opacity: 0.85;
}
#ddp-root .seat-info .pts {
  color: #ffd54f;
  font-weight: 700;
}

#ddp-root .backs {
  display: flex;
}
#ddp-root .backs .card {
  --cw: clamp(18px, 2.6vw, 30px);
}
#ddp-root .backs .card + .card {
  margin-left: calc(var(--cw) * -0.62);
}

/* ---------- Pli en cours ---------- */
#ddp-root .trick {
  grid-area: trick;
  position: relative;
  width: calc(var(--cw) * 3.4);
  height: calc(var(--ch) * 2.3);
}
#ddp-root .slot {
  position: absolute;
}
#ddp-root .slot-0 {
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
}
#ddp-root .slot-2 {
  left: 50%;
  top: 0;
  transform: translateX(-50%);
}
#ddp-root .slot-1 {
  left: 0;
  top: 50%;
  transform: translateY(-50%);
}
#ddp-root .slot-3 {
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

#ddp-root .slot .card {
  animation: arrive 0.25s ease-out;
}
#ddp-root .slot-0 .card {
  --from: 0, 40px;
}
#ddp-root .slot-2 .card {
  --from: 0, -40px;
}
#ddp-root .slot-1 .card {
  --from: -40px, 0;
}
#ddp-root .slot-3 .card {
  --from: 40px, 0;
}
@keyframes arrive {
  from {
    opacity: 0;
    transform: translate(var(--from));
  }
}

#ddp-root .slot .card.wins {
  box-shadow:
    0 0 0 3px var(--accent),
    0 6px 16px rgba(0, 0, 0, 0.4);
}

/* ---------- Cartes ---------- */
#ddp-root .card {
  display: block;
  flex: none;
  width: var(--cw);
  height: calc(var(--cw) * 1.4);
  padding: 0;
  border-radius: calc(var(--cw) * 0.07);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

/* ---------- Main du joueur ---------- */
#ddp-root .hand {
  display: flex;
  justify-content: center;
  max-width: 100%;
  padding-top: 20px;
  min-height: calc(var(--ch) + 20px);
}
#ddp-root .hand .card + .card {
  margin-left: calc(var(--cw) * -0.4);
}
#ddp-root .hand .card {
  position: relative;
  transition:
    transform 0.15s,
    filter 0.15s;
  cursor: default;
}
#ddp-root .hand .card.playable {
  cursor: pointer;
}
#ddp-root .hand .card.playable:hover,
#ddp-root .hand .card.playable:focus-visible {
  transform: translateY(-10px);
  z-index: 2;
}
#ddp-root .hand .card:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
}
#ddp-root .hand .card.blocked {
  filter: brightness(0.55);
}
#ddp-root .hand .card.selected,
#ddp-root .hand .card.selected:hover {
  transform: translateY(-20px);
  box-shadow:
    0 0 0 3px var(--accent),
    0 6px 14px rgba(0, 0, 0, 0.4);
}
#ddp-root .hand .card.received {
  box-shadow:
    0 0 0 3px #4fc3f7,
    0 2px 6px rgba(0, 0, 0, 0.35);
}

/* ---------- Panneau ---------- */
#ddp-root .panel {
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
#ddp-root .panel h3 {
  margin: 18px 0 8px;
  font-size: 1rem;
}
#ddp-root .message {
  min-height: 3em;
  padding: 10px 12px;
  font-weight: 700;
  line-height: 1.4;
  background: #f4f6f8;
  border-radius: 10px;
}
#ddp-root #passBtn {
  width: 100%;
  margin-top: 10px;
}
#ddp-root #passBtn[hidden] {
  display: none;
}

#ddp-root table.scores {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
#ddp-root table.scores th,
#ddp-root table.scores td {
  padding: 4px 6px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
#ddp-root table.scores th:first-child,
#ddp-root table.scores td:first-child {
  text-align: left;
  color: var(--muted);
}
#ddp-root table.scores tfoot td {
  font-weight: 700;
  color: var(--text);
  border-bottom: none;
}
#ddp-root table.scores .best {
  color: #1b8a4b;
}

/* ---------- Boutons ---------- */
#ddp-root .btn {
  padding: 8px 14px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition:
    background 0.15s,
    transform 0.1s;
}
#ddp-root .btn:hover:not(:disabled) {
  background: #f1f3f5;
}
#ddp-root .btn:active:not(:disabled) {
  transform: translateY(1px);
}
#ddp-root .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
#ddp-root .btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #2b2f36;
}
#ddp-root .btn.primary:hover:not(:disabled) {
  background: #ffc933;
}
/* Désactivé : texte net (il indique la progression, ex. « Donner 2/3 cartes »),
   fond pâle et bordure en pointillés pour montrer qu'il n'est pas encore cliquable */
#ddp-root .btn.primary:disabled {
  opacity: 1;
  background: #fff6d6;
  border-style: dashed;
  color: #5c5236;
}

/* ---------- Modales ---------- */
#ddp-root .modal {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(92vw, 460px);
  height: fit-content;
  max-height: 90vh;
  overflow-y: auto;
  padding: 0;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
#ddp-root #helpModal {
  width: min(94vw, 760px);
}
#ddp-root .modal[open] {
  animation: pop 0.25s ease-out;
}
#ddp-root .modal::backdrop {
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
}
@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
}
#ddp-root .modal-body {
  padding: 22px;
}
#ddp-root .modal-body h2 {
  margin: 0 0 10px;
}
#ddp-root .modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
#ddp-root .modal-head h2 {
  margin: 0;
}
#ddp-root .modal-close {
  padding: 4px 8px;
  font-size: 1.2rem;
  color: var(--muted);
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
#ddp-root .modal-close:hover {
  color: var(--text);
  background: var(--border);
}
#ddp-root .modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
}
#ddp-root .rules h3 {
  margin: 16px 0 6px;
  font-size: 1rem;
}
#ddp-root .rules p,
#ddp-root .rules ol,
#ddp-root .rules ul {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--muted);
}
#ddp-root .rules ol,
#ddp-root .rules ul {
  padding-left: 20px;
}
#ddp-root .rules strong {
  color: var(--text);
}
#ddp-root .note {
  margin: 12px 0 0;
  padding: 10px 12px;
  font-size: 0.9rem;
  background: #fff8e1;
  border-radius: 10px;
}

/* ---------- Plein écran ---------- */
#ddp-root.mg-fs {
  padding: 16px;
}

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
  #ddp-root {
    --cw: clamp(34px, 9vw, 70px);
  }
}
@media (max-width: 560px) {
  #ddp-root .table {
    padding: 10px 6px;
    gap: 6px;
    border-width: 4px;
  }
  #ddp-root .seat {
    padding: 4px;
  }
  #ddp-root .seat-name {
    font-size: 0.8rem;
  }
  #ddp-root .seat-info {
    font-size: 0.7rem;
  }
  #ddp-root .hand .card + .card {
    margin-left: calc(var(--cw) * -0.5);
  }
  #ddp-root .backs .card + .card {
    margin-left: calc(var(--cw) * -0.8);
  }
}
